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
This commit is contained in:
Brad Hinegardner
2023-05-31 19:18:10 +00:00
parent 863329a87c
commit e68b7a4dc3
2 changed files with 12 additions and 8 deletions

View File

@@ -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,

View File

@@ -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)