FileDocCategorySizeDatePackage
DrmInfo.javaAPI DocAndroid 5.1 API5258Thu Mar 12 22:22:30 GMT 2015android.drm

DrmInfo

public class DrmInfo extends Object
An entity class that describes the information required to send transactions between a device and an online DRM server. The DRM framework achieves server registration, license acquisition, and any other server-related transactions by passing an instance of this class to {@link DrmManagerClient#processDrmInfo}.

The caller can retrieve the {@link DrmInfo} instance by passing a {@link DrmInfoRequest} instance to {@link DrmManagerClient#acquireDrmInfo}.

Fields Summary
private byte[]
mData
private final String
mMimeType
private final int
mInfoType
private final HashMap
mAttributes
Constructors Summary
public DrmInfo(int infoType, byte[] data, String mimeType)
Creates a DrmInfo object with the given parameters.

param
infoType The type of information.
param
data The trigger data.
param
mimeType The MIME type.


                                 
           
        mInfoType = infoType;
        mMimeType = mimeType;
        mData = data;
        if (!isValid()) {
            final String msg = "infoType: " + infoType + "," +
                               "mimeType: " + mimeType + "," +
                               "data: " + data;

            throw new IllegalArgumentException(msg);
        }
    
public DrmInfo(int infoType, String path, String mimeType)
Creates a DrmInfo object with the given parameters.

param
infoType The type of information.
param
path The trigger data.
param
mimeType The MIME type.

        mInfoType = infoType;
        mMimeType = mimeType;
        try {
            mData = DrmUtils.readBytes(path);
        } catch (IOException e) {
            // As the given path is invalid,
            // set mData = null, so that further processDrmInfo()
            // call would fail with IllegalArgumentException because of mData = null
            mData = null;
        }
        if (!isValid()) {
            final String msg = "infoType: " + infoType + "," +
                               "mimeType: " + mimeType + "," +
                               "data: " + mData;

            throw new IllegalArgumentException();
        }
    
Methods Summary
public java.lang.Objectget(java.lang.String key)
Retrieves the value of a given key.

param
key The key whose value is being retrieved.
return
The value of the key being retrieved. Returns null if the key cannot be found.

        return mAttributes.get(key);
    
public byte[]getData()
Retrieves the trigger data associated with this object.

return
The trigger data.

        return mData;
    
public intgetInfoType()
Retrieves the information type associated with this object.

return
The information type.

        return mInfoType;
    
public java.lang.StringgetMimeType()
Retrieves the MIME type associated with this object.

return
The MIME type.

        return mMimeType;
    
booleanisValid()
Returns whether this instance is valid or not

return
true if valid false if invalid

        return (null != mMimeType && !mMimeType.equals("")
                && null != mData && mData.length > 0 && DrmInfoRequest.isValidType(mInfoType));
    
public java.util.Iteratoriterator()
Retrieves an iterator object that you can use to iterate over the values associated with this DrmInfo object.

return
The iterator object.

        return mAttributes.values().iterator();
    
public java.util.IteratorkeyIterator()
Retrieves an iterator object that you can use to iterate over the keys associated with this DrmInfo object.

return
The iterator object.

        return mAttributes.keySet().iterator();
    
public voidput(java.lang.String key, java.lang.Object value)
Adds optional information as key-value pairs to this object. To add a custom object to the DrmInfo object, you must override the {@link #toString} implementation.

param
key Key to add.
param
value Value to add.

        mAttributes.put(key, value);