diff options
author | Mike Lockwood <lockwood@android.com> | 2010-07-12 18:54:16 -0400 |
---|---|---|
committer | Mike Lockwood <lockwood@android.com> | 2010-07-13 20:04:22 -0400 |
commit | 873871f3e75831bcda6c3f75bb4d53355ca5c53a (patch) | |
tree | e7fcffe64b2104cba18df6f35cf736cee63eb2d3 /media/mtp/MtpServer.cpp | |
parent | 4714b0766ecf48f09f39b4781a5c4deafc092d49 (diff) | |
download | frameworks_av-873871f3e75831bcda6c3f75bb4d53355ca5c53a.zip frameworks_av-873871f3e75831bcda6c3f75bb4d53355ca5c53a.tar.gz frameworks_av-873871f3e75831bcda6c3f75bb4d53355ca5c53a.tar.bz2 |
MTP: Add support for sending events to the host when objects are added and removed
Change-Id: Ia1d5232b919c644c670ff9ca651eca92b3f9ad42
Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'media/mtp/MtpServer.cpp')
-rw-r--r-- | media/mtp/MtpServer.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp index e8f09fa..fda5f8f 100644 --- a/media/mtp/MtpServer.cpp +++ b/media/mtp/MtpServer.cpp @@ -73,6 +73,11 @@ static const MtpOperationCode kSupportedOperationCodes[] = { // MTP_OPERATION_SKIP, }; +static const MtpEventCode kSupportedEventCodes[] = { + MTP_EVENT_OBJECT_ADDED, + MTP_EVENT_OBJECT_REMOVED, +}; + static const MtpObjectProperty kSupportedObjectProperties[] = { MTP_PROPERTY_STORAGE_ID, MTP_PROPERTY_OBJECT_FORMAT, @@ -239,6 +244,24 @@ MtpProperty* MtpServer::getDeviceProperty(MtpPropertyCode propCode) { return NULL; } +void MtpServer::sendObjectAdded(MtpObjectHandle handle) { + LOGD("sendObjectAdded %d\n", handle); + mEvent.setEventCode(MTP_EVENT_OBJECT_ADDED); + mEvent.setTransactionID(mRequest.getTransactionID()); + mEvent.setParameter(1, handle); + int ret = mEvent.write(mFD); + LOGD("mEvent.write returned %d\n", ret); +} + +void MtpServer::sendObjectRemoved(MtpObjectHandle handle) { + LOGD("sendObjectRemoved %d\n", handle); + mEvent.setEventCode(MTP_EVENT_OBJECT_REMOVED); + mEvent.setTransactionID(mRequest.getTransactionID()); + mEvent.setParameter(1, handle); + int ret = mEvent.write(mFD); + LOGD("mEvent.write returned %d\n", ret); +} + void MtpServer::initObjectProperties() { mObjectProperties.push(new MtpProperty(MTP_PROPERTY_STORAGE_ID, MTP_TYPE_UINT16)); mObjectProperties.push(new MtpProperty(MTP_PROPERTY_OBJECT_FORMAT, MTP_TYPE_UINT16)); @@ -326,7 +349,8 @@ MtpResponseCode MtpServer::doGetDeviceInfo() { mData.putUInt16(0); //Functional Mode mData.putAUInt16(kSupportedOperationCodes, sizeof(kSupportedOperationCodes) / sizeof(uint16_t)); // Operations Supported - mData.putEmptyArray(); // Events Supported + mData.putAUInt16(kSupportedEventCodes, + sizeof(kSupportedEventCodes) / sizeof(uint16_t)); // Events Supported mData.putEmptyArray(); // Device Properties Supported mData.putEmptyArray(); // Capture Formats mData.putAUInt16(kSupportedPlaybackFormats, |