From d393216f8a2186eebdb8615c61787ae599c1432f Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Sat, 5 Mar 2016 11:35:20 -0800 Subject: [PATCH] Add error code to MediaCodec.CryptoException Added a code to represent unsupported operations bug: 25929554 Change-Id: Id8bfa092f29de073db19c4d7444f89249ea2cdd5 --- api/current.txt | 1 + api/system-current.txt | 1 + api/test-current.txt | 1 + media/java/android/media/MediaCodec.java | 11 +++++++++++ media/jni/android_media_MediaCodec.cpp | 10 ++++++++++ 5 files changed, 24 insertions(+) diff --git a/api/current.txt b/api/current.txt index 014ae3591a28..977f4cef20dc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -20444,6 +20444,7 @@ package android.media { field public static final int ERROR_NO_KEY = 1; // 0x1 field public static final int ERROR_RESOURCE_BUSY = 3; // 0x3 field public static final int ERROR_SESSION_NOT_OPENED = 5; // 0x5 + field public static final int ERROR_UNSUPPORTED_OPERATION = 6; // 0x6 } public static final class MediaCodec.CryptoInfo { diff --git a/api/system-current.txt b/api/system-current.txt index fc252cef3b88..bc5542036e65 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -21934,6 +21934,7 @@ package android.media { field public static final int ERROR_NO_KEY = 1; // 0x1 field public static final int ERROR_RESOURCE_BUSY = 3; // 0x3 field public static final int ERROR_SESSION_NOT_OPENED = 5; // 0x5 + field public static final int ERROR_UNSUPPORTED_OPERATION = 6; // 0x6 } public static final class MediaCodec.CryptoInfo { diff --git a/api/test-current.txt b/api/test-current.txt index 580af72ad57d..5a5a72ae8142 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -20453,6 +20453,7 @@ package android.media { field public static final int ERROR_NO_KEY = 1; // 0x1 field public static final int ERROR_RESOURCE_BUSY = 3; // 0x3 field public static final int ERROR_SESSION_NOT_OPENED = 5; // 0x5 + field public static final int ERROR_UNSUPPORTED_OPERATION = 6; // 0x6 } public static final class MediaCodec.CryptoInfo { diff --git a/media/java/android/media/MediaCodec.java b/media/java/android/media/MediaCodec.java index 4c6f0e6258f1..c73cad4c1511 100644 --- a/media/java/android/media/MediaCodec.java +++ b/media/java/android/media/MediaCodec.java @@ -2074,6 +2074,16 @@ final public class MediaCodec { */ public static final int ERROR_SESSION_NOT_OPENED = 5; + /** + * This indicates that an operation was attempted that could not be + * supported by the crypto system of the device in its current + * configuration. It may occur when the license policy requires + * device security features that aren't supported by the device, + * or due to an internal error in the crypto system that prevents + * the specified security policy from being met. + */ + public static final int ERROR_UNSUPPORTED_OPERATION = 6; + /** @hide */ @IntDef({ ERROR_NO_KEY, @@ -2081,6 +2091,7 @@ final public class MediaCodec { ERROR_RESOURCE_BUSY, ERROR_INSUFFICIENT_OUTPUT_PROTECTION, ERROR_SESSION_NOT_OPENED, + ERROR_UNSUPPORTED_OPERATION }) @Retention(RetentionPolicy.SOURCE) public @interface CryptoErrorCode {} diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp index d6994b349b27..810996ec79a7 100644 --- a/media/jni/android_media_MediaCodec.cpp +++ b/media/jni/android_media_MediaCodec.cpp @@ -65,6 +65,7 @@ static struct CryptoErrorCodes { jint cryptoErrorResourceBusy; jint cryptoErrorInsufficientOutputProtection; jint cryptoErrorSessionNotOpened; + jint cryptoErrorUnsupportedOperation; } gCryptoErrorCodes; static struct CodecActionCodes { @@ -869,6 +870,10 @@ static void throwCryptoException(JNIEnv *env, status_t err, const char *msg) { err = gCryptoErrorCodes.cryptoErrorSessionNotOpened; defaultMsg = "Attempted to use a closed session"; break; + case ERROR_DRM_CANNOT_HANDLE: + err = gCryptoErrorCodes.cryptoErrorUnsupportedOperation; + defaultMsg = "Operation not supported in this configuration"; + break; default: /* Other negative DRM error codes go out as is. */ break; } @@ -1773,6 +1778,11 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) { gCryptoErrorCodes.cryptoErrorSessionNotOpened = env->GetStaticIntField(clazz.get(), field); + field = env->GetStaticFieldID(clazz.get(), "ERROR_UNSUPPORTED_OPERATION", "I"); + CHECK(field != NULL); + gCryptoErrorCodes.cryptoErrorUnsupportedOperation = + env->GetStaticIntField(clazz.get(), field); + clazz.reset(env->FindClass("android/media/MediaCodec$CodecException")); CHECK(clazz.get() != NULL); field = env->GetStaticFieldID(clazz.get(), "ACTION_TRANSIENT", "I"); -- 2.11.0