diff options
| author | 2021-07-28 13:21:09 +0000 | |
|---|---|---|
| committer | 2021-07-28 13:21:09 +0000 | |
| commit | ebe9e34fbb7113f2c9901b3417f1703e14f6711e (patch) | |
| tree | db21801b37f13ed2f016029070c71185b3f30944 | |
| parent | 1181f3e9aad9ffcc429c98e7dccfe2a2a3bb8076 (diff) | |
| parent | 1d2f630933559a35c7f4d7bacb0ca15980257873 (diff) | |
Merge "Only set userHasDeviceEntryIntent on keyguard" into sc-dev
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 950bd8319755..594dcff2644d 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 ec669711e2db..3a4a819bc623 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 ca114516ef8d..191140c46693 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<FingerprintSensorPropertiesInternal> props = new ArrayList<>(); final List<ComponentInfoInternal> componentInfo = new ArrayList<>(); @@ -264,6 +275,51 @@ public class UdfpsControllerTest extends SysuiTestCase { } @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 when(mKeyguardStateController.canDismissLockScreen()).thenReturn(true); |