Correct locking in PackageManagerService
Bug: 194206793 PackageManagerService.mPackages was used as a lock exactly once. This meant there were two locks guarding LegacyPermissionState (and possibly other state, as well): mLock and mPackages. This change replaces mPackages with mLock as the guard. Two formatting errors were fixed. An instrumented image was used to find other paths that might change LegacyPermissionState outside of mLock; no such paths were found after this fix. Test: atest * android.car.apitest.CarUserManagerTest (requires cf_x86_auto-userdebug) * CtsContentTestCases:IntentFilterTest * CtsDynamicMimeHostTestCases * CtsRoleTestCases * FrameworksServicesTests:UserSystemPackageInstallerTest * FrameworksServicesTests:PackageManagerSettingsTests * FrameworksServicesTests:PackageManagerServiceTest * FrameworksServicesTests:AppsFilterTest * FrameworksServicesTests:PackageInstallerSessionTest * FrameworksServicesTests:ScanTests * UserLifecycleTests#startUser * UserLifecycleTests#stopUser * UserLifecycleTests#switchUser * FrameworksServicesTests:WatcherTest * android.appsecurity.cts.EphemeralTest * android.appsecurity.cts.InstantAppUserTest Change-Id: If2914258c0a020fac124142cb292bafcee5e8a2a
This commit is contained in:
@@ -26533,7 +26533,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
|
||||
boolean readPermissionStateForUser(@UserIdInt int userId) {
|
||||
synchronized (mPackages) {
|
||||
synchronized (mLock) {
|
||||
mPermissionManager.writeLegacyPermissionStateTEMP();
|
||||
mSettings.readPermissionStateForUserSyncLPr(userId);
|
||||
mPermissionManager.readLegacyPermissionStateTEMP();
|
||||
@@ -26609,7 +26609,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (packageName == null || alias == null) {
|
||||
return null;
|
||||
}
|
||||
synchronized(mLock) {
|
||||
synchronized (mLock) {
|
||||
final AndroidPackage pkg = mPackages.get(packageName);
|
||||
if (pkg == null
|
||||
|| shouldFilterApplicationLocked(getPackageSetting(pkg.getPackageName()),
|
||||
@@ -26656,7 +26656,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (packageName == null || ks == null) {
|
||||
return false;
|
||||
}
|
||||
synchronized(mLock) {
|
||||
synchronized (mLock) {
|
||||
final AndroidPackage pkg = mPackages.get(packageName);
|
||||
if (pkg == null
|
||||
|| shouldFilterApplicationLocked(getPackageSetting(pkg.getPackageName()),
|
||||
|
||||
Reference in New Issue
Block a user