电池统计
1.9.9.5 · GitHub
More about this app
Battery health and hardware analysis; Shizuku provides the elevated shell for deep battery parameter reads.
๐ Battery (Battery Health & Hardware Analysis)
A lightweight, accurate, and modern battery health and hardware analysis tool crafted for Android.
๐ฑ Screenshots
| ๐ System API Detection | โก Shizuku Privileged Reading | ๐ History Trend & Decay Stats | โ๏ธ Settings & Backup |
|---|---|---|---|
![]() |
![]() |
![]() |
![]() |
๐ Key Features
1. ๐ Triple Data Collection & Deep Parsing Engine
- System Standard API (BatteryManager): Zero barrier to reading system broadcast and standard API data (battery level, charging status, health state, temperature, voltage, current, etc.).
- Shizuku Privileged Deep Reading (Rootless ADB):
- No root required; obtains underlying shell permissions via Shizuku authorization;
- Directly reads
/sys/class/power_supply/driver nodes anddumpsysbattery services; - Extracts real full charge capacity (FCC), cycle count, microampere-level real-time current, and dual-cell battery architecture;
- Specially adapted for HONOR private battery drivers and node services.
- Lightning-Fast Bugreport Stream Parsing:
- Supports directly importing system bugreport files (
bugreport-*.zipor.txt) ranging from tens to hundreds of megabytes; - Employs native byte stream sliding window fast scanning to locate and parse the
getHealthInfostructure within milliseconds; - Automatically extracts and displays the actual capture/generation timestamp of the bugreport.
- Supports directly importing system bugreport files (
Warning
โ ๏ธ Device Compatibility Notice: Currently, Shizuku Privileged Reading and Bugreport Parsing have been deeply adapted primarily for HONOR devices. Other brands (such as Xiaomi, OPPO, vivo, Samsung, etc.) have not been extensively tested, and compatibility differences may exist in private kernel driver nodes and bugreport formats. System Standard API detection works on all general Android devices.
2. ๐ Battery Health Degradation Trend & Multi-period Loss Statistics
- Smooth Bezier Health Trend Chart: Canvas hardware-accelerated curve fitting for historical snapshot data, supporting touch gestures to inspect details of each snapshot node.
- Multi-dimensional Degradation Rate Estimation:
- ๐ Daily Average Degradation (%/day);
- ๐ Monthly Average Degradation (%/month);
- ๐๏ธ Estimated Yearly Degradation (%/year).
- Periodic Loss Breakdown: Automatically groups and aggregates data by calendar day, month, and year to review starting/ending health percentage changes and charge cycle count increments for each period.
3. ๐ 15 Comprehensive Battery Hardware Parameters
Every parameter is carefully sanitized, validated, and converted into standard physical units:
| Parameter | Description | Source |
|---|---|---|
| ๐ Battery Level | Remaining battery percentage (e.g., 85%) |
System API / Kernel Nodes |
| โก Status | Charging / Discharging / Not Charging / Full | Power Management IC (PMIC) |
| ๐ฉบ Health State | Android diagnostic state (Good / Overheat / Dead / Over Voltage, etc.) | Android Diagnostic API |
| โค๏ธ Battery Health | Actual health percentage (FCC รท Design Capacity) | Precise Algorithmic Calculation |
| ๐ Cycle Count | Equivalent charge/discharge cycles recorded by fuel gauge | Hardware Fuel Gauge Counter |
| ๐ก๏ธ Temperature | Real-time Celsius temperature (accurate to 0.1ยฐC) |
Internal Battery Thermistor |
| ๐ Voltage | Real-time terminal voltage (mV / V) |
Analog-to-Digital Converter (ADC) |
| โก Current | Real-time charge/discharge current (mA, with clear +/- direction) |
Coulomb Counter Sensing Resistor |
| โก Power | Real-time instantaneous operating power (W) |
Dynamic Power Calculation Formula |
| ๐ Design Capacity | Factory nominal design capacity (mAh) |
PowerProfile / Kernel Parameters |
| ๐ Full Charge Capacity (FCC) | Estimated maximum capacity when battery is fully charged (mAh) |
Fuel Gauge Learned Capacity |
| ๐ Current Capacity | Remaining available capacity (mAh) |
Coulomb Counter Charge Tally |
| ๐ Dual Cell | Identification of dual-cell (series/parallel) architecture | Hardware Topology Detection |
| ๐ฌ Technology | Battery chemistry/material type (e.g., Li-ion, Li-poly) |
Hardware Properties |
| ๐ Capture Time | Exact date and time when the detection or bugreport was taken | Automatic Timestamp |
4. ๐จ Modern Material 3 UI & Fluid Interactions
- Material 3 Bottom Navigation: Three core sections: "Detection", "History", and "Settings".
- Gestures & Pull-to-Refresh: Integrated
SwipeRefreshLayoutwith smooth pull-down refresh animations. - Grouped Card Settings:
- Categorized cards for User Interface, Data & Refresh, Shizuku Privilege, and About;
- Consistent
56dpphysical height with auto-centering alignment; - Precision right-aligned compact popup menu that smoothly unfolds from top-right (supporting 1s / 2s / 3s / 5s / 10s refresh intervals).
- System-wide Dark Theme & Rounded Ripple Effects:
- Flawlessly supports light and dark (AMOLED true black/dark grey) themes;
- Rounded mask-clipped ripple feedback for refined aesthetics without clipping overflow.
๐ ๏ธ Technical Architecture
- Programming Language: 100% Kotlin
- Architecture Pattern: MVVM (Model-View-ViewModel) + Unidirectional Reactive Data Flow
- Asynchronous & Concurrency: Kotlin Coroutines + Flow / StateFlow
- View Binding: Android Jetpack ViewBinding
- Component Libraries:
- Google Material Components 3 (
com.google.android.material:material:1.11.0) - AndroidX SwipeRefreshLayout (
androidx.swiperefreshlayout:swiperefreshlayout:1.1.0) - Rikka Shizuku API (
dev.rikka.shizuku:api:13.1.5/provider:13.1.5) - AndroidX Lifecycle & ViewModel KTX (
2.7.0) - Kotlinx Coroutines Android (
1.7.3)
- Google Material Components 3 (
๐ฆ Project Structure
Battery/
โโโ app/
โ โโโ src/main/
โ โ โโโ java/com/battery/analysis/
โ โ โ โโโ model/ # Battery parameters and result models (BatteryInfo, HealthInfoItem)
โ โ โ โโโ provider/ # Data providers (NormalApi, Shizuku, BugreportParser, Fusion)
โ โ โ โโโ ui/ # UI layer (Fragments, ViewPager2 adapters, ViewBinder)
โ โ โ โโโ viewmodel/ # Business logic & state flow ViewModels
โ โ โ โโโ MainActivity.kt # Main Activity (navigation & lifecycle coordination)
โ โ โโโ res/
โ โ โโโ anim/ # Popup animation resources
โ โ โโโ color/ # State color selectors
โ โ โโโ drawable/ # Vector icons and card backgrounds
โ โ โโโ layout/ # Layout XML files
โ โ โโโ values/ # Theme styles, strings, and light color palette
โ โ โโโ values-en/ # English string resources
โ โ โโโ values-night/ # Dark theme and high contrast color palette
โโโ .github/workflows/ # CI/CD automated build and release workflows
โโโ build.gradle.kts # Top-level and module-level build configurations
๐ Build & Setup
1. Prerequisites
- Android Studio: Hedgehog (2023.1.1) or higher
- JDK: OpenJDK 17 or higher
- Android SDK: API 34 (Android 14)
2. Local Build Steps
# Clone the repository
git clone https://github.com/zhyang18/Battery.git
cd Battery
# Build Debug APK
./gradlew assembleDebug
# Build Release APK
./gradlew assembleRelease
Compiled APK artifacts are located in the app/build/outputs/apk/ directory.
๐ฑ Usage Guide
- Standard Detection: Open the app, navigate to the "Detection" tab, and swipe down to refresh all battery metrics fetched via standard APIs.
- Shizuku Privileged Detection:
- Install and start Shizuku on your device (pair via Wireless Debugging or PC ADB);
- In the app's "Settings" tab, click "Request Auth" or switch directly to the "Shizuku" tab. Once granted, real fuel gauge cycle counts and low-level parameters will be parsed in real time.
- Bugreport Analysis:
- In "Developer options" on your device, tap "Take bugreport";
- Once completed, go to the "Bugreport" tab and click "Import Bugreport", select the generated
.zipor.txtfile, and the app will instantly parse and present the capture time along with detailed battery health metrics.
๐ License
This project is licensed under the MIT License.
How Shizuku is used
Can read battery health, per app drain, foreground app, grant usage access, reset stats and keep monitor alive via `Shizuku newProcess and privileged binders`.
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
Shizuku provides an elevated shell and privileged system binders for deep battery and power analysis beyond normal system APIs.
- Read battery health: shows design capacity, full charge capacity, current capacity, cycle count, temperature, voltage, current, power and technology by reading protected battery nodes, system battery output and vendor properties through Shizuku.
- Show per app drain: shows per app power drain, discharge duration, screen time and hardware use such as CPU, network, wake locks and sensors by querying batterystats output and package UID mapping through Shizuku.
- Show single app details: shows CPU, wake lock, GPS, network and foreground service time for a chosen app by querying batterystats for that package through Shizuku.
- Detect foreground app: attributes power use to the app on screen by asking the privileged activity task service for the focused task and top activity through Shizuku.
- Enable usage access: grants its own usage stats access in one tap with system grant commands through Shizuku so power attribution works without manual settings steps.
- Reset discharge stats: clears the system discharge ledger when a new discharge session starts or is cleared through Shizuku.
- Keep background monitor alive: starts a persistent battery monitor helper process with an elevated shell launch through Shizuku so sampling continues in the background.
Android APIs or commands used
cat /sys/class/power_supply/battery/ueventcat /sys/class/power_supply/bms/ueventcat /sys/class/power_supply/*/current_nowcat /sys/class/power_supply/*/voltage_nowcat /sys/class/power_supply/*/power_nowdumpsys batterydumpsys batterystatsdumpsys batterystats --chargeddumpsys batterystats --historydumpsys batterystats --checkindumpsys batterystats --resetdumpsys activity broadcastsdumpsys miui.batterygetproppm list packages -Ucmd package list packages -Uappops setpm grant android.permission.PACKAGE_USAGE_STATSpm revoke moe.shizuku.manager.permission.API_V23IActivityTaskManager.getFocusedRootTaskInfoIActivityTaskManager.getTasksIActivityManager.getTasksapp_processkillpkill -f com.battery.analysis.daemon.BatteryDaemonServer
Notable details
Without Shizuku active or authorized, battery health falls back to normal system APIs with less detail, power statistics run in standard mode, and foreground detection uses normal usage stats.
Changelog
What's new for version 1.9.9.5
๐ฆ ๅบ็จๅฎ่ฃ ๅ
- ๐ Release APK: ็ป็ฑๆญฃๅผ็ญพๅ๏ผๆจ่ๆฅๅธธไฝฟ็จ
- ๐ ๏ธ Debug APK: ่ฐ่ฏๅผๅๅ
๐ ็ๆฌ่ฏดๆ
ไผๅ็ป่ฎก็ฎๆณ
๐ ๆไบคๆดๆฐ่ฎฐๅฝ (Changelog)
็ป่ฎก่ๅด๏ผ
v1.9.9.4.1\(\rightarrow\)v1.9.9.5
- ไผๅ็ป่ฎก็ฎๆณ (45e7986)
- ๅๅฐ้ๆ ทๆๅกไธๅธธ้ฉป้็ฅๆบๅถ็ๆน่ฟ (09c345e)
- ไผๅๅธ่ฝฝใ้่ฃ ็ฌฌไธๆนapp็ป่ฎกๆฐๆฎ๏ผๆฏๆ่ชๅจๅ ๅ ้่ฃ ๅ็ๆฐๆฎๅๅนถ (ffc65c5)
- ไฟฎๅคๆ ้็ขๆจกๅผไธ่ดไธๅฑ็ป่ฎกๆ ๆฐๆฎ้ฎ้ข (e2c5c51)
ๆๅปบ็ผๅท: #209 | ่งฆๅๆไบค: 45e79862944831158d0888f5055a150342fa930a
Permissions
11 permissions requested
Sources
3 sources
Sources
3 sources



