Loading core/java/android/os/storage/StorageVolume.java +19 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class StorageVolume implements Parcelable { private final boolean mRemovable; private final boolean mEmulated; private final int mMtpReserveSpace; private final boolean mAllowMassStorage; private int mStorageId; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, Loading @@ -39,23 +40,25 @@ public class StorageVolume implements Parcelable { // ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts. public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace) { public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage) { mPath = path; mDescription = description; mRemovable = removable; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; } // for parcelling only private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId) { private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage) { mPath = path; mDescription = description; mRemovable = removable; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mStorageId = storageId; } Loading Loading @@ -130,6 +133,15 @@ public class StorageVolume implements Parcelable { return mMtpReserveSpace; } /** * Returns true if this volume can be shared via USB mass storage. * * @return whether mass storage is allowed */ public boolean allowMassStorage() { return mAllowMassStorage; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -158,9 +170,10 @@ public class StorageVolume implements Parcelable { int emulated = in.readInt(); int storageId = in.readInt(); int mtpReserveSpace = in.readInt(); int allowMassStorage = in.readInt(); return new StorageVolume(path, description, removable == 1, emulated == 1, mtpReserveSpace, storageId); mtpReserveSpace, storageId, allowMassStorage == 1); } public StorageVolume[] newArray(int size) { Loading @@ -179,5 +192,6 @@ public class StorageVolume implements Parcelable { parcel.writeInt(mEmulated ? 1 : 0); parcel.writeInt(mStorageId); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mAllowMassStorage ? 1 : 0); } } core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -5156,6 +5156,8 @@ <!-- number of megabytes of storage MTP should reserve for free storage (used for emulated storage that is shared with system's data partition) --> <attr name="mtpReserve" format="integer" /> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> </declare-styleable> </resources> services/java/com/android/server/MountService.java +6 −2 Original line number Diff line number Diff line Loading @@ -1121,16 +1121,20 @@ class MountService extends IMountService.Stub implements INativeDaemonConnectorC com.android.internal.R.styleable.Storage_emulated, false); int mtpReserve = a.getInt( com.android.internal.R.styleable.Storage_mtpReserve, 0); boolean allowMassStorage = a.getBoolean( com.android.internal.R.styleable.Storage_allowMassStorage, false); Slog.d(TAG, "got storage path: " + path + " description: " + description + " primary: " + primary + " removable: " + removable + " emulated: " + emulated + " mtpReserve: " + mtpReserve); " emulated: " + emulated + " mtpReserve: " + mtpReserve + " allowMassStorage: " + allowMassStorage); if (path == null || description == null) { Slog.e(TAG, "path or description is null in readStorageList"); } else { String pathString = path.toString(); StorageVolume volume = new StorageVolume(pathString, description.toString(), removable, emulated, mtpReserve); description.toString(), removable, emulated, mtpReserve, allowMassStorage); if (primary) { if (mPrimaryVolume == null) { mPrimaryVolume = volume; Loading Loading
core/java/android/os/storage/StorageVolume.java +19 −5 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class StorageVolume implements Parcelable { private final boolean mRemovable; private final boolean mEmulated; private final int mMtpReserveSpace; private final boolean mAllowMassStorage; private int mStorageId; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, Loading @@ -39,23 +40,25 @@ public class StorageVolume implements Parcelable { // ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts. public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace) { public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage) { mPath = path; mDescription = description; mRemovable = removable; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; } // for parcelling only private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId) { private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage) { mPath = path; mDescription = description; mRemovable = removable; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mStorageId = storageId; } Loading Loading @@ -130,6 +133,15 @@ public class StorageVolume implements Parcelable { return mMtpReserveSpace; } /** * Returns true if this volume can be shared via USB mass storage. * * @return whether mass storage is allowed */ public boolean allowMassStorage() { return mAllowMassStorage; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -158,9 +170,10 @@ public class StorageVolume implements Parcelable { int emulated = in.readInt(); int storageId = in.readInt(); int mtpReserveSpace = in.readInt(); int allowMassStorage = in.readInt(); return new StorageVolume(path, description, removable == 1, emulated == 1, mtpReserveSpace, storageId); mtpReserveSpace, storageId, allowMassStorage == 1); } public StorageVolume[] newArray(int size) { Loading @@ -179,5 +192,6 @@ public class StorageVolume implements Parcelable { parcel.writeInt(mEmulated ? 1 : 0); parcel.writeInt(mStorageId); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mAllowMassStorage ? 1 : 0); } }
core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -5156,6 +5156,8 @@ <!-- number of megabytes of storage MTP should reserve for free storage (used for emulated storage that is shared with system's data partition) --> <attr name="mtpReserve" format="integer" /> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> </declare-styleable> </resources>
services/java/com/android/server/MountService.java +6 −2 Original line number Diff line number Diff line Loading @@ -1121,16 +1121,20 @@ class MountService extends IMountService.Stub implements INativeDaemonConnectorC com.android.internal.R.styleable.Storage_emulated, false); int mtpReserve = a.getInt( com.android.internal.R.styleable.Storage_mtpReserve, 0); boolean allowMassStorage = a.getBoolean( com.android.internal.R.styleable.Storage_allowMassStorage, false); Slog.d(TAG, "got storage path: " + path + " description: " + description + " primary: " + primary + " removable: " + removable + " emulated: " + emulated + " mtpReserve: " + mtpReserve); " emulated: " + emulated + " mtpReserve: " + mtpReserve + " allowMassStorage: " + allowMassStorage); if (path == null || description == null) { Slog.e(TAG, "path or description is null in readStorageList"); } else { String pathString = path.toString(); StorageVolume volume = new StorageVolume(pathString, description.toString(), removable, emulated, mtpReserve); description.toString(), removable, emulated, mtpReserve, allowMassStorage); if (primary) { if (mPrimaryVolume == null) { mPrimaryVolume = volume; Loading