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

Skip to content
Commit 85cc1844 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Avoid race of checking screen states and sleep token

The callback *GoingToSleep and screenTurn* run on different threads,
so there could be a race if screen on/off in a short time and the
thread has some delays:
Thread1 gets isScreenOnEarly==false
Thread2 modifies isScreenOnEarly=true
Thread2 releases sleep-token
Thread1 acquire sleep-token
Then the final state is screen on but sleep-token is still acquired.

This change moves the fail-safe check from startedGoingToSleep
to finishedGoingToSleep>setAwake(false) and reuse the existing
SleepTokenAcquirer, so it is easier to acquire/release in
DisplayPolicy inside a lock. Now the check of isScreenOnEarly and
sleep-token in screenTurningOn and setAwake are synchronized.

Bug: 364760760
Flag: EXEMPT bugfix
Test: PhoneWindowManagerTests
Change-Id: I5c47b4a745fcd369d3ec825c41a7c1d35ce9feca
parent 2f4e0476
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