An Xposed module to prevent Android from automatically disabling Battery Saver when the device is charging.
Android’s default behavior disables Battery Saver upon charging. This module intercepts specific system calls within the Android System Server (android
package) to prevent this automatic deactivation, allowing Battery Saver to remain active even while plugged in.
The module hooks methods within com.android.server.power.batterysaver.BatterySaverStateMachine
:
enableBatterySaverLocked
(all variants):
XposedBridge.hookAllMethods
.beforeHookedMethod
callback checks configured options and can prevent the original method execution (param.setResult(null)
):
lock_on_plugged_in
: Checks if method arguments contain REASON_STRING_PLUGGED_IN
(“Plugged in”).lock_on_power
: Uses reflection to check the current state of the mIsPowered
field within the BatterySaverStateMachine
instance.lock_any
: Unconditionally blocks the method call.updateStateLocked
:
XposedBridge.hookAllMethods
.beforeHookedMethod
callback modifies internal state:
fake_power
: If enabled, uses reflection to set the mIsPowered
field of the BatterySaverStateMachine
instance to false
before the original method runs, effectively hiding the charging status from the state machine’s internal logic.Note: This module relies on specific class/method names and the mIsPowered
field name within AOSP. Significant changes by OEMs or in future Android versions could impact functionality.
I have some ideas for future enhancements, but these are not guaranteed:
BatterySaverStateMachine
class or equivalent in those versions.BatterySaverStateMachine
, enableBatterySaverLocked
, updateStateLocked
, mIsPowered
). Heavy OEM customization or future Android changes may break hooks.Android System
) or (System Framework
), and reboot. Check Xposed logs for errors related to AlwaysBatterySaver
.Contributions (issues, pull requests) are welcome, especially regarding compatibility improvements, hook refinements, and testing across different ROMs/versions.
A small reaction (👍/❤️) on the Releases page helps!
Disclaimer: Use Xposed modules responsibly. Modifying system behavior carries inherent risks.
io.github.icepony.alwaysbatterysaver
Release Type: Stable
4/22/2025, 7:18:39 AM
This update includes significant improvements to how the module works, offering more reliable control over Battery Saver and introducing new options.
Changes:
Minor Improvements:
We've made big changes under the hood, so please try out the new options and report any issues you find!
Full Changelog: icepony/AlwaysBatterySaver@v2.0...v2.1