summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2012-02-27 18:34:04 -0800
committerJames Dong <jdong@google.com>2012-02-27 18:34:04 -0800
commit5cb68c86ccb34d42bd4fb59128043037f74763a3 (patch)
tree94a5dcc3167c131147417ca6abdcb1b53ad9df26 /drm
parent6f9d697d8316f25be0e2a472604fd7e17d214c64 (diff)
downloadframeworks_base-5cb68c86ccb34d42bd4fb59128043037f74763a3.zip
frameworks_base-5cb68c86ccb34d42bd4fb59128043037f74763a3.tar.gz
frameworks_base-5cb68c86ccb34d42bd4fb59128043037f74763a3.tar.bz2
Fix API issues in DrmRights class.
o account id and subscription id are not mandatory, and thus can be anything such as null or an empty string. o removed unnecessary or thus inconsistent checks for account id and subscription id o updated the javadoc to specify that mimeType could not be null or an empty string. Change-Id: I704f1dd7fc5d33060da908aae0469d560c7db036
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;