2

I am developing an application that is meant to playback Widevine protected contents. I am trying to run application on Genymotion virtual Android device. But when I do so application fails to acquire DRM info. Thus following code returns null and application won't proceed further.

    DrmInfoRequest request = new DrmInfoRequest(DrmInfoRequest.TYPE_REGISTRATION_INFO,
    Settings.WIDEVINE_MIME_TYPE);
    request.put("WVPortalKey", portal);
    DrmInfo response = mDrmManager.acquireDrmInfo(request);

I am wondering if genymotion virtual device is cause of the problem. If so, is it possible to configure genymotion such that it works with DRM? Any help would be highly appreciated.

Farooq Zaman
  • 495
  • 1
  • 6
  • 21
  • Were you able to resolve your issue? Did you also provide the server and asset URI for the DrmInfoRequest? e.g. `request.put("WVDRMServerKey", serverKey)` and `request.put("WVAssetURIKey", assetUri);` – D. Pereira Jan 03 '17 at 18:05

4 Answers4

10

The above method doesn't work for me, acquireDrmInfo(request) always return null. After study Exo-player DashTestRunner. I use following method to get the Widevine DRM information.

private static final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);

@TargetApi (Build.VERSION_CODES.JELLY_BEAN_MR2)
@SuppressWarnings("ResourceType")
private void getWVDrmInfo() {
MediaDrm mediaDrm = null;
try {
  mediaDrm = new MediaDrm(WIDEVINE_UUID);

  String vendor = mediaDrm.getPropertyString(MediaDrm.PROPERTY_VENDOR);
  String version = mediaDrm.getPropertyString(MediaDrm.PROPERTY_VERSION);
  String description = mediaDrm.getPropertyString(MediaDrm.PROPERTY_DESCRIPTION);
  String algorithms = mediaDrm.getPropertyString(MediaDrm.PROPERTY_ALGORITHMS);
  String securityLevel = mediaDrm.getPropertyString("securityLevel");
  String systemId = mediaDrm.getPropertyString("systemId");
  String hdcpLevel = mediaDrm.getPropertyString("hdcpLevel");
  String maxHdcpLevel = mediaDrm.getPropertyString("maxHdcpLevel");
  String usageReportingSupport = mediaDrm.getPropertyString("usageReportingSupport");
  String maxNumberOfSessions = mediaDrm.getPropertyString("maxNumberOfSessions");
  String numberOfOpenSessions = mediaDrm.getPropertyString("numberOfOpenSessions");

  mediaDrm.release();
} catch (UnsupportedSchemeException e) {
  e.printStackTrace();
}
}
Jason Zong
  • 121
  • 1
  • 6
3
    private final static long DEVICE_IS_PROVISIONED = 0;
    private final static long DEVICE_IS_NOT_PROVISIONED = 1;
    private final static long DEVICE_IS_PROVISIONED_SD_ONLY = 2;
    private final static String WIDEVINE_MIME_TYPE = "video/wvm";



            public static boolean isDeviceWidevineDRMProvisioned(Context context)
            {
                boolean isDrmAvailable = true;
                int currentapiVersion = android.os.Build.VERSION.SDK_INT;
                if (currentapiVersion < android.os.Build.VERSION_CODES.KITKAT)
                {
                    //As Media DRM Package is available only after KITKAT(API Level 19)
                    isDrmAvailable = false;
                } else
                {
                    DrmManagerClient drmManagerClient = new DrmManagerClient(context);
                    DrmInfoRequest drmInfoRequest = new DrmInfoRequest(DrmInfoRequest.TYPE_REGISTRATION_INFO, WIDEVINE_MIME_TYPE);
                    drmInfoRequest.put("WVPortalKey", "key provided for drm in widevine portal");
                    DrmInfo drmInfo = drmManagerClient.acquireDrmInfo(drmInfoRequest);
                    if (drmInfo != null)
                    {
                        String kWVDrmInfoRequestStatusKey = (String) drmInfo.get("WVDrmInfoRequestStatusKey");
                        String drmPath = (String) drmInfo.get("drm_path");
                        if ((kWVDrmInfoRequestStatusKey != null && Integer.parseInt(kWVDrmInfoRequestStatusKey) == DEVICE_IS_NOT_PROVISIONED) || (drmPath != null && drmPath.length() == 0))
                        {
                            //not supported
                            isDrmAvailable = false;
                        }
                    }
                }
                return isDrmAvailable;
            }
DeepakPanwar
  • 1,389
  • 14
  • 22
  • Only this works for me. May be you could add why are you checking drmPath and what is it for? Thanks a lot! – Alexey O. Apr 26 '17 at 16:27
  • 1
    @AlexeyO. I had viewed this somewhere in google, may be it is for checking if drm path exist (it is the path of drm file when drm plugin initializes in device), If its not there in device, `ie Drm not available. All condition should meet to check drm available. – DeepakPanwar Apr 27 '17 at 05:47
  • 1
    For me `drmInfo` is always `null`. Where can I find my `WVPortalKey`? Not sure what to use here. – wkarl Jun 14 '19 at 10:18
0

You can registrer error listeners on the manager to get a clue of what is happening:

manager.setOnErrorListener(new DrmManagerClient.OnErrorListener() {
    public void onError(DrmManagerClient drmManagerClient, DrmErrorEvent event) {
        Log.i(TAG, "Error Type : " + event.getType());
    }
});
Miguel Beltran
  • 2,132
  • 1
  • 23
  • 36
0

DRM is a hardware feature. It can't be obtained in emulators.

Cecil Paul
  • 595
  • 6
  • 27