From f8bf3c46f524b1252bf466a351daaef61afdcecb Mon Sep 17 00:00:00 2001 From: Gloria Wang Date: Wed, 16 Mar 2011 10:44:03 -0700 Subject: [PATCH] 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 --- api/12.xml | 2 - api/current.xml | 76 +++++++++++++++++++++- drm/java/android/drm/DrmErrorEvent.java | 18 ++++- drm/java/android/drm/DrmEvent.java | 37 +++++++++++ drm/java/android/drm/DrmInfoEvent.java | 18 ++++- drm/java/android/drm/DrmManagerClient.java | 17 +++-- 6 files changed, 154 insertions(+), 14 deletions(-) diff --git a/api/12.xml b/api/12.xml index a65d9c161e4db..37a81fc8fa52f 100644 --- a/api/12.xml +++ b/api/12.xml @@ -73375,8 +73375,6 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java index 90adb47fe53eb..7cc9a876df828 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 attributes) { + super(uniqueId, type, message, attributes); + } } diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java index f7bc5cd11884f..eba458bf5525b 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 mAttributes = new HashMap(); + + /** + * 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 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 72f37eaf90c5c..190199a4a42c3 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 attributes) { + super(uniqueId, type, message, attributes); + } } diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java index aa56159d54c8b..f7479b5c46fe7 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 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);