summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJeff Tinker <jtinker@google.com>2013-05-01 15:04:36 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-05-01 15:04:36 -0700
commite0eb0e90630c19808429a9bcdc9ff8dff085d2e8 (patch)
tree76640af3c99b18be37d7b90daca1e4f8add3cba2 /media
parentc3bc1b671e3a4feb4f6d2693199f15e42c256fd4 (diff)
parent9ba564c7e205c4b278be61eec773a90a94451251 (diff)
downloadframeworks_base-e0eb0e90630c19808429a9bcdc9ff8dff085d2e8.zip
frameworks_base-e0eb0e90630c19808429a9bcdc9ff8dff085d2e8.tar.gz
frameworks_base-e0eb0e90630c19808429a9bcdc9ff8dff085d2e8.tar.bz2
am 9ba564c7: am 48f2b548: Merge "MediaDrm API: Add two exceptions to handle error path scenarios" into jb-mr2-dev
* commit '9ba564c7e205c4b278be61eec773a90a94451251': MediaDrm API: Add two exceptions to handle error path scenarios
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/DeniedByServerException.java27
-rw-r--r--media/java/android/media/MediaDrm.java34
-rw-r--r--media/java/android/media/MediaDrmException.java5
-rw-r--r--media/java/android/media/NotProvisionedException.java29
-rw-r--r--media/java/android/media/UnsupportedSchemeException.java27
-rw-r--r--media/jni/android_media_MediaDrm.cpp15
6 files changed, 120 insertions, 17 deletions
diff --git a/media/java/android/media/DeniedByServerException.java b/media/java/android/media/DeniedByServerException.java
new file mode 100644
index 0000000..9c1633a
--- /dev/null
+++ b/media/java/android/media/DeniedByServerException.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 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;
+
+/**
+ * Exception thrown when the provisioning server or key server denies a
+ * certficate or license for a device.
+ */
+public final class DeniedByServerException extends MediaDrmException {
+ public DeniedByServerException(String detailMessage) {
+ super(detailMessage);
+ }
+}
diff --git a/media/java/android/media/MediaDrm.java b/media/java/android/media/MediaDrm.java
index a58fa51..be2d9bc 100644
--- a/media/java/android/media/MediaDrm.java
+++ b/media/java/android/media/MediaDrm.java
@@ -127,11 +127,14 @@ public final class MediaDrm {
private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid);
/**
- * Instantiate a MediaDrm object using opaque, crypto scheme specific
- * data.
+ * Instantiate a MediaDrm object
+ *
* @param uuid The UUID of the crypto scheme.
+ *
+ * @throws UnsupportedSchemeException if the device does not support the
+ * specified scheme UUID
*/
- public MediaDrm(UUID uuid) throws MediaDrmException {
+ public MediaDrm(UUID uuid) throws UnsupportedSchemeException {
Looper looper;
if ((looper = Looper.myLooper()) != null) {
mEventHandler = new EventHandler(this, looper);
@@ -268,8 +271,10 @@ public final class MediaDrm {
/**
* Open a new session with the MediaDrm object. A session ID is returned.
+ *
+ * @throws NotProvisionedException if provisioning is needed
*/
- public native byte[] openSession();
+ public native byte[] openSession() throws NotProvisionedException;
/**
* Close a session on the MediaDrm object that was previously opened
@@ -346,10 +351,14 @@ public final class MediaDrm {
* keys, which are identified by a keySetId.
* @param optionalParameters are included in the key request message to
* allow a client application to provide additional message parameters to the server.
+ *
+ * @throws NotProvisionedException if reprovisioning is needed, due to a
+ * problem with the certifcate
*/
public native KeyRequest getKeyRequest(byte[] scope, byte[] init,
String mimeType, int keyType,
- HashMap<String, String> optionalParameters);
+ HashMap<String, String> optionalParameters)
+ throws NotProvisionedException;
/**
@@ -360,8 +369,15 @@ public final class MediaDrm {
*
* @param sessionId the session ID for the DRM session
* @param response the byte array response from the server
+ *
+ * @throws NotProvisionedException if the response indicates that
+ * reprovisioning is required
+ * @throws DeniedByServerException if the response indicates that the
+ * server rejected the request
*/
- public native byte[] provideKeyResponse(byte[] sessionId, byte[] response);
+ public native byte[] provideKeyResponse(byte[] sessionId, byte[] response)
+ throws NotProvisionedException, DeniedByServerException;
+
/**
* Restore persisted offline keys into a new session. keySetId identifies the
@@ -430,8 +446,12 @@ public final class MediaDrm {
*
* @param response the opaque provisioning response byte array to provide to the
* DRM engine plugin.
+ *
+ * @throws DeniedByServerException if the response indicates that the
+ * server rejected the request
*/
- public native void provideProvisionResponse(byte[] response);
+ public native void provideProvisionResponse(byte[] response)
+ throws DeniedByServerException;
/**
* A means of enforcing limits on the number of concurrent streams per subscriber
diff --git a/media/java/android/media/MediaDrmException.java b/media/java/android/media/MediaDrmException.java
index d6f5ff4..d547574 100644
--- a/media/java/android/media/MediaDrmException.java
+++ b/media/java/android/media/MediaDrmException.java
@@ -17,10 +17,9 @@
package android.media;
/**
- * Exception thrown if MediaDrm object could not be instantiated for
- * whatever reason.
+ * Base class for MediaDrm exceptions
*/
-public final class MediaDrmException extends Exception {
+public class MediaDrmException extends Exception {
public MediaDrmException(String detailMessage) {
super(detailMessage);
}
diff --git a/media/java/android/media/NotProvisionedException.java b/media/java/android/media/NotProvisionedException.java
new file mode 100644
index 0000000..32b8151
--- /dev/null
+++ b/media/java/android/media/NotProvisionedException.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2013 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;
+
+/**
+ * Exception thrown when an operation on a MediaDrm object is attempted
+ * and the device does not have a certificate. The app should obtain and
+ * install a certificate using the MediaDrm provisioning methods then retry
+ * the operation.
+ */
+public final class NotProvisionedException extends MediaDrmException {
+ public NotProvisionedException(String detailMessage) {
+ super(detailMessage);
+ }
+}
diff --git a/media/java/android/media/UnsupportedSchemeException.java b/media/java/android/media/UnsupportedSchemeException.java
new file mode 100644
index 0000000..d7b5d47
--- /dev/null
+++ b/media/java/android/media/UnsupportedSchemeException.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2013 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;
+
+/**
+ * Exception thrown when an attempt is made to construct a MediaDrm object
+ * using a crypto scheme UUID that is not supported by the device
+ */
+public final class UnsupportedSchemeException extends MediaDrmException {
+ public UnsupportedSchemeException(String detailMessage) {
+ super(detailMessage);
+ }
+}
diff --git a/media/jni/android_media_MediaDrm.cpp b/media/jni/android_media_MediaDrm.cpp
index d1b499e..ec88949 100644
--- a/media/jni/android_media_MediaDrm.cpp
+++ b/media/jni/android_media_MediaDrm.cpp
@@ -219,12 +219,6 @@ static bool throwExceptionAsNecessary(
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;
}
@@ -238,6 +232,12 @@ static bool throwExceptionAsNecessary(
if (err == BAD_VALUE) {
jniThrowException(env, "java/lang/IllegalArgumentException", msg);
return true;
+ } else if (err == ERROR_DRM_NOT_PROVISIONED) {
+ jniThrowException(env, "android/media/NotProvisionedException", msg);
+ return true;
+ } else if (err == ERROR_DRM_DEVICE_REVOKED) {
+ jniThrowException(env, "android/media/DeniedByServerException", msg);
+ return true;
} else if (err != OK) {
String8 errbuf;
if (drmMessage != NULL) {
@@ -248,6 +248,7 @@ static bool throwExceptionAsNecessary(
msg = errbuf.string();
}
}
+ ALOGE("Illegal state exception: %s", msg);
jniThrowException(env, "java/lang/IllegalStateException", msg);
return true;
}
@@ -574,7 +575,7 @@ static void android_media_MediaDrm_native_setup(
if (err != OK) {
jniThrowException(
env,
- "android/media/MediaDrmException",
+ "android/media/UnsupportedSchemeException",
"Failed to instantiate drm object.");
return;
}