Formalizing states in BatterySaverStateMachine.
Formalizing the states and transitions makes it easier to add new functionality and guarantee correctness. This also fixes the issue where automatically turning off sticky accidentally turns off battery saver since the transition is only done when in the correct state. The problem was that when the battery level changed (above the sticky auto disable threshold), doAutoBatterySaver would be called. stickyEnabled would be true, and the level would be above the threshold, so it would disable sticky. Then at the next level drop, doAutoBatterySaver would be called again, but this time, sticky would be false, so it would go to automatic check and see that the level is above the threshold and then turn off battery saver. Bug: 127659938 Bug: 119764865 Bug: 112232746 Bug: 79580230 Test: atest com.android.server.power.batterysaver.BatterySaverStateMachineTest Test: atest CtsBatterySavingTestCases Change-Id: Ia311d8bdc593a1680eda82d4d06fee21ea45c0ba
Loading
Please register or sign in to comment