Merge "Fix MtpDevice to read 0-byte object correctly."
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index f8b913a..23e432e 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -659,6 +659,13 @@
return false;
}
+ // If object size 0 byte, the remote device can reply response packet
+ // without sending any data packets.
+ if (mData.getContainerType() == MTP_CONTAINER_TYPE_RESPONSE) {
+ mResponse.copyFrom(mData);
+ return mResponse.getResponseCode() == MTP_RESPONSE_OK;
+ }
+
const uint32_t fullLength = mData.getContainerLength();
if ((!expectedLength && fullLength < MTP_CONTAINER_HEADER_SIZE) ||
(expectedLength && *expectedLength + MTP_CONTAINER_HEADER_SIZE != fullLength)) {