diff options
author | Mike Lockwood <lockwood@android.com> | 2011-04-24 18:40:17 -0700 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2011-04-25 17:40:33 -0700 |
commit | 64000788211f4c7e78c80a4a155390d1316e1176 (patch) | |
tree | 5cd67cc35f9df8ffcef27438430c6a087adfa69c /media/mtp/MtpServer.cpp | |
parent | c0502468a29aa2f2b3457e0e08c4a5650a70488d (diff) | |
download | frameworks_av-64000788211f4c7e78c80a4a155390d1316e1176.zip frameworks_av-64000788211f4c7e78c80a4a155390d1316e1176.tar.gz frameworks_av-64000788211f4c7e78c80a4a155390d1316e1176.tar.bz2 |
MTP: Implement GetThumb command
This allows the PC to access thumbnails in JPEG files over MTP/PTP
Bug: 3219495
Change-Id: I4964f8b4826dffb7f0f77464ec91bd2e97a2f007
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpServer.cpp')
-rw-r--r-- | media/mtp/MtpServer.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index b744b5b..4a8fd3e 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -50,7 +50,7 @@ static const MtpOperationCode kSupportedOperationCodes[] = { MTP_OPERATION_GET_OBJECT_HANDLES, MTP_OPERATION_GET_OBJECT_INFO, MTP_OPERATION_GET_OBJECT, -// MTP_OPERATION_GET_THUMB, + MTP_OPERATION_GET_THUMB, MTP_OPERATION_DELETE_OBJECT, MTP_OPERATION_SEND_OBJECT_INFO, MTP_OPERATION_SEND_OBJECT, @@ -370,6 +370,9 @@ bool MtpServer::handleRequest() { case MTP_OPERATION_GET_OBJECT: response = doGetObject(); break; + case MTP_OPERATION_GET_THUMB: + response = doGetThumb(); + break; case MTP_OPERATION_GET_PARTIAL_OBJECT: case MTP_OPERATION_GET_PARTIAL_OBJECT_64: response = doGetPartialObject(operation); @@ -736,6 +739,22 @@ MtpResponseCode MtpServer::doGetObject() { return MTP_RESPONSE_OK; } +MtpResponseCode MtpServer::doGetThumb() { + MtpObjectHandle handle = mRequest.getParameter(1); + size_t thumbSize; + void* thumb = mDatabase->getThumbnail(handle, thumbSize); + if (thumb) { + // send data + mData.setOperationCode(mRequest.getOperationCode()); + mData.setTransactionID(mRequest.getTransactionID()); + mData.writeData(mFD, thumb, thumbSize); + free(thumb); + return MTP_RESPONSE_OK; + } else { + return MTP_RESPONSE_GENERAL_ERROR; + } +} + MtpResponseCode MtpServer::doGetPartialObject(MtpOperationCode operation) { if (!hasStorage()) return MTP_RESPONSE_INVALID_OBJECT_HANDLE; |