Synchronize on the SparseArray object in PendingTempAllowlists.
The field mPendingTempAllowlist in PendingTempAllowlists is a SparseArray. In ActivityManagerService, the lock protection for PendingTempAllowlists object is: @CompositeRWLock({"this", "mProcLock"}) final PendingTempAllowlists mPendingTempAllowlist Which means the mPendingTempAllowlist object can be read when either "this" lock or "mProcLock" lock is held. But the read-operation of SparseArray such as indexOfKey() and size() etc, actually mutate the SparseArray by calling SparseArray.gc(). This makes @CompositeRWLock not to be compatible with SparseArray. Since we can not make SparseArray thread-safe, also we want to maintain the semantic of @CompositeRWLock, we can make PendingTempAllowlists thread-safe at least. Bug: 193788840 Test: Regression test. Change-Id: Ie1c239ad27d1fd6b76676951b470605513848b20
Loading
Please register or sign in to comment