Merge "Fix issue #10034864: Define YouTube application as the preferred..." into lmp-dev

This commit is contained in:
Dianne Hackborn
2014-10-14 19:16:21 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 15 deletions

View File

@ -388,7 +388,7 @@ public class ApplicationErrorReport implements Parcelable {
dest.writeInt(throwLineNumber); dest.writeInt(throwLineNumber);
dest.writeString(stackTrace); dest.writeString(stackTrace);
int total = dest.dataPosition()-start; int total = dest.dataPosition()-start;
if (total > 10*1024) { if (total > 20*1024) {
Slog.d("Error", "ERR: exClass=" + exceptionClassName); Slog.d("Error", "ERR: exClass=" + exceptionClassName);
Slog.d("Error", "ERR: exMsg=" + exceptionMessage); Slog.d("Error", "ERR: exMsg=" + exceptionMessage);
Slog.d("Error", "ERR: file=" + throwFileName); Slog.d("Error", "ERR: file=" + throwFileName);

View File

@ -69,6 +69,7 @@ public final class ActiveServices {
static final boolean DEBUG_DELAYED_SERVICE = ActivityManagerService.DEBUG_SERVICE; static final boolean DEBUG_DELAYED_SERVICE = ActivityManagerService.DEBUG_SERVICE;
static final boolean DEBUG_DELAYED_STARTS = DEBUG_DELAYED_SERVICE; static final boolean DEBUG_DELAYED_STARTS = DEBUG_DELAYED_SERVICE;
static final boolean DEBUG_MU = ActivityManagerService.DEBUG_MU; static final boolean DEBUG_MU = ActivityManagerService.DEBUG_MU;
static final boolean LOG_SERVICE_START_STOP = false;
static final String TAG = ActivityManagerService.TAG; static final String TAG = ActivityManagerService.TAG;
static final String TAG_MU = ActivityManagerService.TAG_MU; static final String TAG_MU = ActivityManagerService.TAG_MU;
@ -1447,8 +1448,10 @@ public final class ActiveServices {
String nameTerm; String nameTerm;
int lastPeriod = r.shortName.lastIndexOf('.'); int lastPeriod = r.shortName.lastIndexOf('.');
nameTerm = lastPeriod >= 0 ? r.shortName.substring(lastPeriod) : r.shortName; nameTerm = lastPeriod >= 0 ? r.shortName.substring(lastPeriod) : r.shortName;
EventLogTags.writeAmCreateService( if (LOG_SERVICE_START_STOP) {
r.userId, System.identityHashCode(r), nameTerm, r.app.uid, r.app.pid); EventLogTags.writeAmCreateService(
r.userId, System.identityHashCode(r), nameTerm, r.app.uid, r.app.pid);
}
synchronized (r.stats.getBatteryStats()) { synchronized (r.stats.getBatteryStats()) {
r.stats.startLaunchedLocked(); r.stats.startLaunchedLocked();
} }
@ -1632,8 +1635,10 @@ public final class ActiveServices {
} }
if (DEBUG_SERVICE) Slog.v(TAG, "Bringing down " + r + " " + r.intent); if (DEBUG_SERVICE) Slog.v(TAG, "Bringing down " + r + " " + r.intent);
EventLogTags.writeAmDestroyService( if (LOG_SERVICE_START_STOP) {
r.userId, System.identityHashCode(r), (r.app != null) ? r.app.pid : -1); EventLogTags.writeAmDestroyService(
r.userId, System.identityHashCode(r), (r.app != null) ? r.app.pid : -1);
}
final ServiceMap smap = getServiceMap(r.userId); final ServiceMap smap = getServiceMap(r.userId);
smap.mServicesByName.remove(r.name); smap.mServicesByName.remove(r.name);

View File

@ -2371,7 +2371,8 @@ final class Settings {
intent.getType(), flags, 0); intent.getType(), flags, 0);
if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Queried " + intent if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Queried " + intent
+ " results: " + ri); + " results: " + ri);
int match = 0; int systemMatch = 0;
int thirdPartyMatch = 0;
if (ri != null && ri.size() > 1) { if (ri != null && ri.size() > 1) {
boolean haveAct = false; boolean haveAct = false;
ComponentName haveNonSys = null; ComponentName haveNonSys = null;
@ -2380,13 +2381,10 @@ final class Settings {
ActivityInfo ai = ri.get(i).activityInfo; ActivityInfo ai = ri.get(i).activityInfo;
set[i] = new ComponentName(ai.packageName, ai.name); set[i] = new ComponentName(ai.packageName, ai.name);
if ((ai.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) { if ((ai.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM) == 0) {
if (ri.get(i).match >= match) { if (ri.get(i).match >= thirdPartyMatch) {
// If any of the matches are not system apps, then // Keep track of the best match we find of all third
// there is a third party app that is now an option... // party apps, for use later to determine if we actually
// so don't set a default since we don't want to hide it. // want to set a preferred app for this intent.
// 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 " if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result "
+ ai.packageName + "/" + ai.name + ": non-system!"); + ai.packageName + "/" + ai.name + ": non-system!");
haveNonSys = set[i]; haveNonSys = set[i];
@ -2397,12 +2395,19 @@ final class Settings {
if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result " if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result "
+ ai.packageName + "/" + ai.name + ": default!"); + ai.packageName + "/" + ai.name + ": default!");
haveAct = true; haveAct = true;
match = ri.get(i).match; systemMatch = ri.get(i).match;
} else { } else {
if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result " if (PackageManagerService.DEBUG_PREFERRED) Log.d(TAG, "Result "
+ ai.packageName + "/" + ai.name + ": skipped"); + ai.packageName + "/" + ai.name + ": skipped");
} }
} }
if (haveNonSys != null && thirdPartyMatch < systemMatch) {
// If we have a matching third party app, but its match is not as
// good as the built-in system app, then we don't want to actually
// consider it a match because presumably the built-in app is still
// the thing we want users to see by default.
haveNonSys = null;
}
if (haveAct && haveNonSys == null) { if (haveAct && haveNonSys == null) {
IntentFilter filter = new IntentFilter(); IntentFilter filter = new IntentFilter();
if (intent.getAction() != null) { if (intent.getAction() != null) {
@ -2435,7 +2440,7 @@ final class Settings {
Slog.w(TAG, "Malformed mimetype " + intent.getType() + " for " + cn); Slog.w(TAG, "Malformed mimetype " + intent.getType() + " for " + cn);
} }
} }
PreferredActivity pa = new PreferredActivity(filter, match, set, cn, true); PreferredActivity pa = new PreferredActivity(filter, systemMatch, set, cn, true);
editPreferredActivitiesLPw(userId).addFilter(pa); editPreferredActivitiesLPw(userId).addFilter(pa);
} else if (haveNonSys == null) { } else if (haveNonSys == null) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();