Added TouchProvider

Test: Manual.
Bug: 227247855
Change-Id: I4a217ef4a068c8b2cae0f345856912028f9a9525
This commit is contained in:
Joshua Mccloskey
2022-03-31 06:20:55 +00:00
committed by Joshua McCloskey
parent 43d5f07670
commit aa07cc3db3
4 changed files with 72 additions and 8 deletions

View File

@@ -0,0 +1,42 @@
/*
* 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)
}

View File

@@ -135,6 +135,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;
@@ -541,7 +542,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;
@@ -571,6 +573,7 @@ public class UdfpsController implements DozeReceiver {
mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
mLatencyTracker = latencyTracker;
mActivityLaunchAnimator = activityLaunchAnimator;
mAlternateTouchProvider = aternateTouchProvider.orElse(null);
mSensorProps = findFirstUdfps();
// At least one UDFPS sensor exists
@@ -787,6 +790,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;
@@ -810,7 +814,11 @@ public class UdfpsController implements DozeReceiver {
}
}
mOnFingerDown = true;
mFingerprintManager.onPointerDown(requestId, mSensorProps.sensorId, x, y, minor, major);
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();
@@ -833,7 +841,11 @@ public class UdfpsController implements DozeReceiver {
mActivePointerId = -1;
mAcquiredReceived = false;
if (mOnFingerDown) {
mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId);
if (mAlternateTouchProvider != null) {
mAlternateTouchProvider.onPointerUp(requestId);
} else {
mFingerprintManager.onPointerUp(requestId, mSensorProps.sensorId);
}
for (Callback cb : mCallbacks) {
cb.onFingerUp();
}

View File

@@ -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;
@@ -182,6 +183,9 @@ public abstract class SystemUIModule {
@BindsOptionalOf
abstract UdfpsHbmProvider optionalUdfpsHbmProvider();
@BindsOptionalOf
abstract AlternateUdfpsTouchProvider optionalUdfpsTouchProvider();
@SysUISingleton
@Binds
abstract SystemClock bindSystemClock(SystemClockImpl systemClock);

View File

@@ -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;
@@ -186,6 +187,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;
@@ -260,7 +263,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());
@@ -491,9 +495,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());
@@ -520,9 +525,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