From bd86eae9a83d5a0ebc4ee4f96efa5c7325d3de20 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Fri, 13 Jan 2023 15:15:33 -0800 Subject: [PATCH] Show wallet option in picker even if not set up. Updates the logic to show the option in the picker as disabled, when the wallet is not yet set up. Fix: 265321396 Test: manually made sure that the wallet option is visible and disabled in the picker before I installed the wallet app. Once a card was added, it became selectable and enabled. Test: updated unit tests. Change-Id: Ie5d854b7314148d3721d6efa2e2e18f883c861c5 --- ...cessWalletKeyguardQuickAffordanceConfig.kt | 4 +-- ...WalletKeyguardQuickAffordanceConfigTest.kt | 32 +++++-------------- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt index 680c06bf2c64d..4ba2eb913742c 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt @@ -100,9 +100,9 @@ constructor( override suspend fun getPickerScreenState(): KeyguardQuickAffordanceConfig.PickerScreenState { return when { - !walletController.isWalletEnabled -> + !walletController.walletClient.isWalletServiceAvailable -> KeyguardQuickAffordanceConfig.PickerScreenState.UnavailableOnDevice - walletController.walletClient.tileIcon == null || queryCards().isEmpty() -> { + !walletController.isWalletEnabled || queryCards().isEmpty() -> { val componentName = walletController.walletClient.createWalletSettingsIntent().toComponentName() val actionText = diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt index ca44fa18f6c49..8f56b9560ec3d 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt @@ -113,21 +113,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { job.cancel() } - @Test - fun `affordance - missing icon - model is none`() = runBlockingTest { - setUpState(hasWalletIcon = false) - var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null - - val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) - - assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden) - - job.cancel() - } - @Test fun `affordance - no selected card - model is none`() = runBlockingTest { - setUpState(hasWalletIcon = false) + setUpState(hasSelectedCard = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) @@ -165,7 +153,7 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { @Test fun `getPickerScreenState - unavailable`() = runTest { setUpState( - isWalletEnabled = false, + isWalletServiceAvailable = false, ) assertThat(underTest.getPickerScreenState()) @@ -173,9 +161,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { } @Test - fun `getPickerScreenState - disabled when there is no icon`() = runTest { + fun `getPickerScreenState - disabled when the feature is not enabled`() = runTest { setUpState( - hasWalletIcon = false, + isWalletEnabled = false, ) assertThat(underTest.getPickerScreenState()) @@ -194,20 +182,16 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { private fun setUpState( isWalletEnabled: Boolean = true, + isWalletServiceAvailable: Boolean = true, isWalletQuerySuccessful: Boolean = true, - hasWalletIcon: Boolean = true, hasSelectedCard: Boolean = true, ) { whenever(walletController.isWalletEnabled).thenReturn(isWalletEnabled) val walletClient: QuickAccessWalletClient = mock() - val icon: Drawable? = - if (hasWalletIcon) { - ICON - } else { - null - } - whenever(walletClient.tileIcon).thenReturn(icon) + whenever(walletClient.tileIcon).thenReturn(ICON) + whenever(walletClient.isWalletServiceAvailable).thenReturn(isWalletServiceAvailable) + whenever(walletController.walletClient).thenReturn(walletClient) whenever(walletController.queryWalletCards(any())).thenAnswer { invocation ->