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

Commit 186b8690 authored by Jae Seo's avatar Jae Seo Committed by Android (Google) Code Review
Browse files

Merge "Ensure that custom label isn't empty" into lmp-dev

parents 4c8db339 05abff10
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -624,7 +624,7 @@ public final class TvInputInfo implements Parcelable {
                return new ArrayList<String>();
            }
            String[] ids = hiddenIdsString.split(TV_INPUT_SEPARATOR);
            return Arrays.asList(ids);
            return new ArrayList(Arrays.asList(ids));
        }

        /**
@@ -665,7 +665,7 @@ public final class TvInputInfo implements Parcelable {
            StringBuilder builder = new StringBuilder();
            boolean firstItem = true;
            for (String inputId : hiddenInputIds) {
                ensureSeparatorIsNotIncluded(inputId);
                ensureValidField(inputId);
                if (firstItem) {
                    firstItem = false;
                } else {
@@ -692,8 +692,8 @@ public final class TvInputInfo implements Parcelable {
            StringBuilder builder = new StringBuilder();
            boolean firstItem = true;
            for (Pair<String, String> pair : customLabels) {
                ensureSeparatorIsNotIncluded(pair.first);
                ensureSeparatorIsNotIncluded(pair.second);
                ensureValidField(pair.first);
                ensureValidField(pair.second);
                if (firstItem) {
                    firstItem = false;
                } else {
@@ -707,7 +707,10 @@ public final class TvInputInfo implements Parcelable {
                    Settings.Secure.TV_INPUT_CUSTOM_LABELS, builder.toString(), userId);
        }

        private static void ensureSeparatorIsNotIncluded(String value) {
        private static void ensureValidField(String value) {
            if (TextUtils.isEmpty(value)) {
                throw new IllegalArgumentException(value + " should not empty ");
            }
            if (value.contains(TV_INPUT_SEPARATOR)) {
                throw new IllegalArgumentException(value + " should not include "
                        + TV_INPUT_SEPARATOR);