From 19c15e3a37721f2b46dd0ce808ec736da84e64e9 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 4 May 2021 09:42:46 -0400 Subject: [PATCH] Don't let UdfpsView intercept touches when pauseAuth=true The UdfpsView was still showing (with alpha 0) when shouldPauseAuth=true, so touches weren't being sent to the window under it. To avoid this, set the UdfpsView to invisible when pauseAuth=true. This CL also fixes a bug where it was possible to slide to authenticate when auth was paused. The isWithinSensorArea method in UdfpsController needs to have an extra check for whether auth is paused. Test: manual, atest SystemUITests Fixes: 187016303 Change-Id: Idcfe95e68cb5ee8e8472f1ecde2bd1fb74f9a151 --- .../systemui/biometrics/UdfpsAnimationView.java | 12 +++++++++++- .../systemui/biometrics/UdfpsController.java | 10 ++++++++-- .../com/android/systemui/biometrics/UdfpsView.java | 14 +++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java index 5647e43660752..2d403f63c2cdf 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java @@ -20,6 +20,8 @@ import android.annotation.Nullable; import android.content.Context; import android.graphics.RectF; import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; /** @@ -73,7 +75,15 @@ abstract class UdfpsAnimationView extends FrameLayout { } protected void updateAlpha() { - getDrawable().setAlpha(calculateAlpha()); + int alpha = calculateAlpha(); + getDrawable().setAlpha(alpha); + + // this is necessary so that touches won't be intercepted if udfps is paused: + if (mPauseAuth && alpha == 0 && getParent() != null) { + ((ViewGroup) getParent()).setVisibility(View.INVISIBLE); + } else { + ((ViewGroup) getParent()).setVisibility(View.VISIBLE); + } } int calculateAlpha() { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index ee5fb313fff35..ecbd82ca1589c 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -296,7 +296,13 @@ public class UdfpsController implements DozeReceiver, HbmCallback { // TODO: move isWithinSensorArea to UdfpsController. return udfpsView.isWithinSensorArea(x, y); } - return getSensorLocation().contains(x, y); + + if (mView == null || mView.getAnimationViewController() == null) { + return false; + } + + return !mView.getAnimationViewController().shouldPauseAuth() + && getSensorLocation().contains(x, y); } private boolean onTouch(View view, MotionEvent event, boolean fromUdfpsView) { @@ -529,7 +535,7 @@ public class UdfpsController implements DozeReceiver, HbmCallback { final int paddingY = animation != null ? animation.getPaddingY() : 0; mCoreLayoutParams.flags = getCoreLayoutParamFlags(); - if (animation.listenForTouchesOutsideView()) { + if (animation != null && animation.listenForTouchesOutsideView()) { mCoreLayoutParams.flags |= WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java index d92d8dfd35548..f10d5f3bca1fd 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java @@ -87,7 +87,8 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin // Don't propagate any touch events to the child views. @Override public boolean onInterceptTouchEvent(MotionEvent ev) { - return true; + return mAnimationViewController == null + || !mAnimationViewController.shouldPauseAuth(); } @Override @@ -131,13 +132,20 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin } void onTouchOutsideView() { - mAnimationViewController.onTouchOutsideView(); + if (mAnimationViewController != null) { + mAnimationViewController.onTouchOutsideView(); + } } - void setAnimationViewController(UdfpsAnimationViewController animationViewController) { + void setAnimationViewController( + @Nullable UdfpsAnimationViewController animationViewController) { mAnimationViewController = animationViewController; } + @Nullable UdfpsAnimationViewController getAnimationViewController() { + return mAnimationViewController; + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow();