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>
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 @@
     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 @@
     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);
 }