Permalink
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/
  • Loading branch information...
1 parent 31bbe1d commit bd70dd7e5e30cab6f717329ad2e9913d91d42f9d @espenfjo espenfjo committed with Whitehawkx Jan 23, 2013
@@ -192,9 +192,15 @@ public void systemReady() {
StorageManager storageManager = (StorageManager)
mContext.getSystemService(Context.STORAGE_SERVICE);
StorageVolume[] volumes = storageManager.getVolumeList();
+
if (volumes.length > 0) {
- massStorageSupported = volumes[0].allowMassStorage();
+ 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
@@ -567,10 +573,10 @@ private void updateUsbNotification() {
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
@@ -204,7 +204,13 @@ public void systemReady() {
boolean massStorageSupported = false;
final StorageManager storageManager = StorageManager.from(mContext);
final StorageVolume primary = storageManager.getPrimaryVolume();
- massStorageSupported = primary != null && primary.allowMassStorage();
+
+ if (Settings.Secure.getInt(mContentResolver, Settings.Secure.USB_MASS_STORAGE_ENABLED, 0 ) == 1 ) {
+ massStorageSupported = primary != null && primary.allowMassStorage();
+ } else {
+ massStorageSupported = false;
+ }
+
mUseUsbNotification = !massStorageSupported;
// make sure the ADB_ENABLED setting value matches the current state

0 comments on commit bd70dd7

Please sign in to comment.