Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 226a778c authored by Thomas Stuart's avatar Thomas Stuart Committed by Android Build Coastguard Worker
Browse files

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:e59a05ecadb572df4b76c98e63165505deefc660)
Merged-In: Id4b4358b141bb211a7e340b979774850b4bd2403
Change-Id: Id4b4358b141bb211a7e340b979774850b4bd2403
parent 2f889a8e
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -64,6 +64,14 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
     * @hide
     */
    public static final int DEFAULT_DESTINATION_PORT = DESTINATION_PORT_ANY;
    /**
     * @hide
     */
    public static final int MAX_STRING_LENGTH = 256;
    /**
     * @hide
     */
    public static final int MAX_LIST_SIZE = 100;

    /**
     * Builder class for {@link VisualVoicemailSmsFilterSettings} objects.
@@ -82,11 +90,16 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
        /**
         * Sets the client prefix for the visual voicemail SMS filter. The client prefix will appear
         * at the start of a visual voicemail SMS message, followed by a colon(:).
         * @throws IllegalArgumentException if the string length is greater than 256 characters
         */
        public Builder setClientPrefix(String clientPrefix) {
            if (clientPrefix == null) {
                throw new IllegalArgumentException("Client prefix cannot be null");
            }
            if (clientPrefix.length() > MAX_STRING_LENGTH) {
                throw new IllegalArgumentException("Client prefix cannot be greater than "
                        + MAX_STRING_LENGTH + " characters");
            }
            mClientPrefix = clientPrefix;
            return this;
        }
@@ -95,11 +108,25 @@ public final class VisualVoicemailSmsFilterSettings implements Parcelable {
         * Sets the originating number allow list for the visual voicemail SMS filter. If the list
         * is not null only the SMS messages from a number in the list can be considered as a visual
         * voicemail SMS. Otherwise, messages from any address will be considered.
         * @throws IllegalArgumentException if the size of the originatingNumbers list is greater
         * than 100 elements
         * @throws IllegalArgumentException if an element within the originatingNumbers list has
         * a string length greater than 256
         */
        public Builder setOriginatingNumbers(List<String> originatingNumbers) {
            if (originatingNumbers == null) {
                throw new IllegalArgumentException("Originating numbers cannot be null");
            }
            if (originatingNumbers.size() > MAX_LIST_SIZE) {
                throw new IllegalArgumentException("The originatingNumbers list size cannot be"
                        + " greater than " + MAX_STRING_LENGTH + " elements");
            }
            for (String num : originatingNumbers) {
                if (num != null && num.length() > MAX_STRING_LENGTH) {
                    throw new IllegalArgumentException("Numbers within the originatingNumbers list"
                            + " cannot be greater than" + MAX_STRING_LENGTH + " characters");
                }
            }
            mOriginatingNumbers = originatingNumbers;
            return this;
        }