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

Commit e9b83480 authored by Edwin Wong's avatar Edwin Wong Committed by Android (Google) Code Review
Browse files

Merge "Pass application packagename to drm plugin."

parents c869ebff 4d1d84e8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.annotation.SystemApi;
import android.app.ActivityThread;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -213,7 +214,7 @@ public final class MediaDrm {
         * It's easier to create it here than in C++.
         */
        native_setup(new WeakReference<MediaDrm>(this),
                getByteArrayFromUUID(uuid));
                getByteArrayFromUUID(uuid),  ActivityThread.currentOpPackageName());
    }

    /**
@@ -1307,7 +1308,8 @@ public final class MediaDrm {
    public native final void release();
    private static native final void native_init();

    private native final void native_setup(Object mediadrm_this, byte[] uuid);
    private native final void native_setup(Object mediadrm_this, byte[] uuid,
            String appPackageName);

    private native final void native_finalize();

+16 −7
Original line number Diff line number Diff line
@@ -335,9 +335,10 @@ static sp<IDrm> GetDrm(JNIEnv *env, jobject thiz) {
}

JDrm::JDrm(
        JNIEnv *env, jobject thiz, const uint8_t uuid[16]) {
        JNIEnv *env, jobject thiz, const uint8_t uuid[16],
        const String8 &appPackageName) {
    mObject = env->NewWeakGlobalRef(thiz);
    mDrm = MakeDrm(uuid);
    mDrm = MakeDrm(uuid, appPackageName);
    if (mDrm != NULL) {
        mDrm->setListener(this);
    }
@@ -369,14 +370,14 @@ sp<IDrm> JDrm::MakeDrm() {
}

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

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

    status_t err = drm->createPlugin(uuid);
    status_t err = drm->createPlugin(uuid, appPackageName);

    if (err != OK) {
        return NULL;
@@ -683,7 +684,7 @@ static void android_media_MediaDrm_native_init(JNIEnv *env) {

static void android_media_MediaDrm_native_setup(
        JNIEnv *env, jobject thiz,
        jobject weak_this, jbyteArray uuidObj) {
        jobject weak_this, jbyteArray uuidObj, jstring jappPackageName) {

    if (uuidObj == NULL) {
        jniThrowException(env, "java/lang/IllegalArgumentException", "uuid is null");
@@ -698,7 +699,15 @@ static void android_media_MediaDrm_native_setup(
        return;
    }

    sp<JDrm> drm = new JDrm(env, thiz, uuid.array());
    String8 packageName;
    if (jappPackageName == NULL) {
        jniThrowException(env, "java/lang/IllegalArgumentException",
                          "application package name cannot be null");
        return;
    }

    packageName = JStringToString8(env, jappPackageName);
    sp<JDrm> drm = new JDrm(env, thiz, uuid.array(), packageName);

    status_t err = drm->initCheck();

@@ -1439,7 +1448,7 @@ static const JNINativeMethod gMethods[] = {
    { "release", "()V", (void *)android_media_MediaDrm_release },
    { "native_init", "()V", (void *)android_media_MediaDrm_native_init },

    { "native_setup", "(Ljava/lang/Object;[B)V",
    { "native_setup", "(Ljava/lang/Object;[BLjava/lang/String;)V",
      (void *)android_media_MediaDrm_native_setup },

    { "native_finalize", "()V",
+2 −2
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ public:
struct JDrm : public BnDrmClient {
    static bool IsCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType);

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

    status_t initCheck() const;
    sp<IDrm> getDrm() { return mDrm; }
@@ -61,7 +61,7 @@ private:
    Mutex mLock;

    static sp<IDrm> MakeDrm();
    static sp<IDrm> MakeDrm(const uint8_t uuid[16]);
    static sp<IDrm> MakeDrm(const uint8_t uuid[16], const String8 &appPackageName);

    DISALLOW_EVIL_CONSTRUCTORS(JDrm);
};