Merge "Don't let UdfpsView intercept touches when pauseAuth=true" into sc-dev

This commit is contained in:
Beverly Tai
2021-05-05 15:29:39 +00:00
committed by Android (Google) Code Review
3 changed files with 30 additions and 6 deletions

View File

@@ -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() {

View File

@@ -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;
}

View File

@@ -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();