From f5d082e611cd4e9444697cfecad05870f206eeb5 Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Tue, 30 Jun 2020 11:30:10 -0400 Subject: [PATCH] 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 --- .../com/android/server/notification/ShortcutHelper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/ShortcutHelper.java b/services/core/java/com/android/server/notification/ShortcutHelper.java index 94b690a4dfce8..9c3d6d352c894 100644 --- a/services/core/java/com/android/server/notification/ShortcutHelper.java +++ b/services/core/java/com/android/server/notification/ShortcutHelper.java @@ -102,9 +102,13 @@ public class ShortcutHelper { HashMap shortcutBubbles = mActiveShortcutBubbles.get(packageName); ArrayList bubbleKeysToRemove = new ArrayList<>(); if (shortcutBubbles != null) { + // Copy to avoid a concurrent modification exception when we remove bubbles from + // shortcutBubbles. + final Set 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)) {