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

Commit 71742eb1 authored by Jean-Baptiste Queru's avatar Jean-Baptiste Queru Committed by Android Git Automerger
Browse files

am 0c869d69: Merge "UsbSetting: The behavior is not right when enable/disable...

am 0c869d69: Merge "UsbSetting: The behavior is not right when enable/disable MTP/PTP with Accessory board connected."

* commit '0c869d69':
  UsbSetting: The behavior is not right when enable/disable MTP/PTP with Accessory board connected.
parents f4cc034e 0c869d69
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -49,9 +49,15 @@ public class UsbSettings extends SettingsPreferenceFragment {
    private UsbManager mUsbManager;
    private CheckBoxPreference mMtp;
    private CheckBoxPreference mPtp;
    private boolean mUsbAccessoryMode;

    private final BroadcastReceiver mStateReceiver = new BroadcastReceiver() {
        public void onReceive(Context content, Intent intent) {
            String action = intent.getAction();
            if (action.equals(UsbManager.ACTION_USB_STATE)) {
               mUsbAccessoryMode = intent.getBooleanExtra(UsbManager.USB_FUNCTION_ACCESSORY, false);
               Log.e(TAG, "UsbAccessoryMode " + mUsbAccessoryMode);
            }
            updateToggles(mUsbManager.getDefaultFunction());
        }
    };
@@ -106,6 +112,18 @@ public class UsbSettings extends SettingsPreferenceFragment {
            mMtp.setChecked(false);
            mPtp.setChecked(false);
        }

        if (!mUsbAccessoryMode) {
            //Enable MTP and PTP switch while USB is not in Accessory Mode, otherwise disable it
            Log.e(TAG, "USB Normal Mode");
            mMtp.setEnabled(true);
            mPtp.setEnabled(true);
        } else {
            Log.e(TAG, "USB Accessory Mode");
            mMtp.setEnabled(false);
            mPtp.setEnabled(false);
        }

    }

    @Override