Merge "Only set userHasDeviceEntryIntent on keyguard" into sc-dev

This commit is contained in:
Beverly Tai
2021-07-28 13:21:09 +00:00
committed by Android (Google) Code Review
3 changed files with 63 additions and 2 deletions

View File

@@ -883,11 +883,15 @@ public class UdfpsController implements DozeReceiver {
private void onFingerDown(int x, int y, float minor, float major) {
mExecution.assertIsMainThread();
mKeyguardBypassController.setUserHasDeviceEntryIntent(true);
if (mView == null) {
Log.w(TAG, "Null view in onFingerDown");
return;
}
if (mView.getAnimationViewController() instanceof UdfpsKeyguardViewController) {
mKeyguardBypassController.setUserHasDeviceEntryIntent(true);
}
if (!mOnFingerDown) {
playStartHaptic();

View File

@@ -222,6 +222,7 @@ open class KeyguardBypassController : Dumpable, StackScrollAlgorithm.BypassContr
pw.println(" launchingAffordance: $launchingAffordance")
pw.println(" qSExpanded: $qSExpanded")
pw.println(" hasFaceFeature: $hasFaceFeature")
pw.println(" userHasDeviceEntryIntent: $userHasDeviceEntryIntent")
}
companion object {

View File

@@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -150,6 +151,10 @@ public class UdfpsControllerTest extends SysuiTestCase {
@Mock
private UdfpsView mUdfpsView;
@Mock
private UdfpsEnrollView mEnrollView;
@Mock
private UdfpsKeyguardView mKeyguardView;
@Mock
private UdfpsKeyguardViewController mUdfpsKeyguardViewController;
@Mock
private TypedArray mBrightnessValues;
@@ -171,7 +176,13 @@ public class UdfpsControllerTest extends SysuiTestCase {
setUpResources();
mExecution = new FakeExecution();
when(mLayoutInflater.inflate(R.layout.udfps_view, null, false)).thenReturn(mUdfpsView);
when(mLayoutInflater.inflate(R.layout.udfps_view, null, false))
.thenReturn(mUdfpsView);
when(mLayoutInflater.inflate(R.layout.udfps_enroll_view, null))
.thenReturn(mEnrollView); // for showOverlay REASON_ENROLL_ENROLLING
when(mLayoutInflater.inflate(R.layout.udfps_keyguard_view, null))
.thenReturn(mKeyguardView); // for showOverlay REASON_AUTH_FPM_KEYGUARD
when(mEnrollView.getContext()).thenReturn(mContext);
final List<FingerprintSensorPropertiesInternal> props = new ArrayList<>();
final List<ComponentInfoInternal> componentInfo = new ArrayList<>();
@@ -263,6 +274,51 @@ public class UdfpsControllerTest extends SysuiTestCase {
verify(mStatusBarKeyguardViewManager).notifyKeyguardAuthenticated(anyBoolean());
}
@Test
public void onActionMove_onKeyguard_setDeviceEntryIntent() throws RemoteException {
// GIVEN the current animation is UdfpsKeyguardViewController
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false);
when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
when(mUdfpsView.getAnimationViewController()).thenReturn(mUdfpsKeyguardViewController);
// GIVEN that the overlay is showing
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD, mUdfpsOverlayControllerCallback);
mFgExecutor.runAllReady();
// WHEN ACTION_DOWN is received
verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0);
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
moveEvent.recycle();
// THEN device entry intent is set to true
verify(mKeyguardBypassController).setUserHasDeviceEntryIntent(true);
}
@Test
public void onActionMove_onEnrollment_neverSetDeviceEntryIntent() throws RemoteException {
// GIVEN the current animation is UdfpsEnrollViewController
when(mKeyguardStateController.canDismissLockScreen()).thenReturn(false);
when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true);
when(mUdfpsView.getAnimationViewController()).thenReturn(
mock(UdfpsEnrollViewController.class));
// GIVEN that the overlay is showing
mOverlayController.showUdfpsOverlay(TEST_UDFPS_SENSOR_ID,
IUdfpsOverlayController.REASON_ENROLL_ENROLLING, mUdfpsOverlayControllerCallback);
mFgExecutor.runAllReady();
// WHEN ACTION_DOWN is received
verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture());
MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0);
mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent);
moveEvent.recycle();
// THEN device entry intent is never set
verify(mKeyguardBypassController, never()).setUserHasDeviceEntryIntent(anyBoolean());
}
@Test
public void onActionMoveTouch_whenCanDismissLockScreen_entersDevice() throws RemoteException {
// GIVEN can dismiss lock screen and the current animation is an UdfpsKeyguardViewController