Skip to content

Commit 2b2c573

Browse files
James DongAndroid (Google) Code Review
authored andcommitted
Merge "Added checks for illegal arguments"
2 parents f65934a + 6c95d4f commit 2b2c573

File tree

4 files changed

+40
-4
lines changed

4 files changed

+40
-4
lines changed

drm/java/android/drm/DrmInfo.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public DrmInfo(int infoType, byte[] data, String mimeType) {
4949
mInfoType = infoType;
5050
mMimeType = mimeType;
5151
mData = data;
52+
if (!isValid()) {
53+
final String msg = "infoType: " + infoType + "," +
54+
"mimeType: " + mimeType + "," +
55+
"data: " + data;
56+
57+
throw new IllegalArgumentException(msg);
58+
}
5259
}
5360

5461
/**
@@ -69,6 +76,13 @@ public DrmInfo(int infoType, String path, String mimeType) {
6976
// call would fail with IllegalArgumentException because of mData = null
7077
mData = null;
7178
}
79+
if (!isValid()) {
80+
final String msg = "infoType: " + infoType + "," +
81+
"mimeType: " + mimeType + "," +
82+
"data: " + mData;
83+
84+
throw new IllegalArgumentException();
85+
}
7286
}
7387

7488
/**

drm/java/android/drm/DrmInfoRequest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public class DrmInfoRequest {
6767
public DrmInfoRequest(int infoType, String mimeType) {
6868
mInfoType = infoType;
6969
mMimeType = mimeType;
70+
if (!isValid()) {
71+
final String msg = "infoType: " + infoType + "," +
72+
"mimeType: " + mimeType;
73+
throw new IllegalArgumentException(msg);
74+
}
7075
}
7176

7277
/**

drm/java/android/drm/DrmInfoStatus.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ public class DrmInfoStatus {
5656
* @param _mimeType The MIME type.
5757
*/
5858
public DrmInfoStatus(int _statusCode, int _infoType, ProcessedData _data, String _mimeType) {
59+
if (!DrmInfoRequest.isValidType(_infoType)) {
60+
throw new IllegalArgumentException("infoType: " + _infoType);
61+
}
62+
5963
statusCode = _statusCode;
6064
infoType = _infoType;
6165
data = _data;

drm/java/android/drm/DrmRights.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ private void instantiate(File rightsFile, String mimeType) {
103103
}
104104

105105
mMimeType = mimeType;
106+
if (!isValid()) {
107+
final String msg = "mimeType: " + mMimeType + "," +
108+
"data: " + mData;
109+
throw new IllegalArgumentException(msg);
110+
}
106111
}
107112

108113
/**
@@ -117,17 +122,25 @@ public DrmRights(ProcessedData data, String mimeType) {
117122
mData = data.getData();
118123

119124
String accountId = data.getAccountId();
120-
if (null != accountId && !accountId.equals("")) {
121-
mAccountId = accountId;
125+
if (null == accountId || !accountId.equals("")) {
126+
throw new IllegalArgumentException("accountId: " + accountId);
122127
}
128+
mAccountId = accountId;
123129

124130
String subscriptionId = data.getSubscriptionId();
125-
if (null != subscriptionId && !subscriptionId.equals("")) {
126-
mSubscriptionId = subscriptionId;
131+
if (null == subscriptionId || !subscriptionId.equals("")) {
132+
throw new IllegalArgumentException(
133+
"subscriptionId: " + subscriptionId);
127134
}
135+
mSubscriptionId = subscriptionId;
128136
}
129137

130138
mMimeType = mimeType;
139+
if (!isValid()) {
140+
final String msg = "mimeType: " + mMimeType + "," +
141+
"data: " + mData;
142+
throw new IllegalArgumentException(msg);
143+
}
131144
}
132145

133146
/**

0 commit comments

Comments
 (0)