From 1d2f630933559a35c7f4d7bacb0ca15980257873 Mon Sep 17 00:00:00 2001 From: Beverly Date: Tue, 27 Jul 2021 12:35:31 -0400 Subject: [PATCH] Only set userHasDeviceEntryIntent on keyguard So we don't bypass after enrollment (or bp). We only care about this on the keyguard. Test: manual, atest UdfpsControllerTest Fixes: 194641124 Change-Id: I9b7338cb8a4f7033a59e23d498bfe9cc51e53f0b --- .../systemui/biometrics/UdfpsController.java | 6 +- .../phone/KeyguardBypassController.kt | 1 + .../biometrics/UdfpsControllerTest.java | 58 ++++++++++++++++++- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 950bd83197555..594dcff2644d2 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -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(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt index ec669711e2db0..3a4a819bc623f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBypassController.kt @@ -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 { diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java index ca114516ef8dd..191140c46693f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java @@ -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 props = new ArrayList<>(); final List 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