Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 813d12dd authored by Ilyas Sung's avatar Ilyas Sung
Browse files

Migrate the setUsbDataSignalingEnabled api to the device policy engine.

- Change isUsbDataSignalingEnabledForUser() to isUsbDataSignalingEnabled()

Bug: 283934505
Test: Manual Test
Change-Id: I1327eaadeb41b64041d722f81a7df5260035a1d1
parent 19aefe04
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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);

+4 −8
Original line number Diff line number Diff line
@@ -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();
+5 −10
Original line number Diff line number Diff line
@@ -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();