summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/mtp/MtpDatabase.h4
-rw-r--r--media/mtp/MtpServer.cpp33
-rw-r--r--media/mtp/MtpServer.h1
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();