summaryrefslogtreecommitdiffstats
path: root/core/java/android/content/pm
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2013-07-23 18:30:18 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-07-23 18:30:18 +0000
commit5cf6663c80a9b6039cc70cc9b4041af64f671571 (patch)
tree124cf32f51cdc19a20fc1937139c1f92f93d02ab /core/java/android/content/pm
parent9a3552bfca9e5be46eae2af6dc7c4547c939c26c (diff)
parentb09491f271c0a647632e5a99bfe280cbb7106195 (diff)
downloadframeworks_base-5cf6663c80a9b6039cc70cc9b4041af64f671571.zip
frameworks_base-5cf6663c80a9b6039cc70cc9b4041af64f671571.tar.gz
frameworks_base-5cf6663c80a9b6039cc70cc9b4041af64f671571.tar.bz2
Merge "Add new facility for apps to declared their preferred intents."
Diffstat (limited to 'core/java/android/content/pm')
-rw-r--r--core/java/android/content/pm/PackageParser.java40
1 files changed, 31 insertions, 9 deletions
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index ce7addc..aaa2640 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -45,9 +45,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateFactory;
-import java.security.cert.CertPath;
-import java.security.cert.X509Certificate;
import java.security.spec.EncodedKeySpec;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.X509EncodedKeySpec;
@@ -2440,7 +2437,7 @@ public class PackageParser {
if (parser.getName().equals("intent-filter")) {
ActivityIntentInfo intent = new ActivityIntentInfo(a);
- if (!parseIntent(res, parser, attrs, flags, intent, outError, !receiver)) {
+ if (!parseIntent(res, parser, attrs, true, intent, outError)) {
return null;
}
if (intent.countActions() == 0) {
@@ -2450,6 +2447,21 @@ public class PackageParser {
} else {
a.intents.add(intent);
}
+ } else if (!receiver && parser.getName().equals("preferred")) {
+ ActivityIntentInfo intent = new ActivityIntentInfo(a);
+ if (!parseIntent(res, parser, attrs, false, intent, outError)) {
+ return null;
+ }
+ if (intent.countActions() == 0) {
+ Slog.w(TAG, "No actions in preferred at "
+ + mArchiveSourcePath + " "
+ + parser.getPositionDescription());
+ } else {
+ if (owner.preferredActivityFilters == null) {
+ owner.preferredActivityFilters = new ArrayList<ActivityIntentInfo>();
+ }
+ owner.preferredActivityFilters.add(intent);
+ }
} else if (parser.getName().equals("meta-data")) {
if ((a.metaData=parseMetaData(res, parser, attrs, a.metaData,
outError)) == null) {
@@ -2613,7 +2625,7 @@ public class PackageParser {
if (parser.getName().equals("intent-filter")) {
ActivityIntentInfo intent = new ActivityIntentInfo(a);
- if (!parseIntent(res, parser, attrs, flags, intent, outError, true)) {
+ if (!parseIntent(res, parser, attrs, true, intent, outError)) {
return null;
}
if (intent.countActions() == 0) {
@@ -3037,7 +3049,7 @@ public class PackageParser {
if (parser.getName().equals("intent-filter")) {
ServiceIntentInfo intent = new ServiceIntentInfo(s);
- if (!parseIntent(res, parser, attrs, flags, intent, outError, false)) {
+ if (!parseIntent(res, parser, attrs, true, intent, outError)) {
return null;
}
@@ -3234,9 +3246,8 @@ public class PackageParser {
private static final String ANDROID_RESOURCES
= "http://schemas.android.com/apk/res/android";
- private boolean parseIntent(Resources res,
- XmlPullParser parser, AttributeSet attrs, int flags,
- IntentInfo outInfo, String[] outError, boolean isActivity)
+ private boolean parseIntent(Resources res, XmlPullParser parser, AttributeSet attrs,
+ boolean allowGlobs, IntentInfo outInfo, String[] outError)
throws XmlPullParserException, IOException {
TypedArray sa = res.obtainAttributes(attrs,
@@ -3327,6 +3338,10 @@ public class PackageParser {
str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifestData_sspPattern, 0);
if (str != null) {
+ if (!allowGlobs) {
+ outError[0] = "sspPattern not allowed here; ssp must be literal";
+ return false;
+ }
outInfo.addDataSchemeSpecificPart(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
}
@@ -3353,6 +3368,10 @@ public class PackageParser {
str = sa.getNonConfigurationString(
com.android.internal.R.styleable.AndroidManifestData_pathPattern, 0);
if (str != null) {
+ if (!allowGlobs) {
+ outError[0] = "pathPattern not allowed here; path must be literal";
+ return false;
+ }
outInfo.addDataPath(str, PatternMatcher.PATTERN_SIMPLE_GLOB);
}
@@ -3414,6 +3433,8 @@ public class PackageParser {
public ArrayList<String> usesOptionalLibraries = null;
public String[] usesLibraryFiles = null;
+ public ArrayList<ActivityIntentInfo> preferredActivityFilters = null;
+
public ArrayList<String> mOriginalPackages = null;
public String mRealPackage = null;
public ArrayList<String> mAdoptPermissions = null;
@@ -4020,6 +4041,7 @@ public class PackageParser {
public CharSequence nonLocalizedLabel;
public int icon;
public int logo;
+ public int preferred;
}
public final static class ActivityIntentInfo extends IntentInfo {