summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
Diffstat (limited to 'drm')
-rw-r--r--drm/common/DrmEngineBase.cpp18
-rw-r--r--drm/common/IDrmManagerService.cpp25
-rw-r--r--drm/drmserver/DrmManager.cpp11
-rw-r--r--drm/drmserver/DrmManagerService.cpp29
-rw-r--r--drm/drmserver/main_drmserver.cpp8
-rwxr-xr-xdrm/java/android/drm/DrmErrorEvent.java30
-rwxr-xr-xdrm/java/android/drm/DrmEvent.java4
-rwxr-xr-xdrm/java/android/drm/DrmInfo.java14
-rwxr-xr-xdrm/java/android/drm/DrmInfoEvent.java40
-rwxr-xr-xdrm/java/android/drm/DrmInfoRequest.java5
-rwxr-xr-xdrm/java/android/drm/DrmInfoStatus.java4
-rwxr-xr-xdrm/java/android/drm/DrmManagerClient.java1
-rwxr-xr-xdrm/java/android/drm/DrmRights.java62
-rwxr-xr-xdrm/java/android/drm/DrmStore.java62
-rwxr-xr-xdrm/java/android/drm/DrmSupportInfo.java11
-rwxr-xr-xdrm/java/android/drm/DrmUtils.java30
-rw-r--r--drm/libdrmframework/DrmManagerClient.cpp14
-rw-r--r--drm/libdrmframework/DrmManagerClientImpl.cpp12
-rw-r--r--drm/libdrmframework/include/DrmManager.h5
-rw-r--r--drm/libdrmframework/include/DrmManagerClientImpl.h8
-rw-r--r--drm/libdrmframework/include/DrmManagerService.h6
-rw-r--r--drm/libdrmframework/include/IDrmManagerService.h14
-rw-r--r--drm/libdrmframework/plugins/common/include/DrmEngineBase.h51
-rw-r--r--drm/libdrmframework/plugins/common/include/IDrmEngine.h10
24 files changed, 379 insertions, 95 deletions
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index 9b16c36..1c345a2 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -120,13 +120,23 @@ DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
}
status_t DrmEngineBase::openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
- return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
+ int uniqueId, DecryptHandle* decryptHandle,
+ int fd, off64_t offset, off64_t length, const char* mime) {
+
+ if (!mime || mime[0] == '\0') {
+ return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
+ }
+
+ return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length, mime);
}
status_t DrmEngineBase::openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
- return onOpenDecryptSession(uniqueId, decryptHandle, uri);
+ int uniqueId, DecryptHandle* decryptHandle,
+ const char* uri, const char* mime) {
+ if (!mime || mime[0] == '\0') {
+ return onOpenDecryptSession(uniqueId, decryptHandle, uri);
+ }
+ return onOpenDecryptSession(uniqueId, decryptHandle, uri, mime);
}
status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index 3ed8ade..43f64f2 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -600,7 +600,7 @@ status_t BpDrmManagerService::getAllSupportInfo(
}
DecryptHandle* BpDrmManagerService::openDecryptSession(
- int uniqueId, int fd, off64_t offset, off64_t length) {
+ int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
ALOGV("Entering BpDrmManagerService::openDecryptSession");
Parcel data, reply;
@@ -609,6 +609,11 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
data.writeFileDescriptor(fd);
data.writeInt64(offset);
data.writeInt64(length);
+ String8 mimeType;
+ if (mime) {
+ mimeType = mime;
+ }
+ data.writeString8(mimeType);
remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);
@@ -620,13 +625,20 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
return handle;
}
-DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
- ALOGV("Entering BpDrmManagerService::openDecryptSession");
+DecryptHandle* BpDrmManagerService::openDecryptSession(
+ int uniqueId, const char* uri, const char* mime) {
+
+ ALOGV("Entering BpDrmManagerService::openDecryptSession: mime=%s", mime? mime: "NULL");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
data.writeString8(String8(uri));
+ String8 mimeType;
+ if (mime) {
+ mimeType = mime;
+ }
+ data.writeString8(mimeType);
remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);
@@ -1265,8 +1277,10 @@ status_t BnDrmManagerService::onTransact(
const off64_t offset = data.readInt64();
const off64_t length = data.readInt64();
+ const String8 mime = data.readString8();
+
DecryptHandle* handle
- = openDecryptSession(uniqueId, fd, offset, length);
+ = openDecryptSession(uniqueId, fd, offset, length, mime.string());
if (NULL != handle) {
writeDecryptHandleToParcelData(handle, reply);
@@ -1283,8 +1297,9 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
const String8 uri = data.readString8();
+ const String8 mime = data.readString8();
- DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
+ DecryptHandle* handle = openDecryptSession(uniqueId, uri.string(), mime.string());
if (NULL != handle) {
writeDecryptHandleToParcelData(handle, reply);
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 3abf3d3..999295a 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -426,7 +426,9 @@ status_t DrmManager::getAllSupportInfo(
return DRM_NO_ERROR;
}
-DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) {
+DecryptHandle* DrmManager::openDecryptSession(
+ int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
+
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -438,7 +440,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
String8 plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
+ result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length, mime);
if (DRM_NO_ERROR == result) {
++mDecryptSessionId;
@@ -453,7 +455,8 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
return handle;
}
-DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
+DecryptHandle* DrmManager::openDecryptSession(
+ int uniqueId, const char* uri, const char* mime) {
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -465,7 +468,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
String8 plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
+ result = rDrmEngine.openDecryptSession(uniqueId, handle, uri, mime);
if (DRM_NO_ERROR == result) {
++mDecryptSessionId;
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index df17ac5..8ba0203 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -159,12 +159,18 @@ int DrmManagerService::checkRightsStatus(
status_t DrmManagerService::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
ALOGV("Entering consumeRights");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve);
}
status_t DrmManagerService::setPlaybackStatus(
int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
ALOGV("Entering setPlaybackStatus");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
@@ -208,20 +214,20 @@ status_t DrmManagerService::getAllSupportInfo(
}
DecryptHandle* DrmManagerService::openDecryptSession(
- int uniqueId, int fd, off64_t offset, off64_t length) {
+ int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
ALOGV("Entering DrmManagerService::openDecryptSession");
if (isProtectedCallAllowed()) {
- return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
+ return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime);
}
return NULL;
}
DecryptHandle* DrmManagerService::openDecryptSession(
- int uniqueId, const char* uri) {
+ int uniqueId, const char* uri, const char* mime) {
ALOGV("Entering DrmManagerService::openDecryptSession with uri");
if (isProtectedCallAllowed()) {
- return mDrmManager->openDecryptSession(uniqueId, uri);
+ return mDrmManager->openDecryptSession(uniqueId, uri, mime);
}
return NULL;
@@ -229,12 +235,18 @@ DecryptHandle* DrmManagerService::openDecryptSession(
status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
ALOGV("Entering closeDecryptSession");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);
}
status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) {
ALOGV("Entering initializeDecryptUnit");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo);
}
@@ -242,18 +254,27 @@ status_t DrmManagerService::decrypt(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
ALOGV("Entering decrypt");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
status_t DrmManagerService::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
ALOGV("Entering finalizeDecryptUnit");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
}
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset) {
ALOGV("Entering pread");
+ if (!isProtectedCallAllowed()) {
+ return DRM_ERROR_NO_PERMISSION;
+ }
return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
}
diff --git a/drm/drmserver/main_drmserver.cpp b/drm/drmserver/main_drmserver.cpp
index ed42818..434d561 100644
--- a/drm/drmserver/main_drmserver.cpp
+++ b/drm/drmserver/main_drmserver.cpp
@@ -14,15 +14,13 @@
* limitations under the License.
*/
-#include <sys/types.h>
-#include <unistd.h>
-#include <grp.h>
+#define LOG_TAG "drmserver"
+//#define LOG_NDEBUG 0
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
#include <utils/Log.h>
-#include <private/android_filesystem_config.h>
#include <DrmManagerService.h>
@@ -32,7 +30,7 @@ int main(int argc, char** argv)
{
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
- ALOGI("ServiceManager: %p", sm.get());
+ ALOGV("ServiceManager: %p", sm.get());
DrmManagerService::instantiate();
ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java
index 2cb82e6..c61819d 100755
--- a/drm/java/android/drm/DrmErrorEvent.java
+++ b/drm/java/android/drm/DrmErrorEvent.java
@@ -24,6 +24,10 @@ import java.util.HashMap;
*
*/
public class DrmErrorEvent extends DrmEvent {
+
+ // Please add newly defined type constants to the end of the list,
+ // and modify checkTypeValidity() accordingly.
+
/**
* Something went wrong installing the rights.
*/
@@ -60,28 +64,46 @@ public class DrmErrorEvent extends DrmEvent {
*/
public static final int TYPE_ACQUIRE_DRM_INFO_FAILED = 2008;
+ // Add more type constants here...
+
+ // FIXME:
+ // We may want to add a user-defined type constant, such as
+ // TYPE_VENDOR_SPECIFIC_FAILED, to take care vendor specific use
+ // cases.
+
+
/**
* Creates a <code>DrmErrorEvent</code> object with the specified parameters.
*
* @param uniqueId Unique session identifier.
- * @param type Type of the event. Could be any of the event types defined above.
- * @param message Message description.
+ * @param type Type of the event. Must be any of the event types defined above.
+ * @param message Message description. It can be null.
*/
public DrmErrorEvent(int uniqueId, int type, String message) {
super(uniqueId, type, message);
+ checkTypeValidity(type);
}
/**
* Creates a <code>DrmErrorEvent</code> object with the specified parameters.
*
* @param uniqueId Unique session identifier.
- * @param type Type of the event. Could be any of the event types defined above.
+ * @param type Type of the event. Must be any of the event types defined above.
* @param message Message description.
* @param attributes Attributes for extensible information. Could be any
- * information provided by the plug-in.
+ * information provided by the plug-in. It can be null.
*/
public DrmErrorEvent(int uniqueId, int type, String message,
HashMap<String, Object> attributes) {
super(uniqueId, type, message, attributes);
+ checkTypeValidity(type);
+ }
+
+ private void checkTypeValidity(int type) {
+ if (type < TYPE_RIGHTS_NOT_INSTALLED ||
+ type > TYPE_ACQUIRE_DRM_INFO_FAILED) {
+ final String msg = "Unsupported type: " + type;
+ throw new IllegalArgumentException(msg);
+ }
}
}
diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java
index 4053eb3..1a19f5c 100755
--- a/drm/java/android/drm/DrmEvent.java
+++ b/drm/java/android/drm/DrmEvent.java
@@ -23,6 +23,10 @@ import java.util.HashMap;
*
*/
public class DrmEvent {
+
+ // Please do not add type constants in this class. More event type constants
+ // should go to DrmInfoEvent or DrmErrorEvent classes.
+
/**
* All of the rights information associated with all DRM schemes have been successfully removed.
*/
diff --git a/drm/java/android/drm/DrmInfo.java b/drm/java/android/drm/DrmInfo.java
index 8812bfe..22d06c7 100755
--- a/drm/java/android/drm/DrmInfo.java
+++ b/drm/java/android/drm/DrmInfo.java
@@ -49,6 +49,13 @@ public class DrmInfo {
mInfoType = infoType;
mMimeType = mimeType;
mData = data;
+ if (!isValid()) {
+ final String msg = "infoType: " + infoType + "," +
+ "mimeType: " + mimeType + "," +
+ "data: " + data;
+
+ throw new IllegalArgumentException(msg);
+ }
}
/**
@@ -69,6 +76,13 @@ public class DrmInfo {
// 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();
+ }
}
/**
diff --git a/drm/java/android/drm/DrmInfoEvent.java b/drm/java/android/drm/DrmInfoEvent.java
index 67aa0a9..2826dce 100755
--- a/drm/java/android/drm/DrmInfoEvent.java
+++ b/drm/java/android/drm/DrmInfoEvent.java
@@ -24,6 +24,10 @@ import java.util.HashMap;
*
*/
public class DrmInfoEvent extends DrmEvent {
+
+ // Please add newly defined type constants to the end of the list,
+ // and modify checkTypeValidity() accordingly.
+
/**
* The registration has already been done by another account ID.
*/
@@ -50,29 +54,57 @@ public class DrmInfoEvent extends DrmEvent {
*/
public static final int TYPE_RIGHTS_REMOVED = 6;
+ // Add more type constants here...
+
+ // FIXME:
+ // We may want to add a user-defined type constant, such as
+ // TYPE_VENDOR_SPECIFIC, to take care vendor specific use
+ // cases.
+
/**
* Creates a <code>DrmInfoEvent</code> object with the specified parameters.
*
* @param uniqueId Unique session identifier.
- * @param type Type of the event. Could be any of the event types defined above.
- * @param message Message description.
+ * @param type Type of the event. Must be any of the event types defined above,
+ * or the constants defined in {@link DrmEvent}.
+ * @param message Message description. It can be null.
*/
public DrmInfoEvent(int uniqueId, int type, String message) {
super(uniqueId, type, message);
+ checkTypeValidity(type);
}
/**
* Creates a <code>DrmInfoEvent</code> object with the specified parameters.
*
* @param uniqueId Unique session identifier.
- * @param type Type of the event. Could be any of the event types defined above.
- * @param message Message description.
+ * @param type Type of the event. Must be any of the event types defined above,
+ * or the constants defined in {@link DrmEvent}
+ * @param message Message description. It can be null.
* @param attributes Attributes for extensible information. Could be any
* information provided by the plug-in.
*/
public DrmInfoEvent(int uniqueId, int type, String message,
HashMap<String, Object> attributes) {
super(uniqueId, type, message, attributes);
+ checkTypeValidity(type);
+ }
+
+ /*
+ * Check the validity of the given type.
+ * To overcome a design flaw, we need also accept the type constants
+ * defined in super class, DrmEvent.
+ */
+ private void checkTypeValidity(int type) {
+ if (type < TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT ||
+ type > TYPE_RIGHTS_REMOVED) {
+
+ if (type != TYPE_ALL_RIGHTS_REMOVED &&
+ type != TYPE_DRM_INFO_PROCESSED) {
+ final String msg = "Unsupported type: " + type;
+ throw new IllegalArgumentException(msg);
+ }
+ }
}
}
diff --git a/drm/java/android/drm/DrmInfoRequest.java b/drm/java/android/drm/DrmInfoRequest.java
index 1429fa5..621da41 100755
--- a/drm/java/android/drm/DrmInfoRequest.java
+++ b/drm/java/android/drm/DrmInfoRequest.java
@@ -67,6 +67,11 @@ public class DrmInfoRequest {
public DrmInfoRequest(int infoType, String mimeType) {
mInfoType = infoType;
mMimeType = mimeType;
+ if (!isValid()) {
+ final String msg = "infoType: " + infoType + "," +
+ "mimeType: " + mimeType;
+ throw new IllegalArgumentException(msg);
+ }
}
/**
diff --git a/drm/java/android/drm/DrmInfoStatus.java b/drm/java/android/drm/DrmInfoStatus.java
index 5c12ae3..2fe0a78 100755
--- a/drm/java/android/drm/DrmInfoStatus.java
+++ b/drm/java/android/drm/DrmInfoStatus.java
@@ -56,6 +56,10 @@ public class DrmInfoStatus {
* @param _mimeType The MIME type.
*/
public DrmInfoStatus(int _statusCode, int _infoType, ProcessedData _data, String _mimeType) {
+ if (!DrmInfoRequest.isValidType(_infoType)) {
+ throw new IllegalArgumentException("infoType: " + _infoType);
+ }
+
statusCode = _statusCode;
infoType = _infoType;
data = _data;
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index f9567a5..482ab0a 100755
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -363,6 +363,7 @@ public class DrmManagerClient {
*
* @return A {@link android.content.ContentValues} instance that contains
* key-value pairs representing the constraints. Null in case of failure.
+ * The keys are defined in {@link DrmStore.ConstraintsColumns}.
*/
public ContentValues getConstraints(String path, int action) {
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
diff --git a/drm/java/android/drm/DrmRights.java b/drm/java/android/drm/DrmRights.java
index ef9c21d..a9b4f05 100755
--- a/drm/java/android/drm/DrmRights.java
+++ b/drm/java/android/drm/DrmRights.java
@@ -30,19 +30,24 @@ import java.io.IOException;
* A caller can also instantiate a {@link DrmRights} object by using the
* {@link DrmRights#DrmRights(String, String)} constructor, which takes a path to a file
* containing rights information instead of a <code>ProcessedData</code>.
+ *<p>
+ * Please note that the account id and subscription id is not mandatory by all DRM agents
+ * or plugins. When account id or subscription id is not required by the specific DRM
+ * agent or plugin, they can be either null, or an empty string, or any other don't-care
+ * string value.
*
*/
public class DrmRights {
private byte[] mData;
private String mMimeType;
- private String mAccountId = "_NO_USER";
- private String mSubscriptionId = "";
+ private String mAccountId;
+ private String mSubscriptionId;
/**
* Creates a <code>DrmRights</code> object with the given parameters.
*
* @param rightsFilePath Path to the file containing rights information.
- * @param mimeType MIME type.
+ * @param mimeType MIME type. Must not be null or an empty string.
*/
public DrmRights(String rightsFilePath, String mimeType) {
File file = new File(rightsFilePath);
@@ -53,22 +58,20 @@ public class DrmRights {
* Creates a <code>DrmRights</code> object with the given parameters.
*
* @param rightsFilePath Path to the file containing rights information.
- * @param mimeType MIME type.
+ * @param mimeType MIME type. Must not be null or an empty string.
* @param accountId Account ID of the user.
*/
public DrmRights(String rightsFilePath, String mimeType, String accountId) {
this(rightsFilePath, mimeType);
- if (null != accountId && !accountId.equals("")) {
- mAccountId = accountId;
- }
+ mAccountId = accountId;
}
/**
* Creates a <code>DrmRights</code> object with the given parameters.
*
* @param rightsFilePath Path to the file containing rights information.
- * @param mimeType MIME type.
+ * @param mimeType MIME type. Must not be null or an empty string.
* @param accountId Account ID of the user.
* @param subscriptionId Subscription ID of the user.
*/
@@ -76,20 +79,15 @@ public class DrmRights {
String rightsFilePath, String mimeType, String accountId, String subscriptionId) {
this(rightsFilePath, mimeType);
- if (null != accountId && !accountId.equals("")) {
- mAccountId = accountId;
- }
-
- if (null != subscriptionId && !subscriptionId.equals("")) {
- mSubscriptionId = subscriptionId;
- }
+ mAccountId = accountId;
+ mSubscriptionId = subscriptionId;
}
/**
* Creates a <code>DrmRights</code> object with the given parameters.
*
* @param rightsFile File containing rights information.
- * @param mimeType MIME type.
+ * @param mimeType MIME type. Must not be null or an empty string.
*/
public DrmRights(File rightsFile, String mimeType) {
instantiate(rightsFile, mimeType);
@@ -103,31 +101,35 @@ public class DrmRights {
}
mMimeType = mimeType;
+ if (!isValid()) {
+ final String msg = "mimeType: " + mMimeType + "," +
+ "data: " + mData;
+ throw new IllegalArgumentException(msg);
+ }
}
/**
* Creates a <code>DrmRights</code> object with the given parameters.
*
* @param data A {@link ProcessedData} object containing rights information.
- * data could be null because it's optional for some DRM schemes.
- * @param mimeType The MIME type.
+ * Must not be null.
+ * @param mimeType The MIME type. It must not be null or an empty string.
*/
public DrmRights(ProcessedData data, String mimeType) {
- if (data != null) {
- mData = data.getData();
-
- String accountId = data.getAccountId();
- if (null != accountId && !accountId.equals("")) {
- mAccountId = accountId;
- }
-
- String subscriptionId = data.getSubscriptionId();
- if (null != subscriptionId && !subscriptionId.equals("")) {
- mSubscriptionId = subscriptionId;
- }
+ if (data == null) {
+ throw new IllegalArgumentException("data is null");
}
+ mData = data.getData();
+ mAccountId = data.getAccountId();
+ mSubscriptionId = data.getSubscriptionId();
mMimeType = mimeType;
+
+ if (!isValid()) {
+ final String msg = "mimeType: " + mMimeType + "," +
+ "data: " + mData;
+ throw new IllegalArgumentException(msg);
+ }
}
/**
diff --git a/drm/java/android/drm/DrmStore.java b/drm/java/android/drm/DrmStore.java
index ae311de..3a77ea1 100755
--- a/drm/java/android/drm/DrmStore.java
+++ b/drm/java/android/drm/DrmStore.java
@@ -23,45 +23,65 @@ package android.drm;
public class DrmStore {
/**
* Interface definition for the columns that represent DRM constraints.
+ * {@link android.drm.DrmManagerClient#getConstraints DrmManagerClient.getConstraints()}
+ * can be called by an application to find out the contraints on the
+ * {@link android.drm.DrmStore.Action actions} that can be performed
+ * on right-protected content. The constants defined in this interface
+ * represent three most common types of constraints: count-based,
+ * date-based, and duration-based. Two or more constraints can be used
+ * at the same time to represent more sophisticated constraints.
+ * In addition, user-defined constraint,
+ * {@link #EXTENDED_METADATA extended metadata}, can be
+ * used if these three types of constraints are not sufficient.
*/
public interface ConstraintsColumns {
/**
- * The maximum repeat count.
+ * This is a count-based constraint. It represents the maximum
+ * repeat count that can be performed on an
+ * {@link android.drm.DrmStore.Action action}.
* <p>
* Type: INTEGER
*/
public static final String MAX_REPEAT_COUNT = "max_repeat_count";
/**
- * The remaining repeat count.
+ * This is a count-based constraint. It represents the remaining
+ * repeat count that can be performed on an
+ * {@link android.drm.DrmStore.Action action}.
* <p>
* Type: INTEGER
*/
public static final String REMAINING_REPEAT_COUNT = "remaining_repeat_count";
/**
- * The time before which the rights-protected file cannot be played/viewed.
+ * This is a date-based constraint. It represents the time before which
+ * an {@link android.drm.DrmStore.Action action} can be performed on
+ * the rights-protected content.
* <p>
* Type: TEXT
*/
public static final String LICENSE_START_TIME = "license_start_time";
/**
- * The time after which the rights-protected file cannot be played/viewed.
+ * This is a date-based constaint. It represents the time after which
+ * an {@link android.drm.DrmStore.Action action} can not be performed on
+ * the rights-protected content.
* <p>
* Type: TEXT
*/
public static final String LICENSE_EXPIRY_TIME = "license_expiry_time";
/**
- * The available time left before the license expires.
+ * This is a duration-based constaint. It represents the available time left
+ * before the license expires.
* <p>
* Type: TEXT
*/
public static final String LICENSE_AVAILABLE_TIME = "license_available_time";
/**
- * The data stream for extended metadata.
+ * This is a user-defined constraint. It represents the additional constraint
+ * using extended metadata.
* <p>
* Type: TEXT
*/
@@ -88,6 +108,12 @@ public class DrmStore {
* A trigger information object type.
*/
public static final int TRIGGER_OBJECT = 0x03;
+
+ /**
+ * @deprecated This class should have been an interface instead.
+ * The default constuctor should have not been exposed.
+ */
+ public DrmObjectType() {}
}
/**
@@ -123,6 +149,12 @@ public class DrmStore {
}
return isValid;
}
+
+ /**
+ * @deprecated This class should have been an interface instead.
+ * The default constuctor should have not been exposed.
+ */
+ public Playback() {}
}
/**
@@ -178,6 +210,12 @@ public class DrmStore {
}
return isValid;
}
+
+ /**
+ * @deprecated This class should have been an interface instead.
+ * The default constuctor should have not been exposed.
+ */
+ public Action() {}
}
/**
@@ -200,6 +238,18 @@ public class DrmStore {
* The digital rights have not been acquired for the rights-protected content.
*/
public static final int RIGHTS_NOT_ACQUIRED = 0x03;
+
+ /**
+ * @deprecated This class should have been an interface instead.
+ * The default constuctor should have not been exposed.
+ */
+ public RightsStatus() {}
}
+
+ /**
+ * @deprecated This class should have been an interface instead.
+ * The default constuctor should have not been exposed.
+ */
+ public DrmStore() {}
}
diff --git a/drm/java/android/drm/DrmSupportInfo.java b/drm/java/android/drm/DrmSupportInfo.java
index 720c545..6484fa7 100755
--- a/drm/java/android/drm/DrmSupportInfo.java
+++ b/drm/java/android/drm/DrmSupportInfo.java
@@ -85,12 +85,23 @@ public class DrmSupportInfo {
* Retrieves the DRM plug-in (agent) description.
*
* @return The plug-in description.
+ * @deprecated The method name is mis-spelled, and it is replaced by
+ * {@link #getDescription()}.
*/
public String getDescriprition() {
return mDescription;
}
/**
+ * Retrieves the DRM plug-in (agent) description.
+ *
+ * @return The plug-in description.
+ */
+ public String getDescription() {
+ return mDescription;
+ }
+
+ /**
* Overridden hash code implementation.
*
* @return The hash code value.
diff --git a/drm/java/android/drm/DrmUtils.java b/drm/java/android/drm/DrmUtils.java
index dc5f1fa..4f7cb22 100755
--- a/drm/java/android/drm/DrmUtils.java
+++ b/drm/java/android/drm/DrmUtils.java
@@ -55,8 +55,8 @@ public class DrmUtils {
bufferedStream.read(data);
}
} finally {
- quiteDispose(bufferedStream);
- quiteDispose(inputStream);
+ quietlyDispose(bufferedStream);
+ quietlyDispose(inputStream);
}
return data;
}
@@ -70,7 +70,7 @@ public class DrmUtils {
outputStream = new FileOutputStream(path);
outputStream.write(data);
} finally {
- quiteDispose(outputStream);
+ quietlyDispose(outputStream);
}
}
}
@@ -80,7 +80,7 @@ public class DrmUtils {
file.delete();
}
- private static void quiteDispose(InputStream stream) {
+ private static void quietlyDispose(InputStream stream) {
try {
if (null != stream) {
stream.close();
@@ -90,7 +90,7 @@ public class DrmUtils {
}
}
- private static void quiteDispose(OutputStream stream) {
+ private static void quietlyDispose(OutputStream stream) {
try {
if (null != stream) {
stream.close();
@@ -175,14 +175,34 @@ public class DrmUtils {
}
}
+ /**
+ * This method returns an iterator object that can be used to iterate over
+ * all values of the metadata.
+ *
+ * @return The iterator object.
+ */
public Iterator<String> iterator() {
return mMap.values().iterator();
}
+ /**
+ * This method returns an iterator object that can be used to iterate over
+ * all keys of the metadata.
+ *
+ * @return The iterator object.
+ */
public Iterator<String> keyIterator() {
return mMap.keySet().iterator();
}
+ /**
+ * This method retrieves the metadata value associated with a given key.
+ *
+ * @param key The key whose value is being retrieved.
+ *
+ * @return The metadata value associated with the given key. Returns null
+ * if the key is not found.
+ */
public String get(String key) {
return mMap.get(key);
}
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index c9c0d57..8768c08 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -116,12 +116,18 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu
return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
}
-sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
- return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
+sp<DecryptHandle> DrmManagerClient::openDecryptSession(
+ int fd, off64_t offset, off64_t length, const char* mime) {
+
+ return mDrmManagerClientImpl->openDecryptSession(
+ mUniqueId, fd, offset, length, mime);
}
-sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) {
- return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
+sp<DecryptHandle> DrmManagerClient::openDecryptSession(
+ const char* uri, const char* mime) {
+
+ return mDrmManagerClientImpl->openDecryptSession(
+ mUniqueId, uri, mime);
}
status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index b222b8f..fb0439e 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -255,15 +255,19 @@ status_t DrmManagerClientImpl::getAllSupportInfo(
}
sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
- int uniqueId, int fd, off64_t offset, off64_t length) {
- return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
+ int uniqueId, int fd, off64_t offset,
+ off64_t length, const char* mime) {
+
+ return getDrmManagerService()->openDecryptSession(
+ uniqueId, fd, offset, length, mime);
}
sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession(
- int uniqueId, const char* uri) {
+ int uniqueId, const char* uri, const char* mime) {
+
DecryptHandle* handle = NULL;
if (NULL != uri) {
- handle = getDrmManagerService()->openDecryptSession(uniqueId, uri);
+ handle = getDrmManagerService()->openDecryptSession(uniqueId, uri, mime);
}
return handle;
}
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index ac2b946..c9167d4 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -111,9 +111,10 @@ public:
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+ DecryptHandle* openDecryptSession(
+ int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
- DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+ DecryptHandle* openDecryptSession(int uniqueId, const char* uri, const char* mime);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index e3338d9..2aa493f 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -300,20 +300,24 @@ public:
* @param[in] fd File descriptor of the protected content to be decrypted
* @param[in] offset Start position of the content
* @param[in] length The length of the protected content
+ * @param[in] mime The mime type of the protected content if it is not NULL or empty
* @return
* Handle for the decryption session
*/
- sp<DecryptHandle> openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+ sp<DecryptHandle> openDecryptSession(
+ int uniqueId, int fd, off64_t offset, off64_t length, const char* mime);
/**
* Open the decrypt session to decrypt the given protected content
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] uri Path of the protected content to be decrypted
+ * @param[in] mime The mime type of the protected content if it is not NULL or empty
* @return
* Handle for the decryption session
*/
- sp<DecryptHandle> openDecryptSession(int uniqueId, const char* uri);
+ sp<DecryptHandle> openDecryptSession(
+ int uniqueId, const char* uri, const char* mime);
/**
* Close the decrypt session for the given handle
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index 9cb5804..1a8c2ae 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -98,9 +98,11 @@ public:
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+ DecryptHandle* openDecryptSession(
+ int uniqueId, int fd, off64_t offset, off64_t length, const char *mime);
- DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+ DecryptHandle* openDecryptSession(
+ int uniqueId, const char* uri, const char* mime);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index b9618bb..a7d21c5 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -139,9 +139,12 @@ public:
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
- virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0;
+ virtual DecryptHandle* openDecryptSession(
+ int uniqueId, int fd, off64_t offset,
+ off64_t length, const char* mime) = 0;
- virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
+ virtual DecryptHandle* openDecryptSession(
+ int uniqueId, const char* uri, const char* mime) = 0;
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
@@ -222,9 +225,12 @@ public:
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
+ virtual DecryptHandle* openDecryptSession(
+ int uniqueId, int fd, off64_t offset, off64_t length,
+ const char* mime);
- virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
+ virtual DecryptHandle* openDecryptSession(
+ int uniqueId, const char* uri, const char* mime);
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index 4a5afcf..08f6e6d 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -80,10 +80,12 @@ public:
DrmSupportInfo* getSupportInfo(int uniqueId);
status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
+ int uniqueId, DecryptHandle* decryptHandle,
+ int fd, off64_t offset, off64_t length, const char* mime);
status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, const char* uri);
+ int uniqueId, DecryptHandle* decryptHandle,
+ const char* uri, const char* mime);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
@@ -375,7 +377,29 @@ protected:
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
+ int uniqueId, DecryptHandle* decryptHandle,
+ int fd, off64_t offset, off64_t length) = 0;
+
+ /**
+ * Open the decrypt session to decrypt the given protected content
+ *
+ * @param[in] uniqueId Unique identifier for a session
+ * @param[in] decryptHandle Handle for the current decryption session
+ * @param[in] fd File descriptor of the protected content to be decrypted
+ * @param[in] offset Start position of the content
+ * @param[in] length The length of the protected content
+ * @param[in] mime Mime type of the protected content
+ * drm plugin may do some optimization since the mime type is known.
+ * @return
+ * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+ */
+ virtual status_t onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle,
+ int fd, off64_t offset, off64_t length,
+ const char* mime) {
+
+ return DRM_ERROR_CANNOT_HANDLE;
+ }
/**
* Open the decrypt session to decrypt the given protected content
@@ -387,7 +411,26 @@ protected:
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+ int uniqueId, DecryptHandle* decryptHandle,
+ const char* uri) = 0;
+
+ /**
+ * Open the decrypt session to decrypt the given protected content
+ *
+ * @param[in] uniqueId Unique identifier for a session
+ * @param[in] decryptHandle Handle for the current decryption session
+ * @param[in] uri Path of the protected content to be decrypted
+ * @param[in] mime Mime type of the protected content. The corresponding
+ * drm plugin may do some optimization since the mime type is known.
+ * @return
+ * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
+ */
+ virtual status_t onOpenDecryptSession(
+ int uniqueId, DecryptHandle* decryptHandle,
+ const char* uri, const char* mime) {
+
+ return DRM_ERROR_CANNOT_HANDLE;
+ }
/**
* Close the decrypt session for the given handle
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index 77460f6..dcf5977 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -320,11 +320,14 @@ public:
* @param[in] fd File descriptor of the protected content to be decrypted
* @param[in] offset Start position of the content
* @param[in] length The length of the protected content
+ * @param[in] mime Mime type of the protected content if it is
+ * not NULL or empty
* @return
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
+ int uniqueId, DecryptHandle* decryptHandle,
+ int fd, off64_t offset, off64_t length, const char* mime) = 0;
/**
* Open the decrypt session to decrypt the given protected content
@@ -332,11 +335,14 @@ public:
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the current decryption session
* @param[in] uri Path of the protected content to be decrypted
+ * @param[in] mime Mime type of the protected content if it is
+ * not NULL or empty
* @return
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
+ int uniqueId, DecryptHandle* decryptHandle,
+ const char* uri, const char* mime) = 0;
/**
* Close the decrypt session for the given handle