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
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user