summaryrefslogtreecommitdiffstats
path: root/media/mtp/MtpServer.cpp
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-07-03 00:44:05 -0400
committerMike Lockwood <lockwood@android.com>2010-07-08 16:21:09 -0400
commit1865a5ddcfe7b0e8dc211419aea1094b1491a5fd (patch)
tree7d5cf198bb5802a4e6faf0f58bccf1ddecd62ce7 /media/mtp/MtpServer.cpp
parentdda7e2b7378755637f188cca7c5ae854427a28f7 (diff)
downloadframeworks_av-1865a5ddcfe7b0e8dc211419aea1094b1491a5fd.zip
frameworks_av-1865a5ddcfe7b0e8dc211419aea1094b1491a5fd.tar.gz
frameworks_av-1865a5ddcfe7b0e8dc211419aea1094b1491a5fd.tar.bz2
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 <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpServer.cpp')
-rw-r--r--media/mtp/MtpServer.cpp17
1 files changed, 8 insertions, 9 deletions
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;