Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76cf8fe7 authored by Jeff Tinker's avatar Jeff Tinker Committed by Android (Google) Code Review
Browse files

Merge "Add ability to test supported content types to MediaDrm" into klp-dev

parents f293627f 7cda4913
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -12524,6 +12524,7 @@ package android.media {
    method public android.media.MediaDrm.ProvisionRequest getProvisionRequest();
    method public java.util.List<byte[]> getSecureStops();
    method public static final boolean isCryptoSchemeSupported(java.util.UUID);
    method public static final boolean isCryptoSchemeSupported(java.util.UUID, java.lang.String);
    method public byte[] openSession() throws android.media.NotProvisionedException;
    method public byte[] provideKeyResponse(byte[], byte[]) throws android.media.DeniedByServerException, android.media.NotProvisionedException;
    method public void provideProvisionResponse(byte[]) throws android.media.DeniedByServerException;
+15 −2
Original line number Diff line number Diff line
@@ -108,7 +108,19 @@ public final class MediaDrm {
     * @param uuid The UUID of the crypto scheme.
     */
    public static final boolean isCryptoSchemeSupported(UUID uuid) {
        return isCryptoSchemeSupportedNative(getByteArrayFromUUID(uuid));
        return isCryptoSchemeSupportedNative(getByteArrayFromUUID(uuid), null);
    }

    /**
     * Query if the given scheme identified by its UUID is supported on
     * this device, and whether the drm plugin is able to handle the
     * media container format specified by mimeType.
     * @param uuid The UUID of the crypto scheme.
     * @param mimeType The MIME type of the media container, e.g. "video/mp4"
     *   or "video/webm"
     */
    public static final boolean isCryptoSchemeSupported(UUID uuid, String mimeType) {
        return isCryptoSchemeSupportedNative(getByteArrayFromUUID(uuid), mimeType);
    }

    private static final byte[] getByteArrayFromUUID(UUID uuid) {
@@ -124,7 +136,8 @@ public final class MediaDrm {
        return uuidBytes;
    }

    private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid);
    private static final native boolean isCryptoSchemeSupportedNative(byte[] uuid,
                                                                      String mimeType);

    /**
     * Instantiate a MediaDrm object
+10 −5
Original line number Diff line number Diff line
@@ -348,14 +348,14 @@ void JDrm::notify(DrmPlugin::EventType eventType, int extra, const Parcel *obj)


// static
bool JDrm::IsCryptoSchemeSupported(const uint8_t uuid[16]) {
bool JDrm::IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) {
    sp<IDrm> drm = MakeDrm();

    if (drm == NULL) {
        return false;
    }

    return drm->isCryptoSchemeSupported(uuid);
    return drm->isCryptoSchemeSupported(uuid, mimeType);
}

status_t JDrm::initCheck() const {
@@ -611,7 +611,7 @@ static void android_media_MediaDrm_native_finalize(
}

static jboolean android_media_MediaDrm_isCryptoSchemeSupportedNative(
        JNIEnv *env, jobject thiz, jbyteArray uuidObj) {
    JNIEnv *env, jobject thiz, jbyteArray uuidObj, jstring jmimeType) {

    if (uuidObj == NULL) {
        jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
@@ -628,7 +628,12 @@ static jboolean android_media_MediaDrm_isCryptoSchemeSupportedNative(
        return false;
    }

    return JDrm::IsCryptoSchemeSupported(uuid.array());
    String8 mimeType;
    if (jmimeType != NULL) {
        mimeType = JStringToString8(env, jmimeType);
    }

    return JDrm::IsCryptoSchemeSupported(uuid.array(), mimeType);
}

static jbyteArray android_media_MediaDrm_openSession(
@@ -1212,7 +1217,7 @@ static JNINativeMethod gMethods[] = {
    { "native_finalize", "()V",
      (void *)android_media_MediaDrm_native_finalize },

    { "isCryptoSchemeSupportedNative", "([B)Z",
    { "isCryptoSchemeSupportedNative", "([BLjava/lang/String;)Z",
      (void *)android_media_MediaDrm_isCryptoSchemeSupportedNative },

    { "openSession", "()[B",
+1 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public:
};

struct JDrm : public BnDrmClient {
    static bool IsCryptoSchemeSupported(const uint8_t uuid[16]);
    static bool IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType);

    JDrm(JNIEnv *env, jobject thiz, const uint8_t uuid[16]);