Serialize key eviction vs. user storage preparation
UserManagerService.onBeforeUnlockUser requires unlocked user key
and is executed on FgThread. Currently key may be locked from
a different thread: UserController.finishUserStopped is executed in
mHandler. This changes moves lockUserKey part to FgThread, so that
key state can be reliably checked before starting onBeforeUnlockUser.
In the worst case user will be RUNNING_LOCKED with "Some functionality
may be limited" warning and unable to start apps. But that seems
fairly harmless.
+ got rid of redundant boolean in finishUserStopped.
Fixes:
72334925
Test: Turn work mode on and off ad nauseam
Test cts-tradefed run commandAndExit cts-dev -m CtsDevicePolicyManagerTestCases
-t com.android.cts.devicepolicy.ManagedProfileTest
Test: creating another user and swithching back and forth
Test: exercising DPMS.lockNow(FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY) via TestDPC
Change-Id: I01d4dea183fd1a35a2e47284c7a544725e8a871f