diff options
Diffstat (limited to 'drm/java')
-rw-r--r-- | drm/java/android/drm/DrmErrorEvent.java | 22 | ||||
-rw-r--r-- | drm/java/android/drm/DrmEvent.java | 37 | ||||
-rw-r--r-- | drm/java/android/drm/DrmInfoEvent.java | 22 | ||||
-rw-r--r-- | drm/java/android/drm/DrmManagerClient.java | 33 |
4 files changed, 99 insertions, 15 deletions
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java index 20fd8aa080f8..7cc9a876df82 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)} @@ -53,16 +55,34 @@ public class DrmErrorEvent extends DrmEvent { * associated with all DRM schemes. */ public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007; + /** + * TYPE_ACQUIRE_DRM_INFO_FAILED, when failed to acquire DrmInfo. + */ + public static final int TYPE_ACQUIRE_DRM_INFO_FAILED = 2008; /** * 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 f7bc5cd11884..eba458bf5525 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 a778e06f8461..190199a4a42c 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)} @@ -45,16 +47,34 @@ public class DrmInfoEvent extends DrmEvent { * already done for the given account. */ public static final int TYPE_ACCOUNT_ALREADY_REGISTERED = 5; + /** + * TYPE_RIGHTS_REMOVED, when the rights has been removed. + */ + public static final int TYPE_RIGHTS_REMOVED = 6; /** * 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 782ffdb8ba44..f7479b5c46fe 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); @@ -181,7 +184,7 @@ public class DrmManagerClient { } public void handleMessage(Message msg) { - DrmInfoEvent event = null; + DrmInfoEvent info = null; DrmErrorEvent error = null; switch (msg.what) { @@ -197,11 +200,15 @@ public class DrmManagerClient { } catch (IOException e) { e.printStackTrace(); } - event = new DrmInfoEvent(uniqueId, infoType, message); + info = new DrmInfoEvent(uniqueId, infoType, message); break; } - case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT: { - event = new DrmInfoEvent(uniqueId, infoType, message); + case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT: + case DrmInfoEvent.TYPE_RIGHTS_INSTALLED: + case DrmInfoEvent.TYPE_WAIT_FOR_RIGHTS: + case DrmInfoEvent.TYPE_ACCOUNT_ALREADY_REGISTERED: + case DrmInfoEvent.TYPE_RIGHTS_REMOVED: { + info = new DrmInfoEvent(uniqueId, infoType, message); break; } default: @@ -209,8 +216,8 @@ public class DrmManagerClient { break; } - if (null != mOnInfoListener && null != event) { - mOnInfoListener.onInfo(DrmManagerClient.this, event); + if (null != mOnInfoListener && null != info) { + mOnInfoListener.onInfo(DrmManagerClient.this, info); } if (null != mOnErrorListener && null != error) { mOnErrorListener.onError(DrmManagerClient.this, error); |