Loading packages/SystemUI/src/com/android/systemui/biometrics/AlternateUdfpsTouchProvider.kt 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.biometrics /** * Interface for controlling the on finger down & on finger up events. */ interface AlternateUdfpsTouchProvider { /** * This operation is used to notify the Fingerprint HAL that * a fingerprint has been detected on the device's screen. * * See fingerprint/ISession#onPointerDown for more details. */ fun onPointerDown(pointerId: Long, x: Int, y: Int, minor: Float, major: Float) /** * onPointerUp: * * This operation can be invoked when the HAL is performing any one of: ISession#authenticate, * ISession#enroll, ISession#detectInteraction. This operation is used to indicate * that a fingerprint that was previously down, is now up. * * See fingerprint/ISession#onPointerUp for more details. */ fun onPointerUp(pointerId: Long) } packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +15 −3 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class UdfpsController implements DozeReceiver { // sensors, this, in addition to a lot of the code here, will be updated. @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps; @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator; @Nullable private final AlternateUdfpsTouchProvider mAlternateTouchProvider; // Tracks the velocity of a touch to help filter out the touches that move too fast. @Nullable private VelocityTracker mVelocityTracker; Loading Loading @@ -537,7 +538,8 @@ public class UdfpsController implements DozeReceiver { @NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, @NonNull SystemUIDialogManager dialogManager, @NonNull LatencyTracker latencyTracker, @NonNull ActivityLaunchAnimator activityLaunchAnimator) { @NonNull ActivityLaunchAnimator activityLaunchAnimator, @NonNull Optional<AlternateUdfpsTouchProvider> aternateTouchProvider) { mContext = context; mExecution = execution; mVibrator = vibrator; Loading Loading @@ -566,6 +568,7 @@ public class UdfpsController implements DozeReceiver { mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLatencyTracker = latencyTracker; mActivityLaunchAnimator = activityLaunchAnimator; mAlternateTouchProvider = aternateTouchProvider.orElse(null); mSensorProps = findFirstUdfps(); // At least one UDFPS sensor exists Loading Loading @@ -782,6 +785,7 @@ public class UdfpsController implements DozeReceiver { private void onFingerDown(long requestId, int x, int y, float minor, float major) { mExecution.assertIsMainThread(); if (mOverlay == null) { Log.w(TAG, "Null request in onFingerDown"); return; Loading @@ -806,7 +810,11 @@ public class UdfpsController implements DozeReceiver { } } mOnFingerDown = true; if (mAlternateTouchProvider != null) { mAlternateTouchProvider.onPointerDown(requestId, x, y, minor, major); } else { mFingerprintManager.onPointerDown(requestId, mSensorProps.sensorId, x, y, minor, major); } Trace.endAsyncSection("UdfpsController.e2e.onPointerDown", 0); final UdfpsView view = mOverlay.getOverlayView(); Loading @@ -827,7 +835,11 @@ public class UdfpsController implements DozeReceiver { mActivePointerId = -1; mAcquiredReceived = false; if (mOnFingerDown) { if (mAlternateTouchProvider != null) { mAlternateTouchProvider.onPointerUp(requestId); } else { mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId); } for (Callback cb : mCallbacks) { cb.onFingerUp(); } Loading packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +4 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.BootCompleteCacheImpl; import com.android.systemui.SystemUIFactory; import com.android.systemui.appops.dagger.AppOpsModule; import com.android.systemui.assist.AssistModule; import com.android.systemui.biometrics.AlternateUdfpsTouchProvider; import com.android.systemui.biometrics.UdfpsHbmProvider; import com.android.systemui.biometrics.dagger.BiometricsModule; import com.android.systemui.classifier.FalsingModule; Loading Loading @@ -182,6 +183,9 @@ public abstract class SystemUIModule { @BindsOptionalOf abstract UdfpsHbmProvider optionalUdfpsHbmProvider(); @BindsOptionalOf abstract AlternateUdfpsTouchProvider optionalUdfpsTouchProvider(); @SysUISingleton @Binds abstract SystemClock bindSystemClock(SystemClockImpl systemClock); Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +11 −5 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; Loading Loading @@ -183,6 +184,8 @@ public class UdfpsControllerTest extends SysuiTestCase { private SystemUIDialogManager mSystemUIDialogManager; @Mock private ActivityLaunchAnimator mActivityLaunchAnimator; @Mock private AlternateUdfpsTouchProvider mTouchProvider; // Capture listeners so that they can be used to send events @Captor private ArgumentCaptor<IUdfpsOverlayController> mOverlayCaptor; Loading Loading @@ -256,7 +259,8 @@ public class UdfpsControllerTest extends SysuiTestCase { mUnlockedScreenOffAnimationController, mSystemUIDialogManager, mLatencyTracker, mActivityLaunchAnimator); mActivityLaunchAnimator, Optional.of(mTouchProvider)); verify(mFingerprintManager).setUdfpsOverlayController(mOverlayCaptor.capture()); mOverlayController = mOverlayCaptor.getValue(); verify(mScreenLifecycle).addObserver(mScreenObserverCaptor.capture()); Loading Loading @@ -418,9 +422,10 @@ public class UdfpsControllerTest extends SysuiTestCase { mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent); moveEvent.recycle(); // THEN FingerprintManager is notified about onPointerDown verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID), eq(mUdfpsController.mSensorProps.sensorId), verify(mTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(0f), eq(0f)); verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(), anyFloat(), anyFloat()); verify(mLatencyTracker).onActionStart(eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE)); // AND illumination begins verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture()); Loading @@ -447,9 +452,10 @@ public class UdfpsControllerTest extends SysuiTestCase { // AND onIlluminatedRunnable that notifies FingerprintManager is set verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture()); mOnIlluminatedRunnableCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID), eq(mUdfpsController.mSensorProps.sensorId), verify(mTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(3f) /* minor */, eq(2f) /* major */); verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(), anyFloat(), anyFloat()); } @Test Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/AlternateUdfpsTouchProvider.kt 0 → 100644 +42 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.systemui.biometrics /** * Interface for controlling the on finger down & on finger up events. */ interface AlternateUdfpsTouchProvider { /** * This operation is used to notify the Fingerprint HAL that * a fingerprint has been detected on the device's screen. * * See fingerprint/ISession#onPointerDown for more details. */ fun onPointerDown(pointerId: Long, x: Int, y: Int, minor: Float, major: Float) /** * onPointerUp: * * This operation can be invoked when the HAL is performing any one of: ISession#authenticate, * ISession#enroll, ISession#detectInteraction. This operation is used to indicate * that a fingerprint that was previously down, is now up. * * See fingerprint/ISession#onPointerUp for more details. */ fun onPointerUp(pointerId: Long) }
packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +15 −3 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class UdfpsController implements DozeReceiver { // sensors, this, in addition to a lot of the code here, will be updated. @VisibleForTesting final FingerprintSensorPropertiesInternal mSensorProps; @NonNull private final ActivityLaunchAnimator mActivityLaunchAnimator; @Nullable private final AlternateUdfpsTouchProvider mAlternateTouchProvider; // Tracks the velocity of a touch to help filter out the touches that move too fast. @Nullable private VelocityTracker mVelocityTracker; Loading Loading @@ -537,7 +538,8 @@ public class UdfpsController implements DozeReceiver { @NonNull UnlockedScreenOffAnimationController unlockedScreenOffAnimationController, @NonNull SystemUIDialogManager dialogManager, @NonNull LatencyTracker latencyTracker, @NonNull ActivityLaunchAnimator activityLaunchAnimator) { @NonNull ActivityLaunchAnimator activityLaunchAnimator, @NonNull Optional<AlternateUdfpsTouchProvider> aternateTouchProvider) { mContext = context; mExecution = execution; mVibrator = vibrator; Loading Loading @@ -566,6 +568,7 @@ public class UdfpsController implements DozeReceiver { mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController; mLatencyTracker = latencyTracker; mActivityLaunchAnimator = activityLaunchAnimator; mAlternateTouchProvider = aternateTouchProvider.orElse(null); mSensorProps = findFirstUdfps(); // At least one UDFPS sensor exists Loading Loading @@ -782,6 +785,7 @@ public class UdfpsController implements DozeReceiver { private void onFingerDown(long requestId, int x, int y, float minor, float major) { mExecution.assertIsMainThread(); if (mOverlay == null) { Log.w(TAG, "Null request in onFingerDown"); return; Loading @@ -806,7 +810,11 @@ public class UdfpsController implements DozeReceiver { } } mOnFingerDown = true; if (mAlternateTouchProvider != null) { mAlternateTouchProvider.onPointerDown(requestId, x, y, minor, major); } else { mFingerprintManager.onPointerDown(requestId, mSensorProps.sensorId, x, y, minor, major); } Trace.endAsyncSection("UdfpsController.e2e.onPointerDown", 0); final UdfpsView view = mOverlay.getOverlayView(); Loading @@ -827,7 +835,11 @@ public class UdfpsController implements DozeReceiver { mActivePointerId = -1; mAcquiredReceived = false; if (mOnFingerDown) { if (mAlternateTouchProvider != null) { mAlternateTouchProvider.onPointerUp(requestId); } else { mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId); } for (Callback cb : mCallbacks) { cb.onFingerUp(); } Loading
packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +4 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.BootCompleteCacheImpl; import com.android.systemui.SystemUIFactory; import com.android.systemui.appops.dagger.AppOpsModule; import com.android.systemui.assist.AssistModule; import com.android.systemui.biometrics.AlternateUdfpsTouchProvider; import com.android.systemui.biometrics.UdfpsHbmProvider; import com.android.systemui.biometrics.dagger.BiometricsModule; import com.android.systemui.classifier.FalsingModule; Loading Loading @@ -182,6 +183,9 @@ public abstract class SystemUIModule { @BindsOptionalOf abstract UdfpsHbmProvider optionalUdfpsHbmProvider(); @BindsOptionalOf abstract AlternateUdfpsTouchProvider optionalUdfpsTouchProvider(); @SysUISingleton @Binds abstract SystemClock bindSystemClock(SystemClockImpl systemClock); Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +11 −5 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.inOrder; Loading Loading @@ -183,6 +184,8 @@ public class UdfpsControllerTest extends SysuiTestCase { private SystemUIDialogManager mSystemUIDialogManager; @Mock private ActivityLaunchAnimator mActivityLaunchAnimator; @Mock private AlternateUdfpsTouchProvider mTouchProvider; // Capture listeners so that they can be used to send events @Captor private ArgumentCaptor<IUdfpsOverlayController> mOverlayCaptor; Loading Loading @@ -256,7 +259,8 @@ public class UdfpsControllerTest extends SysuiTestCase { mUnlockedScreenOffAnimationController, mSystemUIDialogManager, mLatencyTracker, mActivityLaunchAnimator); mActivityLaunchAnimator, Optional.of(mTouchProvider)); verify(mFingerprintManager).setUdfpsOverlayController(mOverlayCaptor.capture()); mOverlayController = mOverlayCaptor.getValue(); verify(mScreenLifecycle).addObserver(mScreenObserverCaptor.capture()); Loading Loading @@ -418,9 +422,10 @@ public class UdfpsControllerTest extends SysuiTestCase { mTouchListenerCaptor.getValue().onTouch(mUdfpsView, moveEvent); moveEvent.recycle(); // THEN FingerprintManager is notified about onPointerDown verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID), eq(mUdfpsController.mSensorProps.sensorId), verify(mTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(0f), eq(0f)); verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(), anyFloat(), anyFloat()); verify(mLatencyTracker).onActionStart(eq(LatencyTracker.ACTION_UDFPS_ILLUMINATE)); // AND illumination begins verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture()); Loading @@ -447,9 +452,10 @@ public class UdfpsControllerTest extends SysuiTestCase { // AND onIlluminatedRunnable that notifies FingerprintManager is set verify(mUdfpsView).startIllumination(mOnIlluminatedRunnableCaptor.capture()); mOnIlluminatedRunnableCaptor.getValue().run(); verify(mFingerprintManager).onPointerDown(eq(TEST_REQUEST_ID), eq(mUdfpsController.mSensorProps.sensorId), verify(mTouchProvider).onPointerDown(eq(TEST_REQUEST_ID), eq(0), eq(0), eq(3f) /* minor */, eq(2f) /* major */); verify(mFingerprintManager, never()).onPointerDown(anyLong(), anyInt(), anyInt(), anyInt(), anyFloat(), anyFloat()); } @Test Loading