From 1865a5ddcfe7b0e8dc211419aea1094b1491a5fd 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/MtpServer.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'media/mtp/MtpServer.cpp') diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index 3456815..967ebc9 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -113,11 +113,10 @@ static const MtpObjectFormat kSupportedPlaybackFormats[] = { // MTP_FORMAT_PLS_PLAYLIST, }; -MtpServer::MtpServer(int fd, const char* databasePath, +MtpServer::MtpServer(int fd, MtpDatabase* database, int fileGroup, int filePerm, int directoryPerm) : mFD(fd), - mDatabasePath(databasePath), - mDatabase(NULL), + mDatabase(database), mFileGroup(fileGroup), mFilePermission(filePerm), mDirectoryPermission(directoryPerm), @@ -126,9 +125,6 @@ MtpServer::MtpServer(int fd, const char* databasePath, mSendObjectHandle(kInvalidObjectHandle), mSendObjectFileSize(0) { - mDatabase = new MtpSqliteDatabase(); - mDatabase->open(databasePath, true); - initObjectProperties(); } @@ -427,6 +423,8 @@ MtpResponseCode MtpServer::doGetObjectHandles() { MtpObjectFormat format = mRequest.getParameter(2); // 0 for all formats MtpObjectHandle parent = mRequest.getParameter(3); // 0xFFFFFFFF for objects with no parent // 0x00000000 for all objects? + if (parent == 0xFFFFFFFF) + parent = 0; MtpObjectHandleList* handles = mDatabase->getObjectList(storageID, format, parent); mData.putAUInt32(handles); @@ -488,9 +486,10 @@ MtpResponseCode MtpServer::doSendObjectInfo() { return MTP_RESPONSE_INVALID_STORAGE_ID; // special case the root - if (parent == MTP_PARENT_ROOT) + if (parent == MTP_PARENT_ROOT) { path = storage->getPath(); - else { + parent = 0; + } else { int64_t dummy; if (!mDatabase->getObjectFilePath(parent, path, dummy)) return MTP_RESPONSE_INVALID_OBJECT_HANDLE; @@ -549,7 +548,7 @@ MtpResponseCode MtpServer::doSendObjectInfo() { } mResponse.setParameter(1, storageID); - mResponse.setParameter(2, parent); + mResponse.setParameter(2, (parent == 0 ? 0xFFFFFFFF: parent)); mResponse.setParameter(3, handle); return MTP_RESPONSE_OK; -- cgit v1.1