Skip to content

Commit 4fc2444

Browse files
Thomas Stuartaoleary
Thomas Stuart
authored andcommitted
enforce limits for VisualVoicemailSmsFilterSettings properties
- clientPrefix is now limited to 256 characters - originatingNumbers is now limited to a list size of 100 and each element is also limited to 256 characters Bug: 308932906 Test: CTS (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:8201f7239c50316aa3c36d90e9f90d0a29e74be1) Merged-In: Id4b4358b141bb211a7e340b979774850b4bd2403 Change-Id: Id4b4358b141bb211a7e340b979774850b4bd2403
1 parent e0e83ca commit 4fc2444

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

telephony/java/android/telephony/VisualVoicemailSmsFilterSettings.java

+27
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
6464
* @hide
6565
*/
6666
public static final int DEFAULT_DESTINATION_PORT = DESTINATION_PORT_ANY;
67+
/**
68+
* @hide
69+
*/
70+
public static final int MAX_STRING_LENGTH = 256;
71+
/**
72+
* @hide
73+
*/
74+
public static final int MAX_LIST_SIZE = 100;
6775

6876
/**
6977
* Builder class for {@link VisualVoicemailSmsFilterSettings} objects.
@@ -82,11 +90,16 @@ public VisualVoicemailSmsFilterSettings build() {
8290
/**
8391
* Sets the client prefix for the visual voicemail SMS filter. The client prefix will appear
8492
* at the start of a visual voicemail SMS message, followed by a colon(:).
93+
* @throws IllegalArgumentException if the string length is greater than 256 characters
8594
*/
8695
public Builder setClientPrefix(String clientPrefix) {
8796
if (clientPrefix == null) {
8897
throw new IllegalArgumentException("Client prefix cannot be null");
8998
}
99+
if (clientPrefix.length() > MAX_STRING_LENGTH) {
100+
throw new IllegalArgumentException("Client prefix cannot be greater than "
101+
+ MAX_STRING_LENGTH + " characters");
102+
}
90103
mClientPrefix = clientPrefix;
91104
return this;
92105
}
@@ -95,11 +108,25 @@ public Builder setClientPrefix(String clientPrefix) {
95108
* Sets the originating number allow list for the visual voicemail SMS filter. If the list
96109
* is not null only the SMS messages from a number in the list can be considered as a visual
97110
* voicemail SMS. Otherwise, messages from any address will be considered.
111+
* @throws IllegalArgumentException if the size of the originatingNumbers list is greater
112+
* than 100 elements
113+
* @throws IllegalArgumentException if an element within the originatingNumbers list has
114+
* a string length greater than 256
98115
*/
99116
public Builder setOriginatingNumbers(List<String> originatingNumbers) {
100117
if (originatingNumbers == null) {
101118
throw new IllegalArgumentException("Originating numbers cannot be null");
102119
}
120+
if (originatingNumbers.size() > MAX_LIST_SIZE) {
121+
throw new IllegalArgumentException("The originatingNumbers list size cannot be"
122+
+ " greater than " + MAX_STRING_LENGTH + " elements");
123+
}
124+
for (String num : originatingNumbers) {
125+
if (num != null && num.length() > MAX_STRING_LENGTH) {
126+
throw new IllegalArgumentException("Numbers within the originatingNumbers list"
127+
+ " cannot be greater than" + MAX_STRING_LENGTH + " characters");
128+
}
129+
}
103130
mOriginatingNumbers = originatingNumbers;
104131
return this;
105132
}

0 commit comments

Comments
 (0)