diff options
author | Mike Lockwood <lockwood@android.com> | 2010-12-07 10:58:56 -0800 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-12-07 10:58:56 -0800 |
commit | 98693f674125484de8873d969c209276a6dd604b (patch) | |
tree | 58c69be45cd71ca9729f1a2388da9a8f18d3ae25 /media/mtp | |
parent | 2e09e289b7e136481e9215bb61ed47cee5d9919b (diff) | |
download | frameworks_av-98693f674125484de8873d969c209276a6dd604b.zip frameworks_av-98693f674125484de8873d969c209276a6dd604b.tar.gz frameworks_av-98693f674125484de8873d969c209276a6dd604b.tar.bz2 |
MTP: Host support for GetObjectPropsSupported and GetObjectPropDesc
Change-Id: I6fd23587597fc68227dfb61118b097eda3e3e1d5
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp')
-rw-r--r-- | media/mtp/MtpDevice.cpp | 35 | ||||
-rw-r--r-- | media/mtp/MtpDevice.h | 3 |
2 files changed, 38 insertions, 0 deletions
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp index 416ebfe..a4d29a7 100644 --- a/media/mtp/MtpDevice.cpp +++ b/media/mtp/MtpDevice.cpp @@ -330,6 +330,23 @@ MtpObjectHandle MtpDevice::getStorageID(MtpObjectHandle handle) { return -1; } +MtpObjectPropertyList* MtpDevice::getObjectPropsSupported(MtpObjectFormat format) { + Mutex::Autolock autoLock(mMutex); + + mRequest.reset(); + mRequest.setParameter(1, format); + if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROPS_SUPPORTED)) + return NULL; + if (!readData()) + return NULL; + MtpResponseCode ret = readResponse(); + if (ret == MTP_RESPONSE_OK) { + return mData.getAUInt16(); + } + return NULL; + +} + MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { Mutex::Autolock autoLock(mMutex); @@ -348,6 +365,24 @@ MtpProperty* MtpDevice::getDevicePropDesc(MtpDeviceProperty code) { return NULL; } +MtpProperty* MtpDevice::getObjectPropDesc(MtpObjectProperty code) { + Mutex::Autolock autoLock(mMutex); + + mRequest.reset(); + mRequest.setParameter(1, code); + if (!sendRequest(MTP_OPERATION_GET_OBJECT_PROP_DESC)) + return NULL; + if (!readData()) + return NULL; + MtpResponseCode ret = readResponse(); + if (ret == MTP_RESPONSE_OK) { + MtpProperty* property = new MtpProperty; + property->read(mData); + return property; + } + return NULL; +} + // reads the object's data and writes it to the specified file path bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) { LOGD("readObject: %s", destPath); diff --git a/media/mtp/MtpDevice.h b/media/mtp/MtpDevice.h index 21c85d5..6eba8c8 100644 --- a/media/mtp/MtpDevice.h +++ b/media/mtp/MtpDevice.h @@ -85,7 +85,10 @@ public: MtpObjectHandle getParent(MtpObjectHandle handle); MtpObjectHandle getStorageID(MtpObjectHandle handle); + MtpObjectPropertyList* getObjectPropsSupported(MtpObjectFormat format); + MtpProperty* getDevicePropDesc(MtpDeviceProperty code); + MtpProperty* getObjectPropDesc(MtpObjectProperty code); bool readObject(MtpObjectHandle handle, const char* destPath, int group, int perm); |