diff options
author | Mike Lockwood <lockwood@android.com> | 2010-08-02 10:52:20 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-08-02 10:52:20 -0400 |
commit | 343af4ef512869695456a91519e73ed3c3d82101 (patch) | |
tree | 5545225fc812b6f6ad0aee784238a80f0a80667b /media/mtp | |
parent | 9c04c4cc038f924d9cb98798e1c07fe6017e85d0 (diff) | |
download | frameworks_av-343af4ef512869695456a91519e73ed3c3d82101.zip frameworks_av-343af4ef512869695456a91519e73ed3c3d82101.tar.gz frameworks_av-343af4ef512869695456a91519e73ed3c3d82101.tar.bz2 |
MTP: Implement GetNumObjects
Change-Id: Iccc3a445f9a1eab7bb76eddd567c6a3a8f155b2b
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp')
-rw-r--r-- | media/mtp/MtpDatabase.h | 4 | ||||
-rw-r--r-- | media/mtp/MtpServer.cpp | 33 | ||||
-rw-r--r-- | media/mtp/MtpServer.h | 1 |
3 files changed, 33 insertions, 5 deletions
diff --git a/media/mtp/MtpDatabase.h b/media/mtp/MtpDatabase.h index a17797e..bbbbc38 100644 --- a/media/mtp/MtpDatabase.h +++ b/media/mtp/MtpDatabase.h @@ -47,6 +47,10 @@ public: MtpObjectFormat format, MtpObjectHandle parent) = 0; + virtual int getNumObjects(MtpStorageID storageID, + MtpObjectFormat format, + MtpObjectHandle parent) = 0; + virtual MtpResponseCode getObjectProperty(MtpObjectHandle handle, MtpObjectProperty property, MtpDataPacket& packet) = 0; diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index 1e41407..50a839e 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -55,10 +55,10 @@ static const MtpOperationCode kSupportedOperationCodes[] = { // MTP_OPERATION_SELF_TEST, // MTP_OPERATION_SET_OBJECT_PROTECTION, // MTP_OPERATION_POWER_DOWN, - MTP_OPERATION_GET_DEVICE_PROP_DESC, - MTP_OPERATION_GET_DEVICE_PROP_VALUE, - MTP_OPERATION_SET_DEVICE_PROP_VALUE, - MTP_OPERATION_RESET_DEVICE_PROP_VALUE, +// MTP_OPERATION_GET_DEVICE_PROP_DESC, +// MTP_OPERATION_GET_DEVICE_PROP_VALUE, +// MTP_OPERATION_SET_DEVICE_PROP_VALUE, +// MTP_OPERATION_RESET_DEVICE_PROP_VALUE, // MTP_OPERATION_TERMINATE_OPEN_CAPTURE, // MTP_OPERATION_MOVE_OBJECT, // MTP_OPERATION_COPY_OBJECT, @@ -67,7 +67,7 @@ static const MtpOperationCode kSupportedOperationCodes[] = { MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED, // MTP_OPERATION_GET_OBJECT_PROP_DESC, MTP_OPERATION_GET_OBJECT_PROP_VALUE, - MTP_OPERATION_SET_OBJECT_PROP_VALUE, +// MTP_OPERATION_SET_OBJECT_PROP_VALUE, // MTP_OPERATION_GET_OBJECT_REFERENCES, // MTP_OPERATION_SET_OBJECT_REFERENCES, // MTP_OPERATION_SKIP, @@ -308,6 +308,9 @@ bool MtpServer::handleRequest() { case MTP_OPERATION_GET_OBJECT_HANDLES: response = doGetObjectHandles(); break; + case MTP_OPERATION_GET_NUM_OBJECTS: + response = doGetNumObjects(); + break; case MTP_OPERATION_GET_OBJECT_PROP_VALUE: response = doGetObjectPropValue(); break; @@ -454,6 +457,26 @@ MtpResponseCode MtpServer::doGetObjectHandles() { return MTP_RESPONSE_OK; } +MtpResponseCode MtpServer::doGetNumObjects() { + if (!mSessionOpen) + return MTP_RESPONSE_SESSION_NOT_OPEN; + MtpStorageID storageID = mRequest.getParameter(1); // 0xFFFFFFFF for all storage + 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; + + int count = mDatabase->getNumObjects(storageID, format, parent); + if (count >= 0) { + mResponse.setParameter(1, count); + return MTP_RESPONSE_OK; + } else { + mResponse.setParameter(1, 0); + return MTP_RESPONSE_INVALID_OBJECT_HANDLE; + } +} + MtpResponseCode MtpServer::doGetObjectPropValue() { MtpObjectHandle handle = mRequest.getParameter(1); MtpObjectProperty property = mRequest.getParameter(2); diff --git a/media/mtp/MtpServer.h b/media/mtp/MtpServer.h index aff973a..9ed1c84 100644 --- a/media/mtp/MtpServer.h +++ b/media/mtp/MtpServer.h @@ -94,6 +94,7 @@ private: MtpResponseCode doGetStorageInfo(); MtpResponseCode doGetObjectPropsSupported(); MtpResponseCode doGetObjectHandles(); + MtpResponseCode doGetNumObjects(); MtpResponseCode doGetObjectPropValue(); MtpResponseCode doGetObjectInfo(); MtpResponseCode doGetObject(); |