Fix race condition in lowlight trigger logic
If the ambient light changes quickly between regular/lowlight before the animations are done, the user can become stuck in a bad state. This is reproducible with adb by forcing/clearing lowlight very quickly. This fix updates the logic to use kotlin, since kotlin suspend functions and coroutines are cancellable and make implementing this kind of cancellation straightforward. Leaning into the kotlin framework to ensure we get cancellation correct, instead of implementing something similar in Java. We also add an additional safeguard of with a 2s timeout, in case the animation never finishes. This ensures that we reset the state and aren't stuck waiting on the animation forever. Bug: 274024126 Test: atest LowLightDreamManagerTest Test: atest LowLightTransitionCoordinatorTest Change-Id: I8078ce9a71074d123d27584d05a9a7f960255812
Loading
Please register or sign in to comment