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

Commit e7ad161e authored by Espen Fjellvær Olsen's avatar Espen Fjellvær Olsen Committed by Gerrit Code Review
Browse files

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

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.

Change-Id: Ie98b12135535968b20b8b515723116729879e9d4
parent c5779685
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -176,9 +176,15 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
        StorageManager storageManager = (StorageManager)
                mContext.getSystemService(Context.STORAGE_SERVICE);
        StorageVolume[] volumes = storageManager.getVolumeList();

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

        mUseUsbNotification = !massStorageSupported;

        // make sure the ADB_ENABLED setting value matches the current state
@@ -551,10 +557,10 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {
                    id = com.android.internal.R.string.usb_mtp_notification_title;
                } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
                    id = com.android.internal.R.string.usb_ptp_notification_title;
                } else if (containsFunction(mCurrentFunctions,
                        UsbManager.USB_FUNCTION_MASS_STORAGE)) {
                } /* else if (containsFunction(mCurrentFunctions, 
                        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; 
                } 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;
                } else {
                    // There is a different notification for USB tethering so we don't need one here
+11 −5
Original line number Diff line number Diff line
@@ -188,9 +188,15 @@ public class UsbDeviceManager {
        StorageManager storageManager = (StorageManager)
                mContext.getSystemService(Context.STORAGE_SERVICE);
        StorageVolume[] volumes = storageManager.getVolumeList();

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

        mUseUsbNotification = !massStorageSupported;

        // make sure the ADB_ENABLED setting value matches the current state
@@ -637,10 +643,10 @@ public class UsbDeviceManager {
                    id = com.android.internal.R.string.usb_mtp_notification_title;
                } else if (containsFunction(mCurrentFunctions, UsbManager.USB_FUNCTION_PTP)) {
                    id = com.android.internal.R.string.usb_ptp_notification_title;
                } else if (containsFunction(mCurrentFunctions,
                        UsbManager.USB_FUNCTION_MASS_STORAGE)) {
                } /* else if (containsFunction(mCurrentFunctions,
                     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; 
                } 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;
                } else {
                    // There is a different notification for USB tethering so we don't need one here