Loading core/java/android/os/storage/StorageVolume.java +11 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class StorageVolume implements Parcelable { private final long mMaxFileSize; /** When set, indicates exclusive ownership of this volume */ private final UserHandle mOwner; private final boolean mAllowMtp; private String mUuid; private String mUserLabel; Loading @@ -60,7 +61,7 @@ public class StorageVolume implements Parcelable { public StorageVolume(File path, int descriptionId, boolean primary, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize, UserHandle owner) { UserHandle owner, boolean allowMtp) { mPath = path; mDescriptionId = descriptionId; mPrimary = primary; Loading @@ -70,6 +71,7 @@ public class StorageVolume implements Parcelable { mAllowMassStorage = allowMassStorage; mMaxFileSize = maxFileSize; mOwner = owner; mAllowMtp = allowMtp; } private StorageVolume(Parcel in) { Loading @@ -86,12 +88,13 @@ public class StorageVolume implements Parcelable { mUuid = in.readString(); mUserLabel = in.readString(); mState = in.readString(); mAllowMtp = in.readInt() != 0; } public static StorageVolume fromTemplate(StorageVolume template, File path, UserHandle owner) { return new StorageVolume(path, template.mDescriptionId, template.mPrimary, template.mRemovable, template.mEmulated, template.mMtpReserveSpace, template.mAllowMassStorage, template.mMaxFileSize, owner); template.mAllowMassStorage, template.mMaxFileSize, owner, template.mAllowMtp); } /** Loading Loading @@ -238,6 +241,10 @@ public class StorageVolume implements Parcelable { return mState; } public boolean isMtpEnabled() { return mAllowMtp; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -275,6 +282,7 @@ public class StorageVolume implements Parcelable { pw.printPair("mUuid", mUuid); pw.printPair("mUserLabel", mUserLabel); pw.printPair("mState", mState); pw.printPair("mAllowMtp", mAllowMtp); pw.decreaseIndent(); } Loading Loading @@ -310,5 +318,6 @@ public class StorageVolume implements Parcelable { parcel.writeString(mUuid); parcel.writeString(mUserLabel); parcel.writeString(mState); parcel.writeInt(mAllowMtp ? 1 : 0); } } core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -7242,6 +7242,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" /> <!-- make false if don't want to get mounted on MTP --> <attr name="allowMtp" format="boolean" /> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> <!-- maximum file size for the volume in megabytes, zero or unspecified if it is unbounded --> Loading services/core/java/com/android/server/MountService.java +5 −3 Original line number Diff line number Diff line Loading @@ -1367,6 +1367,8 @@ class MountService extends IMountService.Stub com.android.internal.R.styleable.Storage_mtpReserve, 0); boolean allowMassStorage = a.getBoolean( com.android.internal.R.styleable.Storage_allowMassStorage, false); boolean allowMtp = a.getBoolean( com.android.internal.R.styleable.Storage_allowMtp, true); // resource parser does not support longs, so XML value is in megabytes long maxFileSize = a.getInt( com.android.internal.R.styleable.Storage_maxFileSize, 0) * 1024L * 1024L; Loading @@ -1375,13 +1377,13 @@ class MountService extends IMountService.Stub " primary: " + primary + " removable: " + removable + " emulated: " + emulated + " mtpReserve: " + mtpReserve + " allowMassStorage: " + allowMassStorage + " maxFileSize: " + maxFileSize); " maxFileSize: " + maxFileSize + " allowMtp: " + allowMtp); if (emulated) { // For devices with emulated storage, we create separate // volumes for each known user. mEmulatedTemplate = new StorageVolume(null, descriptionId, true, false, true, mtpReserve, false, maxFileSize, null); true, mtpReserve, false, maxFileSize, null, allowMtp); final UserManagerService userManager = UserManagerService.getInstance(); for (UserInfo user : userManager.getUsers(false)) { Loading @@ -1394,7 +1396,7 @@ class MountService extends IMountService.Stub } else { final StorageVolume volume = new StorageVolume(new File(path), descriptionId, primary, removable, emulated, mtpReserve, allowMassStorage, maxFileSize, null); allowMassStorage, maxFileSize, null, allowMtp); addVolumeLocked(volume); // Until we hear otherwise, treat as unmounted Loading Loading
core/java/android/os/storage/StorageVolume.java +11 −2 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ public class StorageVolume implements Parcelable { private final long mMaxFileSize; /** When set, indicates exclusive ownership of this volume */ private final UserHandle mOwner; private final boolean mAllowMtp; private String mUuid; private String mUserLabel; Loading @@ -60,7 +61,7 @@ public class StorageVolume implements Parcelable { public StorageVolume(File path, int descriptionId, boolean primary, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize, UserHandle owner) { UserHandle owner, boolean allowMtp) { mPath = path; mDescriptionId = descriptionId; mPrimary = primary; Loading @@ -70,6 +71,7 @@ public class StorageVolume implements Parcelable { mAllowMassStorage = allowMassStorage; mMaxFileSize = maxFileSize; mOwner = owner; mAllowMtp = allowMtp; } private StorageVolume(Parcel in) { Loading @@ -86,12 +88,13 @@ public class StorageVolume implements Parcelable { mUuid = in.readString(); mUserLabel = in.readString(); mState = in.readString(); mAllowMtp = in.readInt() != 0; } public static StorageVolume fromTemplate(StorageVolume template, File path, UserHandle owner) { return new StorageVolume(path, template.mDescriptionId, template.mPrimary, template.mRemovable, template.mEmulated, template.mMtpReserveSpace, template.mAllowMassStorage, template.mMaxFileSize, owner); template.mAllowMassStorage, template.mMaxFileSize, owner, template.mAllowMtp); } /** Loading Loading @@ -238,6 +241,10 @@ public class StorageVolume implements Parcelable { return mState; } public boolean isMtpEnabled() { return mAllowMtp; } @Override public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -275,6 +282,7 @@ public class StorageVolume implements Parcelable { pw.printPair("mUuid", mUuid); pw.printPair("mUserLabel", mUserLabel); pw.printPair("mState", mState); pw.printPair("mAllowMtp", mAllowMtp); pw.decreaseIndent(); } Loading Loading @@ -310,5 +318,6 @@ public class StorageVolume implements Parcelable { parcel.writeString(mUuid); parcel.writeString(mUserLabel); parcel.writeString(mState); parcel.writeInt(mAllowMtp ? 1 : 0); } }
core/res/res/values/attrs.xml +2 −0 Original line number Diff line number Diff line Loading @@ -7242,6 +7242,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" /> <!-- make false if don't want to get mounted on MTP --> <attr name="allowMtp" format="boolean" /> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> <!-- maximum file size for the volume in megabytes, zero or unspecified if it is unbounded --> Loading
services/core/java/com/android/server/MountService.java +5 −3 Original line number Diff line number Diff line Loading @@ -1367,6 +1367,8 @@ class MountService extends IMountService.Stub com.android.internal.R.styleable.Storage_mtpReserve, 0); boolean allowMassStorage = a.getBoolean( com.android.internal.R.styleable.Storage_allowMassStorage, false); boolean allowMtp = a.getBoolean( com.android.internal.R.styleable.Storage_allowMtp, true); // resource parser does not support longs, so XML value is in megabytes long maxFileSize = a.getInt( com.android.internal.R.styleable.Storage_maxFileSize, 0) * 1024L * 1024L; Loading @@ -1375,13 +1377,13 @@ class MountService extends IMountService.Stub " primary: " + primary + " removable: " + removable + " emulated: " + emulated + " mtpReserve: " + mtpReserve + " allowMassStorage: " + allowMassStorage + " maxFileSize: " + maxFileSize); " maxFileSize: " + maxFileSize + " allowMtp: " + allowMtp); if (emulated) { // For devices with emulated storage, we create separate // volumes for each known user. mEmulatedTemplate = new StorageVolume(null, descriptionId, true, false, true, mtpReserve, false, maxFileSize, null); true, mtpReserve, false, maxFileSize, null, allowMtp); final UserManagerService userManager = UserManagerService.getInstance(); for (UserInfo user : userManager.getUsers(false)) { Loading @@ -1394,7 +1396,7 @@ class MountService extends IMountService.Stub } else { final StorageVolume volume = new StorageVolume(new File(path), descriptionId, primary, removable, emulated, mtpReserve, allowMassStorage, maxFileSize, null); allowMassStorage, maxFileSize, null, allowMtp); addVolumeLocked(volume); // Until we hear otherwise, treat as unmounted Loading