Merge "Settings: Disable USB preferences if USB signaling is off" into sc-dev

This commit is contained in:
Alex Johnston
2021-03-24 10:13:47 +00:00
committed by Android (Google) Code Review
4 changed files with 60 additions and 0 deletions

View File

@@ -91,4 +91,27 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
}
@Test
public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setDisabledByAdmin(null);
}
@Test
public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
}
}

View File

@@ -147,4 +147,27 @@ public class UsbAudioRoutingPreferenceControllerTest {
verify(mPreference).setEnabled(false);
verify(mPreference).setChecked(false);
}
@Test
public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setDisabledByAdmin(null);
}
@Test
public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
verify(mPreference).setDisabledByAdmin(eq(new RestrictedLockUtils.EnforcedAdmin(
TEST_COMPONENT_NAME, null, UserHandle.SYSTEM)));
}
}