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
(cherry picked from commit 19c15e3a37721f2b46dd0ce808ec736da84e64e9)
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java
index 5647e43..2d403f6 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.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 @@
}
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 ee5fb31..ecbd82ca 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 @@
// 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 @@
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 d92d8df..f10d5f3 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 @@
// 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 @@
}
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();