public class

DrmManagerClient

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

Class Overview

Interface of DRM Framework. Java application will instantiate this class to access DRM agent through DRM Framework.

Summary

Nested Classes
interface DrmManagerClient.OnErrorListener Interface definition of a callback to be invoked to communicate the error occurred  
interface DrmManagerClient.OnEventListener Interface definition of a callback to be invoked to communicate the result of time consuming APIs asynchronously  
interface DrmManagerClient.OnInfoListener Interface definition of a callback to be invoked to communicate some info and/or warning about DrmManagerClient. 
Constants
int ERROR_NONE Constant field signifies the success or no error occurred
int ERROR_UNKNOWN Constant field signifies that error occurred and the reason is not known
Public Constructors
DrmManagerClient(Context context)
To instantiate DrmManagerClient
Public Methods
DrmInfo acquireDrmInfo(DrmInfoRequest drmInfoRequest)
Retrieves necessary information for register, unregister or rights acquisition.
int acquireRights(DrmInfoRequest drmInfoRequest)
Executes given DrmInfoRequest and returns the rights information asynchronously.
boolean canHandle(Uri uri, String mimeType)
Check whether the given mimetype or uri can be handled.
boolean canHandle(String path, String mimeType)
Check whether the given mimetype or path can be handled.
int checkRightsStatus(String path)
Check whether the given content has valid rights or not
int checkRightsStatus(String path, int action)
Check whether the given content has valid rights or not for specified action.
int checkRightsStatus(Uri uri, int action)
Check whether the given content has valid rights or not for specified action.
int checkRightsStatus(Uri uri)
Check whether the given content has valid rights or not
DrmConvertedStatus closeConvertSession(int convertId)
Informs the Drm Agent when there is no more data which need to be converted or when an error occurs.
DrmConvertedStatus convertData(int convertId, byte[] inputData)
Accepts and converts the input data which is part of DRM file.
String[] getAvailableDrmEngines()
Retrieves informations about all the plug-ins registered with DrmFramework.
ContentValues getConstraints(String path, int action)
Get constraints information evaluated from DRM content
ContentValues getConstraints(Uri uri, int action)
Get constraints information evaluated from DRM content
int getDrmObjectType(Uri uri, String mimeType)
Retrieves the type of the protected object (content, rights, etc..) using specified uri or mimetype.
int getDrmObjectType(String path, String mimeType)
Retrieves the type of the protected object (content, rights, etc..) using specified path or mimetype.
ContentValues getMetadata(Uri uri)
Get metadata information from DRM content
ContentValues getMetadata(String path)
Get metadata information from DRM content
String getOriginalMimeType(String path)
Retrieves the mime type embedded inside the original content
String getOriginalMimeType(Uri uri)
Retrieves the mime type embedded inside the original content
int openConvertSession(String mimeType)
This API is for Forward Lock based DRM scheme.
int processDrmInfo(DrmInfo drmInfo)
Executes given drm information based on its type
int removeAllRights()
Removes all the rights information of every plug-in associated with DRM framework.
int removeRights(String path)
Removes the rights associated with the given protected content
int removeRights(Uri uri)
Removes the rights associated with the given protected content
int saveRights(DrmRights drmRights, String rightsPath, String contentPath)
Save DRM rights to specified rights path and make association with content path.
synchronized void setOnErrorListener(DrmManagerClient.OnErrorListener errorListener)
Register a callback to be invoked when the caller required to receive error result of asynchronous APIs.
synchronized void setOnEventListener(DrmManagerClient.OnEventListener eventListener)
Register a callback to be invoked when the caller required to receive the result of asynchronous APIs.
synchronized void setOnInfoListener(DrmManagerClient.OnInfoListener infoListener)
Register a callback to be invoked when the caller required to receive supplementary information.
Protected Methods
void finalize()
Called before the object's memory is reclaimed by the VM.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ERROR_NONE

Since: API Level 11

Constant field signifies the success or no error occurred

Constant Value: 0 (0x00000000)

public static final int ERROR_UNKNOWN

Since: API Level 11

Constant field signifies that error occurred and the reason is not known

Constant Value: -2000 (0xfffff830)

