Add AMS lock protection to mAppsInBackgroundRestricted collection

When the process is started asynchronously, the mAppsInBackgroundRestricted collection lacks AMS lock
protection and will throw ConcurrentModificationException
crash with a low probability.

Bug: 236582924
Test: Treehugger
Change-Id: Ieec1de9ee1fd336cf1de54566f80442e3cd3acdd
This commit is contained in:
Siting Mo
2022-07-11 15:32:25 +08:00
committed by Jing Ji
parent 184d8894f8
commit a7d6da8032

View File

@@ -2269,7 +2269,9 @@ public final class ProcessList {
final boolean inBgRestricted = ast.isAppBackgroundRestricted(
app.info.uid, app.info.packageName);
if (inBgRestricted) {
mAppsInBackgroundRestricted.add(app);
synchronized (mService) {
mAppsInBackgroundRestricted.add(app);
}
}
app.mState.setBackgroundRestricted(inBgRestricted);
}