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
This commit is contained in:
Pinyao Ting
2021-05-17 13:52:19 -07:00
parent 290fcdde7d
commit 018017e208

View File

@@ -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. */