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

Commit 1b51c72e authored by Jeff Tinker's avatar Jeff Tinker
Browse files

Add missing secure stop methods

b/18053197
b/18076411

Change-Id: Ide9ecab2fd2021f3544491f23ae84c394c48ac14
parent 7a0ae7ed
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -572,6 +572,14 @@ public final class MediaDrm {
     */
    public native List<byte[]> getSecureStops();

    /**
     * Access secure stop by secure stop ID.
     *
     * @param ssid - The secure stop ID provided by the license server.
     *
     * @hide - not part of the public API at this time
     */
    public native byte[] getSecureStop(byte[] ssid);

    /**
     * Process the SecureStop server response message ssRelease.  After authenticating
@@ -581,6 +589,12 @@ public final class MediaDrm {
     */
    public native void releaseSecureStops(byte[] ssRelease);

    /**
     * Remove all secure stops without requiring interaction with the server.
     *
     * @hide - not part of the public API at this time
     */
     public native void releaseAllSecureStops();

    /**
     * String property name: identifies the maker of the DRM engine plugin
+42 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,27 @@ static jobject android_media_MediaDrm_getSecureStops(
    return ListOfVectorsToArrayListOfByteArray(env, secureStops);
}

static jbyteArray android_media_MediaDrm_getSecureStop(
    JNIEnv *env, jobject thiz, jbyteArray ssid) {
    sp<IDrm> drm = GetDrm(env, thiz);

    if (drm == NULL) {
        jniThrowException(env, "java/lang/IllegalStateException",
                          "MediaDrm obj is null");
        return NULL;
    }

    Vector<uint8_t> secureStop;

    status_t err = drm->getSecureStop(JByteArrayToVector(env, ssid), secureStop);

    if (throwExceptionAsNecessary(env, err, "Failed to get secure stop")) {
        return NULL;
    }

    return VectorToJByteArray(env, secureStop);
}

static void android_media_MediaDrm_releaseSecureStops(
    JNIEnv *env, jobject thiz, jbyteArray jssRelease) {
    sp<IDrm> drm = GetDrm(env, thiz);
@@ -1020,6 +1041,21 @@ static void android_media_MediaDrm_releaseSecureStops(
    throwExceptionAsNecessary(env, err, "Failed to release secure stops");
}

static void android_media_MediaDrm_releaseAllSecureStops(
    JNIEnv *env, jobject thiz) {
    sp<IDrm> drm = GetDrm(env, thiz);

    if (drm == NULL) {
        jniThrowException(env, "java/lang/IllegalStateException",
                          "MediaDrm obj is null");
        return;
    }

    status_t err = drm->releaseAllSecureStops();

    throwExceptionAsNecessary(env, err, "Failed to release all secure stops");
}

static jstring android_media_MediaDrm_getPropertyString(
    JNIEnv *env, jobject thiz, jstring jname) {
    sp<IDrm> drm = GetDrm(env, thiz);
@@ -1384,9 +1420,15 @@ static JNINativeMethod gMethods[] = {
    { "getSecureStops", "()Ljava/util/List;",
      (void *)android_media_MediaDrm_getSecureStops },

    { "getSecureStop", "([B)[B",
      (void *)android_media_MediaDrm_getSecureStop },

    { "releaseSecureStops", "([B)V",
      (void *)android_media_MediaDrm_releaseSecureStops },

    { "releaseAllSecureStops", "()V",
      (void *)android_media_MediaDrm_releaseAllSecureStops },

    { "getPropertyString", "(Ljava/lang/String;)Ljava/lang/String;",
      (void *)android_media_MediaDrm_getPropertyString },