OSDN Git Service

Formalizing states in BatterySaverStateMachine.
authorKweku Adams <kwekua@google.com>
Thu, 7 Mar 2019 23:38:21 +0000 (15:38 -0800)
committerKweku Adams <kwekua@google.com>
Tue, 19 Mar 2019 01:31:11 +0000 (18:31 -0700)
commitf57f99edd721af648840c92aa0f05001c52dad6b
treeff9b63bc040d5490165ab679ce2d32599cef7195
parent0718f9d0d564ea0ab0480119999cc400181889e1
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
core/proto/android/server/powermanagerservice.proto
services/core/java/com/android/server/power/batterysaver/BatterySaverController.java
services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
services/tests/mockingservicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java