OSDN Git Service

Fix two shortcut manager issues
authorMakoto Onuki <omakoto@google.com>
Wed, 10 Aug 2016 17:47:13 +0000 (10:47 -0700)
committerMakoto Onuki <omakoto@google.com>
Wed, 10 Aug 2016 17:56:08 +0000 (10:56 -0700)
commit1e1732399a48c9521eea7a117f1f0e87ca64d2ab
treeccb05fdeb2c22f86ebf79c23c13a82a338f71925
parente11059694a8e380e6275968d5cb44994e4c5ecd7
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
services/core/java/com/android/server/pm/ShortcutService.java
services/tests/servicestests/src/com/android/server/pm/BaseShortcutManagerTest.java
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest1.java
services/tests/servicestests/src/com/android/server/pm/ShortcutManagerTest2.java