Resume when keyguard start going away

When keyguard is present we can start resuming when AM receives
a callback that it starts going away and not wait until animation
finishes. This CL also fixes an issue with mKeyguardGoingAway being
removed too early in case there is no transition. Plus it brings
back a fix for pausing stopped activities after keyguard goes away
and they become visible again.

Bug: 73003134
Bug: 73062280
Bug: 71582913
Test: Go to launcher or launch an app, lock and unlock, observe
Change-Id: I541cf1c942526e844a02fe4e69b690ba0008fe0d
diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java
index e361a70..6b8b380 100644
--- a/services/core/java/com/android/server/am/KeyguardController.java
+++ b/services/core/java/com/android/server/am/KeyguardController.java
@@ -117,14 +117,11 @@
         mSecondaryDisplayShowing = secondaryDisplayShowing;
         if (showingChanged) {
             dismissDockedStackIfNeeded();
+            setKeyguardGoingAway(false);
             if (showing) {
-                setKeyguardGoingAway(false);
                 mDismissalRequested = false;
             }
         }
-        if (!showing) {
-            mStackSupervisor.resumeFocusedStackTopActivityLocked();
-        }
         mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
         updateKeyguardSleepToken();
     }
@@ -149,6 +146,7 @@
             updateKeyguardSleepToken();
 
             // Some stack visibility might change (e.g. docked stack)
+            mStackSupervisor.resumeFocusedStackTopActivityLocked();
             mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
             mStackSupervisor.addStartingWindowsForVisibleActivities(true /* taskSwitch */);
             mWindowManager.executeAppTransition();
@@ -395,8 +393,4 @@
         proto.write(KEYGUARD_OCCLUDED, mOccluded);
         proto.end(token);
     }
-
-    public void notifyAppTransitionDone() {
-        setKeyguardGoingAway(false);
-    }
 }