summaryrefslogtreecommitdiff
path: root/media/jni/android_media_MediaCodec.cpp
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2018-12-12 08:31:22 -0800
committerJeff Tinker <jtinker@google.com>2019-01-11 15:31:04 -0800
commit20594d8b9d98209e973b735c33ccb31c3e36d3d1 (patch)
tree91fab08b13344730fddf149141fcd98f004e4e5c /media/jni/android_media_MediaCodec.cpp
parent1bafe67c7855673c163483bedf8e304b9b75ec44 (diff)
Add additional error conditions to MediaDrm
New codes are being added to handle resource contention, lost session state, frame size too large and insufficient security level for decryption. Also cleans up inconsistent use of tamper detected error where invalid state error should have been used. bug:111504510 bug:111505796 test: cts and gts media test cases Change-Id: Ifa652d31ea151fbdc9faa0dd15b19f885d82b916
Diffstat (limited to 'media/jni/android_media_MediaCodec.cpp')
-rw-r--r--media/jni/android_media_MediaCodec.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index 257860890437..7b07bea3cf1a 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -72,7 +72,10 @@ static struct CryptoErrorCodes {
jint cryptoErrorResourceBusy;
jint cryptoErrorInsufficientOutputProtection;
jint cryptoErrorSessionNotOpened;
+ jint cryptoErrorInsufficientSecurity;
jint cryptoErrorUnsupportedOperation;
+ jint cryptoErrorFrameTooLarge;
+ jint cryptoErrorLostState;
} gCryptoErrorCodes;
static struct CodecActionCodes {
@@ -1005,10 +1008,22 @@ 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_INSUFFICIENT_SECURITY:
+ err = gCryptoErrorCodes.cryptoErrorInsufficientSecurity;
+ defaultMsg = "Required security level is not met";
+ break;
case ERROR_DRM_CANNOT_HANDLE:
err = gCryptoErrorCodes.cryptoErrorUnsupportedOperation;
defaultMsg = "Operation not supported in this configuration";
break;
+ case ERROR_DRM_FRAME_TOO_LARGE:
+ err = gCryptoErrorCodes.cryptoErrorFrameTooLarge;
+ defaultMsg = "Decrytped frame exceeds size of output buffer";
+ break;
+ case ERROR_DRM_SESSION_LOST_STATE:
+ err = gCryptoErrorCodes.cryptoErrorLostState;
+ defaultMsg = "Session state was lost, open a new session and retry";
+ break;
default: /* Other negative DRM error codes go out as is. */
break;
}
@@ -1994,11 +2009,26 @@ static void android_media_MediaCodec_native_init(JNIEnv *env) {
gCryptoErrorCodes.cryptoErrorSessionNotOpened =
env->GetStaticIntField(clazz.get(), field);
+ field = env->GetStaticFieldID(clazz.get(), "ERROR_INSUFFICIENT_SECURITY", "I");
+ CHECK(field != NULL);
+ gCryptoErrorCodes.cryptoErrorInsufficientSecurity =
+ env->GetStaticIntField(clazz.get(), field);
+
field = env->GetStaticFieldID(clazz.get(), "ERROR_UNSUPPORTED_OPERATION", "I");
CHECK(field != NULL);
gCryptoErrorCodes.cryptoErrorUnsupportedOperation =
env->GetStaticIntField(clazz.get(), field);
+ field = env->GetStaticFieldID(clazz.get(), "ERROR_FRAME_TOO_LARGE", "I");
+ CHECK(field != NULL);
+ gCryptoErrorCodes.cryptoErrorFrameTooLarge =
+ env->GetStaticIntField(clazz.get(), field);
+
+ field = env->GetStaticFieldID(clazz.get(), "ERROR_LOST_STATE", "I");
+ CHECK(field != NULL);
+ gCryptoErrorCodes.cryptoErrorLostState =
+ 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");