Loading packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +18 −12 Original line number Diff line number Diff line Loading @@ -245,7 +245,7 @@ public class UdfpsController implements DozeReceiver { mAcquiredReceived = true; final UdfpsView view = mOverlay.getOverlayView(); if (view != null) { view.unconfigureDisplay(); unconfigureDisplay(view); } if (acquiredGood) { mOverlay.onAcquiredGood(); Loading Loading @@ -735,6 +735,19 @@ public class UdfpsController implements DozeReceiver { mOverlay = null; mOrientationListener.disable(); } private void unconfigureDisplay(@NonNull UdfpsView view) { if (view.isDisplayConfigured()) { view.unconfigureDisplay(); if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; } mIsAodInterruptActive = false; } } /** Loading Loading @@ -810,12 +823,12 @@ public class UdfpsController implements DozeReceiver { * sensors, this can result in illumination persisting for longer than necessary. */ void onCancelUdfps() { if (mOverlay != null && mOverlay.getOverlayView() != null) { onFingerUp(mOverlay.getRequestId(), mOverlay.getOverlayView()); } if (!mIsAodInterruptActive) { return; } if (mOverlay != null && mOverlay.getOverlayView() != null) { onFingerUp(mOverlay.getRequestId(), mOverlay.getOverlayView()); } if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; Loading Loading @@ -909,15 +922,8 @@ public class UdfpsController implements DozeReceiver { } } mOnFingerDown = false; if (view.isDisplayConfigured()) { view.unconfigureDisplay(); } unconfigureDisplay(view); if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; } mIsAodInterruptActive = false; } /** Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +52 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.graphics.Rect; import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.BiometricOverlayConstants; import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; Loading Loading @@ -682,7 +683,7 @@ public class UdfpsControllerTest extends SysuiTestCase { } @Test public void aodInterruptCancelTimeoutActionWhenFingerUp() throws RemoteException { public void aodInterruptCancelTimeoutActionOnFingerUp() throws RemoteException { when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true); when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true); Loading Loading @@ -733,6 +734,56 @@ public class UdfpsControllerTest extends SysuiTestCase { verify(mUdfpsView, times(1)).unconfigureDisplay(); } @Test public void aodInterruptCancelTimeoutActionOnAcquired() throws RemoteException { when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true); when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true); // GIVEN AOD interrupt mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, TEST_UDFPS_SENSOR_ID, BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback); mScreenObserver.onScreenTurnedOn(); mFgExecutor.runAllReady(); mUdfpsController.onAodInterrupt(0, 0, 0f, 0f); mFgExecutor.runAllReady(); // Configure UdfpsView to accept the acquired event when(mUdfpsView.isDisplayConfigured()).thenReturn(true); // WHEN acquired is received mOverlayController.onAcquired(TEST_UDFPS_SENSOR_ID, BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD); // Configure UdfpsView to accept the ACTION_DOWN event when(mUdfpsView.isDisplayConfigured()).thenReturn(false); // WHEN ACTION_DOWN is received verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture()); MotionEvent downEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, downEvent); mBiometricsExecutor.runAllReady(); downEvent.recycle(); // WHEN ACTION_MOVE is received MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent); mBiometricsExecutor.runAllReady(); moveEvent.recycle(); mFgExecutor.runAllReady(); // Configure UdfpsView to accept the finger up event when(mUdfpsView.isDisplayConfigured()).thenReturn(true); // WHEN it times out mFgExecutor.advanceClockToNext(); mFgExecutor.runAllReady(); // THEN the display should be unconfigured once. If the timeout action is not // cancelled, the display would be unconfigured twice which would cause two // FP attempts. verify(mUdfpsView, times(1)).unconfigureDisplay(); } @Test public void aodInterruptScreenOff() throws RemoteException { // GIVEN screen off Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +18 −12 Original line number Diff line number Diff line Loading @@ -245,7 +245,7 @@ public class UdfpsController implements DozeReceiver { mAcquiredReceived = true; final UdfpsView view = mOverlay.getOverlayView(); if (view != null) { view.unconfigureDisplay(); unconfigureDisplay(view); } if (acquiredGood) { mOverlay.onAcquiredGood(); Loading Loading @@ -735,6 +735,19 @@ public class UdfpsController implements DozeReceiver { mOverlay = null; mOrientationListener.disable(); } private void unconfigureDisplay(@NonNull UdfpsView view) { if (view.isDisplayConfigured()) { view.unconfigureDisplay(); if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; } mIsAodInterruptActive = false; } } /** Loading Loading @@ -810,12 +823,12 @@ public class UdfpsController implements DozeReceiver { * sensors, this can result in illumination persisting for longer than necessary. */ void onCancelUdfps() { if (mOverlay != null && mOverlay.getOverlayView() != null) { onFingerUp(mOverlay.getRequestId(), mOverlay.getOverlayView()); } if (!mIsAodInterruptActive) { return; } if (mOverlay != null && mOverlay.getOverlayView() != null) { onFingerUp(mOverlay.getRequestId(), mOverlay.getOverlayView()); } if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; Loading Loading @@ -909,15 +922,8 @@ public class UdfpsController implements DozeReceiver { } } mOnFingerDown = false; if (view.isDisplayConfigured()) { view.unconfigureDisplay(); } unconfigureDisplay(view); if (mCancelAodTimeoutAction != null) { mCancelAodTimeoutAction.run(); mCancelAodTimeoutAction = null; } mIsAodInterruptActive = false; } /** Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +52 −1 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.graphics.Rect; import android.hardware.biometrics.BiometricFingerprintConstants; import android.hardware.biometrics.BiometricOverlayConstants; import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; Loading Loading @@ -682,7 +683,7 @@ public class UdfpsControllerTest extends SysuiTestCase { } @Test public void aodInterruptCancelTimeoutActionWhenFingerUp() throws RemoteException { public void aodInterruptCancelTimeoutActionOnFingerUp() throws RemoteException { when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true); when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true); Loading Loading @@ -733,6 +734,56 @@ public class UdfpsControllerTest extends SysuiTestCase { verify(mUdfpsView, times(1)).unconfigureDisplay(); } @Test public void aodInterruptCancelTimeoutActionOnAcquired() throws RemoteException { when(mUdfpsView.isWithinSensorArea(anyFloat(), anyFloat())).thenReturn(true); when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true); // GIVEN AOD interrupt mOverlayController.showUdfpsOverlay(TEST_REQUEST_ID, TEST_UDFPS_SENSOR_ID, BiometricOverlayConstants.REASON_AUTH_KEYGUARD, mUdfpsOverlayControllerCallback); mScreenObserver.onScreenTurnedOn(); mFgExecutor.runAllReady(); mUdfpsController.onAodInterrupt(0, 0, 0f, 0f); mFgExecutor.runAllReady(); // Configure UdfpsView to accept the acquired event when(mUdfpsView.isDisplayConfigured()).thenReturn(true); // WHEN acquired is received mOverlayController.onAcquired(TEST_UDFPS_SENSOR_ID, BiometricFingerprintConstants.FINGERPRINT_ACQUIRED_GOOD); // Configure UdfpsView to accept the ACTION_DOWN event when(mUdfpsView.isDisplayConfigured()).thenReturn(false); // WHEN ACTION_DOWN is received verify(mUdfpsView).setOnTouchListener(mTouchListenerCaptor.capture()); MotionEvent downEvent = MotionEvent.obtain(0, 0, ACTION_DOWN, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, downEvent); mBiometricsExecutor.runAllReady(); downEvent.recycle(); // WHEN ACTION_MOVE is received MotionEvent moveEvent = MotionEvent.obtain(0, 0, MotionEvent.ACTION_MOVE, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent); mBiometricsExecutor.runAllReady(); moveEvent.recycle(); mFgExecutor.runAllReady(); // Configure UdfpsView to accept the finger up event when(mUdfpsView.isDisplayConfigured()).thenReturn(true); // WHEN it times out mFgExecutor.advanceClockToNext(); mFgExecutor.runAllReady(); // THEN the display should be unconfigured once. If the timeout action is not // cancelled, the display would be unconfigured twice which would cause two // FP attempts. verify(mUdfpsView, times(1)).unconfigureDisplay(); } @Test public void aodInterruptScreenOff() throws RemoteException { // GIVEN screen off Loading