Methods Summary |
---|
private native DrmInfo | _acquireDrmInfo(int uniqueId, DrmInfoRequest drmInfoRequest)
|
private native boolean | _canHandle(int uniqueId, java.lang.String path, java.lang.String mimeType)
|
private native int | _checkRightsStatus(int uniqueId, java.lang.String path, int action)
|
private native DrmConvertedStatus | _closeConvertSession(int uniqueId, int convertId)
|
private native DrmConvertedStatus | _convertData(int uniqueId, int convertId, byte[] inputData)
|
private native DrmSupportInfo[] | _getAllSupportInfo(int uniqueId)
|
private native android.content.ContentValues | _getConstraints(int uniqueId, java.lang.String path, int usage)
|
private native int | _getDrmObjectType(int uniqueId, java.lang.String path, java.lang.String mimeType)
|
private native android.content.ContentValues | _getMetadata(int uniqueId, java.lang.String path)
|
private native java.lang.String | _getOriginalMimeType(int uniqueId, java.lang.String path, java.io.FileDescriptor fd)
|
private native int | _initialize()
|
private native void | _installDrmEngine(int uniqueId, java.lang.String engineFilepath)
|
private native int | _openConvertSession(int uniqueId, java.lang.String mimeType)
|
private native DrmInfoStatus | _processDrmInfo(int uniqueId, DrmInfo drmInfo)
|
private native void | _release(int uniqueId)
|
private native int | _removeAllRights(int uniqueId)
|
private native int | _removeRights(int uniqueId, java.lang.String path)
|
private native int | _saveRights(int uniqueId, DrmRights drmRights, java.lang.String rightsPath, java.lang.String contentPath)
|
private native void | _setListeners(int uniqueId, java.lang.Object weak_this)
|
public DrmInfo | acquireDrmInfo(DrmInfoRequest drmInfoRequest)Retrieves information for registering, unregistering, or acquiring rights.
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
}
return _acquireDrmInfo(mUniqueId, drmInfoRequest);
|
public int | acquireRights(DrmInfoRequest drmInfoRequest)Processes a given {@link DrmInfoRequest} and returns the rights information asynchronously.
This is a utility method that consists of an
{@link #acquireDrmInfo(DrmInfoRequest) acquireDrmInfo()} and a
{@link #processDrmInfo(DrmInfo) processDrmInfo()} method call. This utility method can be
used only if the selected DRM plug-in (agent) supports this sequence of calls. Some DRM
agents, such as OMA, do not support this utility method, in which case an application must
invoke {@link #acquireDrmInfo(DrmInfoRequest) acquireDrmInfo()} and
{@link #processDrmInfo(DrmInfo) processDrmInfo()} separately.
DrmInfo drmInfo = acquireDrmInfo(drmInfoRequest);
if (null == drmInfo) {
return ERROR_UNKNOWN;
}
return processDrmInfo(drmInfo);
|
public boolean | canHandle(java.lang.String path, java.lang.String mimeType)Checks whether the given MIME type or path can be handled.
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
throw new IllegalArgumentException("Path or the mimetype should be non null");
}
return _canHandle(mUniqueId, path, mimeType);
|
public boolean | canHandle(android.net.Uri uri, java.lang.String mimeType)Checks whether the given MIME type or URI can be handled.
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
throw new IllegalArgumentException("Uri or the mimetype should be non null");
}
return canHandle(convertUriToPath(uri), mimeType);
|
public int | checkRightsStatus(java.lang.String path)Checks whether the given content has valid rights.
return checkRightsStatus(path, DrmStore.Action.DEFAULT);
|
public int | checkRightsStatus(android.net.Uri uri)Check whether the given content has valid rights.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Given uri is not valid");
}
return checkRightsStatus(convertUriToPath(uri));
|
public int | checkRightsStatus(java.lang.String path, int action)Checks whether the given rights-protected content has valid rights for the specified
{@link DrmStore.Action}.
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
throw new IllegalArgumentException("Given path or action is not valid");
}
return _checkRightsStatus(mUniqueId, path, action);
|
public int | checkRightsStatus(android.net.Uri uri, int action)Checks whether the given rights-protected content has valid rights for the specified
{@link DrmStore.Action}.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Given uri is not valid");
}
return checkRightsStatus(convertUriToPath(uri), action);
|
public DrmConvertedStatus | closeConvertSession(int convertId)Informs the DRM plug-in (agent) that there is no more data to convert or that an error
has occurred. Upon successful conversion of the data, the DRM agent will provide an offset
value indicating where the header and body signature should be added. Appending the
signature is necessary to protect the integrity of the converted file.
return _closeConvertSession(mUniqueId, convertId);
|
public DrmConvertedStatus | convertData(int convertId, byte[] inputData)Converts the input data (content) that is part of a rights-protected file. The converted
data and status is returned in a {@link DrmConvertedStatus} object. This method should be
called each time there is a new block of data received by the application.
if (null == inputData || 0 >= inputData.length) {
throw new IllegalArgumentException("Given inputData should be non null");
}
return _convertData(mUniqueId, convertId, inputData);
|
private java.lang.String | convertUriToPath(android.net.Uri uri)This method expects uri in the following format
content://media// (or)
file://sdcard/test.mp4
http://test.com/test.mp4
Here shall be "video" or "audio" or "images"
the index of the content in given table
String path = null;
if (null != uri) {
String scheme = uri.getScheme();
if (null == scheme || scheme.equals("") ||
scheme.equals(ContentResolver.SCHEME_FILE)) {
path = uri.getPath();
} else if (scheme.equals("http")) {
path = uri.toString();
} else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
Cursor cursor = null;
try {
cursor = mContext.getContentResolver().query(uri, projection, null,
null, null);
if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
throw new IllegalArgumentException("Given Uri could not be found" +
" in media store");
}
int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
path = cursor.getString(pathIndex);
} catch (SQLiteException e) {
throw new IllegalArgumentException("Given Uri is not formatted in a way " +
"so that it can be found in media store.");
} finally {
if (null != cursor) {
cursor.close();
}
}
} else {
throw new IllegalArgumentException("Given Uri scheme is not supported");
}
}
return path;
|
private void | createEventThreads()
if (mEventHandler == null && mInfoHandler == null) {
mInfoThread = new HandlerThread("DrmManagerClient.InfoHandler");
mInfoThread.start();
mInfoHandler = new InfoHandler(mInfoThread.getLooper());
mEventThread = new HandlerThread("DrmManagerClient.EventHandler");
mEventThread.start();
mEventHandler = new EventHandler(mEventThread.getLooper());
}
|
private void | createListeners()
_setListeners(mUniqueId, new WeakReference<DrmManagerClient>(this));
|
protected void | finalize()
try {
if (mCloseGuard != null) {
mCloseGuard.warnIfOpen();
}
release();
} finally {
super.finalize();
}
|
public java.lang.String[] | getAvailableDrmEngines()Retrieves information about all the DRM plug-ins (agents) that are registered with
the DRM framework.
DrmSupportInfo[] supportInfos = _getAllSupportInfo(mUniqueId);
ArrayList<String> descriptions = new ArrayList<String>();
for (int i = 0; i < supportInfos.length; i++) {
descriptions.add(supportInfos[i].getDescriprition());
}
String[] drmEngines = new String[descriptions.size()];
return descriptions.toArray(drmEngines);
|
public android.content.ContentValues | getConstraints(android.net.Uri uri, int action)Retrieves constraint information for rights-protected content.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Uri should be non null");
}
return getConstraints(convertUriToPath(uri), action);
|
public android.content.ContentValues | getConstraints(java.lang.String path, int action)Retrieves constraint information for rights-protected content.
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
throw new IllegalArgumentException("Given usage or path is invalid/null");
}
return _getConstraints(mUniqueId, path, action);
|
public int | getDrmObjectType(java.lang.String path, java.lang.String mimeType)Retrieves the type of rights-protected object (for example, content object, rights
object, and so on) using the specified path or MIME type. At least one parameter must
be specified to retrieve the DRM object type.
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
throw new IllegalArgumentException("Path or the mimetype should be non null");
}
return _getDrmObjectType(mUniqueId, path, mimeType);
|
public int | getDrmObjectType(android.net.Uri uri, java.lang.String mimeType)Retrieves the type of rights-protected object (for example, content object, rights
object, and so on) using the specified URI or MIME type. At least one parameter must
be specified to retrieve the DRM object type.
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
throw new IllegalArgumentException("Uri or the mimetype should be non null");
}
String path = "";
try {
path = convertUriToPath(uri);
} catch (Exception e) {
// Even uri is invalid the mimetype shall be valid, so allow to proceed further.
Log.w(TAG, "Given Uri could not be found in media store");
}
return getDrmObjectType(path, mimeType);
|
private int | getErrorType(int infoType)
int error = -1;
switch (infoType) {
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
error = DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED;
break;
}
return error;
|
private int | getEventType(int infoType)
int eventType = -1;
switch (infoType) {
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
eventType = DrmEvent.TYPE_DRM_INFO_PROCESSED;
break;
}
return eventType;
|
public android.content.ContentValues | getMetadata(java.lang.String path)Retrieves metadata information for rights-protected content.
if (null == path || path.equals("")) {
throw new IllegalArgumentException("Given path is invalid/null");
}
return _getMetadata(mUniqueId, path);
|
public android.content.ContentValues | getMetadata(android.net.Uri uri)Retrieves metadata information for rights-protected content.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Uri should be non null");
}
return getMetadata(convertUriToPath(uri));
|
public java.lang.String | getOriginalMimeType(java.lang.String path)Retrieves the MIME type embedded in the original content.
if (null == path || path.equals("")) {
throw new IllegalArgumentException("Given path should be non null");
}
String mime = null;
FileInputStream is = null;
try {
FileDescriptor fd = null;
File file = new File(path);
if (file.exists()) {
is = new FileInputStream(file);
fd = is.getFD();
}
mime = _getOriginalMimeType(mUniqueId, path, fd);
} catch (IOException ioe) {
} finally {
if (is != null) {
try {
is.close();
} catch(IOException e) {}
}
}
return mime;
|
public java.lang.String | getOriginalMimeType(android.net.Uri uri)Retrieves the MIME type embedded in the original content.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Given uri is not valid");
}
return getOriginalMimeType(convertUriToPath(uri));
|
public void | installDrmEngine(java.lang.String engineFilePath)Installs a new DRM plug-in (agent) at runtime.
if (null == engineFilePath || engineFilePath.equals("")) {
throw new IllegalArgumentException(
"Given engineFilePath: "+ engineFilePath + "is not valid");
}
_installDrmEngine(mUniqueId, engineFilePath);
|
public static void | notify(java.lang.Object thisReference, int uniqueId, int infoType, java.lang.String message){@hide}
DrmManagerClient instance = (DrmManagerClient)((WeakReference)thisReference).get();
if (null != instance && null != instance.mInfoHandler) {
Message m = instance.mInfoHandler.obtainMessage(
InfoHandler.INFO_EVENT_TYPE, uniqueId, infoType, message);
instance.mInfoHandler.sendMessage(m);
}
|
public int | openConvertSession(java.lang.String mimeType)Initiates a new conversion session. An application must initiate a conversion session
with this method each time it downloads a rights-protected file that needs to be converted.
This method applies only to forward-locking (copy protection) DRM schemes.
if (null == mimeType || mimeType.equals("")) {
throw new IllegalArgumentException("Path or the mimeType should be non null");
}
return _openConvertSession(mUniqueId, mimeType);
|
public int | processDrmInfo(DrmInfo drmInfo)Processes the given DRM information based on the information type.
if (null == drmInfo || !drmInfo.isValid()) {
throw new IllegalArgumentException("Given drmInfo is invalid/null");
}
int result = ERROR_UNKNOWN;
if (null != mEventHandler) {
Message msg = mEventHandler.obtainMessage(ACTION_PROCESS_DRM_INFO, drmInfo);
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
}
return result;
|
public void | release()Releases resources associated with the current session of DrmManagerClient.
It is considered good practice to call this method when the {@link DrmManagerClient} object
is no longer needed in your application. After release() is called,
{@link DrmManagerClient} is no longer usable since it has lost all of its required resource.
if (mReleased) return;
mReleased = true;
if (mEventHandler != null) {
mEventThread.quit();
mEventThread = null;
}
if (mInfoHandler != null) {
mInfoThread.quit();
mInfoThread = null;
}
mEventHandler = null;
mInfoHandler = null;
mOnEventListener = null;
mOnInfoListener = null;
mOnErrorListener = null;
_release(mUniqueId);
mCloseGuard.close();
|
public int | removeAllRights()Removes all the rights information of every DRM plug-in (agent) associated with
the DRM framework. Will be used during a master reset.
int result = ERROR_UNKNOWN;
if (null != mEventHandler) {
Message msg = mEventHandler.obtainMessage(ACTION_REMOVE_ALL_RIGHTS);
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
}
return result;
|
public int | removeRights(java.lang.String path)Removes the rights associated with the given rights-protected content.
if (null == path || path.equals("")) {
throw new IllegalArgumentException("Given path should be non null");
}
return _removeRights(mUniqueId, path);
|
public int | removeRights(android.net.Uri uri)Removes the rights associated with the given rights-protected content.
if (null == uri || Uri.EMPTY == uri) {
throw new IllegalArgumentException("Given uri is not valid");
}
return removeRights(convertUriToPath(uri));
|
public int | saveRights(DrmRights drmRights, java.lang.String rightsPath, java.lang.String contentPath)Saves rights to a specified path and associates that path with the content path.
Note: For OMA or WM-DRM, rightsPath and
contentPath can be null.
if (null == drmRights || !drmRights.isValid()) {
throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
}
if (null != rightsPath && !rightsPath.equals("")) {
DrmUtils.writeToFile(rightsPath, drmRights.getData());
}
return _saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
public synchronized void | setOnErrorListener(android.drm.DrmManagerClient$OnErrorListener errorListener)Registers an {@link DrmManagerClient.OnErrorListener} callback, which is invoked when
the DRM framework sends error information.
mOnErrorListener = errorListener;
if (null != errorListener) {
createListeners();
}
|
public synchronized void | setOnEventListener(android.drm.DrmManagerClient$OnEventListener eventListener)Registers an {@link DrmManagerClient.OnEventListener} callback, which is invoked when the
DRM framework sends information about DRM processing.
mOnEventListener = eventListener;
if (null != eventListener) {
createListeners();
}
|
public synchronized void | setOnInfoListener(android.drm.DrmManagerClient$OnInfoListener infoListener)Registers an {@link DrmManagerClient.OnInfoListener} callback, which is invoked when the
DRM framework sends status or warning information during registration or rights acquisition.
mOnInfoListener = infoListener;
if (null != infoListener) {
createListeners();
}
|