From de1e37aad04640ef76f3c017b65adca087c7be0f Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Wed, 18 Aug 2010 12:31:09 -0400 Subject: MTP: Compatibility fixes for transferring strings Change-Id: Ic06d754ee68b0389439cdc34f73adff0f2b33afa Signed-off-by: Mike Lockwood --- media/mtp/MtpStringBuffer.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'media/mtp/MtpStringBuffer.cpp') diff --git a/media/mtp/MtpStringBuffer.cpp b/media/mtp/MtpStringBuffer.cpp index 2d3cf69..8bf6731 100644 --- a/media/mtp/MtpStringBuffer.cpp +++ b/media/mtp/MtpStringBuffer.cpp @@ -112,7 +112,7 @@ void MtpStringBuffer::readFromPacket(MtpDataPacket* packet) { void MtpStringBuffer::writeToPacket(MtpDataPacket* packet) const { int count = mCharCount; const uint8_t* src = mBuffer; - packet->putUInt8(count); + packet->putUInt8(count > 0 ? count + 1 : 0); // expand utf8 to 16 bit chars for (int i = 0; i < count; i++) { @@ -133,6 +133,9 @@ void MtpStringBuffer::writeToPacket(MtpDataPacket* packet) const { } packet->putUInt16(ch); } + // only terminate with zero if string is not empty + if (count > 0) + packet->putUInt16(0); } } // namespace android -- cgit v1.1