Fix getLevelLocales crash due to modify collection during iteration Bug: 196308793 Test: mm LocalePickerRoboTests Change-Id: I1eb7e02cc2b805b381f3dd3439ec68f958949e48
diff --git a/src/com/android/localepicker/LocaleStore.java b/src/com/android/localepicker/LocaleStore.java index ff4f85a..c799bd3 100644 --- a/src/com/android/localepicker/LocaleStore.java +++ b/src/com/android/localepicker/LocaleStore.java
@@ -27,9 +27,9 @@ import androidx.annotation.VisibleForTesting; import java.io.Serializable; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.IllformedLocaleException; import java.util.Locale; import java.util.Set; @@ -352,7 +352,8 @@ String parentId = parent == null ? null : parent.getId(); HashSet<LocaleInfo> result = new HashSet<>(); - for (LocaleStore.LocaleInfo li : sLocaleCache.values()) { + ArrayList<LocaleStore.LocaleInfo> localeInfos = new ArrayList<>(sLocaleCache.values()); + for (LocaleStore.LocaleInfo li : localeInfos) { int level = getLevel(ignorables, li, translatedOnly); if (level == 2) { if (parent != null) { // region selection