summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpPacket.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-12-09 18:34:18 -0800
committerMike Lockwood <lockwood@android.com>2010-12-09 18:34:18 -0800
commitf7454622eaac287d20ab43013d7015fe42b894f8 (patch)
tree1bbc63dbaf849ed5226194e933f2de3c9bdb22e0 /media/mtp/MtpPacket.cpp
parent424c6cbfa75da5f4f889ab6517dfee4dd024ba2d (diff)
downloadframeworks_av-f7454622eaac287d20ab43013d7015fe42b894f8.zip
frameworks_av-f7454622eaac287d20ab43013d7015fe42b894f8.tar.gz
frameworks_av-f7454622eaac287d20ab43013d7015fe42b894f8.tar.bz2
MTP host: Handle receiving a response packet instead of data packet.
This will happen if the device needs to report an error rather than returning the data. Change-Id: I477512b3676c2f0518a85a4135832ed4475fbc2d Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpPacket.cpp')
-rw-r--r--media/mtp/MtpPacket.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/media/mtp/MtpPacket.cpp b/media/mtp/MtpPacket.cpp
index bd6196f..a885249 100644
--- a/media/mtp/MtpPacket.cpp
+++ b/media/mtp/MtpPacket.cpp
@@ -84,6 +84,13 @@ void MtpPacket::dump() {
LOGV("\n");
}
+void MtpPacket::copyFrom(const MtpPacket& src) {
+ int length = src.mPacketSize;
+ allocate(length);
+ mPacketSize = length;
+ memcpy(mBuffer, src.mBuffer, length);
+}
+
uint16_t MtpPacket::getUInt16(int offset) const {
return ((uint16_t)mBuffer[offset + 1] << 8) | (uint16_t)mBuffer[offset];
}
@@ -113,6 +120,10 @@ void MtpPacket::setContainerCode(uint16_t code) {
putUInt16(MTP_CONTAINER_CODE_OFFSET, code);
}
+uint16_t MtpPacket::getContainerType() const {
+ return getUInt16(MTP_CONTAINER_TYPE_OFFSET);
+}
+
MtpTransactionID MtpPacket::getTransactionID() const {
return getUInt32(MTP_CONTAINER_TRANSACTION_ID_OFFSET);
}