diff options
author | Jeff Tinker <jtinker@google.com> | 2015-06-19 16:05:11 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-19 16:05:13 +0000 |
commit | 969a06475c18a34fcd1cf181c290d3ef3d0673f7 (patch) | |
tree | b4162d13eb55c174672fff3558ce78a49e98a5b8 /media | |
parent | 1247e48e0262ea9ac807bbd0e0939dc0450cd6ab (diff) | |
parent | 314b7f3af3b253593f45778ba67a519e74829aa4 (diff) | |
download | frameworks_base-969a06475c18a34fcd1cf181c290d3ef3d0673f7.zip frameworks_base-969a06475c18a34fcd1cf181c290d3ef3d0673f7.tar.gz frameworks_base-969a06475c18a34fcd1cf181c290d3ef3d0673f7.tar.bz2 |
Merge "Improve robustness of MediaDrm after mediaserver crash" into mnc-dev
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) { |