From 018017e208311595928ca842b2a5a6af59834cb1 Mon Sep 17 00:00:00 2001 From: Pinyao Ting Date: Mon, 17 May 2021 13:52:19 -0700 Subject: [PATCH] Fix concurrent modification error in ShortcutService The internal api ShortcutService#postValue isn't protected by mLock and thus causing concurrent modification exception. This CL temprorary fixes the issue by protecting above api with existing lock. In the long run we should be moving the lock to package level, which will be implemented in b/186011943 Bug: 187062117, 188397473, 188277633 Test: manual Change-Id: I93537f8abe7a2ec2787949d109c6b3045664d8dd --- services/core/java/com/android/server/pm/ShortcutService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index 20f35f2218d12..1e9d7e1f8ad2d 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -1213,7 +1213,9 @@ public class ShortcutService extends IShortcutService.Stub { final String pkg = shortcutInfo.getPackage(); final int userId = shortcutInfo.getUserId(); final String id = shortcutInfo.getId(); - getPackageShortcutsLocked(pkg, userId).mutateShortcut(id, shortcutInfo, cb); + synchronized (mLock) { + getPackageShortcutsLocked(pkg, userId).mutateShortcut(id, shortcutInfo, cb); + } } /** Return the last reset time. */