Public Constructors

public DrmManagerClient (Context context)

Since: API Level 11

To instantiate DrmManagerClient

Parameters
context context of the caller

Public Methods

public DrmInfo acquireDrmInfo (DrmInfoRequest drmInfoRequest)

Since: API Level 11

Retrieves necessary information for register, unregister or rights acquisition.

Parameters
drmInfoRequest Request information to retrieve drmInfo
Returns
  • DrmInfo Instance as a result of processing given input

public int acquireRights (DrmInfoRequest drmInfoRequest)

Since: API Level 11

Executes given DrmInfoRequest and returns the rights information asynchronously. This is a utility API which consists of acquireDrmInfo(DrmInfoRequest) and processDrmInfo(DrmInfo). It can be used if selected DRM agent can work with this combined sequences. In case of some DRM schemes, such as OMA DRM, application needs to invoke acquireDrmInfo(DrmInfoRequest) and processDrmInfo(DrmInfo), separately.

Parameters
drmInfoRequest Request information to retrieve drmInfo
Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure

public boolean canHandle (Uri uri, String mimeType)

Since: API Level 11

Check whether the given mimetype or uri can be handled.

Parameters
uri Content URI of the data to be handled.
mimeType Mimetype of the object to be handled
Returns
  • true - if the given mimeType or path can be handled false - cannot be handled.

public boolean canHandle (String path, String mimeType)

Since: API Level 11

Check whether the given mimetype or path can be handled.

Parameters
path Path of the content to be handled
mimeType Mimetype of the object to be handled
Returns
  • true - if the given mimeType or path can be handled false - cannot be handled.

public int checkRightsStatus (String path)

Since: API Level 11

Check whether the given content has valid rights or not

Parameters
path Path of the protected content
Returns
  • Status of the rights for the protected content

public int checkRightsStatus (String path, int action)

Since: API Level 11

Check whether the given content has valid rights or not for specified action.

Parameters
path Path of the protected content
action Action to perform
Returns
  • Status of the rights for the protected content

public int checkRightsStatus (Uri uri, int action)

Since: API Level 11

Check whether the given content has valid rights or not for specified action.

Parameters
uri The content URI of the data
action Action to perform
Returns
  • Status of the rights for the protected content

public int checkRightsStatus (Uri uri)

Since: API Level 11

Check whether the given content has valid rights or not

Parameters
uri The content URI of the data
Returns
  • Status of the rights for the protected content

public DrmConvertedStatus closeConvertSession (int convertId)

Since: API Level 11

Informs the Drm Agent when there is no more data which need to be converted or when an error occurs. Upon successful conversion of the complete data, the agent will inform that where the header and body signature should be added. This signature appending is needed to integrity protect the converted file.

Parameters
convertId Handle for the convert session
Returns
  • Return object contains the status of the data conversion, the header and body signature data. It also informs the application on which offset these signature data should be appended.

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

Since: API Level 11

Accepts and converts the input data which is part of DRM file. The resultant converted data and the status is returned in the DrmConvertedInfo object. This method will be called each time there are new block of data received by the application.

Parameters
convertId Handle for the convert session
inputData Input Data which need to be converted
Returns
  • Return object contains the status of the data conversion, the output converted data and offset. In this case the application will ignore the offset information.

public String[] getAvailableDrmEngines ()

Since: API Level 11

Retrieves informations about all the plug-ins registered with DrmFramework.

Returns
  • Array of DrmEngine plug-in strings

public ContentValues getConstraints (String path, int action)

Since: API Level 11

Get constraints information evaluated from DRM content

Parameters
path Content path from where DRM constraints would be retrieved.
action Actions defined in DrmStore.Action
Returns
  • ContentValues instance in which constraints key-value pairs are embedded or null in case of failure

public ContentValues getConstraints (Uri uri, int action)

Since: API Level 11

Get constraints information evaluated from DRM content

Parameters
uri Content URI from where DRM constraints would be retrieved.
action Actions defined in DrmStore.Action
Returns
  • ContentValues instance in which constraints key-value pairs are embedded or null in case of failure

public int getDrmObjectType (Uri uri, String mimeType)

