ShizuStore

电池统计

zhyang18

1.9.9.5 · GitHub

Download APK
Power management Android 7.0+ 2 days ago MIT
179 ShizuStore
927 GitHub
4 Stars
4 MB Size

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.

็ฎ€ไฝ“ไธญๆ–‡ | English

Platform Kotlin Min SDK Target SDK License


๐Ÿ“ฑ Screenshots

๐Ÿ”‹ System API Detection โšก Shizuku Privileged Reading ๐Ÿ“ˆ History Trend & Decay Stats โš™๏ธ Settings & Backup
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 and dumpsys battery 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-*.zip or .txt) ranging from tens to hundreds of megabytes;
    • Employs native byte stream sliding window fast scanning to locate and parse the getHealthInfo structure within milliseconds;
    • Automatically extracts and displays the actual capture/generation timestamp of the bugreport.

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 SwipeRefreshLayout with smooth pull-down refresh animations.
  • Grouped Card Settings:
    • Categorized cards for User Interface, Data & Refresh, Shizuku Privilege, and About;
    • Consistent 56dp physical 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)

๐Ÿ“ฆ 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

  1. Standard Detection: Open the app, navigate to the "Detection" tab, and swipe down to refresh all battery metrics fetched via standard APIs.
  2. 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.
  3. 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 .zip or .txt file, 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.

Close

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/uevent
  • cat /sys/class/power_supply/bms/uevent
  • cat /sys/class/power_supply/*/current_now
  • cat /sys/class/power_supply/*/voltage_now
  • cat /sys/class/power_supply/*/power_now
  • dumpsys battery
  • dumpsys batterystats
  • dumpsys batterystats --charged
  • dumpsys batterystats --history
  • dumpsys batterystats --checkin
  • dumpsys batterystats --reset
  • dumpsys activity broadcasts
  • dumpsys miui.battery
  • getprop
  • pm list packages -U
  • cmd package list packages -U
  • appops set
  • pm grant android.permission.PACKAGE_USAGE_STATS
  • pm revoke moe.shizuku.manager.permission.API_V23
  • IActivityTaskManager.getFocusedRootTaskInfo
  • IActivityTaskManager.getTasks
  • IActivityManager.getTasks
  • app_process
  • kill
  • pkill -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.

Close

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

Close

Permissions

11 permissions requested

  • android.permission.BATTERY_STATS
  • android.permission.PACKAGE_USAGE_STATS
  • android.permission.QUERY_ALL_PACKAGES
  • moe.shizuku.manager.permission.API_V23
  • android.permission.FOREGROUND_SERVICE
  • android.permission.FOREGROUND_SERVICE_SPECIAL_USE
  • android.permission.POST_NOTIFICATIONS
  • android.permission.RECEIVE_BOOT_COMPLETED
  • android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
  • android.permission.WAKE_LOCK
  • com.battery.analysis.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION
Close

Sources

3 sources

1.9.9.5 arm64-v8a GitHub ยท com.battery.analysis
Selected Download
1.9.9.5 armeabi-v7a GitHub ยท com.battery.analysis
Download
1.9.9.5 Universal GitHub ยท com.battery.analysis
Download