Fix FATAL EXCEPTION when Widevine Classic libraries are not found on device.
On device that does not support Widevince Classic playback, display a Toast pop up to inform users. This prevents a FATAL EXCEPTION from occuring when acquireDrmInfo() returns a null response in the absence of Widevine Classic libs. To test this mode, rename libwvdrm_L?.so in system/vendor/lib and reboot. bug: 28964035 Change-Id: Ib47d4b3419a6395d402c1b78f3cdc8472b0d6946
This commit is contained in:
@@ -19,4 +19,5 @@
|
||||
<string name="drm_server">Drm Server</string>
|
||||
<string name="portal_id">Portal Name</string>
|
||||
<string name="update_button">Update Button</string>
|
||||
<string name="no_classic">This device does not support Widevine classic playback."</string>
|
||||
</resources>
|
||||
|
||||
@@ -19,10 +19,11 @@ import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.util.Log;
|
||||
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Button;
|
||||
import android.widget.Toast;
|
||||
|
||||
public abstract class AssetActivity extends Activity {
|
||||
|
||||
@@ -219,8 +220,16 @@ public abstract class AssetActivity extends Activity {
|
||||
Log.d(TAG, "Click Asset path: " + assetPath);
|
||||
Intent intent = new Intent(context, VideoPlayerView.class);
|
||||
intent.putExtra("com.widevine.demo.Path", assetPath);
|
||||
context.startActivity(intent);
|
||||
|
||||
WidevineDrm drm = new WidevineDrm(context);
|
||||
if (drm.canPlayClassicWidevine()) {
|
||||
context.startActivity(intent);
|
||||
} else {
|
||||
Toast toast = Toast.makeText(
|
||||
context, R.string.no_classic, Toast.LENGTH_SHORT);
|
||||
toast.setGravity(Gravity.CENTER, 0, 0);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -162,19 +162,28 @@ public class WidevineDrm {
|
||||
logMessage("plugin: " + mPluginVersion + "\n");
|
||||
}
|
||||
|
||||
public void registerPortal(String portal) {
|
||||
public boolean canPlayClassicWidevine() {
|
||||
return registerPortal(WidevineDrm.Settings.PORTAL_NAME);
|
||||
}
|
||||
|
||||
public boolean 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);
|
||||
boolean canPlayClassicWidevine = true;
|
||||
try {
|
||||
String drmInfoRequestStatusKey = (String)response.get("WVDrmInfoRequestStatusKey");
|
||||
if (null != drmInfoRequestStatusKey && !drmInfoRequestStatusKey.equals("")) {
|
||||
mWVDrmInfoRequestStatusKey = Long.parseLong(drmInfoRequestStatusKey);
|
||||
}
|
||||
mPluginVersion = (String)response.get("WVDrmInfoRequestVersionKey");
|
||||
} catch (NullPointerException e) {
|
||||
canPlayClassicWidevine = false;
|
||||
}
|
||||
|
||||
mPluginVersion = (String)response.get("WVDrmInfoRequestVersionKey");
|
||||
return canPlayClassicWidevine;
|
||||
}
|
||||
|
||||
public int acquireRights(String assetUri) {
|
||||
|
||||
Reference in New Issue
Block a user