diff options
| author | 2024-09-06 11:40:43 +0800 | |
|---|---|---|
| committer | 2024-09-06 12:23:49 +0800 | |
| commit | 85cc18447def03031850e3cc68659f1310ffe2b3 (patch) | |
| tree | 57b3987bd39a4116985b722a109f69ce27caab94 /api/api.go | |
| parent | 2f4e0476d0c690f7a5cb47c72cf61c03d6daf7fa (diff) | |
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
Diffstat (limited to 'api/api.go')
0 files changed, 0 insertions, 0 deletions