From e68b7a4dc37608b6f309651b9bbee8a462d246fb Mon Sep 17 00:00:00 2001 From: Brad Hinegardner Date: Wed, 31 May 2023 19:18:10 +0000 Subject: [PATCH] QuickAccessWalletQuickAffordance Config shouldn't check older setting. Because the setting is now unavailable in favor of the picker and the config was also checking the setting, users could get into a situation where they had "show wallet on lockscreen" disabled, upgrade to the custom shortcuts experience, then not be able to select the wallet shortcut. The KeyguardQuickaffordanceLegacySettingSyncer already handles this. If the user previously has "show wallet on lockscreen" set to disabled, then they update to use custom shortcuts, this Syncer will deselect the Wallet as a quick affordance by default. The QuickAccessWalletKeyguardQuickAffordanceConfig shouldn't rely on this setting, as it creates an unbreakable cyclical dependency. Bug: b/284678447 Test: atest QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt Test: manual - flash prior version of anddroid without custom shortcuts. Set "show wallet on lockscreen" setting to "false" (but otherwise have a working and set up wallet). Upgrade to version with custom shortcuts. Validate that "None" is selected, instead of "wallet". This is thanks to the KeyguardQuickAffordanceLegacySettingSyncer handling this case. Change-Id: Ic3e98a2e00d3dc46dc2ec05390eebb703e55732c --- .../QuickAccessWalletKeyguardQuickAffordanceConfig.kt | 9 +++++++-- ...ckAccessWalletKeyguardQuickAffordanceConfigTest.kt | 11 +++++------ 2 files changed, 12 insertions(+), 8 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 12270784adca8..1ea6463f9460b 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 @@ -63,7 +63,7 @@ constructor( val hasCards = response?.walletCards?.isNotEmpty() == true trySendWithFailureLogging( state( - isFeatureEnabled = walletController.isWalletEnabled, + isFeatureEnabled = isWalletAvailable(), hasCard = hasCards, tileIcon = walletController.walletClient.tileIcon, ), @@ -100,7 +100,7 @@ constructor( return when { !walletController.walletClient.isWalletServiceAvailable -> KeyguardQuickAffordanceConfig.PickerScreenState.UnavailableOnDevice - !walletController.isWalletEnabled || queryCards().isEmpty() -> { + !isWalletAvailable() || queryCards().isEmpty() -> { KeyguardQuickAffordanceConfig.PickerScreenState.Disabled( instructions = listOf( @@ -146,6 +146,11 @@ constructor( } } + private fun isWalletAvailable() = + with(walletController.walletClient) { + isWalletServiceAvailable && isWalletFeatureAvailable + } + private fun state( isFeatureEnabled: Boolean, hasCard: Boolean, 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 111b8e83a9847..d36e77889810b 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 @@ -92,8 +92,8 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { } @Test - fun affordance_walletNotEnabled_modelIsNone() = runBlockingTest { - setUpState(isWalletEnabled = false) + fun affordance_walletFeatureNotEnabled_modelIsNone() = runBlockingTest { + setUpState(isWalletFeatureAvailable = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) @@ -165,7 +165,7 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { @Test fun getPickerScreenState_disabledWhenTheFeatureIsNotEnabled() = runTest { setUpState( - isWalletEnabled = false, + isWalletFeatureAvailable = false, ) assertThat(underTest.getPickerScreenState()) @@ -183,16 +183,15 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { } private fun setUpState( - isWalletEnabled: Boolean = true, + isWalletFeatureAvailable: Boolean = true, isWalletServiceAvailable: Boolean = true, isWalletQuerySuccessful: Boolean = true, hasSelectedCard: Boolean = true, ) { - whenever(walletController.isWalletEnabled).thenReturn(isWalletEnabled) - val walletClient: QuickAccessWalletClient = mock() whenever(walletClient.tileIcon).thenReturn(ICON) whenever(walletClient.isWalletServiceAvailable).thenReturn(isWalletServiceAvailable) + whenever(walletClient.isWalletFeatureAvailable).thenReturn(isWalletFeatureAvailable) whenever(walletController.walletClient).thenReturn(walletClient)