diff options
| author | 2024-03-08 10:36:39 +0000 | |
|---|---|---|
| committer | 2024-03-08 12:32:27 +0000 | |
| commit | f96a5a059e6129d55b08bfefb91737c12022d92c (patch) | |
| tree | 772ababc2c0f650869497a527e850f38cfdf775a | |
| parent | 73dc5d51316a05cc55db0fc8051a70c555120525 (diff) | |
Combine customBiometricPrompt() with constraintBp().
Flag: ACONFIG constraint_bp DEVELOPMENT
Flag: ACONFIG android.hardware.biometrics.custom_biometric_prompt DEVELOPMENT
Test: atest AuthContainerViewTest
Test: atest PromptViewModelTest
Bug: 302735104
Change-Id: Ief073244913131cfdd3c02acf66a5cdb7d112f61
8 files changed, 32 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java index 9de71c1880fe..8bd675c44943 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthContainerView.java @@ -881,7 +881,7 @@ public class AuthContainerView extends LinearLayout final Runnable endActionRunnable = () -> { setVisibility(View.INVISIBLE); - if (Flags.customBiometricPrompt()) { + if (Flags.customBiometricPrompt() && constraintBp()) { mPromptSelectorInteractorProvider.get().resetPrompt(); } removeWindowIfAttached(); diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt index b87fadf995e6..4d88f4945952 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/data/repository/PromptRepository.kt @@ -18,6 +18,7 @@ package com.android.systemui.biometrics.data.repository import android.hardware.biometrics.Flags import android.hardware.biometrics.PromptInfo +import com.android.systemui.Flags.constraintBp import com.android.systemui.biometrics.AuthController import com.android.systemui.biometrics.Utils import com.android.systemui.biometrics.Utils.isDeviceCredentialAllowed @@ -151,6 +152,7 @@ constructor( val hasCredentialViewShown = kind.value !is PromptKind.Biometric val showBpForCredential = Flags.customBiometricPrompt() && + constraintBp() && !Utils.isBiometricAllowed(promptInfo) && isDeviceCredentialAllowed(promptInfo) && promptInfo.contentView != null diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt index e48f05d09fc4..7bb75bf5ca9b 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewBinder.kt @@ -22,6 +22,7 @@ import android.content.Context import android.hardware.biometrics.BiometricAuthenticator import android.hardware.biometrics.BiometricConstants import android.hardware.biometrics.BiometricPrompt +import android.hardware.biometrics.Flags import android.hardware.face.FaceManager import android.text.method.ScrollingMovementMethod import android.util.Log @@ -166,11 +167,14 @@ object BiometricViewBinder { titleView.text = viewModel.title.first() subtitleView.text = viewModel.subtitle.first() descriptionView.text = viewModel.description.first() - BiometricCustomizedViewBinder.bind( - customizedViewContainer, - view.requireViewById(R.id.space_above_content), - viewModel - ) + + if (Flags.customBiometricPrompt() && constraintBp()) { + BiometricCustomizedViewBinder.bind( + customizedViewContainer, + view.requireViewById(R.id.space_above_content), + viewModel + ) + } // set button listeners negativeButton.setOnClickListener { legacyCallback.onButtonNegative() } diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt index 61aeffe03b5d..34b50e47600f 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt @@ -29,6 +29,7 @@ import android.util.Log import android.view.HapticFeedbackConstants import android.view.MotionEvent import com.android.systemui.Flags.bpTalkback +import com.android.systemui.Flags.constraintBp import com.android.systemui.biometrics.UdfpsUtils import com.android.systemui.biometrics.Utils import com.android.systemui.biometrics.domain.interactor.DisplayStateInteractor @@ -284,7 +285,7 @@ constructor( promptSelectorInteractor.prompt .map { when { - !customBiometricPrompt() || it == null -> null + !(customBiometricPrompt() && constraintBp()) || it == null -> null it.logoRes != -1 -> context.resources.getDrawable(it.logoRes, context.theme) it.logoBitmap != null -> BitmapDrawable(context.resources, it.logoBitmap) else -> @@ -304,7 +305,7 @@ constructor( promptSelectorInteractor.prompt .map { when { - !customBiometricPrompt() || it == null -> "" + !(customBiometricPrompt() && constraintBp()) || it == null -> "" it.logoDescription != null -> it.logoDescription else -> try { @@ -329,7 +330,7 @@ constructor( /** Custom content view for the prompt. */ val contentView: Flow<PromptContentView?> = promptSelectorInteractor.prompt - .map { if (customBiometricPrompt()) it?.contentView else null } + .map { if (customBiometricPrompt() && constraintBp()) it?.contentView else null } .distinctUntilChanged() private val originalDescription = diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt index 10b86ea9fd31..2b4e9ec4a017 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/AuthContainerViewTest.kt @@ -20,7 +20,6 @@ import android.content.pm.PackageManager import android.hardware.biometrics.BiometricAuthenticator import android.hardware.biometrics.BiometricConstants import android.hardware.biometrics.BiometricManager -import android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT import android.hardware.biometrics.PromptInfo import android.hardware.biometrics.PromptVerticalListContentView import android.hardware.face.FaceSensorPropertiesInternal @@ -386,7 +385,6 @@ open class AuthContainerViewTest : SysuiTestCase() { @Test fun testShowCredentialUI_withDescription() { - mSetFlagsRule.disableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) val container = initializeFingerprintContainer( authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL ) @@ -397,6 +395,7 @@ open class AuthContainerViewTest : SysuiTestCase() { } @Test + @Ignore("b/302735104") fun testShowCredentialUI_withCustomBp() { val container = initializeFingerprintContainer( authenticators = BiometricManager.Authenticators.DEVICE_CREDENTIAL, diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/PromptRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/PromptRepositoryImplTest.kt index 7b972d3707af..81d4e8302c3f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/PromptRepositoryImplTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/data/repository/PromptRepositoryImplTest.kt @@ -17,9 +17,11 @@ package com.android.systemui.biometrics.data.repository import android.hardware.biometrics.BiometricManager +import android.hardware.biometrics.Flags.FLAG_CUSTOM_BIOMETRIC_PROMPT import android.hardware.biometrics.PromptInfo import android.hardware.biometrics.PromptVerticalListContentView import androidx.test.filters.SmallTest +import com.android.systemui.Flags import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.AuthController import com.android.systemui.biometrics.shared.model.PromptKind @@ -135,6 +137,8 @@ class PromptRepositoryImplTest : SysuiTestCase() { @Test fun showBpWithoutIconForCredential_withCustomBp() = testScope.runTest { + mSetFlagsRule.enableFlags(Flags.FLAG_CONSTRAINT_BP) + mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) for (case in listOf( PromptKind.Biometric(), diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt index 140849b8e257..1aab9e8f800c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt @@ -35,6 +35,7 @@ import android.view.MotionEvent import androidx.test.filters.SmallTest import com.android.internal.widget.LockPatternUtils import com.android.systemui.Flags.FLAG_BP_TALKBACK +import com.android.systemui.Flags.FLAG_CONSTRAINT_BP import com.android.systemui.SysuiTestCase import com.android.systemui.biometrics.AuthController import com.android.systemui.biometrics.UdfpsUtils @@ -1256,6 +1257,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun descriptionOverriddenByContentView() = runGenericTest(contentView = promptContentView, description = "test description") { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val contentView by collectLastValue(viewModel.contentView) val description by collectLastValue(viewModel.description) @@ -1267,6 +1269,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun descriptionWithoutContentView() = runGenericTest(description = "test description") { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val contentView by collectLastValue(viewModel.contentView) val description by collectLastValue(viewModel.description) @@ -1278,6 +1281,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun logoIsNullIfPackageNameNotFound() = runGenericTest(packageName = OP_PACKAGE_NAME_NO_ICON) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logo by collectLastValue(viewModel.logo) assertThat(logo).isNull() } @@ -1285,6 +1289,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa @Test fun defaultLogoIfNoLogoSet() = runGenericTest { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logo by collectLastValue(viewModel.logo) assertThat(logo).isEqualTo(defaultLogoIcon) } @@ -1293,6 +1298,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun logoResSetByApp() = runGenericTest(logoRes = logoResFromApp) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logo by collectLastValue(viewModel.logo) assertThat(logo).isEqualTo(logoFromApp) } @@ -1301,6 +1307,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun logoBitmapSetByApp() = runGenericTest(logoBitmap = logoBitmapFromApp) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logo by collectLastValue(viewModel.logo) assertThat((logo as BitmapDrawable).bitmap).isEqualTo(logoBitmapFromApp) } @@ -1309,6 +1316,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun logoDescriptionIsEmptyIfPackageNameNotFound() = runGenericTest(packageName = OP_PACKAGE_NAME_NO_ICON) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logoDescription by collectLastValue(viewModel.logoDescription) assertThat(logoDescription).isEqualTo("") } @@ -1316,6 +1324,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa @Test fun defaultLogoDescriptionIfNoLogoDescriptionSet() = runGenericTest { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logoDescription by collectLastValue(viewModel.logoDescription) assertThat(logoDescription).isEqualTo(defaultLogoDescription) } @@ -1324,6 +1333,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa fun logoDescriptionSetByApp() = runGenericTest(logoDescription = logoDescriptionFromApp) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) + mSetFlagsRule.enableFlags(FLAG_CONSTRAINT_BP) val logoDescription by collectLastValue(viewModel.logoDescription) assertThat(logoDescription).isEqualTo(logoDescriptionFromApp) } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakePromptRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakePromptRepository.kt index c3af437dafdf..2e2cf9a61a8c 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakePromptRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/data/repository/FakePromptRepository.kt @@ -78,6 +78,7 @@ class FakePromptRepository : PromptRepository { val hasCredentialViewShown = kind.value !is PromptKind.Biometric val showBpForCredential = Flags.customBiometricPrompt() && + com.android.systemui.Flags.constraintBp() && !Utils.isBiometricAllowed(promptInfo) && Utils.isDeviceCredentialAllowed(promptInfo) && promptInfo.contentView != null |