Skip to content

Most visited

Recently visited

navigation
Added in API level 11

DrmManagerClient

public class DrmManagerClient
extends Object

java.lang.Object
   ↳ android.drm.DrmManagerClient


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.

Inherited methods

From class java.lang.Object

Constants

ERROR_NONE

Added in API level 11
int ERROR_NONE

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

Constant Value: 0 (0x00000000)

ERROR_UNKNOWN

Added in API level 11
int ERROR_UNKNOWN

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

Constant Value: -2000 (0xfffff830)

Public constructors

DrmManagerClient

Added in API level 11
DrmManagerClient (Context context)

Creates a DrmManagerClient.

Parameters
context Context: Context of the caller.

Public methods

acquireDrmInfo

Added in API level 11
DrmInfo acquireDrmInfo (DrmInfoRequest drmInfoRequest)

Retrieves information for registering, unregistering, or acquiring rights.

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

acquireRights

Added in API level 11
int acquireRights (DrmInfoRequest drmInfoRequest)

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 DrmInfoRequest: The DrmInfoRequest used to acquire the rights.
Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

canHandle

Added in API level 11
boolean canHandle (Uri uri, 
                String mimeType)

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

Parameters
uri Uri: URI for the content to be handled.
mimeType String: 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.

canHandle

Added in API level 11
boolean canHandle (String path, 
                String mimeType)

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

Parameters
path String: Path of the content to be handled.
mimeType String: 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.

checkRightsStatus

Added in API level 11
int checkRightsStatus (String path)

Checks whether the given content has valid rights.

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

checkRightsStatus

Added in API level 11
int checkRightsStatus (String path, 
                int action)

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

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

checkRightsStatus

Added in API level 11
int checkRightsStatus (Uri uri, 
                int action)

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

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

checkRightsStatus

Added in API level 11
int checkRightsStatus (Uri uri)

Check whether the given content has valid rights.

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

closeConvertSession

Added in API level 11
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.

Parameters
convertId int: 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.

convertData

Added in API level 11
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 DrmConvertedStatus object. This method should be called each time there is a new block of data received by the application.

Parameters
convertId int: Handle for the conversion session.
inputData byte: 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.

getAvailableDrmEngines

Added in API level 11
String[] getAvailableDrmEngines ()

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.

getConstraints

Added in API level 11
ContentValues getConstraints (String path, 
                int action)

Retrieves constraint information for rights-protected content.

Parameters
path String: Path to the content from which you are retrieving DRM constraints.
action int: 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.

getConstraints

Added in API level 11
ContentValues getConstraints (Uri uri, 
                int action)

Retrieves constraint information for rights-protected content.

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

getDrmObjectType

Added in API level 11
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. At least one parameter must be specified to retrieve the DRM object type.

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

getDrmObjectType

Added in API level 11
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. At least one parameter must be specified to retrieve the DRM object type.

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

getMetadata

Added in API level 11
ContentValues getMetadata (Uri uri)

Retrieves metadata information for rights-protected content.

Parameters
uri 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.

getMetadata

Added in API level 11
ContentValues getMetadata (String path)

Retrieves metadata information for rights-protected content.

Parameters
path String: 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.

getOriginalMimeType

Added in API level 11
String getOriginalMimeType (String path)

Retrieves the MIME type embedded in the original content.

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

getOriginalMimeType

Added in API level 11
String getOriginalMimeType (Uri uri)

Retrieves the MIME type embedded in the original content.

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

openConvertSession

Added in API level 11
int openConvertSession (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.

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

processDrmInfo

Added in API level 11
int processDrmInfo (DrmInfo drmInfo)

Processes the given DRM information based on the information type.

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

release

Added in API level 16
void release ()

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.

removeAllRights

Added in API level 11
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.

Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

removeRights

Added in API level 11
int removeRights (String path)

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

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

removeRights

Added in API level 11
int removeRights (Uri uri)

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

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

saveRights

Added in API level 11
int saveRights (DrmRights drmRights, 
                String rightsPath, 
                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.

Parameters
drmRights DrmRights: The DrmRights to be saved.
rightsPath String: File path where rights will be saved.
contentPath String: 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.

setOnErrorListener

Added in API level 11
void setOnErrorListener (DrmManagerClient.OnErrorListener errorListener)

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

Parameters
errorListener DrmManagerClient.OnErrorListener: Interface definition for the callback.

setOnEventListener

Added in API level 11
void setOnEventListener (DrmManagerClient.OnEventListener eventListener)

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

Parameters
eventListener DrmManagerClient.OnEventListener: Interface definition for the callback.

setOnInfoListener

Added in API level 11
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.

Parameters
infoListener DrmManagerClient.OnInfoListener: Interface definition for the callback.

Protected methods

finalize

Added in API level 11
void finalize ()

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
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.