ShizuStore

BatteryWatch

FoxSoftware-code

1.1.0 · GitHub

Download APK
Power management Android 12+ 15 hours ago MIT
73 ShizuStore
38 GitHub
2 Stars
21 MB Size

More about this app

Shows what drains your battery from batterystats, monitors charging (rate, capacity, overheating) and applies reversible fixes; with Shizuku it restricts and force-stops apps directly. No internet permission.

BatteryWatch (StraΕΌnik Baterii)

πŸ‡¬πŸ‡§ English Β· πŸ‡΅πŸ‡± Polski

CI Latest release Android 12+ Kotlin License: MIT

An Android app that shows what is really draining your battery and helps you fix it. It reads the same data the system uses (dumpsys batterystats, dumpsys cpuinfo), turns it into a readable diagnosis and suggests concrete fixes. Every fix can be undone.

No internet permission. All measurements and history stay on your phone. No ads, no trackers.

The interface is available in English and Polish and follows the system language. On Android 13+ you can also pick it per app: Settings β†’ Apps β†’ BatteryWatch β†’ Language.

Features

Screen What it shows
Live Charge level, current draw (mA / W), temperature, drain rate in %/h and the processes using the most CPU. Refreshes only while the screen is open.
Charging A monitor that runs only while plugged in and starts automatically when you connect a charger. Every 10 s it records level, current, voltage, power, temperature and screen state. For each session it computes the rate in %/h, time to 80% and 100%, mAh added and estimated battery capacity, peak and average power, and time above 40 Β°C. It detects thermal throttling and charging pauses. Includes charts, 30-day history and alerts for charge thresholds (80/85/90/100%) and overheating.
Diagnosis Analysis of batterystats since the last full charge: drain with the screen on and off, apps, wakelocks, wakeups and network. It ends with a list of findings sorted by severity, each with a one-tap action.
History A sample every 15 minutes (WorkManager, no permanent background service) and separate drain rates for screen off and screen on.
Actions Auto-brightness, screen timeout, background Wi-Fi/Bluetooth scanning, shortcuts to gestures and AOD, and restricting apps in the background. Every change asks for confirmation and is logged, so you can undo it.

Requirements

  • Android 12 (API 31) or newer. Developed and tested on a OnePlus CPH2609 running Android 16. On other phones some data may be missing or formatted differently. Please report it.
  • A computer with ADB, and USB or wireless debugging enabled on the phone.
  • Optional: Shizuku for actions that need shell privileges.

Installation

Download

Get the signed APK from Releases, install it, then grant the permissions (see below).

Build from source

# JDK 17+ (e.g. the one bundled with Android Studio) and the Android SDK
export JAVA_HOME="/Applications/Android Studio.app/Contents/jbr/Contents/Home"

./gradlew assembleDebug
adb install -r app/build/outputs/apk/debug/app-debug.apk

Grant permissions

./setup_permissions.sh

Battery data on Android is protected by system permissions that a normal app cannot request. setup_permissions.sh grants them once over ADB:

Permission Why
DUMP, BATTERY_STATS, PACKAGE_USAGE_STATS read dumpsys batterystats and cpuinfo
WRITE_SECURE_SETTINGS, WRITE_SETTINGS actions: brightness, screen timeout, Wi-Fi/BT scanning
POST_NOTIFICATIONS charging monitor notifications
battery optimization exemption start the charging monitor from the background when a charger is connected

The permissions survive reboots. You only need to grant them again after uninstalling the app.

OnePlus / OPPO / realme: before running the script, enable "Disable permission monitoring" in Developer options. Without it the system rejects the ADB commands. You can turn the switch back off afterwards.

Shizuku (optional)

When Shizuku is running, "Restrict in background" and "Force stop" run directly (appops RUN_ANY_IN_BACKGROUND, standby-bucket restricted, am force-stop). Without Shizuku the app opens that app's settings page and you make the change yourself.

Project structure

app/src/main/java/pl/foxsoftware/batterywatch/
β”œβ”€β”€ data/       device readers, dumpsys parsers, history and charging session databases
β”œβ”€β”€ domain/     diagnosis rules (FindingsEngine), charging analysis, applying and undoing actions
β”œβ”€β”€ charging/   charging monitor service and its automatic start
└── ui/         Jetpack Compose screens and the ViewModel

