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

Commit 09764a46 authored by Espen Fjellvær Olsen's avatar Espen Fjellvær Olsen Committed by Ricardo Cerqueira
Browse files

Add option for switching between UMS and MTP/PTP mode. (1/2)

Change-Id: I8e692d468cb36ccc97ca69b8a2eb11afeb711eae

This adds support for switching between UMS and MTP/PTP.
Framework part (this part) will only enable UMS if the config setting is set.
Standard is to enable UMS if the primary volume supports UMS.

It's only porting this http://review.cyanogenmod.org/#/c/21117/
parent e8c1c7cb
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -192,9 +192,15 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
        StorageManager storageManager = (StorageManager)
        StorageManager storageManager = (StorageManager)
                mContext.getSystemService(Context.STORAGE_SERVICE);
                mContext.getSystemService(Context.STORAGE_SERVICE);
        StorageVolume[] volumes = storageManager.getVolumeList();
        StorageVolume[] volumes = storageManager.getVolumeList();

        if (volumes.length > 0) {
        if (volumes.length > 0) {
            if (Settings.Secure.getInt(mContentResolver, Settings.Secure.USB_MASS_STORAGE_ENABLED, 0 ) == 1 ) {
                massStorageSupported = volumes[0].allowMassStorage();
                massStorageSupported = volumes[0].allowMassStorage();
            } else {
                massStorageSupported = false;
            }
            }
        }

        mUseUsbNotification = !massStorageSupported;
        mUseUsbNotification = !massStorageSupported;


        // make sure the ADB_ENABLED setting value matches the current state
        // make sure the ADB_ENABLED setting value matches the current state
@@ -567,10 +573,10 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
                    id = com.android.internal.R.string.usb_mtp_notification_title;
                    id = com.android.internal.R.string.usb_mtp_notification_title;
                } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
                } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
                    id = com.android.internal.R.string.usb_ptp_notification_title;
                    id = com.android.internal.R.string.usb_ptp_notification_title;
                } else if (containsFunction(mCurrentFunctions,
                } /* else if (containsFunction(mCurrentFunctions,
                        UsbManager.USB_FUNCTION_MASS_STORAGE)) {
                        UsbManager.USB_FUNCTION_MASS_STORAGE)) { // Disable this as it causes double USB settings menues when in UMS mode.
                    id = com.android.internal.R.string.usb_cd_installer_notification_title;
                    id = com.android.internal.R.string.usb_cd_installer_notification_title;
                } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ACCESSORY)) {
                } */ else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_ACCESSORY)) {
                    id = com.android.internal.R.string.usb_accessory_notification_title;
                    id = com.android.internal.R.string.usb_accessory_notification_title;
                } else {
                } else {
                    // There is a different notification for USB tethering so we don't need one here
                    // There is a different notification for USB tethering so we don't need one here
+7 −1
Original line number Original line Diff line number Diff line
@@ -202,7 +202,13 @@ public class UsbDeviceManager {
        boolean massStorageSupported = false;
        boolean massStorageSupported = false;
        final StorageManager storageManager = StorageManager.from(mContext);
        final StorageManager storageManager = StorageManager.from(mContext);
        final StorageVolume primary = storageManager.getPrimaryVolume();
        final StorageVolume primary = storageManager.getPrimaryVolume();

        if (Settings.Secure.getInt(mContentResolver, Settings.Secure.USB_MASS_STORAGE_ENABLED, 0 ) == 1 ) {
                massStorageSupported = primary != null && primary.allowMassStorage();
                massStorageSupported = primary != null && primary.allowMassStorage();
        } else {
                massStorageSupported = false;
        }

        mUseUsbNotification = !massStorageSupported;
        mUseUsbNotification = !massStorageSupported;


        // make sure the ADB_ENABLED setting value matches the current state
        // make sure the ADB_ENABLED setting value matches the current state