From cb8b3f27d28c74e9b2fcdcbaa071a8049be5cfa6 Mon Sep 17 00:00:00 2001 From: Schneider Victor-tulias Date: Tue, 20 Aug 2024 11:10:09 -0400 Subject: [PATCH] Handle multithreading in ActiveGestureLog ArrayList.add is not thread-safe. Attempting rapid calls across threads is the only way for it to throw ArrayIndexOutOfBoundsException. Flag: EXEMPT bug fix Fixes: 360619084 Test: checked TIS logs Change-Id: I66e5f2e13d5237717abcf42e56efa2942f317676 --- .../src/com/android/quickstep/util/ActiveGestureLog.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java index c54862aba3..d46b8fc51a 100644 --- a/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java +++ b/quickstep/src/com/android/quickstep/util/ActiveGestureLog.java @@ -23,6 +23,7 @@ import com.android.launcher3.util.Preconditions; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Locale; @@ -237,7 +238,8 @@ public class ActiveGestureLog { /** An entire log of entries associated with a single log ID */ protected static class EventLog { - protected final List eventEntries = new ArrayList<>(); + protected final List eventEntries = + Collections.synchronizedList(new ArrayList<>()); protected final int logId; protected final boolean mIsFullyGesturalNavMode;