The big Keyguard transition refactor (8/n)

Don't force mKeyguardGoingAway, as this never recovers. Make sure
to only show the dismissing Keyguard activtiy and recover the
state when trusted state changes.

Test: Make sure Keyguard is in a trusted state, start an activity
with FLAG_DISMISS_KEYGUARD from FLAG_SHOW_WHEN_LOCKED activity
and make sure there is no flicker.

Bug: 32057734
Change-Id: I5d212f6f9d5430250b22c8370f45dc95756432d2
diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java
index 98acc9c..9d8c383 100644
--- a/services/core/java/com/android/server/am/KeyguardController.java
+++ b/services/core/java/com/android/server/am/KeyguardController.java
@@ -154,6 +154,14 @@
         }
     }
 
+    /**
+     * @return True if we may show an activity while Keyguard is showing because we are in the
+     *         process of dismissing it anyways, false otherwise.
+     */
+    boolean canShowActivityWhileKeyguardShowing(boolean dismissKeyguard) {
+        return dismissKeyguard && canDismissKeyguard();
+    }
+
     private void visibilitiesUpdated() {
         final boolean lastOccluded = mOccluded;
         final ActivityRecord lastDismissingKeyguardActivity = mDismissingKeyguardActivity;
@@ -215,7 +223,6 @@
                     && mWindowManager.getPendingAppTransition() == TRANSIT_KEYGUARD_UNOCCLUDE) {
                 mWindowManager.prepareAppTransition(mBeforeUnoccludeTransit,
                         false /* alwaysKeepCurrent */, 0 /* flags */, true /* forceOverride */);
-                mKeyguardGoingAway = true;
                 mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
                 mWindowManager.executeAppTransition();
             }