diff options
| author | 2023-03-23 13:25:58 +0000 | |
|---|---|---|
| committer | 2023-03-23 13:25:58 +0000 | |
| commit | 92a26b6f51b5f303cdcdaeab824e109b3dddc32e (patch) | |
| tree | 687fcc48d577a20345b1ed44e8cb669a2de37825 | |
| parent | 709879dc897ae5f121a14043470ae3d14b045b81 (diff) | |
Fix IndexOutOfBoundsException while handle app crash
The `mActivities` size could change while the the activity is
detached (r.detachFromProcess).
Bug: 274859740
Test: wm presubmit
Change-Id: I05d7b5a79d3f7cffca707a7ad7cce1b871f0c8ff
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowProcessController.java | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/services/core/java/com/android/server/wm/WindowProcessController.java b/services/core/java/com/android/server/wm/WindowProcessController.java index 8685723a5807..c34aa2b336cd 100644 --- a/services/core/java/com/android/server/wm/WindowProcessController.java +++ b/services/core/java/com/android/server/wm/WindowProcessController.java @@ -378,8 +378,9 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio } void handleAppCrash() { - for (int i = mActivities.size() - 1; i >= 0; --i) { - final ActivityRecord r = mActivities.get(i); + ArrayList<ActivityRecord> activities = new ArrayList<>(mActivities); + for (int i = activities.size() - 1; i >= 0; --i) { + final ActivityRecord r = activities.get(i); Slog.w(TAG, " Force finishing activity " + r.mActivityComponent.flattenToShortString()); r.detachFromProcess(); |