BH Quantitative Charging Cutoff & Battery Guard icon

BH Quantitative Charging Cutoff & Battery Guard

v1.46guidecommunity

Automated charging controller that enforces customizable upper charge termination thresholds (e.g. stopping at 80% and resuming at 70%) to maximize lithium battery lifespan.

Community Package•Battery & Power Management•by Bu Tai Hui Qi Wang Ming & HChai•GPL-3.0-only•Updated Jan 1, 2023
Platforms:
✓ Magisk✓ KernelSU✓ APatch
Download v1.46Starting download...
quantitative-charge-cutoff-v1.46.zip

Overview

BH Quantitative Charging Cutoff & Battery Guard (authored by Bu Tai Hui Qi Wang Ming & HChai) is an automated charge controller engineered to protect lithium-ion batteries from overcharging and high-voltage heat stress.

The module runs as a background watchdog that continuously samples battery state-of-charge (SOC). Upon reaching the user-configured limit, it dispatches a hardware cutoff command directly to the Linux kernel power supply subsystem.


Technical Architecture & How It Works

1. Sysfs Charging Switch Negotiation

The daemon (B.sh) locates the active hardware charging control node:

# Common Qualcomm / MediaTek sysfs control nodes:
# 1. /sys/class/power_supply/battery/charging_enabled (1=enable, 0=disable)
# 2. /sys/class/power_supply/battery/input_suspend (0=enable, 1=suspend)

echo 0 > /sys/class/power_supply/battery/charging_enabled
# or
echo 1 > /sys/class/power_supply/battery/input_suspend

2. State Watchdog Loop

The daemon evaluates capacity against thresholds declared in /data/media/0/Android/BHcharging/files.conf:

if [ "$current_capacity" -ge "$Stop_charging" ]; then
    echo 0 > "$USBpath"
    sed -i "s/状态:.*/状态:已停充 (${current_capacity}%)]/g" "$module"
elif [ "$current_capacity" -le "$Resume_charging" ]; then
    echo 1 > "$USBpath"
    sed -i "s/状态:.*/状态:充电中 (${current_capacity}%)]/g" "$module"
fi

Configuration & Verification

Inspect current charging switch state:

# Check charging switch state (0 = charging disabled)
cat /sys/class/power_supply/battery/charging_enabled

Frequently Asked Questions

Why is limiting charge to 80% beneficial?

Lithium-ion cells experience the highest chemical degradation and cathode degradation when held between 4.2V and 4.45V (typically above 80% state-of-charge). Capping charging at 80% can extend cell cycle life by 200% to 300%.

How do I change the stop threshold?

Edit /data/media/0/Android/BHcharging/files.conf and adjust the Stop_charging value to your preferred percentage.