Merge "Migrate the setUsbDataSignalingEnabled api to the device policy engine."

This commit is contained in:
Kholoud Mohamed
2023-06-27 15:57:25 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 20 deletions

View File

@@ -82,8 +82,7 @@ public class ConnectedUsbDeviceUpdaterTest {
@Test
public void initUsbPreference_preferenceInit() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
mDeviceUpdater.initUsbPreference(mContext);

View File

@@ -71,8 +71,7 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
@Test
public void updateState_usbDataSignalingEnabled_shouldNotDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.updateState(mPreference);
@@ -82,8 +81,7 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
@Test
public void updateState_usbDataSignalingDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.updateState(mPreference);
@@ -94,8 +92,7 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
@Test
public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
@@ -105,8 +102,7 @@ public class DefaultUsbConfigurationPreferenceControllerTest {
@Test
public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();

View File

@@ -75,8 +75,7 @@ public class UsbAudioRoutingPreferenceControllerTest {
@Test
public void updateState_usbAudioRoutingEnabled_shouldCheckedPreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
@@ -89,8 +88,7 @@ public class UsbAudioRoutingPreferenceControllerTest {
@Test
public void updateState_usbAudioRoutingDisabled_shouldUncheckedPreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.USB_AUDIO_AUTOMATIC_ROUTING_DISABLED,
@@ -103,8 +101,7 @@ public class UsbAudioRoutingPreferenceControllerTest {
@Test
public void updateState_usbDataSignalingDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.updateState(mPreference);
@@ -150,8 +147,7 @@ public class UsbAudioRoutingPreferenceControllerTest {
@Test
public void onDeveloperOptionsSwitchEnabled_usbEnabled_shouldNotDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(true);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(true);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();
@@ -161,8 +157,7 @@ public class UsbAudioRoutingPreferenceControllerTest {
@Test
public void onDeveloperOptionsSwitchEnabled_usbDisabled_shouldDisablePreference() {
when(mDevicePolicyManager.isUsbDataSignalingEnabledForUser(
UserHandle.myUserId())).thenReturn(false);
when(mDevicePolicyManager.isUsbDataSignalingEnabled()).thenReturn(false);
when(mDevicePolicyManager.getProfileOwner()).thenReturn(TEST_COMPONENT_NAME);
mController.onDeveloperOptionsSwitchEnabled();