No results found

Always Battery Saver - Xposed Module Repository

Always Battery Saver

Xposed Module Android Version GitHub issues GitHub release (latest by date)

An Xposed module to prevent Android from automatically disabling Battery Saver when the device is charging.

Problem & Solution

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.

Technical Overview

The module hooks methods within com.android.server.power.batterysaver.BatterySaverStateMachine:

  1. enableBatterySaverLocked (all variants):

    • Hooks all methods with this name using XposedBridge.hookAllMethods.
    • The 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.
  2. updateStateLocked:

    • Hooks this method using XposedBridge.hookAllMethods.
    • The 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.

Future Ideas (Maybe!)

I have some ideas for future enhancements, but these are not guaranteed:

  • Settings UI: Add a simple configuration UI to toggle the module’s functionality or potentially add more options later.
  • UI Unlocking: Hook the Battery Saver settings page and the Quick Settings tile to prevent them from becoming disabled or grayed out while the device is charging and Battery Saver is forced on by this module.
  • Extend Support to Android 5.0 (Lollipop): Power Saving Mode seems to be present in Android since API level 21, so supporting older devices might be feasible. This would require investigating compatibility with the BatterySaverStateMachine class or equivalent in those versions.

Troubleshooting / Compatibility

  • Functionality depends on AOSP class/method/field names (BatterySaverStateMachine, enableBatterySaverLocked, updateStateLocked, mIsPowered). Heavy OEM customization or future Android changes may break hooks.
  • Conflicts with other power-management Xposed modules are possible, though less likely given the specific target.
  • If Battery Saver still turns off, double-check module activation, scope (Android System) or (System Framework), and reboot. Check Xposed logs for errors related to AlwaysBatterySaver.
  • Report issues with logs on the Issues page.

Contribution

Contributions (issues, pull requests) are welcome, especially regarding compatibility improvements, hook refinements, and testing across different ROMs/versions.

Check Out My Other Project!

  • AlwaysCreateUser: An Xposed Framework module that bypasses Android’s user/profile creation limits, if you like system-level app cloning or isolation

Like the Project?

A small reaction (👍/❤️) on the Releases page helps!

Thanks

  • Xposed Framework Developers
  • CorePatch (Inspiration for hook structure)
  • LLMs (Gemini, DeepSeek, ChatGPT) for assistance.

Disclaimer: Use Xposed modules responsibly. Modifying system behavior carries inherent risks.

Package

io.github.icepony.alwaysbatterysaver

Authors

ice

Releases

Version 2.1: Reworked Controls & Fixes

Release Type: Stable

4/22/2025, 7:18:39 AM

View all releases

Releases

Version 2.1: Reworked Controls & Fixes

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:

  • Improved Reliability: The core logic that prevents Battery Saver from turning off has been completely rewritten. This should improve compatibility across different devices and Android versions.
  • New Control Options:
    • Prevent Disabling on Power: A new setting has been added that stops Battery Saver from automatically turning off only when your device is plugged in and detected as charging.
    • Hide Charging Status: This new option replaces the old "Block update charge state". It works by preventing the system from telling the Battery Saver component that your device is charging. This is another way to help keep Battery Saver active while plugged in.
    • 'Lock Battery Saver State' Updated: The experimental option to aggressively block any change to Battery Saver status has been updated internally.
  • Visual Tweaks: Added basic support for Dark Mode and made minor adjustments to the settings screen layout.

Minor Improvements:

  • In debug builds, the settings options will remain selectable even when the main 'Enable Module' switch is off.

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

Show older versions

© 2021 - 2025 New Xposed Module Repository