MediaDrm: query secure codec requirement w/o session
Bug: 136119370 Test: GtsMediaTestCases Change-Id: I37982e77deff5e2ac21c2d1a5bdf07b1d1f08b15
This commit is contained in:
@@ -21517,6 +21517,8 @@ package android.media {
|
||||
method public void removeKeys(@NonNull byte[]);
|
||||
method public void removeOfflineLicense(@NonNull byte[]);
|
||||
method public void removeSecureStop(@NonNull byte[]);
|
||||
method public boolean requiresSecureDecoder(@NonNull String);
|
||||
method public boolean requiresSecureDecoder(@NonNull String, @android.media.MediaDrm.SecurityLevel int);
|
||||
method public void restoreKeys(@NonNull byte[], @NonNull byte[]);
|
||||
method public void setOnEventListener(@Nullable android.media.MediaDrm.OnEventListener);
|
||||
method public void setOnEventListener(@Nullable android.media.MediaDrm.OnEventListener, @Nullable android.os.Handler);
|
||||
|
||||
@@ -1993,6 +1993,32 @@ public final class MediaDrm implements AutoCloseable {
|
||||
return signRSANative(this, sessionId, algorithm, wrappedKey, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query if the crypto scheme requires the use of a secure decoder
|
||||
* to decode data of the given mime type at the default security level.
|
||||
* The default security level is defined as the highest security level
|
||||
* supported on the device.
|
||||
*
|
||||
* @param mime The mime type of the media data
|
||||
*/
|
||||
public boolean requiresSecureDecoder(@NonNull String mime) {
|
||||
return requiresSecureDecoder(mime, getMaxSecurityLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* Query if the crypto scheme requires the use of a secure decoder
|
||||
* to decode data of the given mime type at the given security level.
|
||||
*
|
||||
* @param level a security level between {@link #SECURITY_LEVEL_SW_SECURE_CRYPTO}
|
||||
* and {@link #SECURITY_LEVEL_HW_SECURE_ALL}. Otherwise the special value
|
||||
* {@link #getMaxSecurityLevel()} is also permitted;
|
||||
* use {@link #getMaxSecurityLevel()} to indicate the maximum security level
|
||||
* supported by the device.
|
||||
* @throws IllegalArgumentException if the requested security level is none of the documented
|
||||
* values for the parameter {@code level}.
|
||||
*/
|
||||
public native boolean requiresSecureDecoder(@NonNull String mime, @SecurityLevel int level);
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
|
||||
@@ -1953,6 +1953,30 @@ static jbyteArray android_media_MediaDrm_signRSANative(
|
||||
return VectorToJByteArray(env, signature);
|
||||
}
|
||||
|
||||
static jboolean android_media_MediaDrm_requiresSecureDecoder(
|
||||
JNIEnv *env, jobject thiz, jstring jmimeType,
|
||||
jint jSecurityLevel) {
|
||||
sp<IDrm> drm = GetDrm(env, thiz);
|
||||
if (!CheckDrm(env, drm)) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
String8 mimeType;
|
||||
if (jmimeType != NULL) {
|
||||
mimeType = JStringToString8(env, jmimeType);
|
||||
}
|
||||
|
||||
DrmPlugin::SecurityLevel securityLevel = jintToSecurityLevel(jSecurityLevel);
|
||||
if (securityLevel == DrmPlugin::kSecurityLevelUnknown) {
|
||||
jniThrowException(env, "java/lang/IllegalArgumentException", "Invalid security level");
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if (securityLevel == DrmPlugin::kSecurityLevelMax) {
|
||||
return drm->requiresSecureDecoder(mimeType.c_str());
|
||||
}
|
||||
return drm->requiresSecureDecoder(mimeType.c_str(), securityLevel);
|
||||
}
|
||||
|
||||
static const JNINativeMethod gMethods[] = {
|
||||
{ "native_release", "()V", (void *)android_media_MediaDrm_native_release },
|
||||
@@ -2075,6 +2099,9 @@ static const JNINativeMethod gMethods[] = {
|
||||
|
||||
{ "getMetricsNative", "()Landroid/os/PersistableBundle;",
|
||||
(void *)android_media_MediaDrm_native_getMetrics },
|
||||
|
||||
{ "requiresSecureDecoder", "(Ljava/lang/String;I)Z",
|
||||
(void *)android_media_MediaDrm_requiresSecureDecoder },
|
||||
};
|
||||
|
||||
int register_android_media_Drm(JNIEnv *env) {
|
||||
|
||||
Reference in New Issue
Block a user