Join now - be part of our community!

MediaDrm JNI exception on Sony Bravia 4K

profile.country.GB.title
zevik0123456789
New

MediaDrm JNI exception on Sony Bravia 4K

Hi,

 

I'm getting the following bug on my Bravia TV when widevine DRM is active:

callstack:

"main" prio=10 tid=1 Native | group="main" sCount=1 dsCount=0 obj=0x747ee578 self=0xac905400 | sysTid=12704 nice=-8 cgrp=bg_non_interactive sched=0/0 handle=0xaf5f4534 | state=S schedstat=( 149135440 51696377 378 ) utm=9 stm=5 core=0 HZ=100 | stack=0xbe1e8000-0xbe1ea000 stackSize=8MB | held mutexes=
#00 pc 00000000000484c8 /system/lib/libc.so (__ioctl+8)
#01 pc 000000000001acdf /system/lib/libc.so (ioctl+38)
#02 pc 000000000003cc55 /system/lib/libbinder.so (_ZN7android14IPCThreadState14talkWithDriverEb+168)
#03 pc 000000000003d62f /system/lib/libbinder.so (_ZN7android14IPCThreadState15waitForResponseEPNS_6ParcelEPi+238)
#04 pc 000000000003655d /system/lib/libbinder.so (_ZN7android8BpBinder8transactEjRKNS_6ParcelEPS1_j+36)
#05 pc 000000000008688f /system/lib/libmedia.so (???)
#06 pc 0000000000025341 /system/lib/libmedia_jni.so (_ZN7android4JDrm7MakeDrmEv+76)
#07 pc 0000000000025045 /system/lib/libmedia_jni.so (_ZN7android4JDrm7MakeDrmEPKh+20)
#08 pc 000000000002511f /system/lib/libmedia_jni.so (_ZN7android4JDrmC1EP7_JNIEnvP8_jobjectPKh+134)
#09 pc 0000000000025fe3 /system/lib/libmedia_jni.so (???)
#10 pc 0000000000448151 /data/dalvik-cache/arm/system@framework@boot-framework.oat (Java_android_media_MediaDrm_native_1setup__Ljava_lang_Object_2_3B+116)
at android.media.MediaDrm.native_setup (Native method)
at android.media.MediaDrm.<init> (MediaDrm.java:215)
.
.
.
.
.
.
at android.app.ActivityThread.handleCreateService (ActivityThread.java:3162)
at android.app.ActivityThread.-wrap5 (ActivityThread.java)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1550)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:154)
at android.app.ActivityThread.main (ActivityThread.java:6077)
at java.lang.reflect.Method.invoke! (Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:755)

3 REPLIES 3
profile.country.GB.title
batee5
Specialist

Hi zevik0123456789,

 

Welcome to our community!

 

This is a rather strange thing to get on the TV. Could you provide us with more details of what exactly were you doing on the TV that caused that? If you have some pictures or a video would also be helpful if you could share them.

 

Regards,

Batee5

profile.country.GB.title
zevik0123456789
New

Hi

Thanks for getting back to us.

 

We wrote an Android application, which involves native (C based) code as well.

From our C code, we try to instantiate an Android MediaDrm object, using widevine. In some cases, we see the crash, as forwarded, but we do not know, why this happens. (this code works without any problem on other Android TV’s).

 

Here is our MediaDrm instantiating code from C:

 

    jclass cls_uuid = (*env)->FindClass(env, "java/util/UUID");

    if(!cls_uuid || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "checkHDCP: failed to get class java.util.UUID");

        HANDLE_EXC(env)

        return NULL;

    }

 

    jmethodID uuid_constr = getJNIMethod(env, "java/util/UUID", "<init>", "(JJ)V");

    if(!uuid_constr || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "checkHDCP: failed to get constructor for  java.util.UUID");

        HANDLE_EXC(env)

        return NULL;

    }

 

    //widevine DRM

    jobject cls_uuid_instance = (*env)->NewObject(env, cls_uuid, uuid_constr, 0xEDEF8BA979D64ACE, 0xA3C827DCD51D21ED);

 

    if(!cls_uuid_instance || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "Failed to get class instance java.util.UUID");

        HANDLE_EXC(env)

        return NULL;

    }

 

    jclass cls_drm = (*env)->FindClass(env, "android/media/MediaDrm");

    if(!cls_drm || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "checkHDCP: failed to get class android/media/MediaDrm/");

        HANDLE_EXC(env)

        return NULL;

    }

 

    jmethodID cls_drm_constr = getJNIMethod(env, "android/media/MediaDrm",

                                            "<init>", "(Ljava/util/UUID;)V");

 

    if(!cls_drm_constr || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "Failed to get constructor android.media.MediaDrm");

        HANDLE_EXC(env)

        return NULL;

    }

 

    // WE SUSSPECT, THAT THIS CALL FAILS WHEN INITIATING MEDIADRM object

    jobject cls_drm_instance = (*env)->NewObject(env, cls_drm, cls_drm_constr, cls_uuid_instance);

    if(!cls_drm_instance || (*env)->ExceptionCheck(env)) {

        OP_PRINT(LOG_PRIO_ERROR, "Failed to get class instance android.media.MediaDrm");

        HANDLE_EXC(env)

        return NULL;

    }

 

 

OP_PRINT is simply writing to the Android LOG and HANDLE_EXC is the following definition:

#define HANDLE_EXC(env) if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionDescribe(env); (*env)->ExceptionClear(env); }

 

we would very much appreciate, if you could provide us with some insights.

 

Thanks a lot in advance

 

profile.country.GB.title
batee5
Specialist

Hi zevik0123456789.

 

Our community here is more about Sony products and using them rather than developing software so It's unlikely you'd get an answer or proper help here. I suggest seeking assistance on forums that are more specialised for developers.

 

Regards,

Batee5