diff options
Diffstat (limited to 'media/mtp')
-rw-r--r-- | media/mtp/Android.mk | 4 | ||||
-rw-r--r-- | media/mtp/MtpServer.cpp | 10 | ||||
-rw-r--r-- | media/mtp/MtpStorage.cpp | 4 | ||||
-rw-r--r-- | media/mtp/MtpStorage.h | 4 |
4 files changed, 16 insertions, 6 deletions
diff --git a/media/mtp/Android.mk b/media/mtp/Android.mk index c25285e..e590bab 100644 --- a/media/mtp/Android.mk +++ b/media/mtp/Android.mk @@ -16,8 +16,6 @@ LOCAL_PATH:= $(call my-dir) -ifneq ($(TARGET_SIMULATOR),true) - include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ @@ -45,8 +43,6 @@ LOCAL_SHARED_LIBRARIES := libutils libcutils libusbhost libbinder include $(BUILD_SHARED_LIBRARY) -endif - ifeq ($(HOST_OS),linux) include $(CLEAR_VARS) diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index bc04e8c..4047e2e 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -237,6 +237,8 @@ void MtpServer::run() { if (mSessionOpen) mDatabase->sessionEnded(); + close(fd); + mFD = -1; } void MtpServer::sendObjectAdded(MtpObjectHandle handle) { @@ -871,6 +873,14 @@ MtpResponseCode MtpServer::doSendObjectInfo() { // check space first if (mSendObjectFileSize > storage->getFreeSpace()) return MTP_RESPONSE_STORAGE_FULL; + uint64_t maxFileSize = storage->getMaxFileSize(); + // check storage max file size + if (maxFileSize != 0) { + // if mSendObjectFileSize is 0xFFFFFFFF, then all we know is the file size + // is >= 0xFFFFFFFF + if (mSendObjectFileSize > maxFileSize || mSendObjectFileSize == 0xFFFFFFFF) + return MTP_RESPONSE_OBJECT_TOO_LARGE; + } LOGD("path: %s parent: %d storageID: %08X", (const char*)path, parent, storageID); MtpObjectHandle handle = mDatabase->beginSendObject((const char*)path, diff --git a/media/mtp/MtpStorage.cpp b/media/mtp/MtpStorage.cpp index fef8066..941e303 100644 --- a/media/mtp/MtpStorage.cpp +++ b/media/mtp/MtpStorage.cpp @@ -33,11 +33,13 @@ namespace android { MtpStorage::MtpStorage(MtpStorageID id, const char* filePath, - const char* description, uint64_t reserveSpace, bool removable) + const char* description, uint64_t reserveSpace, + bool removable, uint64_t maxFileSize) : mStorageID(id), mFilePath(filePath), mDescription(description), mMaxCapacity(0), + mMaxFileSize(maxFileSize), mReserveSpace(reserveSpace), mRemovable(removable) { diff --git a/media/mtp/MtpStorage.h b/media/mtp/MtpStorage.h index 3e4f40d..e5a2e57 100644 --- a/media/mtp/MtpStorage.h +++ b/media/mtp/MtpStorage.h @@ -31,6 +31,7 @@ private: MtpString mFilePath; MtpString mDescription; uint64_t mMaxCapacity; + uint64_t mMaxFileSize; // amount of free space to leave unallocated uint64_t mReserveSpace; bool mRemovable; @@ -38,7 +39,7 @@ private: public: MtpStorage(MtpStorageID id, const char* filePath, const char* description, uint64_t reserveSpace, - bool removable); + bool removable, uint64_t maxFileSize); virtual ~MtpStorage(); inline MtpStorageID getStorageID() const { return mStorageID; } @@ -50,6 +51,7 @@ public: const char* getDescription() const; inline const char* getPath() const { return (const char *)mFilePath; } inline bool isRemovable() const { return mRemovable; } + inline uint64_t getMaxFileSize() const { return mMaxFileSize; } }; }; // namespace android |