From d21eac9c70940f2c73da5faaf401dbbc44b70a15 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Sat, 3 Jul 2010 00:44:05 -0400 Subject: MTP: Use media provider database to implement MTP device support. Uses a new "MTP objects" table in the media provider to support basic enumeration of the external storage file system. Support for accessing audio, video and image metadata in the existing media provider tables will be added in a later commit. The C++ MtpDatabase class is now abstract, to support a proxy subclass that calls through JNI to the Java MtpDatabase class in the media provider. Change-Id: I90f0db5f3acc5d35ae78c27a8507edff16d14305 Signed-off-by: Mike Lockwood --- media/mtp/MtpDataPacket.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'media/mtp/MtpDataPacket.cpp') diff --git a/media/mtp/MtpDataPacket.cpp b/media/mtp/MtpDataPacket.cpp index a7e975c..6f9ea24 100644 --- a/media/mtp/MtpDataPacket.cpp +++ b/media/mtp/MtpDataPacket.cpp @@ -299,17 +299,28 @@ void MtpDataPacket::putAUInt64(const uint64_t* values, int count) { putUInt64(*values++); } -void MtpDataPacket::putString(const MtpStringBuffer& string) -{ +void MtpDataPacket::putString(const MtpStringBuffer& string) { string.writeToPacket(this); } -void MtpDataPacket::putString(const char* s) -{ +void MtpDataPacket::putString(const char* s) { MtpStringBuffer string(s); string.writeToPacket(this); } +void MtpDataPacket::putString(const uint16_t* string) { + int count = 0; + for (int i = 0; i < 256; i++) { + if (string[i]) + count++; + else + break; + } + putUInt8(count); + for (int i = 0; i < count; i++) + putUInt16(string[i]); +} + #ifdef MTP_DEVICE int MtpDataPacket::read(int fd) { // first read the header -- cgit v1.1