• Home
  • History
  • Annotate
  • only in /frameworks/base/services/core/java/com/android/server/power/batterysaver/
History log of /frameworks/base/services/core/java/com/android/server/power/batterysaver/
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
1d146e4493b208e2dcdd201c1a1948d3558cd5a8 04-Jun-2018 Makoto Onuki <omakoto@google.com> Ensure automatic battery saver won't stick

Fixes: 80527470
Test: Manual tests:
Test 1: (make sure automatic BS won't stick)
- Set up automatic battery saver at N%
- Wait until the battery goes below N% -> Battery saver will turn on
- Turn off the device
- Charge it until the battery goes above N%
- Turn on the device
- Make sure battery saver is off.

Test 1: (make sure manual BS will stick)
- Make sure the battery level is above the automatic threshold
- Manually enable BS
- Reboot
- Make sure battery saver is on.

Change-Id: I677fd586f6b25d0200392941cac2d13b57fe10b3
atterySaverStateMachine.java
bd7a62538901e256148186006f60bd4dfa35469a 10-May-2018 Makoto Onuki <omakoto@google.com> Rework battery saver synchronization logic

- Stop using individual lock instances and use use the power manager lock.
- Make sure not to access external components with the lock held,
*except for settings provider*, which is already touched by the power manager
and the battery service

(I'm planning to re-organize things for Q: b/79580230)

Fixes: 79486713

Test: atest /android/pi-dev/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/Battery*Test.java /android/pi-dev/frameworks/base/services/tests/servicestests/src/com/android/server/power/*Test.java
Test: Manual test with ./development/scripts/battery_simulator.py with toggling
battery saver on and off and then watch
adb logcat -b all | grep -P '(battery_saving_stats|battery_saver_mode)'

Change-Id: I8ecdfefe978de348ee979d765c82e3d8f0280082
atterySaverController.java
atterySaverStateMachine.java
atterySavingStats.java
0f8617a646ebc33e2e85a6c61c9533393318d204 30-Apr-2018 Makoto Onuki <omakoto@google.com> Enhance battery saver event log

- Add reason to on/off log
- Add "threshold changed" event log

Bug: 78833408
Test: Manual test + logcat
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
Change-Id: Iddaff8dfa585923c3581552200ea2734b2c1a16d
atterySaverController.java
atterySaverStateMachine.java
6e5eb1dfa6b73e0f6f4dc98baf88a9826e2f1d25 31-Mar-2018 Makoto Onuki <omakoto@google.com> Fix dead lock between AM and BatterySaverStateMachine

Change-Id: If641ad1a0961376de65fdb9d557e7e2e601af389
Fixes: 77308319
Test: Boot, toggle battery saver
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
atterySaverStateMachine.java
a3cd7b9d53cdc98952365b12a8f9d5623726ed52 19-Mar-2018 Makoto Onuki <omakoto@google.com> Sticky battery saver

- When battery saver is enabled manually (i.e. via PM.setPowerSaveMode()),
it'll stick, and we'll re-enable battery saver even after a reboot
or a charge.

- Extracted all battery saver state transition logic into a separate
class.

Fix: 75033216
Bug: 74120126
Test: Manual test with "dumpsys battery set ...."
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySaverStateMachineTest.java
Change-Id: If020cd48f341b339783fe09dd35bc7199e737a52
Test: dumpsys power
Test: incident_report power
Test: atest CtsBatterySavingTestCases
atterySaverStateMachine.java
129349c8f0530765db65ded6f3975fe350938405 22-Mar-2018 Makoto Onuki <omakoto@google.com> Remove EBS notification

Bug: 76099413
Fix: 76099413
Bug: 76020920
Fix: 76020920
Test: manual test with ./development/scripts/battery_simulator.py
Change-Id: Ic51cae63703f6216224ecf00fcdabf5a325cb6ce
atterySaverController.java
7025c3c391d06de07dc7e12ab7ca033c35dd6599 16-Mar-2018 Makoto Onuki <omakoto@google.com> Also show "last BS off time" in dumpsys power

Change-Id: I53d7727847b84b29bdc8285c50ce59def4378684
Fix: 75024658
Bug: 75024658
Test: Manual test with dumpsys power
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
atterySavingStats.java
c733500d1de3db256f5f97b71920f55878b2156f 16-Mar-2018 Makoto Onuki <omakoto@google.com> Add phenotype flag to disable battery saver tron log

- Also improve dumpsys power output.

Example:
===============================================================================
Battery saving stats:
Battery Saver state: OFF
Times enabled: 4

Drain stats:
Battery saver OFF ON
NonDoze NonIntr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h
Intr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h
Deep NonIntr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h
Intr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h
Light NonIntr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h
Intr: 0m 0mAh( 0%) 0.0mAh/h 0m 0mAh( 0%) 0.0mAh/h

Battery saver policy (*NOTE* they only apply when battery saver is ON):
Settings: battery_saver_constants
value: send_tron_log=true
Settings: (overlay)
value:

vibration_disabled=true
animation_disabled=false
fullbackup_deferred=true
keyvaluebackup_deferred=true
firewall_disabled=false
datasaver_disabled=true
launch_boost_disabled=true
:
===============================================================================

Bug: 74742911
Fix: 75024658
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
Test: Manual test with "settings put global battery_saver_constants send_tron_log=true" and
"settings put global battery_saver_constants send_tron_log=false" with
logcat | grep 'sysui_multi.*,1302,'

Change-Id: If0593273e21ace7899ac95642dc9feef2515eea1
atterySavingStats.java
217f5abe76abe4735b3d67d9ad1370cf67a332e1 01-Mar-2018 Makoto Onuki <omakoto@google.com> Send ACTION_POWER_SAVE_MODE_CHANGING to secondary users too

Change-Id: I161506575390f8e28cdfbb2d684c18e10aab5aa5
Fix: 73963359
Test: manual test on a guest user on the BS setting screen.
atterySaverController.java
698f7a068fafa22cae782faf419ab0f6e8a31328 14-Feb-2018 Makoto Onuki <omakoto@google.com> Switch to tron events for battery saver logging

Bug: 73293341
Bug: 73296226
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
Test: manual test
Change-Id: I2230a4968b985a2a357b535c980deb1f8adb64df
atterySavingStats.java
a36dc621ef0b86a0bd46f1d4f5a719a466ba1800 06-Feb-2018 Andreas Gampe <agampe@google.com> Frameworks: Annotate trivial @GuardedBy in services/core

Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.

Derived by errorprone.

Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: I6993325b11c71a4ec27c21935fb54a954d95455f
atterySavingStats.java
ileUpdater.java
b76ed132d4758a19de38135b4faa151ca8b97116 08-Feb-2018 Makoto Onuki <omakoto@google.com> Update battery saving stats labels

Test: build & boot
Change-Id: Icd869e3bf841dee5d0cd11fefe02b966dcffb346
atterySavingStats.java
472d8e34c9b5d68f444b72139d4afef500d73491 31-Jan-2018 Makoto Onuki <omakoto@google.com> Add tron counter for battery % too

Bug: 72229630
Test: manual test with dumpsys power, etc
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
Change-Id: Iec9972a65f8a71bbcc85a1c177b268e91f90c434
atterySavingStats.java
04e9dc91d8005160fe4dcc003d61d9504dd75886 29-Jan-2018 Makoto Onuki <omakoto@google.com> Tron counters for battery saving stats.

It adds 4 sets of the following two counters:
- battery_saver_stats_seconds_XY
Time spent in the current mode, in seconds.
- battery_saver_stats_milliamps_XY
Battery spent in the current mode, in mA.

Where
X = "1":battery saver ON or "0": battery saver OFF.
Y = "1":device interactive or "0": device not interactive.

Which are sent when either of the above states is about to change.

For example, when the user turns on the screen, and turns it off in 60 seconds,
and the battery level dropped 1mA during this (w/ assuming battery saver OFF),
we'd send the following two values:

- battery_saver_stats_seconds_01 = 60
- battery_saver_stats_milliamps_01 = 1

Bug: 72229630
Test: manual test with dumpsys power, etc
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java
Change-Id: I8ab8c395ca17b64638b2b164211528ac74e49023
atterySavingStats.java
076218bfc0094c17f95c2e8afa4d5b2480f03f73 26-Jan-2018 Makoto Onuki <omakoto@google.com> Keep track of battery drain rate in various states...

... and print in dumpsys power.

Bug: 72229630
Test: manual test with dumpsys power, etc
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/BatterySavingStatsTest.java

Change-Id: I43949129ff03c1e0b0fa3aa603e0678b728538ee
atterySaverController.java
atterySavingStats.java
57f0f5513b593c206d8410922a667c8c5f79b2b8 11-Dec-2017 Makoto Onuki <omakoto@google.com> Battery saver: Expose location power save mode as system API

- Expose the location power save mode as a system API for the fuse
provider to change the behavior.

- Didn't choose to expose PowerManager.getPoserSaveState() because the result
class seems to be a bit ugly...

- Not all the modes are exposed since the two existing saving modes are
implemented within the system server and system apps don't need to know them.

Bug: 68769804
Test: Manual test with a test app
Change-Id: I25d8e68bfb79ebbeefbc241479077389c01e0f25
atterySaverLocationPlugin.java
2b186fa2142087cb3bb5d5996febe66b2aaf7aa3 29-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Disable location when screen is off.

Bug: 68769804
Test: manual test
Change-Id: Id93e250e5d189136dd267b21a3977ac95392c50b
atterySaverController.java
atterySaverLocationPlugin.java
9e0aba647c81a174ec5e80a902fa3748b0202bc3 04-Dec-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Extreme battery saver: Log BS state in the event log."
85dd0852fe506bcf800bea99aeb7af401e1485c4 01-Dec-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Log BS state in the event log.

Test: manual test (adb logcat -b events | grep battery_saver_mode)
Bug: 68769804
Change-Id: I93b26e3434a60dcae1efaa7ab8c78da2ba73192c
atterySaverController.java
f27dd76fa9f78eb116d3b425e9896d458aaf96fc 01-Dec-2017 Makoto Onuki <omakoto@google.com> Merge "Extreme battery saver: Show warning notification instead of toast"
afd6ff30816afc545cde4191d4eb56527ce207d6 30-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Remove spammy WTF.

Bug: 68769804
Test: manual test (boot and check logcat)
Change-Id: I3dc0e13a0191f3825f7f5257ae0dd2fdc52d68cc
puFrequencies.java
036cc818a9dea2383d1841133798ba83dbcaec03 30-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Show warning notification instead of toast

(Just for now; we'll remove it before shipping.)

Bug: 68769804
Test: manual test
Change-Id: Ib1d58fbc88f79a62030a2e59d1dce15e9ff1323a
atterySaverController.java
e098b7595a0ab4341a828a356e4dbfec333a6cdd 28-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Tweak to file saver

- Restore the default values after a runtime restart.
- debug.batterysaver.no_write_files sysprop to avoid writing max_freq

Bug 63527520
Test: manual
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/FileUpdaterTest.java

Change-Id: Ic4783f181252b063cfe7ea6fee47b9241f1688cc
atterySaverController.java
ileUpdater.java
1ecaf7c777cdf303e91ecc636af7814fb381f9af 27-Nov-2017 Makoto Onuki <omakoto@google.com> Don't show the battery saver toast when the screen turns on

Bug 68769804
Test: manual test

Change-Id: I4eca183f5e61d31d162d3d0914fe2dc94bb8a11e
atterySaverController.java
7e79be857e5415928a44d56388b538bc62ed8b52 22-Nov-2017 Makoto Onuki <omakoto@google.com> Merge "Extreme battery saver: Disable launch boost"
1e7010087727848a715ecfbc97be9d569dc36868 21-Nov-2017 TreeHugger Robot <treehugger-gerrit@google.com> Merge "Add OWNERS to system_server services."
a7d8c4d9ca619c2565aa7994305cdd8aa52fefc1 21-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Disable launch boost

Bug: 68769804
Test: manual test with debug log in nativeSendPowerHint().
Change-Id: I7ce61463215400379e0aa0d1782b2372495fe97e
atterySaverController.java
9fc31ee1f85e13a03bb15c435c98c6d3101c309e 21-Nov-2017 Michael Wright <michaelwr@google.com> Add OWNERS to system_server services.

Test: N/A
Change-Id: I60174fcbbf2a061df2961239ec1b45df2e6b20ed
WNERS
ce643a309e8d414395ec36188523d10eb64d6618 20-Nov-2017 Makoto Onuki <omakoto@google.com> Extreme battery saver: Cap max cpu frequency.

- Lower the max CPU frequency on battery saver.
- We have different sets of frequencies for screen-on and screen-off.
- The frequency configuration is from R.string.config_batterySaverDeviceSpecificConfig.

Bug: 68769804
Test: Manual test with settings put global battery_saver_device_specific_constants cpufreq-n=0:1324800/4:1497600,cpufreq-i=0:1900800/4:1958400
using cat_repeat /sys/devices/system/cpu/cpu{0,4}/cpufreq/{cpuinfo_cur,scaling_max}_freq

Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/CpuFrequenciesTest.java
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/power/batterysaver/FileUpdaterTest.java
Change-Id: Ie1bb11c46c0d4730129fe9d82e86d8acebe0b560
atterySaverController.java
puFrequencies.java
ileUpdater.java
3aaed2912be642d306fa223edcb58278b0e45795 16-Nov-2017 Makoto Onuki <omakoto@google.com> Follow-up for Ife38c2cd94ac9902911b005dbbca8b0d0a62e6d7

Address review comments on the previous CL.
(Plus a couple bug fixes.)

Test: atest BatterySaverPolicyTest
Test: manual test
Bug: 68769804
Change-Id: If2de9148d1b8175a9f0d66bc3a7ecd02ce7a620b
atterySaverController.java
66a7812bc90b5be7702fe5743d257fddcdb48201 15-Nov-2017 Makoto Onuki <omakoto@google.com> Refactor battery saver logic + add "per device" setting

- Extract the battery saver mode transition logic to BatterySaverController.

This now also supports running different code when screen turns on and off.

- BatterySaverPolicy now takes a "per-device configuration" from config.xml,
which can be overwritten via a global setting. We'll use this to set up
max CPU frequencies.

- The actual part to write max CPU frequencies is not finished yet.

Test: atest BatterySaverPolicyTest
Bug: 68769804
Change-Id: Ife38c2cd94ac9902911b005dbbca8b0d0a62e6d7
atterySaverController.java
ileUpdater.java