summaryrefslogtreecommitdiffstats
path: root/drm/common
diff options
context:
space:
mode:
authorTakeshi Aimi <takeshi.aimi@sonymobile.com>2012-07-11 17:09:21 +0900
committerJeff Tinker <jtinker@google.com>2013-08-23 18:01:07 -0700
commit5ff7836da0220b3097f36c8a5e82111816ebca62 (patch)
tree4612e1308d3dd9961db0fae6d3372203d5937f61 /drm/common
parent62c1a46eec047eb5fbc4b90432ec1ce65b76fb75 (diff)
downloadframeworks_av-5ff7836da0220b3097f36c8a5e82111816ebca62.zip
frameworks_av-5ff7836da0220b3097f36c8a5e82111816ebca62.tar.gz
frameworks_av-5ff7836da0220b3097f36c8a5e82111816ebca62.tar.bz2
Enhancement for OnInfo callback on DRM Framework
In DRM framework, plugins can transmit DrmInfoEvent to Java layer. Although DrmInfoEvent has several entries, current implementation can only convey integer and String. This change enables plugins uto propagate a hashmap to Java layer. The hashmap can have one or more Strings and one byte array as value. Changes are made by Sony Corporation. bug: 10459159 Change-Id: Ic19265d4ad3db4eda66a3c27e1e08873a8f2a4d7 (cherry picked from commit 4f782bf0cb69929ebf03de239e2c9bf8e82adf5e)
Diffstat (limited to 'drm/common')
-rw-r--r--drm/common/DrmInfoEvent.cpp92
-rw-r--r--drm/common/IDrmServiceListener.cpp32
2 files changed, 122 insertions, 2 deletions
diff --git a/drm/common/DrmInfoEvent.cpp b/drm/common/DrmInfoEvent.cpp
index 27a5a2d..2315aa9 100644
--- a/drm/common/DrmInfoEvent.cpp
+++ b/drm/common/DrmInfoEvent.cpp
@@ -16,16 +16,29 @@
#include <utils/String8.h>
#include <drm/DrmInfoEvent.h>
+#include <stdlib.h>
using namespace android;
DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8 message)
: mUniqueId(uniqueId),
mInfoType(infoType),
- mMessage(message) {
+ mMessage(message),
+ mDrmBuffer() {
}
+DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8 message,
+ const DrmBuffer& drmBuffer)
+ : mUniqueId(uniqueId), mInfoType(infoType), mMessage(message), mDrmBuffer() {
+ setData(drmBuffer);
+}
+
+DrmInfoEvent::~DrmInfoEvent() {
+ delete [] mDrmBuffer.data;
+}
+
+
int DrmInfoEvent::getUniqueId() const {
return mUniqueId;
}
@@ -38,3 +51,80 @@ const String8 DrmInfoEvent::getMessage() const {
return mMessage;
}
+int DrmInfoEvent::getCount() const {
+ return mAttributes.size();
+}
+
+status_t DrmInfoEvent::put(const String8& key, String8& value) {
+ mAttributes.add(key, value);
+ return DRM_NO_ERROR;
+}
+
+const String8 DrmInfoEvent::get(const String8& key) const {
+ if (mAttributes.indexOfKey(key) != NAME_NOT_FOUND) {
+ return mAttributes.valueFor(key);
+ }
+ return String8("");
+}
+
+const DrmBuffer& DrmInfoEvent::getData() const {
+ return mDrmBuffer;
+}
+
+void DrmInfoEvent::setData(const DrmBuffer& drmBuffer) {
+ delete [] mDrmBuffer.data;
+ mDrmBuffer.data = new char[drmBuffer.length];;
+ mDrmBuffer.length = drmBuffer.length;
+ memcpy(mDrmBuffer.data, drmBuffer.data, drmBuffer.length);
+}
+
+DrmInfoEvent::KeyIterator DrmInfoEvent::keyIterator() const {
+ return KeyIterator(this);
+}
+
+DrmInfoEvent::Iterator DrmInfoEvent::iterator() const {
+ return Iterator(this);
+}
+
+// KeyIterator implementation
+DrmInfoEvent::KeyIterator::KeyIterator(const DrmInfoEvent::KeyIterator& keyIterator)
+ : mDrmInfoEvent(keyIterator.mDrmInfoEvent), mIndex(keyIterator.mIndex) {
+}
+
+bool DrmInfoEvent::KeyIterator::hasNext() {
+ return (mIndex < mDrmInfoEvent->mAttributes.size());
+}
+
+const String8& DrmInfoEvent::KeyIterator::next() {
+ const String8& key = mDrmInfoEvent->mAttributes.keyAt(mIndex);
+ mIndex++;
+ return key;
+}
+
+DrmInfoEvent::KeyIterator& DrmInfoEvent::KeyIterator::operator=(
+ const DrmInfoEvent::KeyIterator& keyIterator) {
+ mDrmInfoEvent = keyIterator.mDrmInfoEvent;
+ mIndex = keyIterator.mIndex;
+ return *this;
+}
+
+// Iterator implementation
+DrmInfoEvent::Iterator::Iterator(const DrmInfoEvent::Iterator& iterator)
+ : mDrmInfoEvent(iterator.mDrmInfoEvent), mIndex(iterator.mIndex) {
+}
+
+DrmInfoEvent::Iterator& DrmInfoEvent::Iterator::operator=(const DrmInfoEvent::Iterator& iterator) {
+ mDrmInfoEvent = iterator.mDrmInfoEvent;
+ mIndex = iterator.mIndex;
+ return *this;
+}
+
+bool DrmInfoEvent::Iterator::hasNext() {
+ return mIndex < mDrmInfoEvent->mAttributes.size();
+}
+
+const String8& DrmInfoEvent::Iterator::next() {
+ const String8& value = mDrmInfoEvent->mAttributes.editValueAt(mIndex);
+ mIndex++;
+ return value;
+}
diff --git a/drm/common/IDrmServiceListener.cpp b/drm/common/IDrmServiceListener.cpp
index 6eeea40..d825afb 100644
--- a/drm/common/IDrmServiceListener.cpp
+++ b/drm/common/IDrmServiceListener.cpp
@@ -32,6 +32,19 @@ status_t BpDrmServiceListener::notify(const DrmInfoEvent& event) {
data.writeInt32(event.getType());
data.writeString8(event.getMessage());
+ data.writeInt32(event.getCount());
+ DrmInfoEvent::KeyIterator keyIt = event.keyIterator();
+ while (keyIt.hasNext()) {
+ String8 key = keyIt.next();
+ data.writeString8(key);
+ data.writeString8(event.get(key));
+ }
+ const DrmBuffer& value = event.getData();
+ data.writeInt32(value.length);
+ if (value.length > 0) {
+ data.write(value.data, value.length);
+ }
+
remote()->transact(NOTIFY, data, &reply);
return reply.readInt32();
}
@@ -49,7 +62,24 @@ status_t BnDrmServiceListener::onTransact(
int type = data.readInt32();
const String8& message = data.readString8();
- status_t status = notify(DrmInfoEvent(uniqueId, type, message));
+ DrmInfoEvent event(uniqueId, type, message);
+ int size = data.readInt32();
+ for (int index = 0; index < size; index++) {
+ String8 key(data.readString8());
+ String8 value(data.readString8());
+ event.put(key, value);
+ }
+ int valueSize = data.readInt32();
+ if (valueSize > 0) {
+ char* valueData = new char[valueSize];
+ data.read(valueData, valueSize);
+ DrmBuffer drmBuffer(valueData, valueSize);
+ event.setData(drmBuffer);
+ delete[] valueData;
+ }
+
+ status_t status = notify(event);
+
reply->writeInt32(status);
return DRM_NO_ERROR;