Skip to content

Commit 186b869

Browse files
Jae SeoAndroid (Google) Code Review
authored andcommitted
Merge "Ensure that custom label isn't empty" into lmp-dev
2 parents 4c8db33 + 05abff1 commit 186b869

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

media/java/android/media/tv/TvInputInfo.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public static List<String> getHiddenTvInputIds(Context context, int userId) {
624624
return new ArrayList<String>();
625625
}
626626
String[] ids = hiddenIdsString.split(TV_INPUT_SEPARATOR);
627-
return Arrays.asList(ids);
627+
return new ArrayList(Arrays.asList(ids));
628628
}
629629

630630
/**
@@ -665,7 +665,7 @@ public static void putHiddenTvInputList(Context context, List<String> hiddenInpu
665665
StringBuilder builder = new StringBuilder();
666666
boolean firstItem = true;
667667
for (String inputId : hiddenInputIds) {
668-
ensureSeparatorIsNotIncluded(inputId);
668+
ensureValidField(inputId);
669669
if (firstItem) {
670670
firstItem = false;
671671
} else {
@@ -692,8 +692,8 @@ public static void putCustomLabelList(Context context,
692692
StringBuilder builder = new StringBuilder();
693693
boolean firstItem = true;
694694
for (Pair<String, String> pair : customLabels) {
695-
ensureSeparatorIsNotIncluded(pair.first);
696-
ensureSeparatorIsNotIncluded(pair.second);
695+
ensureValidField(pair.first);
696+
ensureValidField(pair.second);
697697
if (firstItem) {
698698
firstItem = false;
699699
} else {
@@ -707,13 +707,16 @@ public static void putCustomLabelList(Context context,
707707
Settings.Secure.TV_INPUT_CUSTOM_LABELS, builder.toString(), userId);
708708
}
709709

710-
private static void ensureSeparatorIsNotIncluded(String value) {
710+
private static void ensureValidField(String value) {
711+
if (TextUtils.isEmpty(value)) {
712+
throw new IllegalArgumentException(value + " should not empty ");
713+
}
711714
if (value.contains(TV_INPUT_SEPARATOR)) {
712-
throw new IllegalArgumentException( value + " should not include "
715+
throw new IllegalArgumentException(value + " should not include "
713716
+ TV_INPUT_SEPARATOR);
714717
}
715718
if (value.contains(CUSTOM_NAME_SEPARATOR)) {
716-
throw new IllegalArgumentException( value + " should not include "
719+
throw new IllegalArgumentException(value + " should not include "
717720
+ CUSTOM_NAME_SEPARATOR);
718721
}
719722
}

0 commit comments

Comments
 (0)