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

Commit 10c2358b authored by Oran Avraham's avatar Oran Avraham Committed by Gerrit Code Review
Browse files

UMS support with any volume, not only primary (2/3)



This patch enables UMS support when any volume supports it, even when the
primary storage doesn't.

1. Vold: assign lun_numbers sequentially to the volumes being added to the
   VolumeManager.
2. Fix portions of code which assume that the device has UMS support iff the
   primary storage supports UMS.
   Instead, determine whether the device supports UMS by checking each volume.
3. Display the UMS option in Settings.apk when any volume supports it.

Change-Id: I00a8338abe566f5fa20653733d13503064183c7e
Signed-off-by: default avatarOran Avraham <oranav@gmail.com>
parent dd5025d8
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -421,6 +421,24 @@ public class StorageManager
        return false;
    }

    /**
     * Query if a USB Mass Storage (UMS) is supported on the device.
     * @return true if UMS is supported.
     *
     * @hide
     */
    public boolean isUsbMassStorageSupported() {
        // TODO: Maybe query mMountService instead?
        StorageVolume[] volumes = getVolumeList();
        if (volumes == null) return false;
        for (int i = 0; i < volumes.length; i++) {
            if (volumes[i].allowMassStorage()) {
                return true;
            }
        }
        return false;
    }

    /**
     * Mount an Opaque Binary Blob (OBB) file. If a <code>key</code> is
     * specified, it is supplied to the mounting process to be used in any
+4 −2
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ class MountService extends IMountService.Stub
    private boolean                               mSendUmsConnectedOnBoot = false;
    // true if we should fake MEDIA_MOUNTED state for external storage
    private boolean                               mEmulateExternalStorage = false;
    private boolean                               mUmsSupported = false;

    /**
     * Private hash of currently mounted secure containers.
@@ -1152,6 +1153,7 @@ class MountService extends IMountService.Stub
                            mVolumes.add(volume);
                        }
                        mVolumeMap.put(pathString, volume);
                        mUmsSupported |= allowMassStorage;
                    }
                    a.recycle();
                }
@@ -1193,8 +1195,8 @@ class MountService extends IMountService.Stub

        IntentFilter filter = new IntentFilter();
        filter.addAction(Intent.ACTION_BOOT_COMPLETED);
        // don't bother monitoring USB if mass storage is not supported on our primary volume
        if (mPrimaryVolume != null && mPrimaryVolume.allowMassStorage()) {
        // don't bother monitoring USB if mass storage is not supported
        if (mUmsSupported) {
            filter.addAction(UsbManager.ACTION_USB_STATE);
        }
        mContext.registerReceiver(mBroadcastReceiver, filter, null, null);
+1 −1
Original line number Diff line number Diff line
@@ -179,7 +179,7 @@ public class LegacyUsbDeviceManager extends UsbDeviceManager {

        if (volumes.length > 0) {
            if (Settings.Secure.getInt(mContentResolver, Settings.Secure.USB_MASS_STORAGE_ENABLED, 0) == 1 ) {
                massStorageSupported = volumes[0].allowMassStorage();
                massStorageSupported = storageManager.isUsbMassStorageSupported();
            } else {
                massStorageSupported = false;
            }
+1 −1
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class UsbDeviceManager {

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