summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-02-28 14:34:02 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-28 14:34:02 -0800
commit2f16d7eae1b2dfd87be5fc55be3bec012ab7389d (patch)
tree824b876f5311a8e5cf04880be5fd79c25a204b13 /drm
parente512ad5089eef76d080fc6fdd17dfb88ad8b72e9 (diff)
parent5cb68c86ccb34d42bd4fb59128043037f74763a3 (diff)
downloadframeworks_base-2f16d7eae1b2dfd87be5fc55be3bec012ab7389d.zip
frameworks_base-2f16d7eae1b2dfd87be5fc55be3bec012ab7389d.tar.gz
frameworks_base-2f16d7eae1b2dfd87be5fc55be3bec012ab7389d.tar.bz2
Merge "Fix API issues in DrmRights class."
Diffstat (limited to 'drm')
-rwxr-xr-xdrm/java/android/drm/DrmRights.java55
1 files changed, 22 insertions, 33 deletions
diff --git a/drm/java/android/drm/DrmRights.java b/drm/java/android/drm/DrmRights.java
index d4afed1..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);
@@ -114,28 +112,19 @@ public class DrmRights {
* 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("")) {
- throw new IllegalArgumentException("accountId: " + accountId);
- }
- mAccountId = accountId;
-
- String subscriptionId = data.getSubscriptionId();
- if (null == subscriptionId || !subscriptionId.equals("")) {
- throw new IllegalArgumentException(
- "subscriptionId: " + subscriptionId);
- }
- 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;