fp6-img/aports/device/fp6-charging-mode/charging-mode-initfs-hook.sh
Jorijn van der Graaf eb13c18ea8 aports: add fp6-charging-mode (offline charging, charger-boot detection)
Charger-insertion boots (androidboot.mode=charger, ABL-appended) divert to
a minimal charging.target instead of the full UI, ending the dead-battery
bootloop: ADSP charging/USB-PD runs, splash+panel killed ~6-10s in via an
initramfs hook, modem+cdsp stopped, radios/sensors suppressed, CPU capped.
Power key reboots to a normal boot, volume-up shows battery status,
volume-down enables USB ssh, unplug powers off. Measured >= breakeven on a
100mA-classified SDP port, strongly net-positive on real chargers.

Suspend duty-cycling (~13mA floor) exists behind an off-by-default flag:
resume from deep suspend intermittently kills the UFS link (hibern8 exit
failed ret=5) - do not enable until that kernel bug is fixed.

Byte-identical to the deployment verified on the dev phone 2026-08-24
(journal/power: r5 armed tests, crash autopsies, measurements).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-24 04:03:06 +02:00

19 lines
882 B
Shell
Executable file

#!/bin/sh
# FP6 offline charging (work/charging-mode): on charger-triggered boots,
# kill the boot splash and panel as early as software can — this hook runs
# right after splash_start in the initramfs (~6-10 s after power-on), vs
# the charging monitor's blank at ~16-20 s. The 0-5 s bootloader logo is
# ABL's and untouchable. Executed via `sh` by run_hooks (subshell, exit is
# safe); written to fall through harmlessly on any failure — a normal boot
# must never be affected.
if grep -Eq '(^| )androidboot\.mode=charger( |$)' /proc/cmdline 2>/dev/null; then
command -v plymouth >/dev/null 2>&1 && plymouth quit 2>/dev/null
for b in /sys/class/backlight/*/brightness; do
[ -w "$b" ] && echo 0 > "$b" 2>/dev/null
done
for f in /sys/class/graphics/fb*/blank; do
[ -w "$f" ] && { echo 4 > "$f" || echo 1 > "$f"; } 2>/dev/null
done
fi
exit 0