diff options
author | Jeff Tinker <jtinker@google.com> | 2015-06-15 17:45:43 -0700 |
---|---|---|
committer | Jeff Tinker <jtinker@google.com> | 2015-06-17 09:32:58 -0700 |
commit | 314b7f3af3b253593f45778ba67a519e74829aa4 (patch) | |
tree | 6131e6a3a099dfaf80bcd86d91da7f22d1f5ef8b /media | |
parent | 2d4dc8db64d0f75e530451acb2c0bea97b9264ff (diff) | |
download | frameworks_base-314b7f3af3b253593f45778ba67a519e74829aa4.zip frameworks_base-314b7f3af3b253593f45778ba67a519e74829aa4.tar.gz frameworks_base-314b7f3af3b253593f45778ba67a519e74829aa4.tar.bz2 |
Improve robustness of MediaDrm after mediaserver crash
If DEAD_OBJECT is returned from binder calls due to
mediaserver crash, throw new MediaDrmResetException.
This allows the app to detect the condition and handle
it properly.
bug: 20614102
Change-Id: Id08b08fb612672fd94383f0470f5fa3f267b944f
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/MediaDrm.java | 21 | ||||
-rw-r--r-- | media/java/android/media/MediaDrmResetException.java | 28 | ||||
-rw-r--r-- | media/jni/android_media_MediaDrm.cpp | 4 |
3 files changed, 49 insertions, 4 deletions
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java index 9acfee2..ab61e2b 100644 --- a/media/java/android/media/MediaDrm.java +++ b/media/java/android/media/MediaDrm.java @@ -89,10 +89,23 @@ import android.util.Log; * encrypted content, the samples returned from the extractor remain encrypted, they * are only decrypted when the samples are delivered to the decoder. * <p> - * MediaDrm methods throw {@link java.lang.IllegalStateException} - * when a method is called on a MediaDrm object that is in an invalid or inoperable - * state. This is typically due to incorrect application API usage, but may also - * be due to an unrecoverable failure in the DRM plugin or security hardware. + * MediaDrm methods throw {@link android.media.MediaDrm.MediaDrmStateException} + * when a method is called on a MediaDrm object that has had an unrecoverable failure + * in the DRM plugin or security hardware. + * {@link android.media.MediaDrm.MediaDrmStateException} extends + * {@link java.lang.IllegalStateException} with the addition of a developer-readable + * diagnostic information string associated with the exception. + * <p> + * In the event of a mediaserver process crash or restart while a MediaDrm object + * is active, MediaDrm methods may throw {@link android.media.MediaDrmResetException}. + * To recover, the app must release the MediaDrm object, then create and initialize + * a new one. + * <p> + * As {@link android.media.MediaDrmResetException} and + * {@link android.media.MediaDrm.MediaDrmStateException} both extend + * {@link java.lang.IllegalStateException}, they should be in an earlier catch() + * block than {@link java.lang.IllegalStateException} if handled separately. + * <p> * <a name="Callbacks"></a> * <h3>Callbacks</h3> * <p>Applications should register for informational events in order diff --git a/media/java/android/media/MediaDrmResetException.java b/media/java/android/media/MediaDrmResetException.java new file mode 100644 index 0000000..3b2da1e --- /dev/null +++ b/media/java/android/media/MediaDrmResetException.java @@ -0,0 +1,28 @@ +/* + * Copyright 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.media; + +/** + * This exception is thrown when the MediaDrm instance has become unusable + * due to a restart of the mediaserver process. To continue, the app must + * release the MediaDrm object, then create and initialize a new one. + */ +public class MediaDrmResetException extends IllegalStateException { + public MediaDrmResetException(String detailMessage) { + super(detailMessage); + } +} diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp index d456dc1..9ec0312 100644 --- a/media/jni/android_media_MediaDrm.cpp +++ b/media/jni/android_media_MediaDrm.cpp @@ -308,6 +308,10 @@ static bool throwExceptionAsNecessary( } else if (err == ERROR_DRM_DEVICE_REVOKED) { jniThrowException(env, "android/media/DeniedByServerException", msg); return true; + } else if (err == DEAD_OBJECT) { + jniThrowException(env, "android/media/MediaDrmResetException", + "mediaserver died"); + return true; } else if (err != OK) { String8 errbuf; if (drmMessage != NULL) { |