Loading packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.biometrics.ui.viewmodel import android.content.Context import android.content.pm.PackageManager import android.graphics.Rect import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable Loading Loading @@ -244,7 +245,13 @@ constructor( !customBiometricPrompt() || it == null -> null it.logoRes != -1 -> context.resources.getDrawable(it.logoRes, context.theme) it.logoBitmap != null -> BitmapDrawable(context.resources, it.logoBitmap) else -> context.packageManager.getApplicationIcon(it.opPackageName) else -> try { context.packageManager.getApplicationIcon(it.opPackageName) } catch (e: PackageManager.NameNotFoundException) { Log.w(TAG, "Cannot find icon for package " + it.opPackageName, e) null } } } .distinctUntilChanged() Loading packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt +14 −2 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ private const val USER_ID = 4 private const val CHALLENGE = 2L private const val DELAY = 1000L private const val OP_PACKAGE_NAME = "biometric.testapp" private const val OP_PACKAGE_NAME_NO_ICON = "biometric.testapp.noicon" @OptIn(ExperimentalCoroutinesApi::class) @SmallTest Loading Loading @@ -1245,6 +1246,14 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa assertThat(contentView).isNull() } @Test fun logoIsNullIfPackageNameNotFound() = runGenericTest(packageName = OP_PACKAGE_NAME_NO_ICON) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) val logo by collectLastValue(viewModel.logo) assertThat(logo).isNull() } @Test fun defaultLogoIfNoLogoSet() = runGenericTest { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) Loading Loading @@ -1291,7 +1300,8 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa contentView: PromptContentView? = null, logoRes: Int = -1, logoBitmap: Bitmap? = null, block: suspend TestScope.() -> Unit packageName: String = OP_PACKAGE_NAME, block: suspend TestScope.() -> Unit, ) { selector.initializePrompt( requireConfirmation = testCase.confirmationRequested, Loading @@ -1302,6 +1312,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa contentViewFromApp = contentView, logoResFromApp = logoRes, logoBitmapFromApp = logoBitmap, packageName = packageName, ) // put the view model in the initial authenticating state, unless explicitly skipped Loading Loading @@ -1481,6 +1492,7 @@ private fun PromptSelectorInteractor.initializePrompt( contentViewFromApp: PromptContentView? = null, logoResFromApp: Int = -1, logoBitmapFromApp: Bitmap? = null, packageName: String = OP_PACKAGE_NAME, ) { val info = PromptInfo().apply { Loading @@ -1500,7 +1512,7 @@ private fun PromptSelectorInteractor.initializePrompt( USER_ID, CHALLENGE, BiometricModalities(fingerprintProperties = fingerprint, faceProperties = face), OP_PACKAGE_NAME, packageName, ) } Loading Loading
packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt +8 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.biometrics.ui.viewmodel import android.content.Context import android.content.pm.PackageManager import android.graphics.Rect import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable Loading Loading @@ -244,7 +245,13 @@ constructor( !customBiometricPrompt() || it == null -> null it.logoRes != -1 -> context.resources.getDrawable(it.logoRes, context.theme) it.logoBitmap != null -> BitmapDrawable(context.resources, it.logoBitmap) else -> context.packageManager.getApplicationIcon(it.opPackageName) else -> try { context.packageManager.getApplicationIcon(it.opPackageName) } catch (e: PackageManager.NameNotFoundException) { Log.w(TAG, "Cannot find icon for package " + it.opPackageName, e) null } } } .distinctUntilChanged() Loading
packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt +14 −2 Original line number Diff line number Diff line Loading @@ -81,6 +81,7 @@ private const val USER_ID = 4 private const val CHALLENGE = 2L private const val DELAY = 1000L private const val OP_PACKAGE_NAME = "biometric.testapp" private const val OP_PACKAGE_NAME_NO_ICON = "biometric.testapp.noicon" @OptIn(ExperimentalCoroutinesApi::class) @SmallTest Loading Loading @@ -1245,6 +1246,14 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa assertThat(contentView).isNull() } @Test fun logoIsNullIfPackageNameNotFound() = runGenericTest(packageName = OP_PACKAGE_NAME_NO_ICON) { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) val logo by collectLastValue(viewModel.logo) assertThat(logo).isNull() } @Test fun defaultLogoIfNoLogoSet() = runGenericTest { mSetFlagsRule.enableFlags(FLAG_CUSTOM_BIOMETRIC_PROMPT) Loading Loading @@ -1291,7 +1300,8 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa contentView: PromptContentView? = null, logoRes: Int = -1, logoBitmap: Bitmap? = null, block: suspend TestScope.() -> Unit packageName: String = OP_PACKAGE_NAME, block: suspend TestScope.() -> Unit, ) { selector.initializePrompt( requireConfirmation = testCase.confirmationRequested, Loading @@ -1302,6 +1312,7 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa contentViewFromApp = contentView, logoResFromApp = logoRes, logoBitmapFromApp = logoBitmap, packageName = packageName, ) // put the view model in the initial authenticating state, unless explicitly skipped Loading Loading @@ -1481,6 +1492,7 @@ private fun PromptSelectorInteractor.initializePrompt( contentViewFromApp: PromptContentView? = null, logoResFromApp: Int = -1, logoBitmapFromApp: Bitmap? = null, packageName: String = OP_PACKAGE_NAME, ) { val info = PromptInfo().apply { Loading @@ -1500,7 +1512,7 @@ private fun PromptSelectorInteractor.initializePrompt( USER_ID, CHALLENGE, BiometricModalities(fingerprintProperties = fingerprint, faceProperties = face), OP_PACKAGE_NAME, packageName, ) } Loading