Add support to query through DrmInfoRequest::TYPE_REGISTRATION_INFO to check if a device is provisioned.
Includes Widevine lib version: 4.5.0.5781 AES BR_PYTHON2 Change-Id: Id5e673b97e3ec80532e2d7f42aae687adfecc765 related-to-bug: 5152997
This commit is contained in:
7
proprietary/samplePlayer/res/layout/notprovisioned.xml
Normal file
7
proprietary/samplePlayer/res/layout/notprovisioned.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<TextView android:id="@+id/textView1" android:text="@string/not_provisioned" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="24pt" android:background="@drawable/background3" android:gravity="center"></TextView>
|
||||
</LinearLayout>
|
||||
@@ -2,6 +2,7 @@
|
||||
<resources>
|
||||
<string name="app_name">Widevine Demo</string>
|
||||
<string name="no_content">No Content Found</string>
|
||||
<string name="not_provisioned">Device Not Provisioned</string>
|
||||
<string name="play">Play</string>
|
||||
<string name="stop">Stop</string>
|
||||
<string name="constraints">Constraints</string>
|
||||
|
||||
@@ -54,7 +54,11 @@ public class VideoPlayerView extends Activity {
|
||||
width = display.getWidth();
|
||||
context = this;
|
||||
contentView = createView();
|
||||
setContentView(contentView);
|
||||
if (drm.isProvisionedDevice()) {
|
||||
setContentView(contentView);
|
||||
} else {
|
||||
setContentView(R.layout.notprovisioned);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,6 +95,7 @@ public class VideoPlayerView extends Activity {
|
||||
|
||||
logs = new TextView(this);
|
||||
drm.setLogListener(drmLogListener);
|
||||
drm.registerPortal(WidevineDrm.Settings.PORTAL_NAME);
|
||||
|
||||
scrollView = new ScrollView(this);
|
||||
scrollView.addView(logs);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
package com.widevine.demo;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
|
||||
//import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -13,6 +15,7 @@ import android.content.Context;
|
||||
|
||||
import android.drm.DrmErrorEvent;
|
||||
import android.drm.DrmEvent;
|
||||
import android.drm.DrmInfo;
|
||||
import android.drm.DrmInfoEvent;
|
||||
import android.drm.DrmInfoRequest;
|
||||
import android.drm.DrmManagerClient;
|
||||
@@ -25,6 +28,9 @@ public class WidevineDrm {
|
||||
}
|
||||
|
||||
private WidevineDrmLogEventListener logEventListener;
|
||||
private final static long DEVICE_IS_PROVISIONED = 0;
|
||||
private final static long DEVICE_IS_NOT_PROVISIONED = 1;
|
||||
private long mWVDrmInfoRequestStatusKey = DEVICE_IS_PROVISIONED;
|
||||
|
||||
public StringBuffer logBuffer = new StringBuffer();
|
||||
|
||||
@@ -125,6 +131,23 @@ public class WidevineDrm {
|
||||
return rightsAcquisitionInfo;
|
||||
}
|
||||
|
||||
public boolean isProvisionedDevice() {
|
||||
return (mWVDrmInfoRequestStatusKey == DEVICE_IS_PROVISIONED);
|
||||
}
|
||||
|
||||
public void registerPortal(String portal) {
|
||||
|
||||
DrmInfoRequest request = new DrmInfoRequest(DrmInfoRequest.TYPE_REGISTRATION_INFO,
|
||||
Settings.WIDEVINE_MIME_TYPE);
|
||||
request.put("WVPortalKey", portal);
|
||||
DrmInfo response = mDrmManager.acquireDrmInfo(request);
|
||||
|
||||
String drmInfoRequestStatusKey = (String)response.get("WVDrmInfoRequestStatusKey");
|
||||
if (null != drmInfoRequestStatusKey && !drmInfoRequestStatusKey.equals("")) {
|
||||
mWVDrmInfoRequestStatusKey = Long.parseLong(drmInfoRequestStatusKey);
|
||||
}
|
||||
}
|
||||
|
||||
public int acquireRights(String assetUri) {
|
||||
|
||||
int rights = mDrmManager.acquireRights(getDrmInfoRequest(assetUri));
|
||||
|
||||
Reference in New Issue
Block a user