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
1 file changed