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

Commit f8ed07fc authored by Jerry Zhang's avatar Jerry Zhang Committed by android-build-merger
Browse files

Refactor setCurrentFunction and setUsbDataUnlocked into one method am: a1b60e62 am: a75fa912

am: fd764ac0

Change-Id: Iee63263785e80cb1a893dc99204bb2fb225a497a
parents 7fd676ee fd764ac0
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -1707,11 +1707,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
    private void writeUsbConfigurationOption(Object newValue) {
        UsbManager manager = (UsbManager)getActivity().getSystemService(Context.USB_SERVICE);
        String function = newValue.toString();
        manager.setCurrentFunction(function);
        if (function.equals("none")) {
            manager.setUsbDataUnlocked(false);
            manager.setCurrentFunction(function, false);
        } else {
            manager.setUsbDataUnlocked(true);
            manager.setCurrentFunction(function, true);
        }
    }

+4 −8
Original line number Diff line number Diff line
@@ -101,20 +101,16 @@ public class UsbBackend {
    private void setUsbFunction(int mode) {
        switch (mode) {
            case MODE_DATA_MTP:
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP);
                mUsbManager.setUsbDataUnlocked(true);
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP, true);
                break;
            case MODE_DATA_PTP:
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP);
                mUsbManager.setUsbDataUnlocked(true);
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP, true);
                break;
            case MODE_DATA_MIDI:
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI);
                mUsbManager.setUsbDataUnlocked(true);
                mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MIDI, true);
                break;
            default:
                mUsbManager.setCurrentFunction(null);
                mUsbManager.setUsbDataUnlocked(false);
                mUsbManager.setCurrentFunction(null, false);
                break;
        }
    }