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

Commit 920e25a1 authored by dhacker29's avatar dhacker29 Committed by Arne Coucheron
Browse files

Allow USB notification to show when primary SD allows UMS and MTP

Previously if primary SD is set to allowMassStorage="true" the USB
dialog would never show.  This checks if persist.sys.usb.config is
set to mtp,adb and then allows the USB notification to show. With
this you can then have the option to select from MTP, PTP and Mass
storage when clicking the pull down notification. When Mass Storage
is selected it activates the USB connected dialog to turn on USB
storage. When set back to MTP the USB connected notification disappears.

Change-Id: I2287075ec93cae75f19e8fb59965d9dddb234aca
parent 219142b4
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -182,8 +182,10 @@ public class UsbDeviceManager {
        mNotificationManager = (NotificationManager)
                mContext.getSystemService(Context.NOTIFICATION_SERVICE);

        // We do not show the USB notification if the primary volume supports mass storage.
        // The legacy mass storage UI will be used instead.
        // We do not show the USB notification if the primary volume supports mass storage, unless
        // persist.sys.usb.config is set to mtp,adb. This will allow the USB notification to show
        // on devices with mtp as default and mass storage enabled on primary, so the user can choose
        // between mtp, ptp, and mass storage. The legacy mass storage UI will be used otherwise.
        boolean massStorageSupported = false;
        StorageManager storageManager = (StorageManager)
                mContext.getSystemService(Context.STORAGE_SERVICE);
@@ -197,7 +199,11 @@ public class UsbDeviceManager {
            }
        }

        if ("mtp,adb".equals(SystemProperties.get("persist.sys.usb.config"))) {
            mUseUsbNotification = true;
        } else {
            mUseUsbNotification = !massStorageSupported;
        }

        // make sure the ADB_ENABLED setting value matches the current state
        Settings.Secure.putInt(mContentResolver, Settings.Secure.ADB_ENABLED, mAdbEnabled ? 1 : 0);