summaryrefslogtreecommitdiffstats
path: root/services/java/com/android
diff options
context:
space:
mode:
authorChristopher Tate <ctate@google.com>2013-11-11 17:43:43 -0800
committerChristopher Tate <ctate@google.com>2013-11-12 12:23:10 -0800
commit087044c902e693dd2b7b267163f4d9f892592a67 (patch)
tree7aaa3dfe0cac63d40988248aec7040765abd40e6 /services/java/com/android
parent596e409ec9703e5071bb9a0de08787cde7745f7a (diff)
downloadframeworks_base-087044c902e693dd2b7b267163f4d9f892592a67.zip
frameworks_base-087044c902e693dd2b7b267163f4d9f892592a67.tar.gz
frameworks_base-087044c902e693dd2b7b267163f4d9f892592a67.tar.bz2
Support preferred activities with zero or one scheme in the filter
Also use the existing full PreferredActivity match machinery instead of the existing direct comparison now that the intent filters can be more flexible. Bug 11482259 Change-Id: Icb649ca60ecfbdb9ee3c256ee512d3f3f989e05f
Diffstat (limited to 'services/java/com/android')
-rwxr-xr-xservices/java/com/android/server/pm/PackageManagerService.java46
1 files changed, 20 insertions, 26 deletions
diff --git a/services/java/com/android/server/pm/PackageManagerService.java b/services/java/com/android/server/pm/PackageManagerService.java
index 7291dd4..7ae9251 100755
--- a/services/java/com/android/server/pm/PackageManagerService.java
+++ b/services/java/com/android/server/pm/PackageManagerService.java
@@ -10011,11 +10011,11 @@ public class PackageManagerService extends IPackageManager.Stub {
}
if (filter.countDataAuthorities() != 0
|| filter.countDataPaths() != 0
- || filter.countDataSchemes() != 0
+ || filter.countDataSchemes() > 1
|| filter.countDataTypes() != 0) {
throw new IllegalArgumentException(
"replacePreferredActivity expects filter to have no data authorities, " +
- "paths, schemes or types.");
+ "paths, or types; and at most one scheme.");
}
synchronized (mPackages) {
if (mContext.checkCallingOrSelfPermission(
@@ -10032,33 +10032,27 @@ public class PackageManagerService extends IPackageManager.Stub {
}
final int callingUserId = UserHandle.getCallingUserId();
- ArrayList<PreferredActivity> removed = null;
PreferredIntentResolver pir = mSettings.mPreferredActivities.get(callingUserId);
if (pir != null) {
- Iterator<PreferredActivity> it = pir.filterIterator();
- String action = filter.getAction(0);
- String category = filter.getCategory(0);
- while (it.hasNext()) {
- PreferredActivity pa = it.next();
- if ((pa.countActions() == 0) || (pa.countCategories() == 0)
- || (pa.getAction(0).equals(action)
- && pa.getCategory(0).equals(category))) {
- if (removed == null) {
- removed = new ArrayList<PreferredActivity>();
- }
- removed.add(pa);
- if (DEBUG_PREFERRED) {
- Slog.i(TAG, "Removing preferred activity "
- + pa.mPref.mComponent + ":");
- filter.dump(new LogPrinter(Log.INFO, TAG), " ");
- }
- }
- }
- if (removed != null) {
- for (int i=0; i<removed.size(); i++) {
- PreferredActivity pa = removed.get(i);
- pir.removeFilter(pa);
+ Intent intent = new Intent(filter.getAction(0)).addCategory(filter.getCategory(0));
+ if (filter.countDataSchemes() == 1) {
+ Uri.Builder builder = new Uri.Builder();
+ builder.scheme(filter.getDataScheme(0));
+ intent.setData(builder.build());
+ }
+ List<PreferredActivity> matches = pir.queryIntent(
+ intent, null, true, callingUserId);
+ if (DEBUG_PREFERRED) {
+ Slog.i(TAG, matches.size() + " preferred matches for " + intent);
+ }
+ for (int i = 0; i < matches.size(); i++) {
+ PreferredActivity pa = matches.get(i);
+ if (DEBUG_PREFERRED) {
+ Slog.i(TAG, "Removing preferred activity "
+ + pa.mPref.mComponent + ":");
+ filter.dump(new LogPrinter(Log.INFO, TAG), " ");
}
+ pir.removeFilter(pa);
}
}
addPreferredActivityInternal(filter, match, set, activity, true, callingUserId);