Loading services/java/com/android/server/pm/PackageManagerService.java +20 −26 Original line number Original line Diff line number Diff line Loading @@ -10011,11 +10011,11 @@ public class PackageManagerService extends IPackageManager.Stub { } } if (filter.countDataAuthorities() != 0 if (filter.countDataAuthorities() != 0 || filter.countDataPaths() != 0 || filter.countDataPaths() != 0 || filter.countDataSchemes() != 0 || filter.countDataSchemes() > 1 || filter.countDataTypes() != 0) { || filter.countDataTypes() != 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "replacePreferredActivity expects filter to have no data authorities, " + "replacePreferredActivity expects filter to have no data authorities, " + "paths, schemes or types."); "paths, or types; and at most one scheme."); } } synchronized (mPackages) { synchronized (mPackages) { if (mContext.checkCallingOrSelfPermission( if (mContext.checkCallingOrSelfPermission( Loading @@ -10032,35 +10032,29 @@ public class PackageManagerService extends IPackageManager.Stub { } } final int callingUserId = UserHandle.getCallingUserId(); final int callingUserId = UserHandle.getCallingUserId(); ArrayList<PreferredActivity> removed = null; PreferredIntentResolver pir = mSettings.mPreferredActivities.get(callingUserId); PreferredIntentResolver pir = mSettings.mPreferredActivities.get(callingUserId); if (pir != null) { if (pir != null) { Iterator<PreferredActivity> it = pir.filterIterator(); Intent intent = new Intent(filter.getAction(0)).addCategory(filter.getCategory(0)); String action = filter.getAction(0); if (filter.countDataSchemes() == 1) { String category = filter.getCategory(0); Uri.Builder builder = new Uri.Builder(); while (it.hasNext()) { builder.scheme(filter.getDataScheme(0)); PreferredActivity pa = it.next(); intent.setData(builder.build()); if ((pa.countActions() == 0) || (pa.countCategories() == 0) } || (pa.getAction(0).equals(action) List<PreferredActivity> matches = pir.queryIntent( && pa.getCategory(0).equals(category))) { intent, null, true, callingUserId); if (removed == null) { if (DEBUG_PREFERRED) { removed = new ArrayList<PreferredActivity>(); Slog.i(TAG, matches.size() + " preferred matches for " + intent); } } removed.add(pa); for (int i = 0; i < matches.size(); i++) { PreferredActivity pa = matches.get(i); if (DEBUG_PREFERRED) { if (DEBUG_PREFERRED) { Slog.i(TAG, "Removing preferred activity " Slog.i(TAG, "Removing preferred activity " + pa.mPref.mComponent + ":"); + pa.mPref.mComponent + ":"); filter.dump(new LogPrinter(Log.INFO, TAG), " "); 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); pir.removeFilter(pa); } } } } } addPreferredActivityInternal(filter, match, set, activity, true, callingUserId); addPreferredActivityInternal(filter, match, set, activity, true, callingUserId); } } } } Loading Loading
services/java/com/android/server/pm/PackageManagerService.java +20 −26 Original line number Original line Diff line number Diff line Loading @@ -10011,11 +10011,11 @@ public class PackageManagerService extends IPackageManager.Stub { } } if (filter.countDataAuthorities() != 0 if (filter.countDataAuthorities() != 0 || filter.countDataPaths() != 0 || filter.countDataPaths() != 0 || filter.countDataSchemes() != 0 || filter.countDataSchemes() > 1 || filter.countDataTypes() != 0) { || filter.countDataTypes() != 0) { throw new IllegalArgumentException( throw new IllegalArgumentException( "replacePreferredActivity expects filter to have no data authorities, " + "replacePreferredActivity expects filter to have no data authorities, " + "paths, schemes or types."); "paths, or types; and at most one scheme."); } } synchronized (mPackages) { synchronized (mPackages) { if (mContext.checkCallingOrSelfPermission( if (mContext.checkCallingOrSelfPermission( Loading @@ -10032,35 +10032,29 @@ public class PackageManagerService extends IPackageManager.Stub { } } final int callingUserId = UserHandle.getCallingUserId(); final int callingUserId = UserHandle.getCallingUserId(); ArrayList<PreferredActivity> removed = null; PreferredIntentResolver pir = mSettings.mPreferredActivities.get(callingUserId); PreferredIntentResolver pir = mSettings.mPreferredActivities.get(callingUserId); if (pir != null) { if (pir != null) { Iterator<PreferredActivity> it = pir.filterIterator(); Intent intent = new Intent(filter.getAction(0)).addCategory(filter.getCategory(0)); String action = filter.getAction(0); if (filter.countDataSchemes() == 1) { String category = filter.getCategory(0); Uri.Builder builder = new Uri.Builder(); while (it.hasNext()) { builder.scheme(filter.getDataScheme(0)); PreferredActivity pa = it.next(); intent.setData(builder.build()); if ((pa.countActions() == 0) || (pa.countCategories() == 0) } || (pa.getAction(0).equals(action) List<PreferredActivity> matches = pir.queryIntent( && pa.getCategory(0).equals(category))) { intent, null, true, callingUserId); if (removed == null) { if (DEBUG_PREFERRED) { removed = new ArrayList<PreferredActivity>(); Slog.i(TAG, matches.size() + " preferred matches for " + intent); } } removed.add(pa); for (int i = 0; i < matches.size(); i++) { PreferredActivity pa = matches.get(i); if (DEBUG_PREFERRED) { if (DEBUG_PREFERRED) { Slog.i(TAG, "Removing preferred activity " Slog.i(TAG, "Removing preferred activity " + pa.mPref.mComponent + ":"); + pa.mPref.mComponent + ":"); filter.dump(new LogPrinter(Log.INFO, TAG), " "); 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); pir.removeFilter(pa); } } } } } addPreferredActivityInternal(filter, match, set, activity, true, callingUserId); addPreferredActivityInternal(filter, match, set, activity, true, callingUserId); } } } } Loading