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

Commit 2676dd76 authored by Hugh Chen's avatar Hugh Chen Committed by Automerger Merge Worker
Browse files

Fix the usb menu didn't switch to "File Transfer/Android Auto" right after...

Fix the usb menu didn't switch to "File Transfer/Android Auto" right after connecting to the car unit. am: 91ed6312

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/13218253

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I3ca5a04cc2e8db3b2f50d1656fa54c8e02f8e394
parents 25ee8c7c 91ed6312
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -72,6 +72,9 @@ public class UsbConnectionBroadcastReceiver extends BroadcastReceiver implements
            if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_RNDIS)) {
                functions |= UsbManager.FUNCTION_RNDIS;
            }
            if (intent.getExtras().getBoolean(UsbManager.USB_FUNCTION_ACCESSORY)) {
                functions |= UsbManager.FUNCTION_ACCESSORY;
            }
            mFunctions = functions;
            mDataRole = mUsbBackend.getDataRole();
            mPowerRole = mUsbBackend.getPowerRole();
+5 −1
Original line number Diff line number Diff line
@@ -100,7 +100,11 @@ public class UsbDetailsFunctionsController extends UsbDetailsController
            pref = getProfilePreference(UsbBackend.usbFunctionsToString(option), title);
            // Only show supported options
            if (mUsbBackend.areFunctionsSupported(option)) {
                if (functions == UsbManager.FUNCTION_ACCESSORY) {
                    pref.setChecked(UsbManager.FUNCTION_MTP == option);
                } else {
                    pref.setChecked(functions == option);
                }
            } else {
                mProfilesContainer.removePreference(pref);
            }
+13 −0
Original line number Diff line number Diff line
@@ -153,6 +153,19 @@ public class UsbDetailsFunctionsControllerTest {
        assertThat(prefs.get(0).isChecked()).isTrue();
    }

    @Test
    public void displayRefresh_accessoryEnabled_shouldCheckSwitches() {
        when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);

        mDetailsFunctionsController.refresh(true, UsbManager.FUNCTION_ACCESSORY, POWER_ROLE_SINK,
                DATA_ROLE_DEVICE);
        List<RadioButtonPreference> prefs = getRadioPreferences();

        assertThat(prefs.get(0).getKey())
                .isEqualTo(UsbBackend.usbFunctionsToString(UsbManager.FUNCTION_MTP));
        assertThat(prefs.get(0).isChecked()).isTrue();
    }

    @Test
    public void onClickMtp_noneEnabled_shouldEnableMtp() {
        when(mUsbBackend.areFunctionsSupported(anyLong())).thenReturn(true);