FileDocCategorySizeDatePackage
DrmRightsManager.javaAPI DocAndroid 1.5 API7775Wed May 06 22:42:00 BST 2009android.drm.mobile1

DrmRightsManager

public class DrmRightsManager extends Object
This class provides interfaces to access the DRM right manager.

Fields Summary
public static final String
DRM_MIMETYPE_RIGHTS_XML_STRING
The "application/vnd.oma.drm.rights+xml" mime type.
public static final String
DRM_MIMETYPE_RIGHTS_WBXML_STRING
The "application/vnd.oma.drm.rights+wbxml" mime type.
private static final int
DRM_MIMETYPE_RIGHTS_XML
The id of "application/vnd.oma.drm.rights+xml" mime type.
private static final int
DRM_MIMETYPE_RIGHTS_WBXML
The id of "application/vnd.oma.drm.rights+wbxml" mime type.
private static final int
DRM_MIMETYPE_MESSAGE
The id of "application/vnd.oma.drm.message" mime type.
private static final int
JNI_DRM_SUCCESS
Successful operation.
private static final int
JNI_DRM_FAILURE
General failure.
private static DrmRightsManager
singleton
The instance of the rights manager.
Constructors Summary
protected DrmRightsManager()
Construct a DrmRightsManager



            
      
    
Methods Summary
public synchronized voiddeleteRights(DrmRights rights)
Delete the specified DRM rights object.

param
rights the specified rights object to be deleted.

        /* call native method to delete the specified rights object */
        int res = nativeDeleteRights(rights);

        if (JNI_DRM_FAILURE == res)
            return;
    
public static synchronized android.drm.mobile1.DrmRightsManagergetInstance()
Get the DrmRightsManager instance.

return
the instance of DrmRightsManager.

        if (singleton == null) {
            singleton = new DrmRightsManager();
        }

        return singleton;
    
public synchronized java.util.ListgetRightsList()
Get the list of all DRM rights saved in local client.

return
the list of all the rights object.

        List rightsList = new ArrayList();

        /* call native method to get how many rights object in current agent */
        int num = nativeGetNumOfRights();

        if (JNI_DRM_FAILURE == num)
            return null;

        if (num > 0) {
            DrmRights[] rightsArray = new DrmRights[num];
            int i;

            for (i = 0; i < num; i++)
                rightsArray[i] = new DrmRights();

            /* call native method to get all the rights information */
            num = nativeGetRightsList(rightsArray, num);

            if (JNI_DRM_FAILURE == num)
                return null;

            /* add all rights informations to ArrayList */
            for (i = 0; i < num; i++)
                rightsList.add(rightsArray[i]);
        }

        return rightsList;
    
public synchronized DrmRightsinstallRights(java.io.InputStream rightsData, int len, java.lang.String mimeTypeStr)
Install one DRM rights and return one instance of DrmRights.

param
rightsData raw rights data.
param
mimeTypeStr the mime type of the rights object.
return
the instance of the installed DrmRights.

        int mimeType = 0;

        if (DRM_MIMETYPE_RIGHTS_XML_STRING.equals(mimeTypeStr))
            mimeType = DRM_MIMETYPE_RIGHTS_XML;
        else if (DRM_MIMETYPE_RIGHTS_WBXML_STRING.equals(mimeTypeStr))
            mimeType = DRM_MIMETYPE_RIGHTS_WBXML;
        else if (DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING.equals(mimeTypeStr))
            mimeType = DRM_MIMETYPE_MESSAGE;
        else
            throw new IllegalArgumentException("mimeType must be DRM_MIMETYPE_RIGHTS_XML or DRM_MIMETYPE_RIGHTS_WBXML or DRM_MIMETYPE_MESSAGE");

        if (len <= 0)
            return null;

        DrmRights rights = new DrmRights();

        /* call native method to install this rights object. */
        int res = nativeInstallDrmRights(rightsData, len, mimeType, rights);

        if (JNI_DRM_FAILURE == res)
            throw new DrmException("nativeInstallDrmRights() returned JNI_DRM_FAILURE");

        return rights;
    
private native intnativeDeleteRights(DrmRights rights)
native method: delete a specified rights object.

param
rights the specified rights object to be deleted.
return
#JNI_DRM_SUCCESS if succeed. #JNI_DRM_FAILURE if fail.

private native intnativeGetNumOfRights()
native method: get how many rights object in current DRM agent.

return
the number of the rights object. #JNI_DRM_FAILURE if fail.

private native intnativeGetRightsList(DrmRights[] rights, int numRights)
native method: get all the rights object in current local agent.

param
rights the array instance of rights object.
param
numRights how many rights can be saved.
return
the number of the rights object has been gotten. #JNI_DRM_FAILURE if fail.

private native intnativeInstallDrmRights(java.io.InputStream data, int len, int mimeType, DrmRights rights)
native method: install rights object to local client.

param
data input DRM rights object data to be installed.
param
len the length of the data.
param
mimeType the mime type of this DRM rights object. the value of this field includes: #DRM_MIMETYPE_RIGHTS_XML #DRM_MIMETYPE_RIGHTS_WBXML
parma
rights the instance of DRMRights to be filled.
return
#JNI_DRM_SUCCESS if succeed. #JNI_DRM_FAILURE if fail.

private native intnativeQueryRights(DrmRawContent content, DrmRights rights)
native method: query the given DRM content's rights object.

param
content the given DRM content.
param
rights the instance of rights to set if have.
return
#JNI_DRM_SUCCESS if succeed. #JNI_DRM_FAILURE if fail.

public synchronized DrmRightsqueryRights(DrmRawContent content)
Query DRM rights of specified DRM raw content.

param
content raw content object.
return
the instance of DrmRights, or null if there is no rights.

        DrmRights rights = new DrmRights();

        /* call native method to query the rights */
        int res = nativeQueryRights(content, rights);

        if (JNI_DRM_FAILURE == res)
            return null;

        return rights;