From 5cb68c86ccb34d42bd4fb59128043037f74763a3 Mon Sep 17 00:00:00 2001 From: James Dong Date: Mon, 27 Feb 2012 18:34:04 -0800 Subject: 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 --- drm/java/android/drm/DrmRights.java | 55 +++++++++++++++---------------------- 1 file changed, 22 insertions(+), 33 deletions(-) (limited to 'drm') 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 ProcessedData. + *

+ * 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 DrmRights 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 DrmRights 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 DrmRights 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 DrmRights 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 DrmRights 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; -- cgit v1.1