Prevent sleep tokens from being created recursively.

Sometimes a keyguard sleep token can be created with recursively call
because we use the local object existing as a condition to create it.
The code flow looks like:

KeyguardController#updateSleepToken
if (mSleepToken == null) then a = acquireSleepToken();
acquireSleepToken
  updateSleepIfNeededLocked
    ensureActivitiesVisible
      keyguardController#visibilitiesUpdated
        updateSleepToken
Then since the local mSleepToken haven't been assigned,
acquireSleepToken would be called again. Which would create another
sleep token and leave the previous one in RootWindowContainer.

To prevent this from happening again, separate updateSleepIfNeeded
from acquireSleepToken, and store sleep token as a map, so no more
sleep token can be created with same key.

Bug: 160351101
Test: atest MultiDisplayKeyguardTests MultiDisplayLockedKeyguardTests/
KeyguardTests KeyguardInputTests KeyguardLockedTests

Change-Id: I168dfe0fa101cb65eb676ca256c03439c8e4193d
6 files changed