summaryrefslogtreecommitdiffstats
path: root/drm/java
diff options
context:
space:
mode:
authorTakeshi Aimi <aimitakeshi@gmail.com>2010-11-16 13:56:11 +0900
committerTakeshi Aimi <aimitakeshi@gmail.com>2010-11-19 22:02:51 +0900
commitdc91865622e3cc9ff0bb33b83f1d3b38cd7a6d7a (patch)
tree910ec95f6e2716cf6911da7247eaee49dc149933 /drm/java
parent14ac9546367d4df37eead55f6762b944b49f33b2 (diff)
downloadframeworks_base-dc91865622e3cc9ff0bb33b83f1d3b38cd7a6d7a.zip
frameworks_base-dc91865622e3cc9ff0bb33b83f1d3b38cd7a6d7a.tar.gz
frameworks_base-dc91865622e3cc9ff0bb33b83f1d3b38cd7a6d7a.tar.bz2
Update of DRM Framework.
-Access permission handling Introduce an internal function which allows the desired process to access decryption flow. This new function is just for reference and each OEM manufacturer should implement/replace with their solutions. -New API, getMetadata() This API is for retrieving media metadata from container-based DRM, such as OMA forward-lock content. This API asks DRM agent to retrieve media metadata hiddein inside of DRM special container. -New API, acquireRights() This API wraps acquireDrmInfo() and processDrmInfo(). If DRM agent has valid implementation of both APIs, Application can acquire DrmRights only by calling this API. -Bug fix in event loop of OnInfoListener. Separate OnInfo event loop from mail thread loop so as to avoid the issue that message is not dispatched when mail thread is busy. Changes are made by SEMC and Sony. Change-Id: I04ee3e0988152a71e221f2256d83253749a29da0
Diffstat (limited to 'drm/java')
-rw-r--r--drm/java/android/drm/DrmErrorEvent.java5
-rw-r--r--drm/java/android/drm/DrmEvent.java6
-rw-r--r--drm/java/android/drm/DrmManagerClient.java97
3 files changed, 60 insertions, 48 deletions
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java
index 9294884..20fd8aa 100644
--- a/drm/java/android/drm/DrmErrorEvent.java
+++ b/drm/java/android/drm/DrmErrorEvent.java
@@ -53,11 +53,6 @@ public class DrmErrorEvent extends DrmEvent {
* associated with all DRM schemes.
*/
public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007;
- /**
- * TYPE_DRM_INFO_ACQUISITION_FAILED, when failed to get the required information to
- * communicate with the service.
- */
- public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2008;
/**
* constructor to create DrmErrorEvent object with given parameters
diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java
index 583337f..f7bc5cd 100644
--- a/drm/java/android/drm/DrmEvent.java
+++ b/drm/java/android/drm/DrmEvent.java
@@ -31,14 +31,8 @@ public class DrmEvent {
* Constant field signifies that given information is processed successfully
*/
public static final int TYPE_DRM_INFO_PROCESSED = 1002;
- /**
- * Constant field signifies that the required information to communicate with
- * the service is acquired sucessfully
- */
- public static final int TYPE_DRM_INFO_ACQUIRED = 1003;
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
- public static final String DRM_INFO_OBJECT = "drm_info_object";
private final int mUniqueId;
private final int mType;
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index 5044d36..2f54b33 100644
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -102,8 +102,7 @@ public class DrmManagerClient {
}
private static final int ACTION_REMOVE_ALL_RIGHTS = 1001;
- private static final int ACTION_ACQUIRE_DRM_INFO = 1002;
- private static final int ACTION_PROCESS_DRM_INFO = 1003;
+ private static final int ACTION_PROCESS_DRM_INFO = 1002;
private int mUniqueId;
private int mNativeContext;
@@ -126,18 +125,6 @@ public class DrmManagerClient {
HashMap<String, Object> attributes = new HashMap<String, Object>();
switch(msg.what) {
- case ACTION_ACQUIRE_DRM_INFO: {
- final DrmInfoRequest request = (DrmInfoRequest) msg.obj;
- DrmInfo drmInfo = _acquireDrmInfo(mUniqueId, request);
- if (null != drmInfo) {
- attributes.put(DrmEvent.DRM_INFO_OBJECT, drmInfo);
- event = new DrmEvent(mUniqueId, DrmEvent.TYPE_DRM_INFO_ACQUIRED, null);
- } else {
- error = new DrmErrorEvent(mUniqueId,
- DrmErrorEvent.TYPE_DRM_INFO_ACQUISITION_FAILED, null);
- }
- break;
- }
case ACTION_PROCESS_DRM_INFO: {
final DrmInfo drmInfo = (DrmInfo) msg.obj;
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
@@ -243,19 +230,14 @@ public class DrmManagerClient {
*/
public DrmManagerClient(Context context) {
mContext = context;
- Looper looper;
- if (null != (looper = Looper.myLooper())) {
- mInfoHandler = new InfoHandler(looper);
- } else if (null != (looper = Looper.getMainLooper())) {
- mInfoHandler = new InfoHandler(looper);
- } else {
- mInfoHandler = null;
- }
+ HandlerThread infoThread = new HandlerThread("DrmManagerClient.InfoHandler");
+ infoThread.start();
+ mInfoHandler = new InfoHandler(infoThread.getLooper());
- HandlerThread thread = new HandlerThread("DrmManagerClient.EventHandler");
- thread.start();
- mEventHandler = new EventHandler(thread.getLooper());
+ HandlerThread eventThread = new HandlerThread("DrmManagerClient.EventHandler");
+ eventThread.start();
+ mEventHandler = new EventHandler(eventThread.getLooper());
// save the unique id
mUniqueId = hashCode();
@@ -335,10 +317,24 @@ public class DrmManagerClient {
return _getConstraints(mUniqueId, path, action);
}
+ /**
+ * Get metadata information from DRM content
+ *
+ * @param path Content path from where DRM metadata would be retrieved.
+ * @return ContentValues instance in which metadata key-value pairs are embedded
+ * or null in case of failure
+ */
+ public ContentValues getMetadata(String path) {
+ if (null == path || path.equals("")) {
+ throw new IllegalArgumentException("Given path is invalid/null");
+ }
+ return _getMetadata(mUniqueId, path);
+ }
+
/**
* Get constraints information evaluated from DRM content
*
- * @param uri The Content URI of the data
+ * @param uri Content URI from where DRM constraints would be retrieved.
* @param action Actions defined in {@link DrmStore.Action}
* @return ContentValues instance in which constraints key-value pairs are embedded
* or null in case of failure
@@ -350,6 +346,20 @@ public class DrmManagerClient {
return getConstraints(convertUriToPath(uri), action);
}
+ /**
+ * Get metadata information from DRM content
+ *
+ * @param uri Content URI from where DRM metadata would be retrieved.
+ * @return ContentValues instance in which metadata key-value pairs are embedded
+ * or null in case of failure
+ */
+ public ContentValues getMetadata(Uri uri) {
+ if (null == uri || Uri.EMPTY == uri) {
+ throw new IllegalArgumentException("Uri should be non null");
+ }
+ return getMetadata(convertUriToPath(uri));
+ }
+
/**
* Save DRM rights to specified rights path
* and make association with content path.
@@ -408,7 +418,7 @@ public class DrmManagerClient {
/**
* Check whether the given mimetype or uri can be handled.
*
- * @param uri The content URI of the data
+ * @param uri Content URI of the data to be handled.
* @param mimeType Mimetype of the object to be handled
* @return
* true - if the given mimeType or path can be handled
@@ -445,20 +455,31 @@ public class DrmManagerClient {
* Retrieves necessary information for register, unregister or rights acquisition.
*
* @param drmInfoRequest Request information to retrieve drmInfo
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @return DrmInfo Instance as a result of processing given input
*/
- public int acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
+ public DrmInfo acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
}
- int result = ERROR_UNKNOWN;
- if (null != mEventHandler) {
- Message msg = mEventHandler.obtainMessage(ACTION_ACQUIRE_DRM_INFO, drmInfoRequest);
- result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
- }
- return result;
+ return _acquireDrmInfo(mUniqueId, drmInfoRequest);
+ }
+
+ /**
+ * Executes given DrmInfoRequest and returns the rights information asynchronously.
+ * This is a utility API which consists of {@link #acquireDrmInfo(DrmInfoRequest)}
+ * and {@link #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
+ * {@link #acquireDrmInfo(DrmInfoRequest)} and {@link #processDrmInfo(DrmInfo)}, separately.
+ *
+ * @param drmInfoRequest Request information to retrieve drmInfo
+ * @return
+ * ERROR_NONE for success
+ * ERROR_UNKNOWN for failure
+ */
+ public int acquireRights(DrmInfoRequest drmInfoRequest) {
+ DrmInfo drmInfo = acquireDrmInfo(drmInfoRequest);
+ return processDrmInfo(drmInfo);
}
/**
@@ -750,6 +771,8 @@ public class DrmManagerClient {
private native ContentValues _getConstraints(int uniqueId, String path, int usage);
+ private native ContentValues _getMetadata(int uniqueId, String path);
+
private native boolean _canHandle(int uniqueId, String path, String mimeType);
private native DrmInfoStatus _processDrmInfo(int uniqueId, DrmInfo drmInfo);