diff options
| author | 2020-08-27 08:54:07 +0000 | |
|---|---|---|
| committer | 2020-08-27 08:54:07 +0000 | |
| commit | 83462e4f8e8ce91d388ff8f5229bd67a505cfa78 (patch) | |
| tree | 77d575585920d15efe4bae2f1953eb3d55173e5d | |
| parent | 308b772c1f65c3014e9b971929fe06355abd612c (diff) | |
| parent | 44591227f20f9f1f806838b413c3403cfae480ec (diff) | |
Merge "Add missing synchronized(mLock) blocks into PackageManagerService" into rvc-qpr-dev
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 0cec95d2fa89..1b9b7b232ce3 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -2376,9 +2376,12 @@ public class PackageManagerService extends IPackageManager.Stub final int callingUserId = UserHandle.getUserId(callingUid); for (String packageName : packages) { - PackageSetting setting = mSettings.mPackages.get(packageName); - if (setting != null - && !shouldFilterApplicationLocked(setting, callingUid, callingUserId)) { + final boolean filterApp; + synchronized (mLock) { + final PackageSetting ps = mSettings.getPackageLPr(packageName); + filterApp = shouldFilterApplicationLocked(ps, callingUid, callingUserId); + } + if (!filterApp) { notifyInstallObserver(packageName); } } @@ -8914,10 +8917,10 @@ public class PackageManagerService extends IPackageManager.Stub if (providerInfo == null) { return null; } - if (!mSettings.isEnabledAndMatchLPr(providerInfo, flags, userId)) { - return null; - } synchronized (mLock) { + if (!mSettings.isEnabledAndMatchLPr(providerInfo, flags, userId)) { + return null; + } final PackageSetting ps = mSettings.mPackages.get(providerInfo.packageName); final ComponentName component = new ComponentName(providerInfo.packageName, providerInfo.name); @@ -9004,9 +9007,11 @@ public class PackageManagerService extends IPackageManager.Stub String targetPackage, int flags) { final int callingUid = Binder.getCallingUid(); final int callingUserId = UserHandle.getUserId(callingUid); - final PackageSetting ps = mSettings.mPackages.get(targetPackage); - if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { - return ParceledListSlice.emptyList(); + synchronized (mLock) { + final PackageSetting ps = mSettings.getPackageLPr(targetPackage); + if (shouldFilterApplicationLocked(ps, callingUid, callingUserId)) { + return ParceledListSlice.emptyList(); + } } return new ParceledListSlice<>(queryInstrumentationInternal(targetPackage, flags, callingUserId)); @@ -19356,9 +19361,11 @@ public class PackageManagerService extends IPackageManager.Stub mPermissionManager.enforceCrossUserPermission(callingUid, userId, true /* requireFullPermission */, false /* checkShell */, "clear application data"); - final PackageSetting ps = mSettings.getPackageLPr(packageName); - final boolean filterApp = - (ps != null && shouldFilterApplicationLocked(ps, callingUid, userId)); + final boolean filterApp; + synchronized (mLock) { + final PackageSetting ps = mSettings.getPackageLPr(packageName); + filterApp = shouldFilterApplicationLocked(ps, callingUid, userId); + } if (!filterApp && mProtectedPackages.isPackageDataProtected(userId, packageName)) { throw new SecurityException("Cannot clear data for a protected package: " + packageName); @@ -19638,11 +19645,13 @@ public class PackageManagerService extends IPackageManager.Stub if (mContext.checkCallingOrSelfPermission( android.Manifest.permission.SET_PREFERRED_APPLICATIONS) != PackageManager.PERMISSION_GRANTED) { - if (getUidTargetSdkVersionLockedLPr(callingUid) - < Build.VERSION_CODES.FROYO) { - Slog.w(TAG, "Ignoring addPreferredActivity() from uid " - + callingUid); - return; + synchronized (mLock) { + if (getUidTargetSdkVersionLockedLPr(callingUid) + < Build.VERSION_CODES.FROYO) { + Slog.w(TAG, "Ignoring addPreferredActivity() from uid " + + callingUid); + return; + } } mContext.enforceCallingOrSelfPermission( android.Manifest.permission.SET_PREFERRED_APPLICATIONS, null); @@ -19814,8 +19823,9 @@ public class PackageManagerService extends IPackageManager.Stub /** This method takes a specific user id as well as UserHandle.USER_ALL. */ private void clearPackagePreferredActivities(String packageName, int userId) { final SparseBooleanArray changedUsers = new SparseBooleanArray(); - - clearPackagePreferredActivitiesLPw(packageName, changedUsers, userId); + synchronized (mLock) { + clearPackagePreferredActivitiesLPw(packageName, changedUsers, userId); + } if (changedUsers.size() > 0) { updateDefaultHomeNotLocked(changedUsers); postPreferredActivityChangedBroadcast(userId); @@ -19937,7 +19947,9 @@ public class PackageManagerService extends IPackageManager.Stub // writer try { final SparseBooleanArray changedUsers = new SparseBooleanArray(); - clearPackagePreferredActivitiesLPw(null, changedUsers, userId); + synchronized (mLock) { + clearPackagePreferredActivitiesLPw(null, changedUsers, userId); + } if (changedUsers.size() > 0) { postPreferredActivityChangedBroadcast(userId); } @@ -20942,15 +20954,19 @@ public class PackageManagerService extends IPackageManager.Stub // Limit who can change which apps if (!UserHandle.isSameApp(callingUid, pkgSetting.appId)) { // Don't allow apps that don't have permission to modify other apps - if (!allowedByPermission - || shouldFilterApplicationLocked(pkgSetting, callingUid, userId)) { + final boolean filterApp; + synchronized (mLock) { + filterApp = (!allowedByPermission + || shouldFilterApplicationLocked(pkgSetting, callingUid, userId)); + } + if (filterApp) { throw new SecurityException( "Attempt to change component state; " - + "pid=" + Binder.getCallingPid() - + ", uid=" + callingUid - + (className == null + + "pid=" + Binder.getCallingPid() + + ", uid=" + callingUid + + (className == null ? ", package=" + packageName - : ", component=" + packageName + "/" + className)); + : ", component=" + packageName + "/" + className)); } // Don't allow changing protected packages. if (mProtectedPackages.isPackageStateProtected(userId, packageName)) { |