Clear the previous states before setting the new app visibility

If setAppVisibility() is called multiple times in a short interval
while the screen is turned off between the calls, the visibility of
the app would be wrong. For example, the user may see the app under
the launcher, not the wallpaper under the launcher.

The flow to the issue:
1. Screen is on.
2. AM calls setAppVisibility() token=App A's token, visible=true
3. Screen is turned off.
4. AM calls setAppVisibility() token=App A's token, visible=false

Note:
a. In 2., WM would put App A into mOpeningApps, and tell it to be
   visible.
b. In 4., because the screen is off now, App A would not be removed
   from mOpeningApps. App A might be told to be invisible directly
   through setTokenVisibilityLocked(), but it would be told to be
   visible again in handleAppTransitionReadyLocked() later.

Change-Id: Icf3d69031ea2822245008248ec8f12bd57218880
1 file changed