Loading packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +11 −9 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ class UdfpsController implements DozeReceiver { Log.v(TAG, "showUdfpsOverlay | adding window"); mView.setShowReason(reason); mWindowManager.addView(mView, computeLayoutParams()); mIsOverlayShowing = true; mView.setOnTouchListener(mOnTouchListener); mIsOverlayShowing = true; } catch (RuntimeException e) { Log.e(TAG, "showUdfpsOverlay | failed to add window", e); } Loading Loading @@ -434,20 +434,22 @@ class UdfpsController implements DozeReceiver { } private void onFingerDown(int x, int y, float minor, float major) { mView.setScrimAlpha(computeScrimOpacity()); mView.showScrimAndDot(); try { if (mHbmSupported) { try { FileWriter fw = new FileWriter(mHbmPath); fw.write(mHbmEnableCommand); fw.close(); } mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major); } catch (IOException e) { mView.hideScrimAndDot(); Log.e(TAG, "onFingerDown | failed to enable HBM: " + e.getMessage()); } } mView.setScrimAlpha(computeScrimOpacity()); mView.setRunAfterShowingScrimAndDot(() -> { mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major); }); mView.showScrimAndDot(); } private void onFingerUp() { mFingerprintManager.onPointerUp(mSensorProps.sensorId); Loading packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,10 @@ public class UdfpsView extends View implements DozeReceiver, private boolean mIsHbmSupported; @Nullable private String mDebugMessage; // Runnable that will be run after the illumination dot and scrim are shown. // The runnable is reset to null after it's executed once. @Nullable private Runnable mRunAfterShowingScrimAndDot; public UdfpsView(Context context, AttributeSet attrs) { super(context, attrs); Loading Loading @@ -279,6 +283,11 @@ public class UdfpsView extends View implements DozeReceiver, } canvas.restore(); if (mShowScrimAndDot && mRunAfterShowingScrimAndDot != null) { post(mRunAfterShowingScrimAndDot); mRunAfterShowingScrimAndDot = null; } } RectF getSensorRect() { Loading @@ -294,6 +303,10 @@ public class UdfpsView extends View implements DozeReceiver, postInvalidate(); } void setRunAfterShowingScrimAndDot(Runnable runnable) { mRunAfterShowingScrimAndDot = runnable; } boolean isValidTouch(float x, float y, float pressure) { // The X and Y coordinates of the sensor's center. final float cx = mSensorRect.centerX(); Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +13 −6 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ public class UdfpsControllerTest extends SysuiTestCase { @Captor private ArgumentCaptor<IUdfpsOverlayController> mOverlayCaptor; private IUdfpsOverlayController mOverlayController; @Captor private ArgumentCaptor<UdfpsView.OnTouchListener> mTouchListenerCaptor; @Captor private ArgumentCaptor<Runnable> mRunAfterShowingScrimAndDotCaptor; @Before public void setUp() { Loading Loading @@ -190,11 +191,14 @@ public class UdfpsControllerTest extends SysuiTestCase { MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event); event.recycle(); // THEN the event is passed to the FingerprintManager // THEN the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); // AND a runnable that passes the event to FingerprintManager is set on the view verify(mUdfpsView).setRunAfterShowingScrimAndDot( mRunAfterShowingScrimAndDotCaptor.capture()); mRunAfterShowingScrimAndDotCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(mUdfpsController.mSensorProps.sensorId), eq(0), eq(0), eq(0f), eq(0f)); // AND the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); } @Test Loading @@ -205,11 +209,14 @@ public class UdfpsControllerTest extends SysuiTestCase { mFgExecutor.runAllReady(); // WHEN fingerprint is requested because of AOD interrupt mUdfpsController.onAodInterrupt(0, 0, 2f, 3f); // THEN the event is passed to the FingerprintManager // THEN the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); // AND a runnable that passes the event to FingerprintManager is set on the view verify(mUdfpsView).setRunAfterShowingScrimAndDot( mRunAfterShowingScrimAndDotCaptor.capture()); mRunAfterShowingScrimAndDotCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(mUdfpsController.mSensorProps.sensorId), eq(0), eq(0), eq(3f) /* minor */, eq(2f) /* major */); // AND the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +11 −9 Original line number Diff line number Diff line Loading @@ -342,8 +342,8 @@ class UdfpsController implements DozeReceiver { Log.v(TAG, "showUdfpsOverlay | adding window"); mView.setShowReason(reason); mWindowManager.addView(mView, computeLayoutParams()); mIsOverlayShowing = true; mView.setOnTouchListener(mOnTouchListener); mIsOverlayShowing = true; } catch (RuntimeException e) { Log.e(TAG, "showUdfpsOverlay | failed to add window", e); } Loading Loading @@ -434,20 +434,22 @@ class UdfpsController implements DozeReceiver { } private void onFingerDown(int x, int y, float minor, float major) { mView.setScrimAlpha(computeScrimOpacity()); mView.showScrimAndDot(); try { if (mHbmSupported) { try { FileWriter fw = new FileWriter(mHbmPath); fw.write(mHbmEnableCommand); fw.close(); } mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major); } catch (IOException e) { mView.hideScrimAndDot(); Log.e(TAG, "onFingerDown | failed to enable HBM: " + e.getMessage()); } } mView.setScrimAlpha(computeScrimOpacity()); mView.setRunAfterShowingScrimAndDot(() -> { mFingerprintManager.onPointerDown(mSensorProps.sensorId, x, y, minor, major); }); mView.showScrimAndDot(); } private void onFingerUp() { mFingerprintManager.onPointerUp(mSensorProps.sensorId); Loading
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java +13 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,10 @@ public class UdfpsView extends View implements DozeReceiver, private boolean mIsHbmSupported; @Nullable private String mDebugMessage; // Runnable that will be run after the illumination dot and scrim are shown. // The runnable is reset to null after it's executed once. @Nullable private Runnable mRunAfterShowingScrimAndDot; public UdfpsView(Context context, AttributeSet attrs) { super(context, attrs); Loading Loading @@ -279,6 +283,11 @@ public class UdfpsView extends View implements DozeReceiver, } canvas.restore(); if (mShowScrimAndDot && mRunAfterShowingScrimAndDot != null) { post(mRunAfterShowingScrimAndDot); mRunAfterShowingScrimAndDot = null; } } RectF getSensorRect() { Loading @@ -294,6 +303,10 @@ public class UdfpsView extends View implements DozeReceiver, postInvalidate(); } void setRunAfterShowingScrimAndDot(Runnable runnable) { mRunAfterShowingScrimAndDot = runnable; } boolean isValidTouch(float x, float y, float pressure) { // The X and Y coordinates of the sensor's center. final float cx = mSensorRect.centerX(); Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +13 −6 Original line number Diff line number Diff line Loading @@ -106,6 +106,7 @@ public class UdfpsControllerTest extends SysuiTestCase { @Captor private ArgumentCaptor<IUdfpsOverlayController> mOverlayCaptor; private IUdfpsOverlayController mOverlayController; @Captor private ArgumentCaptor<UdfpsView.OnTouchListener> mTouchListenerCaptor; @Captor private ArgumentCaptor<Runnable> mRunAfterShowingScrimAndDotCaptor; @Before public void setUp() { Loading Loading @@ -190,11 +191,14 @@ public class UdfpsControllerTest extends SysuiTestCase { MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN, 0, 0, 0); mTouchListenerCaptor.getValue().onTouch(mUdfpsView, event); event.recycle(); // THEN the event is passed to the FingerprintManager // THEN the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); // AND a runnable that passes the event to FingerprintManager is set on the view verify(mUdfpsView).setRunAfterShowingScrimAndDot( mRunAfterShowingScrimAndDotCaptor.capture()); mRunAfterShowingScrimAndDotCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(mUdfpsController.mSensorProps.sensorId), eq(0), eq(0), eq(0f), eq(0f)); // AND the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); } @Test Loading @@ -205,11 +209,14 @@ public class UdfpsControllerTest extends SysuiTestCase { mFgExecutor.runAllReady(); // WHEN fingerprint is requested because of AOD interrupt mUdfpsController.onAodInterrupt(0, 0, 2f, 3f); // THEN the event is passed to the FingerprintManager // THEN the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); // AND a runnable that passes the event to FingerprintManager is set on the view verify(mUdfpsView).setRunAfterShowingScrimAndDot( mRunAfterShowingScrimAndDotCaptor.capture()); mRunAfterShowingScrimAndDotCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(mUdfpsController.mSensorProps.sensorId), eq(0), eq(0), eq(3f) /* minor */, eq(2f) /* major */); // AND the scrim and dot is shown verify(mUdfpsView).showScrimAndDot(); } @Test Loading