Fix two shortcut manager issues
- isUserUnlocked check is still racy
We used a local copy of each user state in mUnlockedUsers, and updated
it in the service lifecycle events. However because
SystemService.onUnlockUser() is called on Handler, there was a brief
window between when the user was actually unlocked and the shortcut
manager thought the user was unlocked.
So now check with activity manager for the latest state too. We still
check with the local copy first, because we want to consider STOPPING
as "unlocked".
- Messenger loses all bitmap icons.
Because we delay-save the shortcuts.xml file, if the device shut down
before we save the XML file but after removing the bitmap files,
we'd lose the bitmaps.
(Apparently SystemService.onCleanupUser() may not be called even when
a device is cleanly shutting down.)
So don't remove bitmap files synchronously, ever, and instead after
saving the XML just run the dangling file cleanup.
Bug
30784267
Bug
30730471
Change-Id: Ie58656efba2dca2b00582e145613bc56266a091e