Merge "MediaDrm API Updates per api council review" into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index 3b57f18..90179ee 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15730,7 +15730,7 @@
method public void restoreKeys(byte[], byte[]);
method public void setOnEventListener(android.media.MediaDrm.OnEventListener);
method public void setOnExpirationUpdateListener(android.media.MediaDrm.OnExpirationUpdateListener, android.os.Handler);
- method public void setOnKeysChangeListener(android.media.MediaDrm.OnKeysChangeListener, android.os.Handler);
+ method public void setOnKeyStatusChangeListener(android.media.MediaDrm.OnKeyStatusChangeListener, android.os.Handler);
method public void setPropertyByteArray(java.lang.String, byte[]);
method public void setPropertyString(java.lang.String, java.lang.String);
field public static final int EVENT_KEY_EXPIRED = 3; // 0x3
@@ -15738,11 +15738,6 @@
field public static final deprecated int EVENT_PROVISION_REQUIRED = 1; // 0x1
field public static final int EVENT_SESSION_RECLAIMED = 5; // 0x5
field public static final int EVENT_VENDOR_DEFINED = 4; // 0x4
- field public static final int KEY_STATUS_EXPIRED = 1; // 0x1
- field public static final int KEY_STATUS_INTERNAL_ERROR = 4; // 0x4
- field public static final int KEY_STATUS_OUTPUT_NOT_ALLOWED = 2; // 0x2
- field public static final int KEY_STATUS_PENDING = 3; // 0x3
- field public static final int KEY_STATUS_USABLE = 0; // 0x0
field public static final int KEY_TYPE_OFFLINE = 2; // 0x2
field public static final int KEY_TYPE_RELEASE = 3; // 0x3
field public static final int KEY_TYPE_STREAMING = 1; // 0x1
@@ -15751,9 +15746,6 @@
field public static final java.lang.String PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId";
field public static final java.lang.String PROPERTY_VENDOR = "vendor";
field public static final java.lang.String PROPERTY_VERSION = "version";
- field public static final int REQUEST_TYPE_INITIAL = 0; // 0x0
- field public static final int REQUEST_TYPE_RELEASE = 2; // 0x2
- field public static final int REQUEST_TYPE_RENEWAL = 1; // 0x1
}
public final class MediaDrm.CryptoSession {
@@ -15767,11 +15759,19 @@
method public byte[] getData();
method public java.lang.String getDefaultUrl();
method public int getRequestType();
+ field public static final int REQUEST_TYPE_INITIAL = 0; // 0x0
+ field public static final int REQUEST_TYPE_RELEASE = 2; // 0x2
+ field public static final int REQUEST_TYPE_RENEWAL = 1; // 0x1
}
public static final class MediaDrm.KeyStatus {
method public byte[] getKeyId();
method public int getStatusCode();
+ field public static final int STATUS_EXPIRED = 1; // 0x1
+ field public static final int STATUS_INTERNAL_ERROR = 4; // 0x4
+ field public static final int STATUS_OUTPUT_NOT_ALLOWED = 2; // 0x2
+ field public static final int STATUS_PENDING = 3; // 0x3
+ field public static final int STATUS_USABLE = 0; // 0x0
}
public static final class MediaDrm.MediaDrmStateException extends java.lang.IllegalStateException {
@@ -15786,8 +15786,8 @@
method public abstract void onExpirationUpdate(android.media.MediaDrm, byte[], long);
}
- public static abstract interface MediaDrm.OnKeysChangeListener {
- method public abstract void onKeysChange(android.media.MediaDrm, byte[], java.util.List<android.media.MediaDrm.KeyStatus>, boolean);
+ public static abstract interface MediaDrm.OnKeyStatusChangeListener {
+ method public abstract void onKeyStatusChange(android.media.MediaDrm, byte[], java.util.List<android.media.MediaDrm.KeyStatus>, boolean);
}
public static final class MediaDrm.ProvisionRequest {
diff --git a/api/system-current.txt b/api/system-current.txt
index dbe0d4f..97535ce 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -16967,7 +16967,7 @@
method public void restoreKeys(byte[], byte[]);
method public void setOnEventListener(android.media.MediaDrm.OnEventListener);
method public void setOnExpirationUpdateListener(android.media.MediaDrm.OnExpirationUpdateListener, android.os.Handler);
- method public void setOnKeysChangeListener(android.media.MediaDrm.OnKeysChangeListener, android.os.Handler);
+ method public void setOnKeyStatusChangeListener(android.media.MediaDrm.OnKeyStatusChangeListener, android.os.Handler);
method public void setPropertyByteArray(java.lang.String, byte[]);
method public void setPropertyString(java.lang.String, java.lang.String);
method public void unprovisionDevice();
@@ -16976,11 +16976,6 @@
field public static final deprecated int EVENT_PROVISION_REQUIRED = 1; // 0x1
field public static final int EVENT_SESSION_RECLAIMED = 5; // 0x5
field public static final int EVENT_VENDOR_DEFINED = 4; // 0x4
- field public static final int KEY_STATUS_EXPIRED = 1; // 0x1
- field public static final int KEY_STATUS_INTERNAL_ERROR = 4; // 0x4
- field public static final int KEY_STATUS_OUTPUT_NOT_ALLOWED = 2; // 0x2
- field public static final int KEY_STATUS_PENDING = 3; // 0x3
- field public static final int KEY_STATUS_USABLE = 0; // 0x0
field public static final int KEY_TYPE_OFFLINE = 2; // 0x2
field public static final int KEY_TYPE_RELEASE = 3; // 0x3
field public static final int KEY_TYPE_STREAMING = 1; // 0x1
@@ -16989,9 +16984,6 @@
field public static final java.lang.String PROPERTY_DEVICE_UNIQUE_ID = "deviceUniqueId";
field public static final java.lang.String PROPERTY_VENDOR = "vendor";
field public static final java.lang.String PROPERTY_VERSION = "version";
- field public static final int REQUEST_TYPE_INITIAL = 0; // 0x0
- field public static final int REQUEST_TYPE_RELEASE = 2; // 0x2
- field public static final int REQUEST_TYPE_RENEWAL = 1; // 0x1
}
public final class MediaDrm.CryptoSession {
@@ -17005,11 +16997,19 @@
method public byte[] getData();
method public java.lang.String getDefaultUrl();
method public int getRequestType();
+ field public static final int REQUEST_TYPE_INITIAL = 0; // 0x0
+ field public static final int REQUEST_TYPE_RELEASE = 2; // 0x2
+ field public static final int REQUEST_TYPE_RENEWAL = 1; // 0x1
}
public static final class MediaDrm.KeyStatus {
method public byte[] getKeyId();
method public int getStatusCode();
+ field public static final int STATUS_EXPIRED = 1; // 0x1
+ field public static final int STATUS_INTERNAL_ERROR = 4; // 0x4
+ field public static final int STATUS_OUTPUT_NOT_ALLOWED = 2; // 0x2
+ field public static final int STATUS_PENDING = 3; // 0x3
+ field public static final int STATUS_USABLE = 0; // 0x0
}
public static final class MediaDrm.MediaDrmStateException extends java.lang.IllegalStateException {
@@ -17024,8 +17024,8 @@
method public abstract void onExpirationUpdate(android.media.MediaDrm, byte[], long);
}
- public static abstract interface MediaDrm.OnKeysChangeListener {
- method public abstract void onKeysChange(android.media.MediaDrm, byte[], java.util.List<android.media.MediaDrm.KeyStatus>, boolean);
+ public static abstract interface MediaDrm.OnKeyStatusChangeListener {
+ method public abstract void onKeyStatusChange(android.media.MediaDrm, byte[], java.util.List<android.media.MediaDrm.KeyStatus>, boolean);
}
public static final class MediaDrm.ProvisionRequest {
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index acff301..52ba9ec 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -110,10 +110,10 @@
private static final String PERMISSION = android.Manifest.permission.ACCESS_DRM_CERTIFICATES;
private EventHandler mEventHandler;
- private EventHandler mOnKeysChangeEventHandler;
+ private EventHandler mOnKeyStatusChangeEventHandler;
private EventHandler mOnExpirationUpdateEventHandler;
private OnEventListener mOnEventListener;
- private OnKeysChangeListener mOnKeysChangeListener;
+ private OnKeyStatusChangeListener mOnKeyStatusChangeListener;
private OnExpirationUpdateListener mOnExpirationUpdateListener;
private long mNativeContext;
@@ -297,8 +297,8 @@
* @param handler the handler on which the listener should be invoked, or
* null if the listener should be invoked on the calling thread's looper.
*/
- public void setOnKeysChangeListener(
- @Nullable OnKeysChangeListener listener, @Nullable Handler handler) {
+ public void setOnKeyStatusChangeListener(
+ @Nullable OnKeyStatusChangeListener listener, @Nullable Handler handler) {
if (listener != null) {
Looper looper = handler != null ? handler.getLooper() : Looper.myLooper();
if (looper != null) {
@@ -307,14 +307,14 @@
}
}
}
- mOnKeysChangeListener = listener;
+ mOnKeyStatusChangeListener = listener;
}
/**
* Interface definition for a callback to be invoked when the keys in a drm
* session change states.
*/
- public interface OnKeysChangeListener
+ public interface OnKeyStatusChangeListener
{
/**
* Called when the keys in a session change status, such as when the license
@@ -328,64 +328,64 @@
* which may trigger an attempt to resume playback on the media stream
* if it is currently blocked waiting for a key.
*/
- void onKeysChange(
+ void onKeyStatusChange(
@NonNull MediaDrm md, @NonNull byte[] sessionId,
@NonNull List<KeyStatus> keyInformation,
boolean hasNewUsableKey);
}
/**
- * The key is currently usable to decrypt media data
- */
- public static final int KEY_STATUS_USABLE = 0;
-
- /**
- * The key is no longer usable to decrypt media data because its
- * expiration time has passed.
- */
- public static final int KEY_STATUS_EXPIRED = 1;
-
- /**
- * The key is not currently usable to decrypt media data because its
- * output requirements cannot currently be met.
- */
- public static final int KEY_STATUS_OUTPUT_NOT_ALLOWED = 2;
-
- /**
- * The status of the key is not yet known and is being determined.
- * The status will be updated with the actual status when it has
- * been determined.
- */
- public static final int KEY_STATUS_PENDING = 3;
-
- /**
- * The key is not currently usable to decrypt media data because of an
- * internal error in processing unrelated to input parameters. This error
- * is not actionable by an app.
- */
- public static final int KEY_STATUS_INTERNAL_ERROR = 4;
-
- /** @hide */
- @IntDef({
- KEY_STATUS_USABLE,
- KEY_STATUS_EXPIRED,
- KEY_STATUS_OUTPUT_NOT_ALLOWED,
- KEY_STATUS_PENDING,
- KEY_STATUS_INTERNAL_ERROR,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface KeyStatusCode {}
-
- /**
* Defines the status of a key.
* A KeyStatus for each key in a session is provided to the
- * {@link OnKeysChangeListener#onKeysChange}
+ * {@link OnKeyStatusChangeListener#onKeyStatusChange}
* listener.
*/
public static final class KeyStatus {
private final byte[] mKeyId;
private final int mStatusCode;
+ /**
+ * The key is currently usable to decrypt media data
+ */
+ public static final int STATUS_USABLE = 0;
+
+ /**
+ * The key is no longer usable to decrypt media data because its
+ * expiration time has passed.
+ */
+ public static final int STATUS_EXPIRED = 1;
+
+ /**
+ * The key is not currently usable to decrypt media data because its
+ * output requirements cannot currently be met.
+ */
+ public static final int STATUS_OUTPUT_NOT_ALLOWED = 2;
+
+ /**
+ * The status of the key is not yet known and is being determined.
+ * The status will be updated with the actual status when it has
+ * been determined.
+ */
+ public static final int STATUS_PENDING = 3;
+
+ /**
+ * The key is not currently usable to decrypt media data because of an
+ * internal error in processing unrelated to input parameters. This error
+ * is not actionable by an app.
+ */
+ public static final int STATUS_INTERNAL_ERROR = 4;
+
+ /** @hide */
+ @IntDef({
+ STATUS_USABLE,
+ STATUS_EXPIRED,
+ STATUS_OUTPUT_NOT_ALLOWED,
+ STATUS_PENDING,
+ STATUS_INTERNAL_ERROR,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface KeyStatusCode {}
+
KeyStatus(@NonNull byte[] keyId, @KeyStatusCode int statusCode) {
mKeyId = keyId;
mStatusCode = statusCode;
@@ -393,6 +393,9 @@
/**
* Returns the status code for the key
+ * @return one of {@link #STATUS_USABLE}, {@link #STATUS_EXPIRED},
+ * {@link #STATUS_OUTPUT_NOT_ALLOWED}, {@link #STATUS_PENDING}
+ * or {@link #STATUS_INTERNAL_ERROR}.
*/
@KeyStatusCode
public int getStatusCode() { return mStatusCode; }
@@ -484,7 +487,7 @@
private static final int DRM_EVENT = 200;
private static final int EXPIRATION_UPDATE = 201;
- private static final int KEYS_CHANGE = 202;
+ private static final int KEY_STATUS_CHANGE = 202;
private class EventHandler extends Handler
{
@@ -522,8 +525,8 @@
}
return;
- case KEYS_CHANGE:
- if (mOnKeysChangeListener != null) {
+ case KEY_STATUS_CHANGE:
+ if (mOnKeyStatusChangeListener != null) {
if (msg.obj != null && msg.obj instanceof Parcel) {
Parcel parcel = (Parcel)msg.obj;
byte[] sessionId = parcel.createByteArray();
@@ -531,9 +534,9 @@
List<KeyStatus> keyStatusList = keyStatusListFromParcel(parcel);
boolean hasNewUsableKey = (parcel.readInt() != 0);
- Log.i(TAG, "Drm keys change");
- mOnKeysChangeListener.onKeysChange(mMediaDrm, sessionId, keyStatusList,
- hasNewUsableKey);
+ Log.i(TAG, "Drm key status changed");
+ mOnKeyStatusChangeListener.onKeyStatusChange(mMediaDrm, sessionId,
+ keyStatusList, hasNewUsableKey);
}
}
}
@@ -641,30 +644,6 @@
public @interface KeyType {}
/**
- * Key request type is initial license request
- */
- public static final int REQUEST_TYPE_INITIAL = 0;
-
- /**
- * Key request type is license renewal
- */
- public static final int REQUEST_TYPE_RENEWAL = 1;
-
- /**
- * Key request type is license release
- */
- public static final int REQUEST_TYPE_RELEASE = 2;
-
- /** @hide */
- @IntDef({
- REQUEST_TYPE_INITIAL,
- REQUEST_TYPE_RENEWAL,
- REQUEST_TYPE_RELEASE,
- })
- @Retention(RetentionPolicy.SOURCE)
- public @interface RequestType {}
-
- /**
* Contains the opaque data an app uses to request keys from a license server
*/
public static final class KeyRequest {
@@ -672,6 +651,30 @@
private String mDefaultUrl;
private int mRequestType;
+ /**
+ * Key request type is initial license request
+ */
+ public static final int REQUEST_TYPE_INITIAL = 0;
+
+ /**
+ * Key request type is license renewal
+ */
+ public static final int REQUEST_TYPE_RENEWAL = 1;
+
+ /**
+ * Key request type is license release
+ */
+ public static final int REQUEST_TYPE_RELEASE = 2;
+
+ /** @hide */
+ @IntDef({
+ REQUEST_TYPE_INITIAL,
+ REQUEST_TYPE_RENEWAL,
+ REQUEST_TYPE_RELEASE,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface RequestType {}
+
KeyRequest() {}
/**
@@ -707,6 +710,8 @@
/**
* Get the type of the request
+ * @return one of {@link #REQUEST_TYPE_INITIAL},
+ * {@link #REQUEST_TYPE_RENEWAL} or {@link #REQUEST_TYPE_RELEASE}
*/
@RequestType
public int getRequestType() { return mRequestType; }
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index f8146a7..d456dc10 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -99,7 +99,7 @@
struct EventWhat {
jint kWhatDrmEvent;
jint kWhatExpirationUpdate;
- jint kWhatKeysChange;
+ jint kWhatKeyStatusChange;
} gEventWhat;
struct KeyTypes {
@@ -221,7 +221,7 @@
jwhat = gEventWhat.kWhatExpirationUpdate;
break;
case DrmPlugin::kDrmPluginEventKeysChange:
- jwhat = gEventWhat.kWhatKeysChange;
+ jwhat = gEventWhat.kWhatKeyStatusChange;
break;
default:
ALOGE("Invalid event DrmPlugin::EventType %d, ignored", (int)eventType);
@@ -609,8 +609,8 @@
gEventWhat.kWhatDrmEvent = env->GetStaticIntField(clazz, field);
GET_STATIC_FIELD_ID(field, clazz, "EXPIRATION_UPDATE", "I");
gEventWhat.kWhatExpirationUpdate = env->GetStaticIntField(clazz, field);
- GET_STATIC_FIELD_ID(field, clazz, "KEYS_CHANGE", "I");
- gEventWhat.kWhatKeysChange = env->GetStaticIntField(clazz, field);
+ GET_STATIC_FIELD_ID(field, clazz, "KEY_STATUS_CHANGE", "I");
+ gEventWhat.kWhatKeyStatusChange = env->GetStaticIntField(clazz, field);
GET_STATIC_FIELD_ID(field, clazz, "KEY_TYPE_STREAMING", "I");
gKeyTypes.kKeyTypeStreaming = env->GetStaticIntField(clazz, field);
@@ -619,13 +619,6 @@
GET_STATIC_FIELD_ID(field, clazz, "KEY_TYPE_RELEASE", "I");
gKeyTypes.kKeyTypeRelease = env->GetStaticIntField(clazz, field);
- GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_INITIAL", "I");
- gKeyRequestTypes.kKeyRequestTypeInitial = env->GetStaticIntField(clazz, field);
- GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_RENEWAL", "I");
- gKeyRequestTypes.kKeyRequestTypeRenewal = env->GetStaticIntField(clazz, field);
- GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_RELEASE", "I");
- gKeyRequestTypes.kKeyRequestTypeRelease = env->GetStaticIntField(clazz, field);
-
GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_NONE", "I");
gCertificateTypes.kCertificateTypeNone = env->GetStaticIntField(clazz, field);
GET_STATIC_FIELD_ID(field, clazz, "CERTIFICATE_TYPE_X509", "I");
@@ -636,6 +629,13 @@
GET_FIELD_ID(gFields.keyRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;");
GET_FIELD_ID(gFields.keyRequest.requestType, clazz, "mRequestType", "I");
+ GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_INITIAL", "I");
+ gKeyRequestTypes.kKeyRequestTypeInitial = env->GetStaticIntField(clazz, field);
+ GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_RENEWAL", "I");
+ gKeyRequestTypes.kKeyRequestTypeRenewal = env->GetStaticIntField(clazz, field);
+ GET_STATIC_FIELD_ID(field, clazz, "REQUEST_TYPE_RELEASE", "I");
+ gKeyRequestTypes.kKeyRequestTypeRelease = env->GetStaticIntField(clazz, field);
+
FIND_CLASS(clazz, "android/media/MediaDrm$ProvisionRequest");
GET_FIELD_ID(gFields.provisionRequest.data, clazz, "mData", "[B");
GET_FIELD_ID(gFields.provisionRequest.defaultUrl, clazz, "mDefaultUrl", "Ljava/lang/String;");