summaryrefslogtreecommitdiffstats
path: root/media/jni
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2014-06-19 13:58:12 -0700
committerJeff Tinker <jtinker@google.com>2014-06-20 13:41:30 -0700
commitd712e1a387f06fedb33d083730d279b26ed5e399 (patch)
treec73c4e1794537af9f14505f7713b50812cfc15f6 /media/jni
parent9285d1bf9c57e5f1da8f8d8ef7a6a38b2f0e4ec3 (diff)
downloadframeworks_base-d712e1a387f06fedb33d083730d279b26ed5e399.zip
frameworks_base-d712e1a387f06fedb33d083730d279b26ed5e399.tar.gz
frameworks_base-d712e1a387f06fedb33d083730d279b26ed5e399.tar.bz2
Add diagnostic error code to MediaDrm IllegalStateExceptions
bug: 13976775 Change-Id: I682dd66a79252a9ee030b3cab5deb350e653e933
Diffstat (limited to 'media/jni')
-rw-r--r--media/jni/android_media_MediaDrm.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index 4fbd2a4..5f27b16 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -110,6 +110,11 @@ struct CertificateFields {
jfieldID certificateData;
};
+struct StateExceptionFields {
+ jmethodID init;
+ jclass classId;
+};
+
struct fields_t {
jfieldID context;
jmethodID post_event;
@@ -121,6 +126,7 @@ struct fields_t {
IteratorFields iterator;
EntryFields entry;
CertificateFields certificate;
+ StateExceptionFields stateException;
jclass certificateClassId;
jclass hashmapClassId;
jclass arraylistClassId;
@@ -212,6 +218,14 @@ void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra,
}
}
+static void throwStateException(JNIEnv *env, const char *msg, status_t err) {
+ ALOGE("Illegal state exception: %s (%d)", msg, err);
+
+ jobject exception = env->NewObject(gFields.stateException.classId,
+ gFields.stateException.init, static_cast<int>(err),
+ env->NewStringUTF(msg));
+ env->Throw(static_cast<jthrowable>(exception));
+}
static bool throwExceptionAsNecessary(
JNIEnv *env, status_t err, const char *msg = NULL) {
@@ -275,8 +289,7 @@ static bool throwExceptionAsNecessary(
msg = errbuf.string();
}
}
- ALOGE("Illegal state exception: %s", msg);
- jniThrowException(env, "java/lang/IllegalStateException", msg);
+ throwStateException(env, msg, err);
return true;
}
return false;
@@ -608,6 +621,10 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) {
FIND_CLASS(clazz, "java/util/ArrayList");
gFields.arraylistClassId = static_cast<jclass>(env->NewGlobalRef(clazz));
+
+ FIND_CLASS(clazz, "android/media/MediaDrm$MediaDrmStateException");
+ GET_METHOD_ID(gFields.stateException.init, clazz, "<init>", "(ILjava/lang/String;)V");
+ gFields.stateException.classId = static_cast<jclass>(env->NewGlobalRef(clazz));
}
static void android_media_MediaDrm_native_setup(