Migrate the setUsbDataSignalingEnabled api to the device policy engine.

- Change isUsbDataSignalingEnabledForUser() to isUsbDataSignalingEnabled()

Bug: 283934505
Test: Manual Test
Change-Id: I1327eaadeb41b64041d722f81a7df5260035a1d1
This commit is contained in:
Ilyas Sung
2023-06-01 15:03:30 +00:00
parent 19aefe0421
commit 813d12dd8c
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();