Loading media/jni/android_media_MtpClient.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "jni.h" #include "JNIHelp.h" #include "android_runtime/AndroidRuntime.h" #include "private/android_filesystem_config.h" #include "MtpClient.h" #include "MtpDevice.h" Loading Loading @@ -197,7 +198,7 @@ android_media_MtpClient_import_file(JNIEnv *env, jobject thiz, MtpDevice* device = client->getDevice(device_id); if (device) { const char *destPathStr = env->GetStringUTFChars(dest_path, NULL); bool result = device->readObject(object_id, destPathStr); bool result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); env->ReleaseStringUTFChars(dest_path, destPathStr); return result; } Loading media/mtp/MtpDevice.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { } // reads the object's data and writes it to the specified file path bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) { LOGD("readObject: %s", destPath); int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC); if (fd < 0) { Loading @@ -357,6 +357,12 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { return false; } fchown(fd, getuid(), group); // set permissions int mask = umask(0); fchmod(fd, perm); umask(mask); Mutex::Autolock autoLock(mMutex); bool result = false; Loading media/mtp/MtpDevice.h +4 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ public: MtpDeviceInfo* getDeviceInfo(); MtpStorageIDList* getStorageIDs(); MtpStorageInfo* getStorageInfo(MtpStorageID storageID); MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent); MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent); MtpObjectInfo* getObjectInfo(MtpObjectHandle handle); void* getThumbnail(MtpObjectHandle handle, int& outLength); MtpObjectHandle sendObjectInfo(MtpObjectInfo* info); Loading @@ -86,7 +87,8 @@ public: MtpProperty* getDevicePropDesc(MtpDeviceProperty code); bool readObject(MtpObjectHandle handle, const char* destPath); bool readObject(MtpObjectHandle handle, const char* destPath, int group, int perm); private: bool sendRequest(MtpOperationCode operation); Loading Loading
media/jni/android_media_MtpClient.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ #include "jni.h" #include "JNIHelp.h" #include "android_runtime/AndroidRuntime.h" #include "private/android_filesystem_config.h" #include "MtpClient.h" #include "MtpDevice.h" Loading Loading @@ -197,7 +198,7 @@ android_media_MtpClient_import_file(JNIEnv *env, jobject thiz, MtpDevice* device = client->getDevice(device_id); if (device) { const char *destPathStr = env->GetStringUTFChars(dest_path, NULL); bool result = device->readObject(object_id, destPathStr); bool result = device->readObject(object_id, destPathStr, AID_SDCARD_RW, 0664); env->ReleaseStringUTFChars(dest_path, destPathStr); return result; } Loading
media/mtp/MtpDevice.cpp +7 −1 Original line number Diff line number Diff line Loading @@ -349,7 +349,7 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { } // reads the object's data and writes it to the specified file path bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) { LOGD("readObject: %s", destPath); int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC); if (fd < 0) { Loading @@ -357,6 +357,12 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath) { return false; } fchown(fd, getuid(), group); // set permissions int mask = umask(0); fchmod(fd, perm); umask(mask); Mutex::Autolock autoLock(mMutex); bool result = false; Loading
media/mtp/MtpDevice.h +4 −2 Original line number Diff line number Diff line Loading @@ -75,7 +75,8 @@ public: MtpDeviceInfo* getDeviceInfo(); MtpStorageIDList* getStorageIDs(); MtpStorageInfo* getStorageInfo(MtpStorageID storageID); MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent); MtpObjectHandleList* getObjectHandles(MtpStorageID storageID, MtpObjectFormat format, MtpObjectHandle parent); MtpObjectInfo* getObjectInfo(MtpObjectHandle handle); void* getThumbnail(MtpObjectHandle handle, int& outLength); MtpObjectHandle sendObjectInfo(MtpObjectInfo* info); Loading @@ -86,7 +87,8 @@ public: MtpProperty* getDevicePropDesc(MtpDeviceProperty code); bool readObject(MtpObjectHandle handle, const char* destPath); bool readObject(MtpObjectHandle handle, const char* destPath, int group, int perm); private: bool sendRequest(MtpOperationCode operation); Loading