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

Commit 630a51cd authored by Nick Chameyev's avatar Nick Chameyev
Browse files

Fix ArrayIndexOutOfBoundsException in ScreenTimeoutPolicyListenersContainer

Guards access to mLastReportedState with mLock.

We had two usages without using mLock and on different threads:
- onCallbackDied on binder thread calls mLastReportedState.remove()
- notifyListenerIfNeeded reads/writes the map (on single thread), but as it could be also updated from a binder thread & it's not synchronized on a lock & the collection is not thread safe, we might get inconsistent state

Practically, I think right now this issue might likely happen only
when SystemUI crashes which causes onCallbackDied to be invoked
(SystemUI is the only current remote client, and we never call
 removeScreenTimeoutPolicyListener). The current bugreports contain SystemUI crash before this.

Also made mScreenTimeoutPolicy non-volatile as it is not needed anymore
(accessed only under mLock).

Test: atest NotifierTest
Flag: com.android.server.power.feature.flags.enable_screen_timeout_policy_listener_api
Bug: 414978378
Change-Id: Id32073b6e61c9104339e2fccc3006c5ff776e889
parent 06e23aca
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment