am 15afd076: Merge "MTP: Have GetStorageInfo command return correct storage type for removable storage" into honeycomb-mr2
* commit '15afd076d6070374cbb4f9dcbe28dda67caa0718': MTP: Have GetStorageInfo command return correct storage type for removable storage
This commit is contained in:
@@ -29,12 +29,15 @@ public class MtpStorage {
|
|||||||
private final String mPath;
|
private final String mPath;
|
||||||
private final String mDescription;
|
private final String mDescription;
|
||||||
private final long mReserveSpace;
|
private final long mReserveSpace;
|
||||||
|
private final boolean mRemovable;
|
||||||
|
|
||||||
public MtpStorage(int id, String path, String description, long reserveSpace) {
|
public MtpStorage(int id, String path, String description,
|
||||||
|
long reserveSpace, boolean removable) {
|
||||||
mStorageId = id;
|
mStorageId = id;
|
||||||
mPath = path;
|
mPath = path;
|
||||||
mDescription = description;
|
mDescription = description;
|
||||||
mReserveSpace = reserveSpace;
|
mReserveSpace = reserveSpace;
|
||||||
|
mRemovable = removable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -86,4 +89,12 @@ public class MtpStorage {
|
|||||||
return mReserveSpace;
|
return mReserveSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the storage is removable.
|
||||||
|
*
|
||||||
|
* @return is removable
|
||||||
|
*/
|
||||||
|
public final boolean isRemovable() {
|
||||||
|
return mRemovable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ static jfieldID field_MtpStorage_storageId;
|
|||||||
static jfieldID field_MtpStorage_path;
|
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 Mutex sMutex;
|
static Mutex sMutex;
|
||||||
|
|
||||||
@@ -245,11 +246,13 @@ android_mtp_MtpServer_add_storage(JNIEnv *env, jobject thiz, jobject jstorage)
|
|||||||
jstring path = (jstring)env->GetObjectField(jstorage, field_MtpStorage_path);
|
jstring path = (jstring)env->GetObjectField(jstorage, field_MtpStorage_path);
|
||||||
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);
|
||||||
|
|
||||||
const char *pathStr = env->GetStringUTFChars(path, NULL);
|
const char *pathStr = env->GetStringUTFChars(path, NULL);
|
||||||
const char *descriptionStr = env->GetStringUTFChars(description, NULL);
|
const char *descriptionStr = env->GetStringUTFChars(description, NULL);
|
||||||
|
|
||||||
MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr, reserveSpace);
|
MtpStorage* storage = new MtpStorage(storageID, pathStr, descriptionStr,
|
||||||
|
reserveSpace, removable);
|
||||||
thread->addStorage(storage);
|
thread->addStorage(storage);
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(path, pathStr);
|
env->ReleaseStringUTFChars(path, pathStr);
|
||||||
@@ -318,7 +321,12 @@ int register_android_mtp_MtpServer(JNIEnv *env)
|
|||||||
}
|
}
|
||||||
field_MtpStorage_reserveSpace = env->GetFieldID(clazz, "mReserveSpace", "J");
|
field_MtpStorage_reserveSpace = env->GetFieldID(clazz, "mReserveSpace", "J");
|
||||||
if (field_MtpStorage_reserveSpace == NULL) {
|
if (field_MtpStorage_reserveSpace == NULL) {
|
||||||
LOGE("Can't find MtpStorage.mStorageId");
|
LOGE("Can't find MtpStorage.mReserveSpace");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
field_MtpStorage_removable = env->GetFieldID(clazz, "mRemovable", "Z");
|
||||||
|
if (field_MtpStorage_removable == NULL) {
|
||||||
|
LOGE("Can't find MtpStorage.mRemovable");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz);
|
clazz_MtpStorage = (jclass)env->NewGlobalRef(clazz);
|
||||||
|
|||||||
@@ -33,12 +33,13 @@
|
|||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
MtpStorage::MtpStorage(MtpStorageID id, const char* filePath,
|
MtpStorage::MtpStorage(MtpStorageID id, const char* filePath,
|
||||||
const char* description, uint64_t reserveSpace)
|
const char* description, uint64_t reserveSpace, bool removable)
|
||||||
: mStorageID(id),
|
: mStorageID(id),
|
||||||
mFilePath(filePath),
|
mFilePath(filePath),
|
||||||
mDescription(description),
|
mDescription(description),
|
||||||
mMaxCapacity(0),
|
mMaxCapacity(0),
|
||||||
mReserveSpace(reserveSpace)
|
mReserveSpace(reserveSpace),
|
||||||
|
mRemovable(removable)
|
||||||
{
|
{
|
||||||
LOGV("MtpStorage id: %d path: %s\n", id, filePath);
|
LOGV("MtpStorage id: %d path: %s\n", id, filePath);
|
||||||
}
|
}
|
||||||
@@ -47,7 +48,7 @@ MtpStorage::~MtpStorage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int MtpStorage::getType() const {
|
int MtpStorage::getType() const {
|
||||||
return MTP_STORAGE_FIXED_RAM;
|
return (mRemovable ? MTP_STORAGE_REMOVABLE_RAM : MTP_STORAGE_FIXED_RAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MtpStorage::getFileSystemType() const {
|
int MtpStorage::getFileSystemType() const {
|
||||||
|
|||||||
@@ -33,10 +33,12 @@ private:
|
|||||||
uint64_t mMaxCapacity;
|
uint64_t mMaxCapacity;
|
||||||
// amount of free space to leave unallocated
|
// amount of free space to leave unallocated
|
||||||
uint64_t mReserveSpace;
|
uint64_t mReserveSpace;
|
||||||
|
bool mRemovable;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MtpStorage(MtpStorageID id, const char* filePath,
|
MtpStorage(MtpStorageID id, const char* filePath,
|
||||||
const char* description, uint64_t reserveSpace);
|
const char* description, uint64_t reserveSpace,
|
||||||
|
bool removable);
|
||||||
virtual ~MtpStorage();
|
virtual ~MtpStorage();
|
||||||
|
|
||||||
inline MtpStorageID getStorageID() const { return mStorageID; }
|
inline MtpStorageID getStorageID() const { return mStorageID; }
|
||||||
@@ -47,6 +49,7 @@ public:
|
|||||||
uint64_t getFreeSpace();
|
uint64_t getFreeSpace();
|
||||||
const char* getDescription() const;
|
const char* getDescription() const;
|
||||||
inline const char* getPath() const { return (const char *)mFilePath; }
|
inline const char* getPath() const { return (const char *)mFilePath; }
|
||||||
|
inline bool isRemovable() const { return mRemovable; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace android
|
}; // namespace android
|
||||||
|
|||||||
Reference in New Issue
Block a user