diff options
15 files changed, 56 insertions, 22 deletions
diff --git a/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java b/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java index 4bf9a740f971..f701ec3ec367 100644 --- a/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java +++ b/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java @@ -39,6 +39,7 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna * See {@link FingerprintSensorProperties.SensorType}. */ public final @FingerprintSensorProperties.SensorType int sensorType; + public final boolean halControlsIllumination; private final List<SensorLocationInternal> mSensorLocations; @@ -46,6 +47,7 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, @NonNull List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, + boolean halControlsIllumination, boolean resetLockoutRequiresHardwareAuthToken, @NonNull List<SensorLocationInternal> sensorLocations) { // IBiometricsFingerprint@2.1 handles lockout in the framework, so the challenge is not @@ -55,6 +57,7 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna super(sensorId, strength, maxEnrollmentsPerUser, componentInfo, resetLockoutRequiresHardwareAuthToken, false /* resetLockoutRequiresChallenge */); this.sensorType = sensorType; + this.halControlsIllumination = halControlsIllumination; this.mSensorLocations = List.copyOf(sensorLocations); } @@ -68,14 +71,15 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna boolean resetLockoutRequiresHardwareAuthToken) { // TODO(b/179175438): Value should be provided from the HAL this(sensorId, strength, maxEnrollmentsPerUser, componentInfo, sensorType, - resetLockoutRequiresHardwareAuthToken, List.of(new SensorLocationInternal( - "" /* displayId */, 540 /* sensorLocationX */, 1636 /* sensorLocationY */, - 130 /* sensorRadius */))); + false /* halControlsIllumination */, resetLockoutRequiresHardwareAuthToken, + List.of(new SensorLocationInternal("" /* displayId */, 540 /* sensorLocationX */, + 1636 /* sensorLocationY */, 130 /* sensorRadius */))); } protected FingerprintSensorPropertiesInternal(Parcel in) { super(in); sensorType = in.readInt(); + halControlsIllumination = in.readBoolean(); mSensorLocations = in.createTypedArrayList(SensorLocationInternal.CREATOR); } @@ -101,6 +105,7 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna public void writeToParcel(Parcel dest, int flags) { super.writeToParcel(dest, flags); dest.writeInt(sensorType); + dest.writeBoolean(halControlsIllumination); dest.writeTypedList(mSensorLocations); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java index d59ad9286b10..932489372872 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java @@ -278,6 +278,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba } }); mUdfpsController.setAuthControllerUpdateUdfpsLocation(this::updateUdfpsLocation); + mUdfpsController.setHalControlsIllumination(mUdfpsProps.get(0).halControlsIllumination); mUdfpsBounds = mUdfpsProps.get(0).getLocation().getRect(); updateUdfpsLocation(); } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java index 432d2930453c..a35f0427e55a 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java @@ -131,6 +131,7 @@ public class UdfpsController implements DozeReceiver { // Currently the UdfpsController supports a single UDFPS sensor. If devices have multiple // sensors, this, in addition to a lot of the code here, will be updated. @VisibleForTesting int mSensorId; + private boolean mHalControlsIllumination; @VisibleForTesting @NonNull UdfpsOverlayParams mOverlayParams = new UdfpsOverlayParams(); // TODO(b/229290039): UDFPS controller should manage its dimensions on its own. Remove this. @Nullable private Runnable mAuthControllerUpdateUdfpsLocation; @@ -201,9 +202,10 @@ public class UdfpsController implements DozeReceiver { mKeyguardUpdateMonitor, mDialogManager, mDumpManager, mLockscreenShadeTransitionController, mConfigurationController, mSystemClock, mKeyguardStateController, - mUnlockedScreenOffAnimationController, mHbmProvider, requestId, reason, - callback, (view, event, fromUdfpsView) -> onTouch(requestId, event, - fromUdfpsView), mActivityLaunchAnimator))); + mUnlockedScreenOffAnimationController, mHalControlsIllumination, + mHbmProvider, requestId, reason, callback, + (view, event, fromUdfpsView) -> onTouch(requestId, event, + fromUdfpsView), mActivityLaunchAnimator))); } @Override @@ -310,6 +312,11 @@ public class UdfpsController implements DozeReceiver { mAuthControllerUpdateUdfpsLocation = r; } + // TODO(b/229290039): UDFPS controller should manage its properties on its own. Remove this. + public void setHalControlsIllumination(boolean value) { + mHalControlsIllumination = value; + } + /** * Calculate the pointer speed given a velocity tracker and the pointer id. * This assumes that the velocity tracker has already been passed all relevant motion events. diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index 9c8aee4e93a7..2d51c973b0b1 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -77,6 +77,7 @@ class UdfpsControllerOverlay( private val systemClock: SystemClock, private val keyguardStateController: KeyguardStateController, private val unlockedScreenOffAnimationController: UnlockedScreenOffAnimationController, + private val halControlsIllumination: Boolean, private var hbmProvider: UdfpsHbmProvider, val requestId: Long, @ShowReason val requestReason: Int, @@ -137,6 +138,7 @@ class UdfpsControllerOverlay( R.layout.udfps_view, null, false ) as UdfpsView).apply { overlayParams = params + halControlsIllumination = this@UdfpsControllerOverlay.halControlsIllumination setHbmProvider(hbmProvider) val animation = inflateUdfpsAnimation(this, controller) if (animation != null) { diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java index 38c937feb941..f26dd5f57061 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHbmProvider.java @@ -34,8 +34,11 @@ public interface UdfpsHbmProvider { * invoked from the UI thread. * * @param onHbmEnabled A runnable that will be executed once HBM is enabled. + * + * TODO(b/231335067): enableHbm with halControlsIllumination=true shouldn't make sense. + * This only makes sense now because vendor code may rely on the side effects of enableHbm. */ - void enableHbm(@Nullable Runnable onHbmEnabled); + void enableHbm(boolean halControlsIllumination, @Nullable Runnable onHbmEnabled); /** * UdfpsView will call this to disable HBM when illumination is no longer needed. @@ -46,8 +49,6 @@ public interface UdfpsHbmProvider { * The call must be made from the UI thread. The callback, if provided, will also be invoked * from the UI thread. * - * - * * @param onHbmDisabled A runnable that will be executed once HBM is disabled. */ void disableHbm(@Nullable Runnable onHbmDisabled); diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt index 2aa345ab28dc..245c2252d57b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.kt @@ -63,9 +63,12 @@ class UdfpsView( /** View controller (can be different for enrollment, BiometricPrompt, Keyguard, etc.). */ var animationViewController: UdfpsAnimationViewController<*>? = null - /** Parameters that affect the position and size of the overlay. Visible for testing. */ + /** Parameters that affect the position and size of the overlay. */ var overlayParams = UdfpsOverlayParams() + /** Whether the HAL is responsible for enabling and disabling of LHBM. */ + var halControlsIllumination: Boolean = true + /** Debug message. */ var debugMessage: String? = null set(value) { @@ -154,11 +157,17 @@ class UdfpsView( } private fun doIlluminate(onIlluminatedRunnable: Runnable?) { - hbmProvider?.enableHbm() { + // TODO(b/231335067): enableHbm with halControlsIllumination=true shouldn't make sense. + // This only makes sense now because vendor code may rely on the side effects of enableHbm. + hbmProvider?.enableHbm(halControlsIllumination) { if (onIlluminatedRunnable != null) { - // No framework API can reliably tell when a frame reaches the panel. A timeout - // is the safest solution. - postDelayed(onIlluminatedRunnable, onIlluminatedDelayMs) + if (halControlsIllumination) { + onIlluminatedRunnable.run() + } else { + // No framework API can reliably tell when a frame reaches the panel. A timeout + // is the safest solution. + postDelayed(onIlluminatedRunnable, onIlluminatedDelayMs) + } } else { Log.w(TAG, "doIlluminate | onIlluminatedRunnable is null") } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt index 57f36172c998..92c2a1b9b23a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt @@ -29,6 +29,7 @@ fun SensorLocationInternal.asFingerprintSensorProperties( @FingerprintSensorProperties.SensorType sensorType: Int = FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, maxEnrollmentsPerUser: Int = 1, + halControlsIllumination: Boolean = true, info: List<ComponentInfoInternal> = listOf(ComponentInfoInternal("a", "b", "c", "d", "e")), resetLockoutRequiresHardwareAuthToken: Boolean = false ) = FingerprintSensorPropertiesInternal( @@ -37,6 +38,7 @@ fun SensorLocationInternal.asFingerprintSensorProperties( maxEnrollmentsPerUser, info, sensorType, + halControlsIllumination, resetLockoutRequiresHardwareAuthToken, listOf(this) ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SidefpsControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SidefpsControllerTest.kt index 102f37c4a037..dec2b82ed88f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/SidefpsControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/SidefpsControllerTest.kt @@ -185,6 +185,7 @@ class SidefpsControllerTest : SysuiTestCase() { 5 /* maxEnrollmentsPerUser */, listOf() /* componentInfo */, FingerprintSensorProperties.TYPE_POWER_BUTTON, + true /* halControlsIllumination */, true /* resetLockoutRequiresHardwareAuthToken */, locations ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt index a57b011d7125..fc5ccbcb4a76 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt @@ -65,6 +65,7 @@ import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.Mockito.`when` as whenever +private const val HAL_CONTROLS_ILLUMINATION = true private const val REQUEST_ID = 2L // Dimensions for the current display resolution. @@ -129,8 +130,8 @@ class UdfpsControllerOverlayTest : SysuiTestCase() { statusBarStateController, panelExpansionStateManager, statusBarKeyguardViewManager, keyguardUpdateMonitor, dialogManager, dumpManager, transitionController, configurationController, systemClock, keyguardStateController, - unlockedScreenOffAnimationController, hbmProvider, REQUEST_ID, reason, - controllerCallback, onTouch, activityLaunchAnimator) + unlockedScreenOffAnimationController, HAL_CONTROLS_ILLUMINATION, hbmProvider, + REQUEST_ID, reason, controllerCallback, onTouch, activityLaunchAnimator) block() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapterTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapterTest.java index 27755edecba6..cd646c665d03 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsDialogMeasureAdapterTest.java @@ -62,6 +62,7 @@ public class UdfpsDialogMeasureAdapterTest extends SysuiTestCase { 0 /* sensorId */, SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */, componentInfo, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, + true /* halControlsIllumination */, true /* resetLockoutRequiresHardwareAuthToken */, List.of(new SensorLocationInternal("" /* displayId */, sensorLocationX, sensorLocationY, sensorRadius))); @@ -127,6 +128,7 @@ public class UdfpsDialogMeasureAdapterTest extends SysuiTestCase { 0 /* sensorId */, SensorProperties.STRENGTH_STRONG, 5 /* maxEnrollmentsPerUser */, componentInfo, FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, + true /* halControlsIllumination */, true /* resetLockoutRequiresHardwareAuthToken */, List.of(new SensorLocationInternal("" /* displayId */, sensorLocationX, sensorLocationY, sensorRadius))); diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt index 744af589dfac..0327cfcf3450 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsViewTest.kt @@ -36,6 +36,7 @@ import org.junit.Before import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.mockito.ArgumentMatchers.anyBoolean import org.mockito.Mock import org.mockito.Mockito.never import org.mockito.Mockito.nullable @@ -43,7 +44,6 @@ import org.mockito.Mockito.verify import org.mockito.junit.MockitoJUnit import org.mockito.Mockito.`when` as whenever -private const val DISPLAY_ID = "" // default display id private const val SENSOR_X = 50 private const val SENSOR_Y = 250 private const val SENSOR_RADIUS = 10 @@ -146,7 +146,7 @@ class UdfpsViewTest : SysuiTestCase() { view.startIllumination(onDone) val illuminator = withArgCaptor<Runnable> { - verify(hbmProvider).enableHbm(capture()) + verify(hbmProvider).enableHbm(anyBoolean(), capture()) } assertThat(view.isIlluminationRequested).isTrue() diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java index be923a68391c..5ff316e2efec 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/LockIconViewControllerTest.java @@ -413,6 +413,7 @@ public class LockIconViewControllerTest extends SysuiTestCase { /* max enrollments per user */ 5, /* component info */ new ArrayList<>(), /* sensorType */ 3, + /* halControlsIllumination */ true, /* resetLockoutRequiresHwToken */ false, List.of(new SensorLocationInternal("" /* displayId */, (int) udfpsLocation.x, (int) udfpsLocation.y, radius))); diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java index b5c8cd16a355..bc550d311370 100644 --- a/services/core/java/com/android/server/biometrics/AuthService.java +++ b/services/core/java/com/android/server/biometrics/AuthService.java @@ -805,9 +805,10 @@ public class AuthService extends SystemService { if (isUdfps && udfpsProps.length == 3) { return new FingerprintSensorPropertiesInternal(sensorId, Utils.authenticatorStrengthToPropertyStrength(strength), maxEnrollmentsPerUser, - componentInfo, sensorType, resetLockoutRequiresHardwareAuthToken, - List.of(new SensorLocationInternal("" /* display */, - udfpsProps[0], udfpsProps[1], udfpsProps[2]))); + componentInfo, sensorType, true /* halControlsIllumination */, + resetLockoutRequiresHardwareAuthToken, + List.of(new SensorLocationInternal("" /* display */, udfpsProps[0], + udfpsProps[1], udfpsProps[2]))); } else { return new FingerprintSensorPropertiesInternal(sensorId, Utils.authenticatorStrengthToPropertyStrength(strength), maxEnrollmentsPerUser, diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java index 998a8e1e9f90..a600f08efc24 100644 --- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java +++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java @@ -176,6 +176,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi prop.commonProps.maxEnrollmentsPerUser, componentInfo, prop.sensorType, + prop.halControlsIllumination, true /* resetLockoutRequiresHardwareAuthToken */, !workaroundLocations.isEmpty() ? workaroundLocations : Arrays.stream(prop.sensorLocations).map(location -> diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/Fingerprint21UdfpsMock.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/Fingerprint21UdfpsMock.java index 485a674dda92..bea0f4ffd45d 100644 --- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/Fingerprint21UdfpsMock.java +++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/hidl/Fingerprint21UdfpsMock.java @@ -400,7 +400,7 @@ public class Fingerprint21UdfpsMock extends Fingerprint21 implements TrustManage .getInteger(R.integer.config_fingerprintMaxTemplatesPerUser); mSensorProperties = new FingerprintSensorPropertiesInternal(sensorProps.sensorId, sensorProps.sensorStrength, maxTemplatesAllowed, sensorProps.componentInfo, - FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, + FingerprintSensorProperties.TYPE_UDFPS_OPTICAL, false /* halControlsIllumination */, resetLockoutRequiresHardwareAuthToken, sensorProps.getAllLocations()); mMockHalResultController = controller; mUserHasTrust = new SparseBooleanArray(); |