diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 0dadee7f1fc4c..4e33ca88ba1bc 100644 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -2285,7 +2285,7 @@ final class Settings { Intent finalIntent = new Intent(intent); finalIntent.setData(builder.build()); applyDefaultPreferredActivityLPw(service, finalIntent, flags, cn, - scheme, ssp, null, null, null, userId); + scheme, ssp, null, null, userId); doScheme = false; } for (int iauth=0; iauth ri = service.mActivities.queryIntent(intent, intent.getType(), flags, 0); if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Queried " + intent @@ -2369,19 +2368,24 @@ final class Settings { int match = 0; if (ri != null && ri.size() > 1) { boolean haveAct = false; - boolean haveNonSys = false; + ComponentName haveNonSys = null; ComponentName[] set = new ComponentName[ri.size()]; for (int i=0; i= match) { + // If any of the matches are not system apps, then + // there is a third party app that is now an option... + // so don't set a default since we don't want to hide it. + // Only do this if the match of this one is at least as good + // as what we have found as the built-in app; if it isn't + // as good, the user won't want it anyway, right? + if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result " + + ai.packageName + "/" + ai.name + ": non-system!"); + haveNonSys = set[i]; + break; + } } else if (cn.getPackageName().equals(ai.packageName) && cn.getClassName().equals(ai.name)) { if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result " @@ -2393,7 +2397,7 @@ final class Settings { + ai.packageName + "/" + ai.name + ": skipped"); } } - if (haveAct && !haveNonSys) { + if (haveAct && haveNonSys == null) { IntentFilter filter = new IntentFilter(); if (intent.getAction() != null) { filter.addAction(intent.getAction()); @@ -2427,9 +2431,25 @@ final class Settings { } PreferredActivity pa = new PreferredActivity(filter, match, set, cn, true); editPreferredActivitiesLPw(userId).addFilter(pa); - } else if (!haveNonSys) { - Slog.w(TAG, "No component found for default preferred activity " + cn); + } else if (haveNonSys == null) { + StringBuilder sb = new StringBuilder(); + sb.append("No component "); + sb.append(cn.flattenToShortString()); + sb.append(" found setting preferred "); + sb.append(intent); + sb.append("; possible matches are "); + for (int i=0; i 0) sb.append(", "); + sb.append(set[i].flattenToShortString()); + } + Slog.w(TAG, sb.toString()); + } else { + Slog.i(TAG, "Not setting preferred " + intent + "; found third party match " + + haveNonSys.flattenToShortString()); } + } else { + Slog.w(TAG, "No potential matches found for " + intent + " while setting preferred " + + cn.flattenToShortString()); } } diff --git a/tests/ActivityTests/AndroidManifest.xml b/tests/ActivityTests/AndroidManifest.xml index 3fb547dc4bf80..f31f4f280a829 100644 --- a/tests/ActivityTests/AndroidManifest.xml +++ b/tests/ActivityTests/AndroidManifest.xml @@ -30,6 +30,20 @@ + + + + + + + + + + + +