Merge "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" into honeycomb-mr1

This commit is contained in:
Gloria Wang
2011-03-17 10:49:43 -07:00
committed by Android (Google) Code Review
6 changed files with 154 additions and 14 deletions

View File

@ -73375,8 +73375,6 @@
</parameter> </parameter>
<parameter name="event" type="android.drm.DrmEvent"> <parameter name="event" type="android.drm.DrmEvent">
</parameter> </parameter>
<parameter name="attributes" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
</parameter>
</method> </method>
</interface> </interface>
<interface name="DrmManagerClient.OnInfoListener" <interface name="DrmManagerClient.OnInfoListener"

View File

@ -72665,6 +72665,22 @@
<parameter name="message" type="java.lang.String"> <parameter name="message" type="java.lang.String">
</parameter> </parameter>
</constructor> </constructor>
<constructor name="DrmErrorEvent"
type="android.drm.DrmErrorEvent"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="uniqueId" type="int">
</parameter>
<parameter name="type" type="int">
</parameter>
<parameter name="message" type="java.lang.String">
</parameter>
<parameter name="attributes" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
</parameter>
</constructor>
<field name="TYPE_ACQUIRE_DRM_INFO_FAILED" <field name="TYPE_ACQUIRE_DRM_INFO_FAILED"
type="int" type="int"
transient="false" transient="false"
@ -72775,7 +72791,36 @@
</parameter> </parameter>
<parameter name="message" type="java.lang.String"> <parameter name="message" type="java.lang.String">
</parameter> </parameter>
<parameter name="attributes" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
</parameter>
</constructor> </constructor>
<constructor name="DrmEvent"
type="android.drm.DrmEvent"
static="false"
final="false"
deprecated="not deprecated"
visibility="protected"
>
<parameter name="uniqueId" type="int">
</parameter>
<parameter name="type" type="int">
</parameter>
<parameter name="message" type="java.lang.String">
</parameter>
</constructor>
<method name="getAttribute"
return="java.lang.Object"
abstract="false"
native="false"
synchronized="false"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="key" type="java.lang.String">
</parameter>
</method>
<method name="getMessage" <method name="getMessage"
return="java.lang.String" return="java.lang.String"
abstract="false" abstract="false"
@ -72809,6 +72854,17 @@
visibility="public" visibility="public"
> >
</method> </method>
<field name="DRM_INFO_OBJECT"
type="java.lang.String"
transient="false"
volatile="false"
value="&quot;drm_info_object&quot;"
static="true"
final="true"
deprecated="not deprecated"
visibility="public"
>
</field>
<field name="DRM_INFO_STATUS_OBJECT" <field name="DRM_INFO_STATUS_OBJECT"
type="java.lang.String" type="java.lang.String"
transient="false" transient="false"
@ -72985,6 +73041,22 @@
<parameter name="message" type="java.lang.String"> <parameter name="message" type="java.lang.String">
</parameter> </parameter>
</constructor> </constructor>
<constructor name="DrmInfoEvent"
type="android.drm.DrmInfoEvent"
static="false"
final="false"
deprecated="not deprecated"
visibility="public"
>
<parameter name="uniqueId" type="int">
</parameter>
<parameter name="type" type="int">
</parameter>
<parameter name="message" type="java.lang.String">
</parameter>
<parameter name="attributes" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
</parameter>
</constructor>
<field name="TYPE_ACCOUNT_ALREADY_REGISTERED" <field name="TYPE_ACCOUNT_ALREADY_REGISTERED"
type="int" type="int"
transient="false" transient="false"
@ -73767,8 +73839,6 @@
</parameter> </parameter>
<parameter name="event" type="android.drm.DrmEvent"> <parameter name="event" type="android.drm.DrmEvent">
</parameter> </parameter>
<parameter name="attributes" type="java.util.HashMap&lt;java.lang.String, java.lang.Object&gt;">
</parameter>
</method> </method>
</interface> </interface>
<interface name="DrmManagerClient.OnInfoListener" <interface name="DrmManagerClient.OnInfoListener"
@ -267075,7 +267145,7 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="t" type="T"> <parameter name="arg0" type="T">
</parameter> </parameter>
</method> </method>
</interface> </interface>

View File

