summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpDataPacket.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-04-24 18:40:17 -0700
committerMike Lockwood <lockwood@android.com>2011-04-25 17:40:33 -0700
commit64000788211f4c7e78c80a4a155390d1316e1176 (patch)
tree5cd67cc35f9df8ffcef27438430c6a087adfa69c /media/mtp/MtpDataPacket.cpp
parentc0502468a29aa2f2b3457e0e08c4a5650a70488d (diff)
downloadframeworks_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/MtpDataPacket.cpp')
-rw-r--r--media/mtp/MtpDataPacket.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp
index 0b0c80d..817eac0 100644
--- a/media/mtp/MtpDataPacket.cpp
+++ b/media/mtp/MtpDataPacket.cpp
@@ -388,6 +388,16 @@ int MtpDataPacket::writeDataHeader(int fd, uint32_t length) {
int ret = ::write(fd, mBuffer, MTP_CONTAINER_HEADER_SIZE);
return (ret < 0 ? ret : 0);
}
+
+int MtpDataPacket::writeData(int fd, void* data, uint32_t length) {
+ MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, length + MTP_CONTAINER_HEADER_SIZE);
+ MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
+ int ret = ::write(fd, mBuffer, MTP_CONTAINER_HEADER_SIZE);
+ if (ret == MTP_CONTAINER_HEADER_SIZE)
+ ret = ::write(fd, data, length);
+ return (ret < 0 ? ret : 0);
+}
+
#endif // MTP_DEVICE
#ifdef MTP_HOST