List of usage examples for android.media MediaDrm MediaDrm
public MediaDrm(@NonNull UUID uuid) throws UnsupportedSchemeException
From source file:at.amartinz.hardware.drm.BaseDrmInfo.java
private MediaDrm setup() { MediaDrm drm;//from w w w . j a va2 s . c o m try { drm = new MediaDrm(getUuid()); } catch (UnsupportedSchemeException use) { drm = null; } if (drm == null) { return null; } vendor = getProperty(drm, MediaDrm.PROPERTY_VENDOR); version = getProperty(drm, MediaDrm.PROPERTY_VERSION); description = getProperty(drm, MediaDrm.PROPERTY_DESCRIPTION); systemId = getProperty(drm, "systemId"); deviceId = getProperty(drm, MediaDrm.PROPERTY_DEVICE_UNIQUE_ID); algorithms = getProperty(drm, MediaDrm.PROPERTY_ALGORITHMS); algorithms = splitList(algorithms); securityLevel = getProperty(drm, "securityLevel"); hdcpLevel = getProperty(drm, "hdcpLevel"); hdcpLevelMax = getProperty(drm, "maxHdcpLevel"); isUsageReportingSupported = getBooleanProperty(drm, "usageReportingSupport"); sessionNumberMax = getProperty(drm, "maxNumberOfSessions"); sessionNumberOpen = getProperty(drm, "numberOfOpenSessions"); return drm; }
From source file:org.chromium.media.MediaDrmBridge.java
private MediaDrmBridge(UUID schemeUUID, String securityLevel, int nativeMediaDrmBridge) throws android.media.UnsupportedSchemeException { mSchemeUUID = schemeUUID;/*from www.j av a 2 s .c om*/ mMediaDrm = new MediaDrm(schemeUUID); mHandler = new Handler(); mNativeMediaDrmBridge = nativeMediaDrmBridge; mResetDeviceCredentialsPending = false; mMediaDrm.setOnEventListener(new MediaDrmListener()); mMediaDrm.setPropertyString(PRIVACY_MODE, "enable"); String currentSecurityLevel = mMediaDrm.getPropertyString(SECURITY_LEVEL); Log.e(TAG, "Security level: current " + currentSecurityLevel + ", new " + securityLevel); if (!securityLevel.equals(currentSecurityLevel)) mMediaDrm.setPropertyString(SECURITY_LEVEL, securityLevel); }
From source file:mtmo.test.mediadrm.MainActivity.java
private void checkMarlinPluginInfo() { try {// w w w .ja va2s. com MediaDrm mediaDrm = new MediaDrm(Constants.MBB_UUID); String duid = mediaDrm.getPropertyString(Constants.QUERY_NAME_DUID); mLogger.d("duid: " + duid); } catch (UnsupportedSchemeException e) { Toast.makeText(MainActivity.this, "Unsupported Scheme", Toast.LENGTH_LONG).show(); e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } return; }
From source file:mtmo.test.mediadrm.MainActivity.java
private void setupDrmProcessButton(final int appMode) { final Button btnRegistration = (Button) findViewById(R.id.btn_registration); final Button btnSaveLicense = (Button) findViewById(R.id.btn_license); final Button btnDeregistration = (Button) findViewById(R.id.btn_deregistration); final Button btnCheckRights = (Button) findViewById(R.id.btn_check_rights); final Button btnRemoveRights = (Button) findViewById(R.id.btn_remove_rights); final Button btnStatus = (Button) findViewById(R.id.btn_check_regist); if (btnRegistration != null) { btnRegistration.setOnClickListener(new OnClickListener() { @Override//from ww w . ja v a 2 s . c o m public void onClick(View v) { mLogger.enter("requeseted registration..."); final TaskInfo taskInfo = new TaskInfo(TaskType.REGISTRATION, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnSaveLicense != null) { btnSaveLicense.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted getting License..."); final TaskInfo taskInfo = new TaskInfo(TaskType.LICENSE, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnDeregistration != null) { btnDeregistration.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted deregistration..."); final TaskInfo taskInfo = new TaskInfo(TaskType.DEREGISTRATION, mAccountId, mServiceId, mCurrentATKNFilePath); mHandler.post(new TaskStarter(taskInfo)); } }); } if (btnCheckRights != null) { btnCheckRights.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted check License..."); TextView log = (TextView) findViewById(R.id.log); byte[] sessionId = null; MediaDrm mediaDrm = null; byte[] contentData = null; log.setText(""); try { mediaDrm = new MediaDrm(Constants.MBB_UUID); sessionId = mediaDrm.openSession(); switch (appMode) { case Constants.APP_MODE_ABS: ABSContentInfo absContentInfo = getABSContentInfo(); contentData = Utils.readPsshDataFromFile(true); mediaDrm.restoreKeys(sessionId, InitData.getPSSHTableForAndroid(contentData, absContentInfo.getVideoKid())); break; case Constants.APP_MODE_OFFLINE: contentData = Utils.readIPMPDataFromFile(true); mediaDrm.restoreKeys(sessionId, InitData.getIPMPTableForAndroid(contentData)); break; default: Toast.makeText(mContext, "Unknown App Mode", Toast.LENGTH_SHORT).show(); return; } HashMap<String, String> infoMap = mediaDrm.queryKeyStatus(sessionId); if (infoMap != null && infoMap.size() > 0) { StringBuilder sb = new StringBuilder(); Iterator<String> iterator = infoMap.keySet().iterator(); log.setText(""); Time time = new Time(); while (iterator.hasNext()) { String name = iterator.next(); time.set(Long.valueOf(infoMap.get(name))); mLogger.d("\t" + name + " = " + infoMap.get(name) + " [" + time.format2445() + "]"); sb.append( "\n\t" + name + " = " + infoMap.get(name) + " [" + time.format2445() + "]"); } log.append(sb); } mediaDrm.closeSession(sessionId); sessionId = null; Toast.makeText(MainActivity.this, "queryKeyStatus finished", Toast.LENGTH_LONG).show(); return; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (UnsupportedSchemeException e) { e.printStackTrace(); } catch (NotProvisionedException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } mediaDrm.closeSession(sessionId); sessionId = null; Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } }); } if (btnRemoveRights != null) { btnRemoveRights.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.d("requeseted removing License..."); Toast.makeText(MainActivity.this, "Not implementation", Toast.LENGTH_LONG).show(); } }); } if (btnStatus != null) { btnStatus.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mLogger.enter("Check registration Status..."); RequestParser parser = null; MediaDrm mediaDrm = null; byte[] sessionid = null; HashMap<String, String> optionalParameters = null; try { mediaDrm = new MediaDrm(Constants.MBB_UUID); sessionid = mediaDrm.openSession(); KeyRequest keyRequest = mediaDrm.getKeyRequest(sessionid, InitData.getPropertyTableForAndroid(Constants.QUERY_NAME_REGISTERED_STATE, Utils.accountIdToMarlinFormat(mAccountId), mServiceId), Constants.REQUEST_MIMETYPE_QUERY_PROPERTY, MediaDrm.KEY_TYPE_OFFLINE, optionalParameters); parser = new RequestParser(keyRequest.getData()); if (parser.parse()) { Toast.makeText(MainActivity.this, parser.getProperty(), Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } return; } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (UnsupportedSchemeException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } catch (NotProvisionedException e) { e.printStackTrace(); } Toast.makeText(MainActivity.this, "Failure", Toast.LENGTH_LONG).show(); } }); } }