From f87326c32823fe12bd2e4f76887c708eca52c429 Mon Sep 17 00:00:00 2001 From: Hao Dong Date: Tue, 6 Dec 2022 18:17:12 +0000 Subject: [PATCH] Add a flag for moving UdfpsEnroll* from SystemUI to settings. - Adds SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS flag to guard the change. - Remove the black fp drawable in udfps_fpm_other_view.xml - Uses UdfpsFpmOtherViewController when the flag is enabled, so that SystemUI doesn't show anything for settings enrollment. Turn this flag on via adb: adb shell setprop sys.fflag.override.settings_show_udfps_enroll_in_settings true Test: manually tested on device Bug: 260617060 Change-Id: I1842c4351041fdabc16bde9d5d5a708efb258cb2 --- .../fingerprint/FingerprintManager.java | 9 ++++ core/java/android/util/FeatureFlagUtils.java | 9 ++++ packages/SystemUI/ktfmt_includes.txt | 4 +- ...ther_view.xml => udfps_fpm_empty_view.xml} | 10 +---- .../biometrics/UdfpsControllerOverlay.kt | 41 ++++++++++++------- ...psFpmOtherView.kt => UdfpsFpmEmptyView.kt} | 15 +++---- ...ller.kt => UdfpsFpmEmptyViewController.kt} | 11 +++-- .../biometrics/UdfpsControllerOverlayTest.kt | 4 +- .../biometrics/UdfpsControllerTest.java | 6 +-- 9 files changed, 64 insertions(+), 45 deletions(-) rename packages/SystemUI/res/layout/{udfps_fpm_other_view.xml => udfps_fpm_empty_view.xml} (75%) rename packages/SystemUI/src/com/android/systemui/biometrics/{UdfpsFpmOtherView.kt => UdfpsFpmEmptyView.kt} (72%) rename packages/SystemUI/src/com/android/systemui/biometrics/{UdfpsFpmOtherViewController.kt => UdfpsFpmEmptyViewController.kt} (83%) diff --git a/core/java/android/hardware/fingerprint/FingerprintManager.java b/core/java/android/hardware/fingerprint/FingerprintManager.java index a748b600a65e7..04a204a09f5e9 100644 --- a/core/java/android/hardware/fingerprint/FingerprintManager.java +++ b/core/java/android/hardware/fingerprint/FingerprintManager.java @@ -464,6 +464,12 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing * @param remaining The number of remaining steps */ public void onEnrollmentProgress(int remaining) { } + + /** + * Called when a fingerprint image has been acquired. + * @param isAcquiredGood whether the fingerprint image was good. + */ + public void onAcquired(boolean isAcquiredGood){ } } /** @@ -1392,6 +1398,9 @@ public class FingerprintManager implements BiometricAuthenticator, BiometricFing if (mAuthenticationCallback != null) { mAuthenticationCallback.onAuthenticationAcquired(acquireInfo); } + if (mEnrollmentCallback != null) { + mEnrollmentCallback.onAcquired(acquireInfo == FINGERPRINT_ACQUIRED_GOOD); + } final String msg = getAcquiredString(mContext, acquireInfo, vendorCode); if (msg == null) { return; diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java index 57ade13865009..96d63d84b6131 100644 --- a/core/java/android/util/FeatureFlagUtils.java +++ b/core/java/android/util/FeatureFlagUtils.java @@ -151,6 +151,14 @@ public class FeatureFlagUtils { */ public static final String SETTINGS_FLASH_ALERTS = "settings_flash_alerts"; + /** + * Flag to disable/enable showing udfps enroll view in settings. If it's disabled, udfps enroll + * view is shown in system ui. + * @hide + */ + public static final String SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS = + "settings_show_udfps_enroll_in_settings"; + private static final Map DEFAULT_FLAGS; static { @@ -190,6 +198,7 @@ public class FeatureFlagUtils { DEFAULT_FLAGS.put(SETTINGS_ACCESSIBILITY_HEARING_AID_PAGE, "false"); DEFAULT_FLAGS.put(SETTINGS_AUDIO_ROUTING, "false"); DEFAULT_FLAGS.put(SETTINGS_FLASH_ALERTS, "false"); + DEFAULT_FLAGS.put(SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS, "false"); } private static final Set PERSISTENT_FLAGS; diff --git a/packages/SystemUI/ktfmt_includes.txt b/packages/SystemUI/ktfmt_includes.txt index 7243ca4cece05..b530dd5dc48df 100644 --- a/packages/SystemUI/ktfmt_includes.txt +++ b/packages/SystemUI/ktfmt_includes.txt @@ -80,8 +80,8 @@ -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsDrawable.kt -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpDrawable.kt --packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherView.kt --packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherViewController.kt +-packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt +-packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyViewController.kt -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsHapticsSimulator.kt -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsOverlayParams.kt -packages/SystemUI/src/com/android/systemui/biometrics/UdfpsShell.kt diff --git a/packages/SystemUI/res/layout/udfps_fpm_other_view.xml b/packages/SystemUI/res/layout/udfps_fpm_empty_view.xml similarity index 75% rename from packages/SystemUI/res/layout/udfps_fpm_other_view.xml rename to packages/SystemUI/res/layout/udfps_fpm_empty_view.xml index 6ecbb473d720c..de43a5e8b0297 100644 --- a/packages/SystemUI/res/layout/udfps_fpm_other_view.xml +++ b/packages/SystemUI/res/layout/udfps_fpm_empty_view.xml @@ -14,15 +14,9 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> - - - - - + diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt index a3c4985fd5ccf..1b6c8c68497e0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsControllerOverlay.kt @@ -33,6 +33,7 @@ import android.hardware.fingerprint.IUdfpsOverlayControllerCallback import android.os.Build import android.os.RemoteException import android.provider.Settings +import android.util.FeatureFlagUtils import android.util.Log import android.util.RotationUtils import android.view.LayoutInflater @@ -232,18 +233,30 @@ class UdfpsControllerOverlay @JvmOverloads constructor( return when (filteredRequestReason) { REASON_ENROLL_FIND_SENSOR, REASON_ENROLL_ENROLLING -> { - UdfpsEnrollViewController( - view.addUdfpsView(R.layout.udfps_enroll_view) { - updateSensorLocation(sensorBounds) - }, - enrollHelper ?: throw IllegalStateException("no enrollment helper"), - statusBarStateController, - shadeExpansionStateManager, - dialogManager, - dumpManager, - featureFlags, - overlayParams.scaleFactor - ) + if (FeatureFlagUtils.isEnabled(context, + FeatureFlagUtils.SETTINGS_SHOW_UDFPS_ENROLL_IN_SETTINGS)) { + // Enroll udfps UI is handled by settings, so use empty view here + UdfpsFpmEmptyViewController( + view.addUdfpsView(R.layout.udfps_fpm_empty_view), + statusBarStateController, + shadeExpansionStateManager, + dialogManager, + dumpManager + ) + } else { + UdfpsEnrollViewController( + view.addUdfpsView(R.layout.udfps_enroll_view) { + updateSensorLocation(sensorBounds) + }, + enrollHelper ?: throw IllegalStateException("no enrollment helper"), + statusBarStateController, + shadeExpansionStateManager, + dialogManager, + dumpManager, + featureFlags, + overlayParams.scaleFactor + ) + } } REASON_AUTH_KEYGUARD -> { UdfpsKeyguardViewController( @@ -277,8 +290,8 @@ class UdfpsControllerOverlay @JvmOverloads constructor( } REASON_AUTH_OTHER, REASON_AUTH_SETTINGS -> { - UdfpsFpmOtherViewController( - view.addUdfpsView(R.layout.udfps_fpm_other_view), + UdfpsFpmEmptyViewController( + view.addUdfpsView(R.layout.udfps_fpm_empty_view), statusBarStateController, shadeExpansionStateManager, dialogManager, diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherView.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt similarity index 72% rename from packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherView.kt rename to packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt index 4d6da8f4b3eb5..e8f041ec0d713 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherView.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyView.kt @@ -17,24 +17,19 @@ package com.android.systemui.biometrics import android.content.Context import android.util.AttributeSet -import android.widget.ImageView -import com.android.systemui.R /** - * View corresponding with udfps_fpm_other_view.xml + * View corresponding with udfps_fpm_empty_view.xml + * + * Currently doesn't draw anything. */ -class UdfpsFpmOtherView( +class UdfpsFpmEmptyView( context: Context, attrs: AttributeSet? ) : UdfpsAnimationView(context, attrs) { + // Drawable isn't ever added to the view, so we don't currently show anything private val fingerprintDrawable: UdfpsFpDrawable = UdfpsFpDrawable(context) - private lateinit var fingerprintView: ImageView - - override fun onFinishInflate() { - fingerprintView = findViewById(R.id.udfps_fpm_other_fp_view)!! - fingerprintView.setImageDrawable(fingerprintDrawable) - } override fun getDrawable(): UdfpsDrawable = fingerprintDrawable } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherViewController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyViewController.kt similarity index 83% rename from packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherViewController.kt rename to packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyViewController.kt index 7c232789bcacd..d122d64aab2c0 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmOtherViewController.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsFpmEmptyViewController.kt @@ -21,18 +21,17 @@ import com.android.systemui.shade.ShadeExpansionStateManager import com.android.systemui.statusbar.phone.SystemUIDialogManager /** - * Class that coordinates non-HBM animations for non keyguard, enrollment or biometric prompt - * states. + * Class that coordinates non-HBM animations for non keyguard, or biometric prompt states. * - * Currently only shows the fp drawable. + * Currently doesn't draw anything. */ -class UdfpsFpmOtherViewController( - view: UdfpsFpmOtherView, +class UdfpsFpmEmptyViewController( + view: UdfpsFpmEmptyView, statusBarStateController: StatusBarStateController, shadeExpansionStateManager: ShadeExpansionStateManager, systemUIDialogManager: SystemUIDialogManager, dumpManager: DumpManager -) : UdfpsAnimationViewController( +) : UdfpsAnimationViewController( view, statusBarStateController, shadeExpansionStateManager, 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 c6fa9832c68cc..7c9d22f0270cb 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerOverlayTest.kt @@ -124,8 +124,8 @@ class UdfpsControllerOverlayTest : SysuiTestCase() { .thenReturn(mock(UdfpsBpView::class.java)) whenever(inflater.inflate(R.layout.udfps_keyguard_view, null)) .thenReturn(mock(UdfpsKeyguardView::class.java)) - whenever(inflater.inflate(R.layout.udfps_fpm_other_view, null)) - .thenReturn(mock(UdfpsFpmOtherView::class.java)) + whenever(inflater.inflate(R.layout.udfps_fpm_empty_view, null)) + .thenReturn(mock(UdfpsFpmEmptyView::class.java)) whenever(udfpsEnrollView.context).thenReturn(context) } diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java index 83a6db032858f..d7b7a7d02fbbe 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/UdfpsControllerTest.java @@ -190,7 +190,7 @@ public class UdfpsControllerTest extends SysuiTestCase { @Mock private UdfpsBpView mBpView; @Mock - private UdfpsFpmOtherView mFpmOtherView; + private UdfpsFpmEmptyView mFpmEmptyView; @Mock private UdfpsKeyguardView mKeyguardView; private final UdfpsAnimationViewController mUdfpsKeyguardViewController = @@ -240,8 +240,8 @@ public class UdfpsControllerTest extends SysuiTestCase { .thenReturn(mKeyguardView); // for showOverlay REASON_AUTH_FPM_KEYGUARD when(mLayoutInflater.inflate(R.layout.udfps_bp_view, null)) .thenReturn(mBpView); - when(mLayoutInflater.inflate(R.layout.udfps_fpm_other_view, null)) - .thenReturn(mFpmOtherView); + when(mLayoutInflater.inflate(R.layout.udfps_fpm_empty_view, null)) + .thenReturn(mFpmEmptyView); when(mEnrollView.getContext()).thenReturn(mContext); when(mKeyguardUpdateMonitor.isFingerprintDetectionRunning()).thenReturn(true); when(mSessionTracker.getSessionId(anyInt())).thenReturn(