Don't hold mPackages calling addPreferredActivityInternal

Fixes: 130635790
Test: manual
Change-Id: I1b8246b73a65c819ce22fe447e88e9116d9c5fbf
This commit is contained in:
Todd Kennedy
2019-04-16 09:58:35 -07:00
parent 10ae84a9c1
commit 193924cc9c

View File

@@ -19890,26 +19890,28 @@ public class PackageManagerService extends IPackageManager.Stub
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
true /* requireFullPermission */, false /* checkShell */,
"replace preferred activity");
synchronized (mPackages) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.SET_PREFERRED_APPLICATIONS)
!= PackageManager.PERMISSION_GRANTED) {
synchronized (mPackages) {
if (getUidTargetSdkVersionLockedLPr(callingUid)
< Build.VERSION_CODES.FROYO) {
Slog.w(TAG, "Ignoring replacePreferredActivity() from uid "
+ Binder.getCallingUid());
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) {
// 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) {
PreferredActivity cur = existing.get(0);
final PreferredActivity cur = existing.get(0);
if (DEBUG_PREFERRED) {
Slog.i(TAG, "Checking replace of preferred:");
filter.dump(new LogPrinter(Log.INFO, TAG), " ");
@@ -19939,14 +19941,13 @@ public class PackageManagerService extends IPackageManager.Stub
return;
}
}
if (existing != null) {
if (DEBUG_PREFERRED) {
Slog.i(TAG, existing.size() + " existing preferred matches for:");
filter.dump(new LogPrinter(Log.INFO, TAG), " ");
}
for (int i = 0; i < existing.size(); i++) {
PreferredActivity pa = existing.get(i);
for (int i = existing.size() - 1; i >= 0; --i) {
final PreferredActivity pa = existing.get(i);
if (DEBUG_PREFERRED) {
Slog.i(TAG, "Removing existing preferred activity "
+ pa.mPref.mComponent + ":");
@@ -19956,9 +19957,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