Tests

./gradlew testDebugUnitTest

The parser and diagnosis rules are tested against a real, anonymized batterystats dump from a OnePlus CPH2609 (app/src/test/resources). Email addresses and third-party app names were replaced with example.com and com.example.appNN.

To add a dump from your own phone (adb shell dumpsys batterystats > dump.txt), remove email addresses and the list of installed apps before sharing it.

Contributing

Contributions are welcome, especially:

  • Testing on other phones (Samsung, Pixel, Xiaomi…) and reporting what's missing
  • Translations into other languages: copy res/values/strings.xml to res/values-xx/ and add the language to locales_config.xml. TranslationsTest checks that every language has the same keys and format arguments
  • New diagnosis rules in FindingsEngine

Look for issues labeled good first issue, or ask in Discussions. When reporting a bug, include your phone model, Android version and what doesn't show up. Don't paste a full batterystats dump, because it contains personal data.

Security

  • The app doesn't connect to the internet and doesn't send any data.
  • Every settings change asks for confirmation and stores the previous value, so you can undo it from the app.
  • The ADB permissions are powerful (WRITE_SECURE_SETTINGS, DUMP). Only install APKs built from this source or downloaded from this repository's Releases.

License

MIT

Close

How Shizuku is used

Can restrict background apps, force-stop draining apps and toggle Wi-Fi scanning via `Shizuku shell commands`.

This is an AI-assisted analysis of Shizuku-related usages in the app's public source code. It is best effort, so it may not catch every single usage.

How this app uses Shizuku

BatteryWatch uses Shizuku to run privileged shell commands that curb battery drain and fix wasteful settings.

  • Restrict background apps: limit a draining app picked from diagnosis or the actions list with cmd appops set RUN_ANY_IN_BACKGROUND ignore combined with am set-standby-bucket restricted through Shizuku.
  • Force stop apps: immediately stop a draining app chosen by the user with the am force-stop shell command through Shizuku.
  • Toggle Wi-Fi scanning: turn always-available Wi-Fi scanning on or off from settings or a finding with the cmd wifi set-scan-always-available shell command through Shizuku.
  • Revert applied fixes: restore the previous background restriction or scanning value with the stored reverse shell command through Shizuku.

Android APIs or commands used

  • cmd appops get
  • cmd appops set
  • am get-standby-bucket
  • am set-standby-bucket
  • am force-stop
  • cmd wifi set-scan-always-available

Notable details

Without Shizuku the same actions open the system settings screen for the app or feature instead of applying the change directly. Shell fixes that change state keep a stored reverse value so they can be undone.

Close

Changelog

What's new for version 1.1.0

What's new

  • English interface. The app now follows the system language: English by default, Polish on Polish phones.
  • Per-app language on Android 13+: Settings β†’ Apps β†’ BatteryWatch β†’ Language.
  • Dates and times use your locale's format.
  • New TranslationsTest checks that every language has the same texts and format arguments, so adding a language is safe (how to contribute a translation).

Upgrading from 1.0.0

Install BatteryWatch-1.1.0.apk over the old version. It's signed with the same key, so permissions and charging history are kept. Existing charging sessions are still recognized.

Install

Requires Android 12+. After installing, grant the permissions once over ADB with setup_permissions.sh.

Close

Permissions

14 permissions requested

  • android.permission.DUMP
  • android.permission.BATTERY_STATS
  • android.permission.WRITE_SECURE_SETTINGS
  • android.permission.PACKAGE_USAGE_STATS
  • android.permission.WRITE_SETTINGS
  • android.permission.QUERY_ALL_PACKAGES
  • android.permission.FOREGROUND_SERVICE
  • android.permission.FOREGROUND_SERVICE_SPECIAL_USE
  • android.permission.POST_NOTIFICATIONS
  • android.permission.WAKE_LOCK
  • android.permission.ACCESS_NETWORK_STATE
  • android.permission.RECEIVE_BOOT_COMPLETED
  • pl.foxsoftware.batterywatch.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
  • moe.shizuku.manager.permission.API_V23
Close