@ -16,6 +16,8 @@
package android.drm; package android.drm;
import java.util.HashMap;
/** /**
* This is an entity class which would be passed to caller in * This is an entity class which would be passed to caller in
* {@link DrmManagerClient.OnErrorListener#onError(DrmManagerClient, DrmErrorEvent)} * {@link DrmManagerClient.OnErrorListener#onError(DrmManagerClient, DrmErrorEvent)}
@ -62,11 +64,25 @@ public class DrmErrorEvent extends DrmEvent {
* constructor to create DrmErrorEvent object with given parameters * constructor to create DrmErrorEvent object with given parameters
* *
* @param uniqueId Unique session identifier * @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 * @param message Message description
*/ */
public DrmErrorEvent(int uniqueId, int type, String message) { public DrmErrorEvent(int uniqueId, int type, String message) {
super(uniqueId, type, 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);
}
} }

View File

@ -16,6 +16,8 @@
package android.drm; package android.drm;
import java.util.HashMap;
/** /**
* This is the base class which would be used to notify the caller * This is the base class which would be used to notify the caller
* about any event occurred in DRM framework. * 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 int TYPE_DRM_INFO_PROCESSED = 1002;
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object"; 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 mUniqueId;
private final int mType; private final int mType;
private String mMessage = ""; 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 * constructor for DrmEvent class
* *
@ -80,5 +107,15 @@ public class DrmEvent {
public String getMessage() { public String getMessage() {
return mMessage; 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);
}
} }

View File

@ -16,6 +16,8 @@
package android.drm; package android.drm;
import java.util.HashMap;
/** /**
* This is an entity class which would be passed to caller in * This is an entity class which would be passed to caller in
* {@link DrmManagerClient.OnInfoListener#onInfo(DrmManagerClient, DrmInfoEvent)} * {@link DrmManagerClient.OnInfoListener#onInfo(DrmManagerClient, DrmInfoEvent)}
@ -54,11 +56,25 @@ public class DrmInfoEvent extends DrmEvent {
* constructor to create DrmInfoEvent object with given parameters * constructor to create DrmInfoEvent object with given parameters
* *
* @param uniqueId Unique session identifier * @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 * @param message Message description
*/ */
public DrmInfoEvent(int uniqueId, int type, String message) { public DrmInfoEvent(int uniqueId, int type, String message) {
super(uniqueId, type, 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);
}
} }

View File

@ -81,10 +81,8 @@ public class DrmManagerClient {
* *
* @param client DrmManagerClient instance * @param client DrmManagerClient instance
* @param event instance which wraps type and message * @param event instance which wraps type and message
* @param attributes resultant values in key and value pair.
*/ */
public void onEvent(DrmManagerClient client, DrmEvent event, public void onEvent(DrmManagerClient client, DrmEvent event);
HashMap<String, Object> attributes);
} }
/** /**
@ -128,12 +126,17 @@ public class DrmManagerClient {
case ACTION_PROCESS_DRM_INFO: { case ACTION_PROCESS_DRM_INFO: {
final DrmInfo drmInfo = (DrmInfo) msg.obj; final DrmInfo drmInfo = (DrmInfo) msg.obj;
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo); DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status); attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
event = new DrmEvent(mUniqueId, getEventType(status.infoType), null); attributes.put(DrmEvent.DRM_INFO_OBJECT, drmInfo);
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
event = new DrmEvent(mUniqueId,
getEventType(status.infoType), null, attributes);
} else { } else {
int infoType = (null != status) ? status.infoType : drmInfo.getInfoType(); int infoType = (null != status) ? status.infoType : drmInfo.getInfoType();
error = new DrmErrorEvent(mUniqueId, getErrorType(infoType), null); error = new DrmErrorEvent(mUniqueId,
getErrorType(infoType), null, attributes);
} }
break; break;
} }
@ -151,7 +154,7 @@ public class DrmManagerClient {
return; return;
} }
if (null != mOnEventListener && null != event) { if (null != mOnEventListener && null != event) {
mOnEventListener.onEvent(DrmManagerClient.this, event, attributes); mOnEventListener.onEvent(DrmManagerClient.this, event);
} }
if (null != mOnErrorListener && null != error) { if (null != mOnErrorListener && null != error) {
mOnErrorListener.onError(DrmManagerClient.this, error); mOnErrorListener.onError(DrmManagerClient.this, error);