summaryrefslogtreecommitdiffstats
path: root/media/jni
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2013-05-21 12:48:14 -0700
committerJeff Tinker <jtinker@google.com>2013-05-21 12:55:59 -0700
commiteada5376d9c34f77bd3ba86a2ea674e3bde5e961 (patch)
treee1edc0ab12b766296bbb477d33032b0579481f9d /media/jni
parent4c32885c4249be9b0a9e674b96ebacc78152b47e (diff)
downloadframeworks_base-eada5376d9c34f77bd3ba86a2ea674e3bde5e961.zip
frameworks_base-eada5376d9c34f77bd3ba86a2ea674e3bde5e961.tar.gz
frameworks_base-eada5376d9c34f77bd3ba86a2ea674e3bde5e961.tar.bz2
Improve exception error messages to help diagnose app errors
bug: 9072051 Change-Id: I45057951d1a62b1b4a996e85f01601239e1b7161
Diffstat (limited to 'media/jni')
-rw-r--r--media/jni/android_media_MediaDrm.cpp102
1 files changed, 70 insertions, 32 deletions
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index ec88949..3d7784d 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -128,7 +128,8 @@ JNIDrmListener::JNIDrmListener(JNIEnv* env, jobject thiz, jobject weak_thiz)
jclass clazz = env->GetObjectClass(thiz);
if (clazz == NULL) {
ALOGE("Can't find android/media/MediaDrm");
- jniThrowException(env, "java/lang/Exception", NULL);
+ jniThrowException(env, "java/lang/Exception",
+ "Can't find android/media/MediaDrm");
return;
}
mClass = (jclass)env->NewGlobalRef(clazz);
@@ -408,13 +409,15 @@ static KeyedVector<String8, String8> HashMapToKeyedVector(JNIEnv *env, jobject &
if (entry) {
jobject obj = env->CallObjectMethod(entry, gFields.entry.getKey);
if (!env->IsInstanceOf(obj, clazz)) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "HashMap key is not a String");
}
jstring jkey = static_cast<jstring>(obj);
obj = env->CallObjectMethod(entry, gFields.entry.getValue);
if (!env->IsInstanceOf(obj, clazz)) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "HashMap value is not a String");
}
jstring jvalue = static_cast<jstring>(obj);
@@ -486,12 +489,12 @@ static sp<JDrm> setDrm(
static bool CheckSession(JNIEnv *env, const sp<IDrm> &drm, jbyteArray const &jsessionId)
{
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException", "MediaDrm obj is null");
return false;
}
if (jsessionId == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException", "sessionId is null");
return false;
}
return true;
@@ -557,14 +560,15 @@ static void android_media_MediaDrm_native_setup(
jobject weak_this, jbyteArray uuidObj) {
if (uuidObj == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException", "uuid is null");
return;
}
Vector<uint8_t> uuid = JByteArrayToVector(env, uuidObj);
if (uuid.size() != 16) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "invalid UUID size, expected 16 bytes");
return;
}
@@ -604,7 +608,7 @@ static jboolean android_media_MediaDrm_isCryptoSchemeSupportedNative(
jniThrowException(
env,
"java/lang/IllegalArgumentException",
- NULL);
+ "invalid UUID size, expected 16 bytes");
return false;
}
@@ -616,7 +620,8 @@ static jbyteArray android_media_MediaDrm_openSession(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return NULL;
}
@@ -712,7 +717,8 @@ static jbyteArray android_media_MediaDrm_provideKeyResponse(
Vector<uint8_t> sessionId(JByteArrayToVector(env, jsessionId));
if (jresponse == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "key response is null");
return NULL;
}
Vector<uint8_t> response(JByteArrayToVector(env, jresponse));
@@ -729,7 +735,8 @@ static void android_media_MediaDrm_removeKeys(
sp<IDrm> drm = GetDrm(env, thiz);
if (jkeysetId == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "keySetId is null");
return;
}
@@ -788,7 +795,8 @@ static jobject android_media_MediaDrm_getProvisionRequest(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return NULL;
}
@@ -824,12 +832,14 @@ static void android_media_MediaDrm_provideProvisionResponse(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return;
}
if (jresponse == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "provision response is null");
return;
}
@@ -845,7 +855,8 @@ static jobject android_media_MediaDrm_getSecureStops(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return NULL;
}
@@ -865,7 +876,8 @@ static void android_media_MediaDrm_releaseSecureStops(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return;
}
@@ -881,12 +893,14 @@ static jstring android_media_MediaDrm_getPropertyString(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return NULL;
}
if (jname == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property name String is null");
return NULL;
}
@@ -907,12 +921,14 @@ static jbyteArray android_media_MediaDrm_getPropertyByteArray(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return NULL;
}
if (jname == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property name String is null");
return NULL;
}
@@ -933,12 +949,20 @@ static void android_media_MediaDrm_setPropertyString(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return;
}
- if (jname == NULL || jvalue == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ if (jname == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property name String is null");
+ return;
+ }
+
+ if (jvalue == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property value String is null");
return;
}
@@ -955,12 +979,20 @@ static void android_media_MediaDrm_setPropertyByteArray(
sp<IDrm> drm = GetDrm(env, thiz);
if (drm == NULL) {
- jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ jniThrowException(env, "java/lang/IllegalStateException",
+ "MediaDrm obj is null");
return;
}
- if (jname == NULL || jvalue == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ if (jname == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property name String is null");
+ return;
+ }
+
+ if (jvalue == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "property value byte array is null");
return;
}
@@ -983,7 +1015,8 @@ static void android_media_MediaDrm_setCipherAlgorithmNative(
}
if (jalgorithm == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "algorithm String is null");
return;
}
@@ -1006,7 +1039,8 @@ static void android_media_MediaDrm_setMacAlgorithmNative(
}
if (jalgorithm == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "algorithm String is null");
return;
}
@@ -1030,7 +1064,8 @@ static jbyteArray android_media_MediaDrm_encryptNative(
}
if (jkeyId == NULL || jinput == NULL || jiv == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "required argument is null");
return NULL;
}
@@ -1058,7 +1093,8 @@ static jbyteArray android_media_MediaDrm_decryptNative(
}
if (jkeyId == NULL || jinput == NULL || jiv == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "required argument is null");
return NULL;
}
@@ -1085,7 +1121,8 @@ static jbyteArray android_media_MediaDrm_signNative(
}
if (jkeyId == NULL || jmessage == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "required argument is null");
return NULL;
}
@@ -1112,7 +1149,8 @@ static jboolean android_media_MediaDrm_verifyNative(
}
if (jkeyId == NULL || jmessage == NULL || jsignature == NULL) {
- jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ jniThrowException(env, "java/lang/IllegalArgumentException",
+ "required argument is null");
return false;
}