Fields Summary |
---|
private android.drm.mobile1.DrmRights | mRightThe DRM right object. |
private final android.drm.mobile1.DrmRawContent | mDrmObjectThe DrmRawContent. |
private final android.net.Uri | mDataUri |
private final byte[] | mData |
private byte[] | mDecryptedDataThe decrypted data. |
private static final String | LOG_TAGThe log tag. |
private static final boolean | DEBUG |
private static final boolean | LOCAL_LOGV |
Methods Summary |
---|
public boolean | consumeRights()Consume the rights.
if (mRight == null) {
return false;
}
return mRight.consumeRights(getPermission());
|
public java.lang.String | getContentType()Get the decrypted object's content-type.
return mDrmObject.getContentType();
|
public byte[] | getDecryptedData()Get decrypted data.
if ((mDecryptedData == null) && (mRight != null)) {
// Decrypt it.
InputStream decryptedDataStream = mDrmObject.getContentInputStream(mRight);
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[256];
int len;
while ((len = decryptedDataStream.read(buffer)) > 0) {
baos.write(buffer, 0, len);
}
mDecryptedData = baos.toByteArray();
} finally {
try {
decryptedDataStream.close();
} catch (IOException e) {
Log.e(LOG_TAG, e.getMessage(), e);
}
}
}
if (mDecryptedData != null) {
byte[] decryptedData = new byte[mDecryptedData.length];
System.arraycopy(mDecryptedData, 0, decryptedData, 0, mDecryptedData.length);
return decryptedData;
}
return null;
|
public byte[] | getOriginalData()
return mData;
|
public android.net.Uri | getOriginalUri()
return mDataUri;
|
private int | getPermission()Get permission type for the decrypted content-type.
String contentType = mDrmObject.getContentType();
if (ContentType.isAudioType(contentType) ||
ContentType.isVideoType(contentType)) {
return DrmRights.DRM_PERMISSION_PLAY;
}
return DrmRights.DRM_PERMISSION_DISPLAY;
|
public java.lang.String | getRightsAddress()Get URL of right.
if (mDrmObject == null) {
return null;
}
return mDrmObject.getRightsAddress();
|
public void | installRights(byte[] rightData)Install Right.
if (rightData == null) {
throw new DrmException("Right data may not be null.");
}
if (LOCAL_LOGV) {
Log.v(LOG_TAG, "Installing DRM rights.");
}
ByteArrayInputStream rightDataStream = new ByteArrayInputStream(rightData);
mRight = DrmRightsManager.getInstance().installRights(
rightDataStream, rightData.length,
DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING);
|
public boolean | isAllowedToForward()Check whether this DRM object can be forwarded.
if (DrmRawContent.DRM_SEPARATE_DELIVERY != mDrmObject.getRawType()) {
return false;
}
return true;
|
public static boolean | isDrmObject(java.lang.String contentType)Check whether a object is DRM object.
if (contentType == null) {
return false;
}
if (contentType.equalsIgnoreCase(DrmRawContent.DRM_MIMETYPE_CONTENT_STRING) ||
contentType.equalsIgnoreCase(DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING)) {
return true;
}
return false;
|
public boolean | isRightsInstalled()Check whether the DRM object's right is existed. If not, we should
download it.
if (mRight != null) {
return true;
}
mRight = DrmRightsManager.getInstance().queryRights(mDrmObject);
return mRight != null ? true : false;
|