Since: API Level 11

Retrieves the type of the protected object (content, rights, etc..) using specified uri or mimetype. At least one parameter should be non null to retrieve DRM object type

Parameters
uri The content URI of the data
mimeType Mimetype of the content or null.
Returns
  • Type of the DRM content.

public int getDrmObjectType (String path, String mimeType)

Since: API Level 11

Retrieves the type of the protected object (content, rights, etc..) using specified path or mimetype. At least one parameter should be non null to retrieve DRM object type

Parameters
path Path of the content or null.
mimeType Mimetype of the content or null.
Returns
  • Type of the DRM content.

public ContentValues getMetadata (Uri uri)

Since: API Level 11

Get metadata information from DRM content

Parameters
uri Content URI from where DRM metadata would be retrieved.
Returns
  • ContentValues instance in which metadata key-value pairs are embedded or null in case of failure

public ContentValues getMetadata (String path)

Since: API Level 11

Get metadata information from DRM content

Parameters
path Content path from where DRM metadata would be retrieved.
Returns
  • ContentValues instance in which metadata key-value pairs are embedded or null in case of failure

public String getOriginalMimeType (String path)

Since: API Level 11

Retrieves the mime type embedded inside the original content

Parameters
path Path of the protected content
Returns
  • Mimetype of the original content, such as "video/mpeg"

public String getOriginalMimeType (Uri uri)

Since: API Level 11

Retrieves the mime type embedded inside the original content

Parameters
uri The content URI of the data
Returns
  • Mimetype of the original content, such as "video/mpeg"

public int openConvertSession (String mimeType)

Since: API Level 11

This API is for Forward Lock based DRM scheme. Each time the application tries to download a new DRM file which needs to be converted, then the application has to begin with calling this API.

Parameters
mimeType Description/MIME type of the input data packet
Returns
  • convert ID which will be used for maintaining convert session.

public int processDrmInfo (DrmInfo drmInfo)

Since: API Level 11

Executes given drm information based on its type

Parameters
drmInfo Information needs to be processed
Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure

public int removeAllRights ()

Since: API Level 11

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

Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure

public int removeRights (String path)

Since: API Level 11

Removes the rights associated with the given protected content

Parameters
path Path of the protected content
Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure

public int removeRights (Uri uri)

Since: API Level 11

Removes the rights associated with the given protected content

Parameters
uri The content URI of the data
Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure

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

Since: API Level 11

Save DRM rights to specified rights path and make association with content path.

In case of OMA or WM-DRM, rightsPath and contentPath could be null.

Parameters
drmRights DrmRights to be saved
rightsPath File path where rights to be saved
contentPath File path where content was saved
Returns
  • ERROR_NONE for success ERROR_UNKNOWN for failure
Throws
IOException if failed to save rights information in the given path

public synchronized void setOnErrorListener (DrmManagerClient.OnErrorListener errorListener)

Since: API Level 11

Register a callback to be invoked when the caller required to receive error result of asynchronous APIs.

public synchronized void setOnEventListener (DrmManagerClient.OnEventListener eventListener)

Since: API Level 11

Register a callback to be invoked when the caller required to receive the result of asynchronous APIs.

public synchronized void setOnInfoListener (DrmManagerClient.OnInfoListener infoListener)

Since: API Level 11

Register a callback to be invoked when the caller required to receive supplementary information.

Protected Methods

protected void finalize ()

Since: API Level 11

Called before the object's memory is reclaimed by the VM. This can only happen once the garbage collector has detected that the object is no longer reachable by any thread of the running application.

The method can be used to free system resources or perform other cleanup before the object is garbage collected. The default implementation of the method is empty, which is also expected by the VM, but subclasses can override finalize() as required. Uncaught exceptions which are thrown during the execution of this method cause it to terminate immediately but are otherwise ignored.

Note that the VM does guarantee that finalize() is called at most once for any object, but it doesn't guarantee when (if at all) finalize() will be called. For example, object B's finalize() can delay the execution of object A's finalize() method and therefore it can delay the reclamation of A's memory. To be safe, use a ReferenceQueue, because it provides more control over the way the VM deals with references during garbage collection.