diff options
author | Gloria Wang <gwang@google.com> | 2011-03-16 10:44:03 -0700 |
---|---|---|
committer | Gloria Wang <gwang@google.com> | 2011-03-16 21:36:30 -0700 |
commit | f8bf3c46f524b1252bf466a351daaef61afdcecb (patch) | |
tree | 40f222d60751b8278291b5890d7fc3f2fb6a75eb /drm/java | |
parent | 3913c131c61288c5b4eedb063d9eb6b6204d2a1f (diff) | |
download | frameworks_base-f8bf3c46f524b1252bf466a351daaef61afdcecb.zip frameworks_base-f8bf3c46f524b1252bf466a351daaef61afdcecb.tar.gz frameworks_base-f8bf3c46f524b1252bf466a351daaef61afdcecb.tar.bz2 |
Fix for 4089881.
- Add one more parameter in the interface of DrmEvent and its subclasses
DrmInfoEvent and DrmErrorEvent
- Send back DrmInfo in the response of async processDrmInfo calls
Change-Id: Ia9b1a641296629a19ae4ffa7913e6c878fd340f8
Diffstat (limited to 'drm/java')
-rw-r--r-- | drm/java/android/drm/DrmErrorEvent.java | 18 | ||||
-rw-r--r-- | drm/java/android/drm/DrmEvent.java | 37 | ||||
-rw-r--r-- | drm/java/android/drm/DrmInfoEvent.java | 18 | ||||
-rw-r--r-- | drm/java/android/drm/DrmManagerClient.java | 17 |
4 files changed, 81 insertions, 9 deletions
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java index 90adb47f..7cc9a87 100644 --- a/drm/java/android/drm/DrmErrorEvent.java +++ b/drm/java/android/drm/DrmErrorEvent.java @@ -16,6 +16,8 @@ package android.drm; +import java.util.HashMap; + /** * This is an entity class which would be passed to caller in * {@link DrmManagerClient.OnErrorListener#onError(DrmManagerClient, DrmErrorEvent)} @@ -62,11 +64,25 @@ public class DrmErrorEvent extends DrmEvent { * constructor to create DrmErrorEvent object with given parameters * * @param uniqueId Unique session identifier - * @param type Type of information + * @param type Type of the event. It could be one of the types defined above * @param message Message description */ public DrmErrorEvent(int uniqueId, int type, String message) { super(uniqueId, type, message); } + + /** + * constructor to create DrmErrorEvent object with given parameters + * + * @param uniqueId Unique session identifier + * @param type Type of the event. It could be one of the types defined above + * @param message Message description + * @param attributes Attributes for extensible information. Could be any + * information provided by the plugin + */ + public DrmErrorEvent(int uniqueId, int type, String message, + HashMap<String, Object> attributes) { + super(uniqueId, type, message, attributes); + } } diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java index f7bc5cd..eba458b 100644 --- a/drm/java/android/drm/DrmEvent.java +++ b/drm/java/android/drm/DrmEvent.java @@ -16,6 +16,8 @@ package android.drm; +import java.util.HashMap; + /** * This is the base class which would be used to notify the caller * about any event occurred in DRM framework. @@ -33,11 +35,36 @@ public class DrmEvent { public static final int TYPE_DRM_INFO_PROCESSED = 1002; public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object"; + public static final String DRM_INFO_OBJECT = "drm_info_object"; private final int mUniqueId; private final int mType; private String mMessage = ""; + private HashMap<String, Object> mAttributes = new HashMap<String, Object>(); + + /** + * constructor for DrmEvent class + * + * @param uniqueId Unique session identifier + * @param type Type of information + * @param message Message description + * @param attributes Attributes for extensible information + */ + protected DrmEvent(int uniqueId, int type, String message, + HashMap<String, Object> attributes) { + mUniqueId = uniqueId; + mType = type; + + if (null != message) { + mMessage = message; + } + + if (null != attributes) { + mAttributes = attributes; + } + } + /** * constructor for DrmEvent class * @@ -80,5 +107,15 @@ public class DrmEvent { public String getMessage() { return mMessage; } + + /** + * Returns the attribute corresponding to the specified key + * + * @return one of the attributes or null if no mapping for + * the key is found + */ + public Object getAttribute(String key) { + return mAttributes.get(key); + } } diff --git a/drm/java/android/drm/DrmInfoEvent.java b/drm/java/android/drm/DrmInfoEvent.java index 72f37ea..190199a 100644 --- a/drm/java/android/drm/DrmInfoEvent.java +++ b/drm/java/android/drm/DrmInfoEvent.java @@ -16,6 +16,8 @@ package android.drm; +import java.util.HashMap; + /** * This is an entity class which would be passed to caller in * {@link DrmManagerClient.OnInfoListener#onInfo(DrmManagerClient, DrmInfoEvent)} @@ -54,11 +56,25 @@ public class DrmInfoEvent extends DrmEvent { * constructor to create DrmInfoEvent object with given parameters * * @param uniqueId Unique session identifier - * @param type Type of information + * @param type Type of the event. It could be one of the types defined above * @param message Message description */ public DrmInfoEvent(int uniqueId, int type, String message) { super(uniqueId, type, message); } + + /** + * constructor to create DrmInfoEvent object with given parameters + * + * @param uniqueId Unique session identifier + * @param type Type of the event. It could be one of the types defined above + * @param message Message description + * @param attributes Attributes for extensible information. Could be any + * information provided by the plugin + */ + public DrmInfoEvent(int uniqueId, int type, String message, + HashMap<String, Object> attributes) { + super(uniqueId, type, message, attributes); + } } diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java index aa56159..f7479b5 100644 --- a/drm/java/android/drm/DrmManagerClient.java +++ b/drm/java/android/drm/DrmManagerClient.java @@ -81,10 +81,8 @@ public class DrmManagerClient { * * @param client DrmManagerClient instance * @param event instance which wraps type and message - * @param attributes resultant values in key and value pair. */ - public void onEvent(DrmManagerClient client, DrmEvent event, - HashMap<String, Object> attributes); + public void onEvent(DrmManagerClient client, DrmEvent event); } /** @@ -128,12 +126,17 @@ public class DrmManagerClient { case ACTION_PROCESS_DRM_INFO: { final DrmInfo drmInfo = (DrmInfo) msg.obj; DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo); + + attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status); + attributes.put(DrmEvent.DRM_INFO_OBJECT, drmInfo); + if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) { - attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status); - event = new DrmEvent(mUniqueId, getEventType(status.infoType), null); + event = new DrmEvent(mUniqueId, + getEventType(status.infoType), null, attributes); } else { int infoType = (null != status) ? status.infoType : drmInfo.getInfoType(); - error = new DrmErrorEvent(mUniqueId, getErrorType(infoType), null); + error = new DrmErrorEvent(mUniqueId, + getErrorType(infoType), null, attributes); } break; } @@ -151,7 +154,7 @@ public class DrmManagerClient { return; } if (null != mOnEventListener && null != event) { - mOnEventListener.onEvent(DrmManagerClient.this, event, attributes); + mOnEventListener.onEvent(DrmManagerClient.this, event); } if (null != mOnErrorListener && null != error) { mOnErrorListener.onError(DrmManagerClient.this, error); |