diff options
author | Jeff Tinker <jtinker@google.com> | 2013-04-17 14:24:40 -0700 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2013-04-17 16:46:49 -0700 |
commit | f7568b5ee96b3d80721c76ab3d47f1368a99bf98 (patch) | |
tree | 1bd4122ea66af5efe05aa5cff81cd5e3f7339952 | |
parent | e1c76bebef41d362369627ed0c06ea9a01c6bddb (diff) | |
download | frameworks_base-f7568b5ee96b3d80721c76ab3d47f1368a99bf98.zip frameworks_base-f7568b5ee96b3d80721c76ab3d47f1368a99bf98.tar.gz frameworks_base-f7568b5ee96b3d80721c76ab3d47f1368a99bf98.tar.bz2 |
Improve error handling for DRM errors reported by plugins
Change-Id: I25df78f16379b32c54189949daa3ab9c91187375
related-to-bug: 8621516
-rw-r--r-- | media/jni/android_media_MediaDrm.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index d9d466e..d1b499e 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -30,6 +30,7 @@ #include <media/IDrm.h> #include <media/IMediaPlayerService.h> #include <media/stagefright/foundation/ADebug.h> +#include <media/stagefright/MediaErrors.h> namespace android { @@ -191,10 +192,62 @@ void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra, static bool throwExceptionAsNecessary( JNIEnv *env, status_t err, const char *msg = NULL) { + const char *drmMessage = NULL; + + switch(err) { + case ERROR_DRM_UNKNOWN: + drmMessage = "General DRM error"; + break; + case ERROR_DRM_NO_LICENSE: + drmMessage = "No license"; + break; + case ERROR_DRM_LICENSE_EXPIRED: + drmMessage = "License expired"; + break; + case ERROR_DRM_SESSION_NOT_OPENED: + drmMessage = "Session not opened"; + break; + case ERROR_DRM_DECRYPT_UNIT_NOT_INITIALIZED: + drmMessage = "Not initialized"; + break; + case ERROR_DRM_DECRYPT: + drmMessage = "Decrypt error"; + break; + case ERROR_DRM_CANNOT_HANDLE: + drmMessage = "Unsupported scheme or data format"; + break; + case ERROR_DRM_TAMPER_DETECTED: + drmMessage = "Invalid state"; + break; + case ERROR_DRM_NOT_PROVISIONED: + drmMessage = "Not provisioned"; + break; + case ERROR_DRM_DEVICE_REVOKED: + drmMessage = "Device revoked"; + break; + default: + break; + } + + String8 vendorMessage; + if (err >= ERROR_DRM_VENDOR_MIN && err <= ERROR_DRM_VENDOR_MAX) { + vendorMessage.format("DRM vendor-defined error: %d", err); + drmMessage = vendorMessage.string(); + } + if (err == BAD_VALUE) { jniThrowException(env, "java/lang/IllegalArgumentException", msg); return true; } else if (err != OK) { + String8 errbuf; + if (drmMessage != NULL) { + if (msg == NULL) { + msg = drmMessage; + } else { + errbuf.format("%s: %s", msg, drmMessage); + msg = errbuf.string(); + } + } jniThrowException(env, "java/lang/IllegalStateException", msg); return true; } |