Update showing udfps keyguard affordance logic

- Don't show if QS is expanded

Test: manual
Bug: 183112863
Bug: 175717712
Change-Id: I9836e391d32982613e7a04b4e97bc9f4d8bbf986
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
index 08e5d56..1f652db 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsKeyguardViewController.java
@@ -33,6 +33,7 @@
     @NonNull private final StatusBarKeyguardViewManager mKeyguardViewManager;
 
     private boolean mForceShow;
+    private boolean mQsExpanded;
 
     protected UdfpsKeyguardViewController(
             @NonNull UdfpsKeyguardView view,
@@ -64,7 +65,7 @@
     protected void onViewDetached() {
         super.onViewDetached();
         mStatusBarStateController.removeCallback(mStateListener);
-        mAlternateAuthInterceptor.reset();
+        mAlternateAuthInterceptor.resetForceShow();
         mKeyguardViewManager.setAlternateAuthInterceptor(null);
     }
 
@@ -100,6 +101,11 @@
         if (mForceShow) {
             return false;
         }
+
+        if (mQsExpanded) {
+            return true;
+        }
+
         return super.shouldPauseAuth();
     }
 
@@ -130,7 +136,7 @@
                 }
 
                 @Override
-                public boolean reset() {
+                public boolean resetForceShow() {
                     if (!mForceShow) {
                         return false;
                     }
@@ -140,7 +146,7 @@
                 }
 
                 @Override
-                public boolean isShowingAlternativeAuth() {
+                public boolean isShowingAlternateAuth() {
                     return mForceShow;
                 }
 
@@ -150,6 +156,12 @@
                 }
 
                 @Override
+                public void setQsExpanded(boolean expanded) {
+                    mQsExpanded = expanded;
+                    updatePauseAuth();
+                }
+
+                @Override
                 public void dump(PrintWriter pw) {
                     pw.print(getTag());
                 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
index 4ef6668..07800b3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java
@@ -1824,6 +1824,7 @@
             mNotificationContainerParent.setQsExpanded(expanded);
             mPulseExpansionHandler.setQsExpanded(expanded);
             mKeyguardBypassController.setQSExpanded(expanded);
+            mStatusBarKeyguardViewManager.setQsExpanded(expanded);
         }
     }
 
