Fix race condition in PM snapshots
Bug: 177499032
Fix a race condition in snapshot generation. The root cause is that
the "invalid" flag and the current snapshot are not read atomically.
Therefore, the invalid flag that is read might not apply to the
snapshot being held by thread.
Three things are fixed in this change:
1. If the current thread already holds mLock then the live computer
is used even if the snapshot computer was requested. See the bug
for a description of why this works and why it is important even
without items 2 and 3.
2. Otherwise, the snapshot lock it taken to decide if the current
snapshot can be reused or if it must be rebuilt.
3. Two formatting/editorial nits are fixed.
Test: atest
* FrameworksServicesTests:UserSystemPackageInstallerTest
* FrameworksServicesTests:PackageManagerSettingsTests
* FrameworksServicesTests:PackageManagerServiceTest
* FrameworksServicesTests:AppsFilterTest
* FrameworksServicesTests:PackageInstallerSessionTest
* FrameworksServicesTests:ScanTests
* UserLifecycleTests#startUser
* UserLifecycleTests#stopUser
* UserLifecycleTests#switchUser
Change-Id: I67dfcfde87e2b4cbc74b66a7d2921e602883be83
1 file changed