Fix getLevelLocales crash due to modify collection during iteration am: fa53f6ee90 am: a6448a12de
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/opt/localepicker/+/18124562
Change-Id: Ie4d662751c6eadaa3282d203e9f536759d3e6a3c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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