Merge "Update bouncer visibility on altAuthBouncer changes" into tm-dev am: 5778a88d45

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17776443

Change-Id: Iebb3c566976eb4375930ab01d63ea0c27de9b826
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
index 1a726ce..4ec479a 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
@@ -21,7 +21,6 @@
 import android.animation.ValueAnimator;
 import android.annotation.NonNull;
 import android.content.res.Configuration;
-import android.util.Log;
 import android.util.MathUtils;
 import android.view.MotionEvent;
 
@@ -83,7 +82,7 @@
      * {@link KeyguardBouncer#EXPANSION_HIDDEN} (1f)
      */
     private float mInputBouncerHiddenAmount;
-    private boolean mIsBouncerVisible;
+    private boolean mIsGenericBouncerShowing; // whether UDFPS bouncer or input bouncer is visible
 
     protected UdfpsKeyguardViewController(
             @NonNull UdfpsKeyguardView view,
@@ -151,8 +150,7 @@
         mKeyguardStateController.addCallback(mKeyguardStateControllerCallback);
         mStatusBarState = getStatusBarStateController().getState();
         mQsExpanded = mKeyguardViewManager.isQsExpanded();
-        mInputBouncerHiddenAmount = KeyguardBouncer.EXPANSION_HIDDEN;
-        mIsBouncerVisible = mKeyguardViewManager.bouncerIsOrWillBeShowing();
+        updateGenericBouncerVisibility();
         mConfigurationController.addCallback(mConfigurationListener);
         getPanelExpansionStateManager().addExpansionListener(mPanelExpansionListener);
         updateAlpha();
@@ -187,7 +185,7 @@
         pw.println("mFaceDetectRunning=" + mFaceDetectRunning);
         pw.println("mStatusBarState=" + StatusBarState.toString(mStatusBarState));
         pw.println("mQsExpanded=" + mQsExpanded);
-        pw.println("mIsBouncerVisible=" + mIsBouncerVisible);
+        pw.println("mIsGenericBouncerShowing=" + mIsGenericBouncerShowing);
         pw.println("mInputBouncerHiddenAmount=" + mInputBouncerHiddenAmount);
         pw.println("mPanelExpansionFraction=" + mPanelExpansionFraction);
         pw.println("unpausedAlpha=" + mView.getUnpausedAlpha());
@@ -225,6 +223,8 @@
         } else {
             mKeyguardUpdateMonitor.requestFaceAuthOnOccludingApp(false);
         }
+
+        updateGenericBouncerVisibility();
         updateAlpha();
         updatePauseAuth();
         return true;
@@ -241,7 +241,7 @@
         }
 
         if (mUdfpsRequested && !getNotificationShadeVisible()
-                && (!mIsBouncerVisible
+                && (!mIsGenericBouncerShowing
                 || mInputBouncerHiddenAmount != KeyguardBouncer.EXPANSION_VISIBLE)
                 && mKeyguardStateController.isShowing()) {
             return false;
@@ -267,13 +267,8 @@
             return true;
         }
 
-        if (mInputBouncerHiddenAmount < .5f || mIsBouncerVisible) {
-            if (!getStatusBarStateController().isDozing()) {
-                return true;
-            } else {
-                Log.e(TAG, "Bouncer state claims visible on doze hiddenAmount="
-                        + mInputBouncerHiddenAmount + " bouncerVisible=" + mIsBouncerVisible);
-            }
+        if (mInputBouncerHiddenAmount < .5f) {
+            return true;
         }
 
         return false;
@@ -351,6 +346,21 @@
         mView.setUnpausedAlpha(alpha);
     }
 
+    /**
+     * Updates mIsGenericBouncerShowing (whether any bouncer is showing) and updates the
+     * mInputBouncerHiddenAmount to reflect whether the input bouncer is fully showing or not.
+     */
+    private void updateGenericBouncerVisibility() {
+        mIsGenericBouncerShowing = mKeyguardViewManager.isBouncerShowing(); // includes altBouncer
+        final boolean altBouncerShowing = mKeyguardViewManager.isShowingAlternateAuth();
+        if (altBouncerShowing || !mKeyguardViewManager.bouncerIsOrWillBeShowing()) {
+            mInputBouncerHiddenAmount = 1f;
+        } else if (mIsGenericBouncerShowing) {
+            // input bouncer is fully showing
+            mInputBouncerHiddenAmount = 0f;
+        }
+    }
+
     private final StatusBarStateController.StateListener mStateListener =
             new StatusBarStateController.StateListener() {
         @Override
@@ -434,14 +444,13 @@
                     updatePauseAuth();
                 }
 
+                /**
+                 * Only called on primary auth bouncer changes, not on whether the UDFPS bouncer
+                 * visibility changes.
+                 */
                 @Override
                 public void onBouncerVisibilityChanged() {
-                    mIsBouncerVisible = mKeyguardViewManager.isBouncerShowing();
-                    if (!mIsBouncerVisible) {
-                        mInputBouncerHiddenAmount = 1f;
-                    } else if (mKeyguardViewManager.isBouncerShowing()) {
-                        mInputBouncerHiddenAmount = 0f;
-                    }
+                    updateGenericBouncerVisibility();
                     updateAlpha();
                     updatePauseAuth();
                 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index 8016ea5..6758b76 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -1270,6 +1270,8 @@
         pw.println("  mAfterKeyguardGoneAction: " + mAfterKeyguardGoneAction);
         pw.println("  mAfterKeyguardGoneRunnables: " + mAfterKeyguardGoneRunnables);
         pw.println("  mPendingWakeupAction: " + mPendingWakeupAction);
+        pw.println("  isBouncerShowing(): " + isBouncerShowing());
+        pw.println("  bouncerIsOrWillBeShowing(): " + bouncerIsOrWillBeShowing());
 
         if (mBouncer != null) {
             mBouncer.dump(pw);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java
index 186f2bb..1296417 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java
@@ -205,6 +205,7 @@
 
         captureAltAuthInterceptor();
         when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true);
+        when(mStatusBarKeyguardViewManager.bouncerIsOrWillBeShowing()).thenReturn(true);
         mAltAuthInterceptor.onBouncerVisibilityChanged();
 
         assertTrue(mController.shouldPauseAuth());