Fix race condition around CE storage becoming available.
This fixes a race condition that exists around preparing CE storage, and a package being reinstalled at the same time. The normal CE data unlock procedure is something like this: 1. User state is RUNNING_LOCKED 2. UserController calls onBeforeUnlockUser() 3. onBeforeUnlockUser() prepares CE storage 4. onBeforeUnlockUser() calls PackageManagerService.reconcileAppsData() 5. reconcileAppsData() prepares app CE data directories, creating dirs when needed 6. UserController changes state to RUNNING_UNLOCKING The race comes into the picture when an app is installed right between step 5 and step 6; when a new app is installed, PMS does have a function to create the CE app data directory; but that function only creates CE data directories when the user state is RUNNING_UNLOCKING (or later); so even though technically CE storage became available in step 3, other parts of PMS will only use it after step 6 has completed. To fix this, we use StorageManagerService to record the fact that CE storage for a particular user is prepared; then, PackageManagerService can query StorageManager to ask whether CE storage is prepared. That in combination with the user key being unlocked is then used as a condition for creating CE data directories from PackageManagerService. Bug: 187103629 Test: manual Change-Id: Ice81ae98441b9ed287e8db4196a041c3d47afce9 Merged-In: Ice81ae98441b9ed287e8db4196a041c3d47afce9
Loading
Please register or sign in to comment