Android APIs
public class

DrmManagerClient

extends Object
java.lang.Object
   ↳ android.drm.DrmManagerClient

Class Overview

The main programming interface for the DRM framework. An application must instantiate this class to access DRM agents through the DRM framework.

Summary

Nested Classes
interface DrmManagerClient.OnErrorListener Interface definition for a callback that receives information about DRM framework errors. 
interface DrmManagerClient.OnEventListener Interface definition for a callback that receives information about DRM processing events. 
interface DrmManagerClient.OnInfoListener Interface definition for a callback that receives status messages and warnings during registration and rights acquisition. 
Constants
int ERROR_NONE Indicates that a request was successful or that no error occurred.
int ERROR_UNKNOWN Indicates that an error occurred and the reason is not known.
Public Constructors
DrmManagerClient(Context context)
Creates a DrmManagerClient.
Public Methods
DrmInfo acquireDrmInfo(DrmInfoRequest drmInfoRequest)
Retrieves information for registering, unregistering, or acquiring rights.
int acquireRights(DrmInfoRequest drmInfoRequest)
Processes a given DrmInfoRequest and returns the rights information asynchronously.
boolean canHandle(Uri uri, String mimeType)
Checks whether the given MIME type or URI can be handled.
boolean canHandle(String path, String mimeType)
Checks whether the given MIME type or path can be handled.
int checkRightsStatus(String path)
Checks whether the given content has valid rights.
int checkRightsStatus(String path, int action)
Checks whether the given rights-protected content has valid rights for the specified DrmStore.Action.
int checkRightsStatus(Uri uri, int action)
Checks whether the given rights-protected content has valid rights for the specified DrmStore.Action.
int checkRightsStatus(Uri uri)
Check whether the given content has valid rights.
DrmConvertedStatus closeConvertSession(int convertId)
Informs the DRM plug-in (agent) that there is no more data to convert or that an error has occurred.
DrmConvertedStatus convertData(int convertId, byte[] inputData)
Converts the input data (content) that is part of a rights-protected file.
String[] getAvailableDrmEngines()
Retrieves information about all the DRM plug-ins (agents) that are registered with the DRM framework.
ContentValues getConstraints(String path, int action)
Retrieves constraint information for rights-protected content.
ContentValues getConstraints(Uri uri, int action)
Retrieves constraint information for rights-protected content.
int getDrmObjectType(Uri uri, 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.
int getDrmObjectType(String path, 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.
ContentValues getMetadata(Uri uri)
Retrieves metadata information for rights-protected content.
ContentValues getMetadata(String path)
Retrieves metadata information for rights-protected content.
String getOriginalMimeType(String path)
Retrieves the MIME type embedded in the original content.
String getOriginalMimeType(Uri uri)
Retrieves the MIME type embedded in the original content.
int openConvertSession(String mimeType)
Initiates a new conversion session.
int processDrmInfo(DrmInfo drmInfo)
Processes the given DRM information based on the information type.
void release()
Releases resources associated with the current session of DrmManagerClient.
int removeAllRights()
Removes all the rights information of every DRM plug-in (agent) associated with the DRM framework.
int removeRights(String path)
Removes the rights associated with the given rights-protected content.
int removeRights(Uri uri)
Removes the rights associated with the given rights-protected content.
int saveRights(DrmRights drmRights, String rightsPath, String contentPath)
Saves rights to a specified path and associates that path with the content path.
void setOnErrorListener(DrmManagerClient.OnErrorListener errorListener)
Registers an DrmManagerClient.OnErrorListener callback, which is invoked when the DRM framework sends error information.
void setOnEventListener(DrmManagerClient.OnEventListener eventListener)
Registers an DrmManagerClient.OnEventListener callback, which is invoked when the DRM framework sends information about DRM processing.
void setOnInfoListener(DrmManagerClient.OnInfoListener infoListener)
Registers an DrmManagerClient.OnInfoListener callback, which is invoked when the DRM framework sends status or warning information during registration or rights acquisition.
Protected Methods
void finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ERROR_NONE

Added in API level 11

Indicates that a request was successful or that no error occurred.

Constant Value: 0 (0x00000000)

public static final int ERROR_UNKNOWN

Added in API level 11

Indicates that an error occurred and the reason is not known.

Constant Value: -2000 (0xfffff830)

Public Constructors

public DrmManagerClient (Context context)

Added in API level 11

Creates a DrmManagerClient.

Parameters
context Context of the caller.

Public Methods

public DrmInfo acquireDrmInfo (DrmInfoRequest drmInfoRequest)

Added in API level 11

Retrieves information for registering, unregistering, or acquiring rights.

Parameters
drmInfoRequest The DrmInfoRequest that specifies the type of DRM information being retrieved.
Returns
DrmInfo A DrmInfo instance.

public int acquireRights (DrmInfoRequest drmInfoRequest)

Added in API level 11

Processes a given DrmInfoRequest and returns the rights information asynchronously.

This is a utility method that consists of an acquireDrmInfo() and a 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 acquireDrmInfo() and processDrmInfo() separately.

Parameters
drmInfoRequest The DrmInfoRequest used to acquire the rights.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

public boolean canHandle (Uri uri, String mimeType)

Added in API level 11

Checks whether the given MIME type or URI can be handled.

Parameters
uri URI for the content to be handled.
mimeType MIME type of the object to be handled
Returns
boolean True if the given MIME type or URI can be handled; false if they cannot be handled.

public boolean canHandle (String path, String mimeType)

Added in API level 11

Checks whether the given MIME type or path can be handled.

Parameters
path Path of the content to be handled.
mimeType MIME type of the object to be handled.
Returns
boolean True if the given MIME type or path can be handled; false if they cannot be handled.

public int checkRightsStatus (String path)

Added in API level 11

Checks whether the given content has valid rights.

Parameters
path Path to the rights-protected content.
Returns
int An int representing the DrmStore.RightsStatus of the content.

public int checkRightsStatus (String path, int action)

Added in API level 11

Checks whether the given rights-protected content has valid rights for the specified DrmStore.Action.

Parameters
path Path to the rights-protected content.
action The DrmStore.Action to perform.
Returns
int An int representing the DrmStore.RightsStatus of the content.

public int checkRightsStatus (Uri uri, int action)

Added in API level 11

Checks whether the given rights-protected content has valid rights for the specified DrmStore.Action.

Parameters
uri URI for the rights-protected content.
action The DrmStore.Action to perform.
Returns
int An int representing the DrmStore.RightsStatus of the content.

public int checkRightsStatus (Uri uri)

Added in API level 11

Check whether the given content has valid rights.

Parameters
uri URI of the rights-protected content.
Returns
int An int representing the DrmStore.RightsStatus of the content.

public DrmConvertedStatus closeConvertSession (int convertId)

Added in API level 11

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.

Parameters
convertId Handle for the conversion session.
Returns
DrmConvertedStatus A DrmConvertedStatus object that contains the status of the data conversion, the converted data, and the offset for the header and body signature.

public DrmConvertedStatus convertData (int convertId, byte[] inputData)

Added in API level 11

Converts the input data (content) that is part of a rights-protected file. The converted data and status is returned in a DrmConvertedStatus object. This method should be called each time there is a new block of data received by the application.

Parameters
convertId Handle for the conversion session.
inputData Input data that needs to be converted.
Returns
DrmConvertedStatus A DrmConvertedStatus object that contains the status of the data conversion, the converted data, and offset for the header and body signature. An application can ignore the offset because it is only relevant to the closeConvertSession() method.

public String[] getAvailableDrmEngines ()

Added in API level 11

Retrieves information about all the DRM plug-ins (agents) that are registered with the DRM framework.

Returns
String[] A String array of DRM plug-in descriptions.

public ContentValues getConstraints (String path, int action)

Added in API level 11

Retrieves constraint information for rights-protected content.

Parameters
path Path to the content from which you are retrieving DRM constraints.
action Action defined in DrmStore.Action.
Returns
ContentValues A ContentValues instance that contains key-value pairs representing the constraints. Null in case of failure. The keys are defined in DrmStore.ConstraintsColumns.

public ContentValues getConstraints (Uri uri, int action)

Added in API level 11

Retrieves constraint information for rights-protected content.

Parameters
uri URI for the content from which you are retrieving DRM constraints.
action Action defined in DrmStore.Action.
Returns
ContentValues A ContentValues instance that contains key-value pairs representing the constraints. Null in case of failure.

public int getDrmObjectType (Uri uri, String mimeType)

Added in API level 11

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.

Parameters
uri URI for the content or null.
mimeType MIME type of the content or null.
Returns
int An int that corresponds to a DrmStore.DrmObjectType.

public int getDrmObjectType (String path, String mimeType)

Added in API level 11

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.

Parameters
path Path to the content or null.
mimeType MIME type of the content or null.
Returns
int An int that corresponds to a DrmStore.DrmObjectType.

public ContentValues getMetadata (Uri uri)

Added in API level 11

Retrieves metadata information for rights-protected content.

Parameters
uri URI for the content from which you are retrieving metadata information.
Returns
ContentValues A ContentValues instance that contains key-value pairs representing the constraints. Null in case of failure.

public ContentValues getMetadata (String path)

Added in API level 11

Retrieves metadata information for rights-protected content.

Parameters
path Path to the content from which you are retrieving metadata information.
Returns
ContentValues A ContentValues instance that contains key-value pairs representing the metadata. Null in case of failure.

public String getOriginalMimeType (String path)

Added in API level 11

Retrieves the MIME type embedded in the original content.

Parameters
path Path to the rights-protected content.
Returns
String The MIME type of the original content, such as video/mpeg.

public String getOriginalMimeType (Uri uri)

Added in API level 11

Retrieves the MIME type embedded in the original content.

Parameters
uri URI of the rights-protected content.
Returns
String MIME type of the original content, such as video/mpeg.

public int openConvertSession (String mimeType)

Added in API level 11

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.

Parameters
mimeType MIME type of the input data packet.
Returns
int A convert ID that is used used to maintain the conversion session.

public int processDrmInfo (DrmInfo drmInfo)

Added in API level 11

Processes the given DRM information based on the information type.

Parameters
drmInfo The DrmInfo to be processed.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

public void release ()

Added in API level 16

Releases resources associated with the current session of DrmManagerClient. It is considered good practice to call this method when the DrmManagerClient object is no longer needed in your application. After release() is called, DrmManagerClient is no longer usable since it has lost all of its required resource.

public int removeAllRights ()

Added in API level 11

Removes all the rights information of every DRM plug-in (agent) associated with the DRM framework. Will be used during a master reset.

Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

public int removeRights (String path)

Added in API level 11

Removes the rights associated with the given rights-protected content.

Parameters
path Path to the rights-protected content.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

public int removeRights (Uri uri)

Added in API level 11

Removes the rights associated with the given rights-protected content.

Parameters
uri URI for the rights-protected content.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

public int saveRights (DrmRights drmRights, String rightsPath, String contentPath)

Added in API level 11

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.

Parameters
drmRights The DrmRights to be saved.
rightsPath File path where rights will be saved.
contentPath File path where content is saved.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.
Throws
IOException If the call failed to save rights information at the given rightsPath.

public void setOnErrorListener (DrmManagerClient.OnErrorListener errorListener)

Added in API level 11

Registers an DrmManagerClient.OnErrorListener callback, which is invoked when the DRM framework sends error information.

Parameters
errorListener Interface definition for the callback.

public void setOnEventListener (DrmManagerClient.OnEventListener eventListener)

Added in API level 11

Registers an DrmManagerClient.OnEventListener callback, which is invoked when the DRM framework sends information about DRM processing.

Parameters
eventListener Interface definition for the callback.

public void setOnInfoListener (DrmManagerClient.OnInfoListener infoListener)

Added in API level 11

Registers an DrmManagerClient.OnInfoListener callback, which is invoked when the DRM framework sends status or warning information during registration or rights acquisition.

Parameters
infoListener Interface definition for the callback.

Protected Methods

protected void finalize ()

Added in API level 11

Invoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.

Note that objects that override finalize are significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicit close method (and implement Closeable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like a BigInteger where typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.

If you must use finalizers, consider at least providing your own ReferenceQueue and having your own thread process that queue.

Unlike constructors, finalizers are not automatically chained. You are responsible for calling super.finalize() yourself.

Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.

Throws
Throwable