Update wallet setting availability

For devices that don't support wallet, don't even show the setting in
a disabled state, which can cause confusion and lead the user to
believe they can enable it somehow.

Fixes: 251089510
Test: WalletPrivacyPreferenceControllerTest
Change-Id: I5d60957f24712bb4d75e72fa5f64cab35b6d6a5f
This commit is contained in:
Matt Pietal
2023-01-04 21:39:43 +00:00
parent cb8c1c6c85
commit c617ae851d
2 changed files with 25 additions and 4 deletions

View File

@@ -64,15 +64,18 @@ public class WalletPrivacyPreferenceController extends TogglePreferenceControlle
public int getAvailabilityStatus() {
if (CustomizableLockScreenUtils.isFeatureEnabled(mContext)) {
return UNSUPPORTED_ON_DEVICE;
} else if (!isEnabled()) {
return UNSUPPORTED_ON_DEVICE;
} else if (!isSecure()) {
return DISABLED_DEPENDENT_SETTING;
}
return isEnabled() && isSecure() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
return AVAILABLE;
}
@Override
public void updateState(Preference preference) {
super.updateState(preference);
preference.setEnabled(getAvailabilityStatus() != DISABLED_DEPENDENT_SETTING);
preference.setEnabled(getAvailabilityStatus() == AVAILABLE);
refreshSummary(preference);
}

View File

@@ -141,11 +141,29 @@ public class WalletPrivacyPreferenceControllerTest {
}
@Test
public void getAvailabilityStatus_noService_returnsDisabled() {
public void getAvailabilityStatus_noServiceAndIsSecure_returnsUnsupported() {
when(mClient.isWalletServiceAvailable()).thenReturn(false);
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.UNSUPPORTED_ON_DEVICE);
}
@Test
public void getAvailabilityStatus_hasServiceButNotSecure_returnsDisabled() {
when(mClient.isWalletServiceAvailable()).thenReturn(true);
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(false);
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
}
@Test
public void getAvailabilityStatus_hasServiceAndIsSecure_returnsAvailable() {
when(mClient.isWalletServiceAvailable()).thenReturn(true);
when(mLockPatternUtils.isSecure(anyInt())).thenReturn(true);
assertThat(mController.getAvailabilityStatus()).isEqualTo(
BasePreferenceController.AVAILABLE);
}
}