Fix DisplayManager race condition when state is unknown
The race was happening when: 1. STATE_UNKNOWN arrives to PhotonicModulator#setState. 2. Inside PhotonicModulator#setState, mStateChangeInprogress is set to true, and the setState method finishes. 3. in the run loop, in one iteration, we reach mLock.wait() (with mStateChangeInprogress still set to true, as the state changed from something to unknown). Now, setState can be executed again as the lock is not held anymore. 4. A new PhotonicModulator#setState arrives. however, mStateChangeInProgress is true, so mLock.notifyAll() is not called anymore. It was previously fixed by I903f6392cbe42031aab8ffdbfbe541463d6b5e01 making the display not going to UNKNOWN state anymore, but this cl fixes the general case and revert the changes to set the display to off in `onDisplayChanged`. Bug: 262294651 Test: Running foldable test suite for 20 times with abtd: before the fix it had high flakiness, after it had 0% flakiness. There are no tests for DisplayPowerState currently. Change-Id: I165b260d60e03c8e4707c7704847c77a225fd43d
Loading
Please register or sign in to comment