Fix a timing issue where LauncherApps registers its callback twice
There is an edge case while the launcher process is killed and restarted by unexpected behavior. LauncherApps unregisters a listener by being called back onCallbackDied from PackageCallbackList when the launcher process is killed. However the launcher process is immediately restarted and registers a listener in the middle of processing binderDied() even before calling the onCallbackDied() in the binderDied(). This solution is to maintain a boolean, isWatchingPackageBroadcasts, determining whether or not the monitor has been registered. startWatchingPackageBroadcasts() and stopWatchingPackageBroadcasts() are always called with the mListeners lock held, it can check/toggle the state safely in those methods. Test: compile & verify basic functions working Bug: 162753652 Change-Id: If91e4bc32b17b88576777699b3d8d9f409fae91d
Loading
Please register or sign in to comment