Avoid another concurrent modification exception in ShortcutHelper.

Bug: 159923411
Test: atest SystemUITests
Test: add a lot of test bubbles along w/ fb bubbles, uninstall bubbles test app, no crash!
Change-Id: Iede3f1aa776c96d1498667b7e50c85db0ddafe5b
This commit is contained in:
Josh Tsuji
2020-06-30 11:30:10 -04:00
parent f629b618a4
commit f5d082e611

View File

@@ -102,9 +102,13 @@ public class ShortcutHelper {
HashMap<String, String> shortcutBubbles = mActiveShortcutBubbles.get(packageName);
ArrayList<String> bubbleKeysToRemove = new ArrayList<>();
if (shortcutBubbles != null) {
// Copy to avoid a concurrent modification exception when we remove bubbles from
// shortcutBubbles.
final Set<String> shortcutIds = new HashSet<>(shortcutBubbles.keySet());
// If we can't find one of our bubbles in the shortcut list, that bubble needs
// to be removed.
for (String shortcutId : shortcutBubbles.keySet()) {
for (String shortcutId : shortcutIds) {
boolean foundShortcut = false;
for (int i = 0; i < shortcuts.size(); i++) {
if (shortcuts.get(i).getId().equals(shortcutId)) {