DrmManagerClient


public class DrmManagerClient
extends Object implements AutoCloseable

java.lang.Object
   ↳ android.drm.DrmManagerClient


This class was deprecated in API level 30.
Please use MediaDrm

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(String path, String mimeType)

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

boolean canHandle(Uri uri, String mimeType)

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

int checkRightsStatus(String path)

Checks whether the given content has valid rights.

int checkRightsStatus(Uri uri)

Check 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.

void close()

Releases resources associated with the current session of DrmManagerClient.

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.

Collection<DrmSupportInfo> getAvailableDrmSupportInfo()

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(String path)

Retrieves metadata information for rights-protected content.

ContentValues getMetadata(Uri uri)

Retrieves metadata information for rights-protected content.

String getOriginalMimeType(Uri uri)

Retrieves the MIME type embedded in the original content.

String getOriginalMimeType(String path)

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()

This method was deprecated in API level 24. replaced by close().

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()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Inherited methods

Constants

ERROR_NONE

Added in API level 11
public static final 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
public static final 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
public DrmManagerClient (Context context)

Creates a DrmManagerClient.

Parameters
context Context: Context of the caller.

Public methods

acquireDrmInfo

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

canHandle

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

checkRightsStatus

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

checkRightsStatus

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

close

Added in API level 24
Deprecated in API level 30
public void close ()

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 this method is called, DrmManagerClient is no longer usable since it has lost all of its required resource. This method was added in API 24. In API versions 16 through 23, release() should be called instead. There is no need to do anything for API versions prior to 16.

closeConvertSession

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

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
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 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
public 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.

getAvailableDrmSupportInfo

Added in API level 30
Deprecated in API level 30
public Collection<DrmSupportInfo> getAvailableDrmSupportInfo ()

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

Returns
Collection<DrmSupportInfo> List of all the DRM plug-ins (agents) that are registered with the DRM framework. This value cannot be null.

getConstraints

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

getMetadata

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

getOriginalMimeType

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

getOriginalMimeType

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

openConvertSession

Added in API level 11
public 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
public 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
Deprecated in API level 24
public void release ()

This method was deprecated in API level 24.
replaced by close().

removeAllRights

Added in API level 11
public int removeAllRights ()

Removes all the rights information of every DRM plug-in (agent) associated with the DRM framework.

Returns
int ERROR_NONE for success; ERROR_UNKNOWN for failure.

removeRights

Added in API level 11
public 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
public 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
public 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
public 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
public 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
public 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
protected void finalize ()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Throws
Throwable