Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2569de9f authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Make CommandQueue callbacks thread safe

There have been crashes as callbacks were added/removed from different threads.

Bug: 362719719
Bug: 412238143
Test: CommandQueueTest
Flag: NONE - trivial bugfix
Change-Id: I40db5a6e3211b46931b2548608e470f8c4b1092f
parent 198c0c89
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -85,8 +85,9 @@ import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * This class takes the functions from IStatusBar that come in on
@@ -198,7 +199,7 @@ public class CommandQueue extends IStatusBar.Stub implements
    private static final String SHOW_IME_SWITCHER_KEY = "showImeSwitcherKey";

    private final Object mLock = new Object();
    private final ArrayList<Callbacks> mCallbacks = new ArrayList<>();
    private final List<Callbacks> mCallbacks = new CopyOnWriteArrayList<Callbacks>();
    private final Handler mHandler = new H(Looper.getMainLooper());
    /** A map of display id - disable flag pair */
    private final SparseArray<Pair<Integer, Integer>> mDisplayDisabled = new SparseArray<>();