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 | be125a50b41f15810145671e0fcbdaf13b363e03 (patch) | |
| tree | a0af388e0524314a55da06d48d16928bfc90c1a0 /media/mtp/MtpServer.cpp | |
| parent | 77ad5e64116ba692efea060d528681c069aa439b (diff) | |
| download | frameworks_base-be125a50b41f15810145671e0fcbdaf13b363e03.zip frameworks_base-be125a50b41f15810145671e0fcbdaf13b363e03.tar.gz frameworks_base-be125a50b41f15810145671e0fcbdaf13b363e03.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, |