@@ -3389,7 +3390,7 @@
         return new TouchHandler() {
             @Override
             public boolean onInterceptTouchEvent(MotionEvent event) {
-                if (mStatusBarKeyguardViewManager.isShowingAlternativeAuthOrAnimating()) {
+                if (mStatusBarKeyguardViewManager.isShowingAlternateAuthOrAnimating()) {
                     return true;
                 }
                 if (mBlockTouches || mQsFullyExpanded && mQs.disallowPanelTouches()) {
@@ -3420,8 +3421,8 @@
             @Override
             public boolean onTouch(View v, MotionEvent event) {
                 final boolean showingOrAnimatingAltAuth =
-                        mStatusBarKeyguardViewManager.isShowingAlternativeAuthOrAnimating();
-                if (showingOrAnimatingAltAuth) {
+                        mStatusBarKeyguardViewManager.isShowingAlternateAuthOrAnimating();
+                if (showingOrAnimatingAltAuth && event.getAction() == MotionEvent.ACTION_DOWN) {
                     mStatusBarKeyguardViewManager.resetAlternateAuth();
                 }
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
index ed4f324..77abe79 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelViewController.java
@@ -454,7 +454,7 @@
                 mView.postOnAnimation(mPostCollapseRunnable);
             }
         } else if (!mStatusBar.isBouncerShowing()
-                && !mStatusBarKeyguardViewManager.isShowingAlternativeAuthOrAnimating()) {
+                && !mStatusBarKeyguardViewManager.isShowingAlternateAuthOrAnimating()) {
             boolean expands = onEmptySpaceClick(mInitialTouchX);
             onTrackingStopped(expands);
         }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 427df5e..e481ded 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -4187,7 +4187,7 @@
                 mNotificationPanelViewController.isLaunchingAffordanceWithPreview();
         mScrimController.setLaunchingAffordanceWithPreview(launchingAffordanceWithPreview);
 
-        if (mStatusBarKeyguardViewManager.isShowingAlternativeAuth()) {
+        if (mStatusBarKeyguardViewManager.isShowingAlternateAuth()) {
             mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED);
         } else if (mBouncerShowing) {
             // Bouncer needs the front scrim when it's on top of an activity,
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 c1f300b..7ee7aa4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -476,11 +476,12 @@
                 return;
             }
 
-            if (mAlternateAuthInterceptor != null
-                    && mAlternateAuthInterceptor.showAlternativeAuthMethod()) {
-                mStatusBar.updateScrimController();
+            if (mAlternateAuthInterceptor != null) {
                 mAfterKeyguardGoneAction = r;
                 mKeyguardGoneCancelAction = cancelAction;
+                if (mAlternateAuthInterceptor.showAlternativeAuthMethod()) {
+                    mStatusBar.updateScrimController();
+                }
                 return;
             }
 
@@ -528,7 +529,7 @@
      * Stop showing any alternate auth methods
      */
     public void resetAlternateAuth() {
-        if (mAlternateAuthInterceptor != null && mAlternateAuthInterceptor.reset()) {
+        if (mAlternateAuthInterceptor != null && mAlternateAuthInterceptor.resetForceShow()) {
             mStatusBar.updateScrimController();
         }
     }
@@ -1125,18 +1126,27 @@
         setDozing(isDozing);
     }
 
+    /**
+     * Set whether qs is currently expanded
+     */
+    public void setQsExpanded(boolean expanded) {
+        if (mAlternateAuthInterceptor != null) {
+            mAlternateAuthInterceptor.setQsExpanded(expanded);
+        }
+    }
+
     public KeyguardBouncer getBouncer() {
         return mBouncer;
     }
 
-    public boolean isShowingAlternativeAuth() {
+    public boolean isShowingAlternateAuth() {
         return mAlternateAuthInterceptor != null
-                && mAlternateAuthInterceptor.isShowingAlternativeAuth();
+                && mAlternateAuthInterceptor.isShowingAlternateAuth();
     }
 
-    public boolean isShowingAlternativeAuthOrAnimating() {
+    public boolean isShowingAlternateAuthOrAnimating() {
         return mAlternateAuthInterceptor != null
-                && (mAlternateAuthInterceptor.isShowingAlternativeAuth()
+                && (mAlternateAuthInterceptor.isShowingAlternateAuth()
                 || mAlternateAuthInterceptor.isAnimating());
     }
 
@@ -1169,12 +1179,12 @@
          * reset the state to the default (only keyguard showing, no auth methods showing)
          * @return whether alternative auth method was newly hidden
          */
-        boolean reset();
+        boolean resetForceShow();
 
         /**
          * @return true if alternative auth method is showing
          */
-        boolean isShowingAlternativeAuth();
+        boolean isShowingAlternateAuth();
 
         /**
          * print information for the alternate auth interceptor registered
@@ -1185,5 +1195,10 @@
          * @return true if the new auth method is currently animating in or out.
          */
         boolean isAnimating();
+
+        /**
+         * Set whether qs is currently expanded
+         */
+        void setQsExpanded(boolean expanded);
     }
 }
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 65f0f7b..4410992 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsKeyguardViewControllerTest.java
@@ -170,11 +170,11 @@
 
         mAltAuthInterceptor.showAlternativeAuthMethod(); // force show
         assertFalse(mController.shouldPauseAuth());
-        assertTrue(mAltAuthInterceptor.isShowingAlternativeAuth());
+        assertTrue(mAltAuthInterceptor.isShowingAlternateAuth());
 
-        mAltAuthInterceptor.reset(); // stop force show
+        mAltAuthInterceptor.resetForceShow(); // stop force show
         assertTrue(mController.shouldPauseAuth());
-        assertFalse(mAltAuthInterceptor.isShowingAlternativeAuth());
+        assertFalse(mAltAuthInterceptor.isShowingAlternateAuth());
     }
 
     @Test
@@ -190,7 +190,7 @@
         mController.onViewDetached();
 
         // THEN alt auth state reports not showing
-        assertFalse(mAltAuthInterceptor.isShowingAlternativeAuth());
+        assertFalse(mAltAuthInterceptor.isShowingAlternateAuth());
     }
 
     private void sendStatusBarStateChanged(int statusBarState) {