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

Commit cfd328b6 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Allow disabling both MTP and PTP.

Require that MTP and PTP are mutually exclusive when enabled, but
allow them to be both disabled.  Users can enable them again under
Storage menu item in Settings.

Bug: 6518257
Change-Id: I43419fa619ce2c62dd5e8c14d6c645d24fd8943a
parent 3c8a4c3b
Loading
Loading
Loading
Loading
+10 −16
Original line number Diff line number Diff line
@@ -123,7 +123,6 @@ public class UsbSettings extends SettingsPreferenceFragment {
            mMtp.setEnabled(false);
            mPtp.setEnabled(false);
        }

    }

    @Override
@@ -134,22 +133,17 @@ public class UsbSettings extends SettingsPreferenceFragment {
        if (Utils.isMonkeyRunning()) {
            return true;
        }
        // temporary hack - using check boxes as radio buttons
        // don't allow unchecking them
        if (preference instanceof CheckBoxPreference) {
            CheckBoxPreference checkBox = (CheckBoxPreference)preference;
            if (!checkBox.isChecked()) {
                checkBox.setChecked(true);
                return true;
            }
        }
        if (preference == mMtp) {
            mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_MTP, true);
            updateToggles(UsbManager.USB_FUNCTION_MTP);
        } else if (preference == mPtp) {
            mUsbManager.setCurrentFunction(UsbManager.USB_FUNCTION_PTP, true);
            updateToggles(UsbManager.USB_FUNCTION_PTP);

        String function = "none";
        if (preference == mMtp && mMtp.isChecked()) {
            function = UsbManager.USB_FUNCTION_MTP;
        } else if (preference == mPtp && mPtp.isChecked()) {
            function = UsbManager.USB_FUNCTION_PTP;
        }

        mUsbManager.setCurrentFunction(function, true);
        updateToggles(function);

        return true;
    }
}