Loading core/java/android/os/storage/StorageVolume.java +20 −4 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ public class StorageVolume implements Parcelable { private final int mMtpReserveSpace; private final int mMtpReserveSpace; private final boolean mAllowMassStorage; private final boolean mAllowMassStorage; private int mStorageId; private int mStorageId; // maximum file size for the storage, or zero for no limit private final long mMaxFileSize; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, Loading @@ -41,18 +43,20 @@ public class StorageVolume implements Parcelable { public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public StorageVolume(String path, String description, boolean removable, public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage) { boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize) { mPath = path; mPath = path; mDescription = description; mDescription = description; mRemovable = removable; mRemovable = removable; mEmulated = emulated; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mAllowMassStorage = allowMassStorage; mMaxFileSize = maxFileSize; } } // for parcelling only // for parcelling only private StorageVolume(String path, String description, boolean removable, private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage) { boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage, long maxFileSize) { mPath = path; mPath = path; mDescription = description; mDescription = description; mRemovable = removable; mRemovable = removable; Loading @@ -60,6 +64,7 @@ public class StorageVolume implements Parcelable { mMtpReserveSpace = mtpReserveSpace; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mAllowMassStorage = allowMassStorage; mStorageId = storageId; mStorageId = storageId; mMaxFileSize = maxFileSize; } } /** /** Loading Loading @@ -142,6 +147,15 @@ public class StorageVolume implements Parcelable { return mAllowMassStorage; return mAllowMassStorage; } } /** * Returns maximum file size for the volume, or zero if it is unbounded. * * @return maximum file size */ public long getMaxFileSize() { return mMaxFileSize; } @Override @Override public boolean equals(Object obj) { public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -171,9 +185,10 @@ public class StorageVolume implements Parcelable { int storageId = in.readInt(); int storageId = in.readInt(); int mtpReserveSpace = in.readInt(); int mtpReserveSpace = in.readInt(); int allowMassStorage = in.readInt(); int allowMassStorage = in.readInt(); long maxFileSize = in.readLong(); return new StorageVolume(path, description, return new StorageVolume(path, description, removable == 1, emulated == 1, removable == 1, emulated == 1, mtpReserveSpace, mtpReserveSpace, storageId, allowMassStorage == 1); storageId, allowMassStorage == 1, maxFileSize); } } public StorageVolume[] newArray(int size) { public StorageVolume[] newArray(int size) { Loading @@ -193,5 +208,6 @@ public class StorageVolume implements Parcelable { parcel.writeInt(mStorageId); parcel.writeInt(mStorageId); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mAllowMassStorage ? 1 : 0); parcel.writeInt(mAllowMassStorage ? 1 : 0); parcel.writeLong(mMaxFileSize); } } } } core/res/res/values/attrs.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5318,6 +5318,8 @@ <attr name="mtpReserve" format="integer" /> <attr name="mtpReserve" format="integer" /> <!-- true if the storage can be shared via USB mass storage --> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> <attr name="allowMassStorage" format="boolean" /> <!-- maximum file size for the volume in megabytes, zero or unspecified if it is unbounded --> <attr name="maxFileSize" format="integer" /> </declare-styleable> </declare-styleable> <declare-styleable name="SwitchPreference"> <declare-styleable name="SwitchPreference"> Loading media/java/android/mtp/MtpPropertyGroup.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -330,7 +330,6 @@ class MtpPropertyGroup { } } int count = (c == null ? 1 : c.getCount()); int count = (c == null ? 1 : c.getCount()); Log.d(TAG, "count: " + count); MtpPropertyList result = new MtpPropertyList(count * mProperties.length, MtpPropertyList result = new MtpPropertyList(count * mProperties.length, MtpConstants.RESPONSE_OK); MtpConstants.RESPONSE_OK); Loading media/java/android/mtp/MtpStorage.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class MtpStorage { private final String mDescription; private final String mDescription; private final long mReserveSpace; private final long mReserveSpace; private final boolean mRemovable; private final boolean mRemovable; private final long mMaxFileSize; public MtpStorage(StorageVolume volume) { public MtpStorage(StorageVolume volume) { mStorageId = volume.getStorageId(); mStorageId = volume.getStorageId(); Loading @@ -39,6 +40,7 @@ public class MtpStorage { mDescription = volume.getDescription(); mDescription = volume.getDescription(); mReserveSpace = volume.getMtpReserveSpace(); mReserveSpace = volume.getMtpReserveSpace(); mRemovable = volume.isRemovable(); mRemovable = volume.isRemovable(); mMaxFileSize = volume.getMaxFileSize(); } } /** /** Loading Loading @@ -98,4 +100,13 @@ public class MtpStorage { public final boolean isRemovable() { public final boolean isRemovable() { return mRemovable; return mRemovable; } } /** * Returns maximum file size for the storage, or zero if it is unbounded. * * @return maximum file size */ public long getMaxFileSize() { return mMaxFileSize; } } } media/jni/android_mtp_MtpServer.cpp +9 −1 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,7 @@ static jfieldID field_MtpStorage_path; static jfieldID field_MtpStorage_description; static jfieldID field_MtpStorage_description; static jfieldID field_MtpStorage_reserveSpace; static jfieldID field_MtpStorage_reserveSpace; static jfieldID field_MtpStorage_removable; static jfieldID field_MtpStorage_removable; static jfieldID field_MtpStorage_maxFileSize; static Mutex sMutex; static Mutex sMutex; Loading Loading @@ -228,12 +229,14 @@ android_mtp_MtpServer_add_storage(JNIEnv *env, jobject thiz, jobject jstorage) jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description); jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description); jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace); jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace); jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable); jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable); jlong maxFileSize = env->GetLongField(jstorage, field_MtpStorage_maxFileSize); const char *pathStr = env->GetStringUTFChars(path, NULL); const char *pathStr = env->GetStringUTFChars(path, NULL); if (pathStr != NULL) { if (pathStr != NULL) { const char *descriptionStr = env->GetStringUTFChars(description, NULL); const char *descriptionStr = env->GetStringUTFChars(description, NULL); if (descriptionStr != NULL) { if (descriptionStr != NULL) { MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable); MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable, maxFileSize); thread->addStorage(storage); thread->addStorage(storage); env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(description, descriptionStr); env->ReleaseStringUTFChars(description, descriptionStr); Loading Loading @@ -312,6 +315,11 @@ int register_android_mtp_MtpServer(JNIEnv *env) LOGE("Can't find MtpStorage.mRemovable"); LOGE("Can't find MtpStorage.mRemovable"); return -1; return -1; } } field_MtpStorage_maxFileSize = env->GetFieldID(clazz, "mMaxFileSize", "J"); if (field_MtpStorage_maxFileSize == NULL) { LOGE("Can't find MtpStorage.mMaxFileSize"); return -1; } clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz); clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz); clazz = env->FindClass("android/mtp/MtpServer"); clazz = env->FindClass("android/mtp/MtpServer"); Loading Loading
core/java/android/os/storage/StorageVolume.java +20 −4 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ public class StorageVolume implements Parcelable { private final int mMtpReserveSpace; private final int mMtpReserveSpace; private final boolean mAllowMassStorage; private final boolean mAllowMassStorage; private int mStorageId; private int mStorageId; // maximum file size for the storage, or zero for no limit private final long mMaxFileSize; // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // StorageVolume extra for ACTION_MEDIA_REMOVED, ACTION_MEDIA_UNMOUNTED, ACTION_MEDIA_CHECKING, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, // ACTION_MEDIA_NOFS, ACTION_MEDIA_MOUNTED, ACTION_MEDIA_SHARED, ACTION_MEDIA_UNSHARED, Loading @@ -41,18 +43,20 @@ public class StorageVolume implements Parcelable { public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public static final String EXTRA_STORAGE_VOLUME = "storage_volume"; public StorageVolume(String path, String description, boolean removable, public StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, boolean allowMassStorage) { boolean emulated, int mtpReserveSpace, boolean allowMassStorage, long maxFileSize) { mPath = path; mPath = path; mDescription = description; mDescription = description; mRemovable = removable; mRemovable = removable; mEmulated = emulated; mEmulated = emulated; mMtpReserveSpace = mtpReserveSpace; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mAllowMassStorage = allowMassStorage; mMaxFileSize = maxFileSize; } } // for parcelling only // for parcelling only private StorageVolume(String path, String description, boolean removable, private StorageVolume(String path, String description, boolean removable, boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage) { boolean emulated, int mtpReserveSpace, int storageId, boolean allowMassStorage, long maxFileSize) { mPath = path; mPath = path; mDescription = description; mDescription = description; mRemovable = removable; mRemovable = removable; Loading @@ -60,6 +64,7 @@ public class StorageVolume implements Parcelable { mMtpReserveSpace = mtpReserveSpace; mMtpReserveSpace = mtpReserveSpace; mAllowMassStorage = allowMassStorage; mAllowMassStorage = allowMassStorage; mStorageId = storageId; mStorageId = storageId; mMaxFileSize = maxFileSize; } } /** /** Loading Loading @@ -142,6 +147,15 @@ public class StorageVolume implements Parcelable { return mAllowMassStorage; return mAllowMassStorage; } } /** * Returns maximum file size for the volume, or zero if it is unbounded. * * @return maximum file size */ public long getMaxFileSize() { return mMaxFileSize; } @Override @Override public boolean equals(Object obj) { public boolean equals(Object obj) { if (obj instanceof StorageVolume && mPath != null) { if (obj instanceof StorageVolume && mPath != null) { Loading Loading @@ -171,9 +185,10 @@ public class StorageVolume implements Parcelable { int storageId = in.readInt(); int storageId = in.readInt(); int mtpReserveSpace = in.readInt(); int mtpReserveSpace = in.readInt(); int allowMassStorage = in.readInt(); int allowMassStorage = in.readInt(); long maxFileSize = in.readLong(); return new StorageVolume(path, description, return new StorageVolume(path, description, removable == 1, emulated == 1, removable == 1, emulated == 1, mtpReserveSpace, mtpReserveSpace, storageId, allowMassStorage == 1); storageId, allowMassStorage == 1, maxFileSize); } } public StorageVolume[] newArray(int size) { public StorageVolume[] newArray(int size) { Loading @@ -193,5 +208,6 @@ public class StorageVolume implements Parcelable { parcel.writeInt(mStorageId); parcel.writeInt(mStorageId); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mMtpReserveSpace); parcel.writeInt(mAllowMassStorage ? 1 : 0); parcel.writeInt(mAllowMassStorage ? 1 : 0); parcel.writeLong(mMaxFileSize); } } } }
core/res/res/values/attrs.xml +2 −0 Original line number Original line Diff line number Diff line Loading @@ -5318,6 +5318,8 @@ <attr name="mtpReserve" format="integer" /> <attr name="mtpReserve" format="integer" /> <!-- true if the storage can be shared via USB mass storage --> <!-- true if the storage can be shared via USB mass storage --> <attr name="allowMassStorage" format="boolean" /> <attr name="allowMassStorage" format="boolean" /> <!-- maximum file size for the volume in megabytes, zero or unspecified if it is unbounded --> <attr name="maxFileSize" format="integer" /> </declare-styleable> </declare-styleable> <declare-styleable name="SwitchPreference"> <declare-styleable name="SwitchPreference"> Loading
media/java/android/mtp/MtpPropertyGroup.java +0 −1 Original line number Original line Diff line number Diff line Loading @@ -330,7 +330,6 @@ class MtpPropertyGroup { } } int count = (c == null ? 1 : c.getCount()); int count = (c == null ? 1 : c.getCount()); Log.d(TAG, "count: " + count); MtpPropertyList result = new MtpPropertyList(count * mProperties.length, MtpPropertyList result = new MtpPropertyList(count * mProperties.length, MtpConstants.RESPONSE_OK); MtpConstants.RESPONSE_OK); Loading
media/java/android/mtp/MtpStorage.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -32,6 +32,7 @@ public class MtpStorage { private final String mDescription; private final String mDescription; private final long mReserveSpace; private final long mReserveSpace; private final boolean mRemovable; private final boolean mRemovable; private final long mMaxFileSize; public MtpStorage(StorageVolume volume) { public MtpStorage(StorageVolume volume) { mStorageId = volume.getStorageId(); mStorageId = volume.getStorageId(); Loading @@ -39,6 +40,7 @@ public class MtpStorage { mDescription = volume.getDescription(); mDescription = volume.getDescription(); mReserveSpace = volume.getMtpReserveSpace(); mReserveSpace = volume.getMtpReserveSpace(); mRemovable = volume.isRemovable(); mRemovable = volume.isRemovable(); mMaxFileSize = volume.getMaxFileSize(); } } /** /** Loading Loading @@ -98,4 +100,13 @@ public class MtpStorage { public final boolean isRemovable() { public final boolean isRemovable() { return mRemovable; return mRemovable; } } /** * Returns maximum file size for the storage, or zero if it is unbounded. * * @return maximum file size */ public long getMaxFileSize() { return mMaxFileSize; } } }
media/jni/android_mtp_MtpServer.cpp +9 −1 Original line number Original line Diff line number Diff line Loading @@ -48,6 +48,7 @@ static jfieldID field_MtpStorage_path; static jfieldID field_MtpStorage_description; static jfieldID field_MtpStorage_description; static jfieldID field_MtpStorage_reserveSpace; static jfieldID field_MtpStorage_reserveSpace; static jfieldID field_MtpStorage_removable; static jfieldID field_MtpStorage_removable; static jfieldID field_MtpStorage_maxFileSize; static Mutex sMutex; static Mutex sMutex; Loading Loading @@ -228,12 +229,14 @@ android_mtp_MtpServer_add_storage(JNIEnv *env, jobject thiz, jobject jstorage) jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description); jstring description = (jstring)env->GetObjectField(jstorage, field_MtpStorage_description); jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace); jlong reserveSpace = env->GetLongField(jstorage, field_MtpStorage_reserveSpace); jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable); jboolean removable = env->GetBooleanField(jstorage, field_MtpStorage_removable); jlong maxFileSize = env->GetLongField(jstorage, field_MtpStorage_maxFileSize); const char *pathStr = env->GetStringUTFChars(path, NULL); const char *pathStr = env->GetStringUTFChars(path, NULL); if (pathStr != NULL) { if (pathStr != NULL) { const char *descriptionStr = env->GetStringUTFChars(description, NULL); const char *descriptionStr = env->GetStringUTFChars(description, NULL); if (descriptionStr != NULL) { if (descriptionStr != NULL) { MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable); MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace, removable, maxFileSize); thread->addStorage(storage); thread->addStorage(storage); env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(path, pathStr); env->ReleaseStringUTFChars(description, descriptionStr); env->ReleaseStringUTFChars(description, descriptionStr); Loading Loading @@ -312,6 +315,11 @@ int register_android_mtp_MtpServer(JNIEnv *env) LOGE("Can't find MtpStorage.mRemovable"); LOGE("Can't find MtpStorage.mRemovable"); return -1; return -1; } } field_MtpStorage_maxFileSize = env->GetFieldID(clazz, "mMaxFileSize", "J"); if (field_MtpStorage_maxFileSize == NULL) { LOGE("Can't find MtpStorage.mMaxFileSize"); return -1; } clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz); clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz); clazz = env->FindClass("android/mtp/MtpServer"); clazz = env->FindClass("android/mtp/MtpServer"); Loading