Merge "Don't hold mPackages calling addPreferredActivityInternal" into qt-dev

am: b33a6c6067

Change-Id: I73c0ae9ed9df61acde669029d0b0c532af350f5a
This commit is contained in:
Todd Kennedy
2019-04-16 17:13:15 -07:00
committed by android-build-merger

View File

@@ -19905,26 +19905,28 @@ public class PackageManagerService extends IPackageManager.Stub
mPermissionManager.enforceCrossUserPermission(callingUid, userId, mPermissionManager.enforceCrossUserPermission(callingUid, userId,
true /* requireFullPermission */, false /* checkShell */, true /* requireFullPermission */, false /* checkShell */,
"replace preferred activity"); "replace preferred activity");
synchronized (mPackages) { if (mContext.checkCallingOrSelfPermission(
if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
android.Manifest.permission.SET_PREFERRED_APPLICATIONS) != PackageManager.PERMISSION_GRANTED) {
!= PackageManager.PERMISSION_GRANTED) { synchronized (mPackages) {
if (getUidTargetSdkVersionLockedLPr(callingUid) if (getUidTargetSdkVersionLockedLPr(callingUid)
< Build.VERSION_CODES.FROYO) { < Build.VERSION_CODES.FROYO) {
Slog.w(TAG, "Ignoring replacePreferredActivity() from uid " Slog.w(TAG, "Ignoring replacePreferredActivity() from uid "
+ Binder.getCallingUid()); + Binder.getCallingUid());
return; return;
} }
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
} }
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null);
}
PreferredIntentResolver pir = mSettings.mPreferredActivities.get(userId); synchronized (mPackages) {
final PreferredIntentResolver pir = mSettings.mPreferredActivities.get(userId);
if (pir != null) { if (pir != null) {
// Get all of the existing entries that exactly match this filter. // Get all of the existing entries that exactly match this filter.
ArrayList<PreferredActivity> existing = pir.findFilters(filter); final ArrayList<PreferredActivity> existing = pir.findFilters(filter);
if (existing != null && existing.size() == 1) { if (existing != null && existing.size() == 1) {
PreferredActivity cur = existing.get(0); final PreferredActivity cur = existing.get(0);
if (DEBUG_PREFERRED) { if (DEBUG_PREFERRED) {
Slog.i(TAG, "Checking replace of preferred:"); Slog.i(TAG, "Checking replace of preferred:");
filter.dump(new LogPrinter(Log.INFO, TAG), " "); filter.dump(new LogPrinter(Log.INFO, TAG), " ");
@@ -19954,14 +19956,13 @@ public class PackageManagerService extends IPackageManager.Stub
return; return;
} }
} }
if (existing != null) { if (existing != null) {
if (DEBUG_PREFERRED) { if (DEBUG_PREFERRED) {
Slog.i(TAG, existing.size() + " existing preferred matches for:"); Slog.i(TAG, existing.size() + " existing preferred matches for:");
filter.dump(new LogPrinter(Log.INFO, TAG), " "); filter.dump(new LogPrinter(Log.INFO, TAG), " ");
} }
for (int i = 0; i < existing.size(); i++) { for (int i = existing.size() - 1; i >= 0; --i) {
PreferredActivity pa = existing.get(i); final PreferredActivity pa = existing.get(i);
if (DEBUG_PREFERRED) { if (DEBUG_PREFERRED) {
Slog.i(TAG, "Removing existing preferred activity " Slog.i(TAG, "Removing existing preferred activity "
+ pa.mPref.mComponent + ":"); + pa.mPref.mComponent + ":");
@@ -19971,9 +19972,9 @@ public class PackageManagerService extends IPackageManager.Stub
} }
} }
} }
addPreferredActivityInternal(filter, match, set, activity, true, userId,
"Replacing preferred");
} }
addPreferredActivityInternal(filter, match, set, activity, true, userId,
"Replacing preferred");
} }
@Override @Override