Refresh the charge icon immediately on charger plug/unplug
This commit is contained in:
1 parent
6a6222c198
commit
eaf08abcd4
9 files changed
+159
-6
No files matched your search
@@ -57,7 +57,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7`
|
|||||||
- `./scripts/prune-rootfs-packages.sh <rootfs-dir> world|purge` — removes Wayland-only, Rust-based, and retired packages from a target rootfs inside the build container.
|
- `./scripts/prune-rootfs-packages.sh <rootfs-dir> world|purge` — removes Wayland-only, Rust-based, and retired packages from a target rootfs inside the build container.
|
||||||
- `./scripts/build-bananarchy-daemons.sh` — cross-builds the three compiled ARM idle daemons (`bananarchy-lid`, `bananarchy-cover-idle`, `bananarchy-volume-keys`) from `src/bananarchy-daemons/`; `--check` validates the ARM ELF artifacts and overlay sync. No Python-based daemon runs in the idle system.
|
- `./scripts/build-bananarchy-daemons.sh` — cross-builds the three compiled ARM idle daemons (`bananarchy-lid`, `bananarchy-cover-idle`, `bananarchy-volume-keys`) from `src/bananarchy-daemons/`; `--check` validates the ARM ELF artifacts and overlay sync. No Python-based daemon runs in the idle system.
|
||||||
- `./scripts/build-lk2nd-beatles.sh` — cross-builds all three beatles lk2nd images (normal, diagnostic and display; the display image is the flasher default) from the pinned upstream lk2nd commit plus `bootloader/lk2nd/nokia-beatles.patch` in rootless Docker (`--check` validates all three shipped images, `--only normal|diagnostic|display` builds one, `--force-panel-init` forces the panel replay, `--with-display` enables SPI display during boot). Offline validators: `scripts/check-lk2nd-beatles.py` and `scripts/test-lk2nd-beatles-port.py`.
|
- `./scripts/build-lk2nd-beatles.sh` — cross-builds all three beatles lk2nd images (normal, diagnostic and display; the display image is the flasher default) from the pinned upstream lk2nd commit plus `bootloader/lk2nd/nokia-beatles.patch` in rootless Docker (`--check` validates all three shipped images, `--only normal|diagnostic|display` builds one, `--force-panel-init` forces the panel replay, `--with-display` enables SPI display during boot). Offline validators: `scripts/check-lk2nd-beatles.py` and `scripts/test-lk2nd-beatles-port.py`.
|
||||||
- `./scripts/test-webarchy-renderer.py`, `./scripts/test-idle-blank-lock.py` and `./scripts/test-bluetooth-scan.py` — host unit/integration tests for the Webarchy renderer profile, the idle-blank screenlock wiring and the Bluetooth discovery parser (all also run by `check-rebuild.sh`).
|
- `./scripts/test-webarchy-renderer.py`, `./scripts/test-idle-blank-lock.py`, `./scripts/test-bluetooth-scan.py` and `./scripts/test-battery-charge-event.py` — host unit/integration tests for the Webarchy renderer profile, the idle-blank screenlock wiring, the Bluetooth discovery parser and the charger plug/unplug icon refresh (all also run by `check-rebuild.sh`).
|
||||||
- `./scripts/check-rebuild.sh` — offline preflight for a clean clone (syntax, package list, plugin artifacts, overlay sync, SMS long-message rendering guard, ignored local agent config, Docker, version helper).
|
- `./scripts/check-rebuild.sh` — offline preflight for a clean clone (syntax, package list, plugin artifacts, overlay sync, SMS long-message rendering guard, ignored local agent config, Docker, version helper).
|
||||||
- `./scripts/sync-prebuilt-overlay.sh [--check]` — mirrors `prebuilt/` artifacts into `overlay/rootfs/`; `--check` only reports drift.
|
- `./scripts/sync-prebuilt-overlay.sh [--check]` — mirrors `prebuilt/` artifacts into `overlay/rootfs/`; `--check` only reports drift.
|
||||||
- `./scripts/bootstrap-flash-deps.sh` — installs `pyusb` and `pyserial` into the gitignored `.flash-deps/` directory for `flash-edl.py`.
|
- `./scripts/bootstrap-flash-deps.sh` — installs `pyusb` and `pyserial` into the gitignored `.flash-deps/` directory for `flash-edl.py`.
|
||||||
|
|||||||
@@ -13,6 +13,10 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
|||||||
|
|
||||||
Work since `a1108` has focused on reliable 2720 Flip hardware support and a reproducible boot/flash path. Earlier incremental and superseded diagnostic entries are consolidated here.
|
Work since `a1108` has focused on reliable 2720 Flip hardware support and a reproducible boot/flash path. Earlier incremental and superseded diagnostic entries are consolidated here.
|
||||||
|
|
||||||
|
### Charger plug/unplug battery icon
|
||||||
|
|
||||||
|
- **Charge icon stayed unchanged on VBUS transitions**: `85-bananarchy-battery.rules` treated every PM8916 event as a capacity change, but `sxmo_hook_battery.sh` caches `state:percentage` and the charger `online` / battery `status` sysfs attributes can still hold the old value while the uevent is delivered. The cache therefore swallowed exactly the plug/unplug event the user wanted to see. Charger events now run `/usr/bin/bananarchy-battery-charge-event.sh`, which forces an immediate `sxmo_hook_battery.sh force` republish (the forced path removes the icon file so `sxmo_status.sh` cannot skip an unchanged value), then re-reads sysfs after two seconds; `flock` coalesces the uevent burst. A generic `ENV{POWER_SUPPLY_ONLINE}` rule covers firmware revisions that publish VBUS on a separate USB/Mains supply. `scripts/test-battery-charge-event.py` validates the immediate + delayed refresh with a stubbed hook, and `check-rebuild.sh` guards the rules, helper and overlay installation. `nokia-argon` keeps the same capacity-change path.
|
||||||
|
|
||||||
### Bluetooth scanning
|
### Bluetooth scanning
|
||||||
|
|
||||||
- **Scan found no devices**: the Bluetooth tab ran `bluetoothctl --timeout 15 scan on` with stdout discarded and then queried `bluetoothctl devices` from a second process. BlueZ discovery belongs to the D-Bus client that started it: when the scanning client exits, discovery stops and unpaired devices may be removed before the follow-up query, so a fresh scan legitimately produced an empty list on the 2720 Flip's WCNSS controller. `networks.so` now captures the discovery stream, parses ANSI-coloured `[NEW]`/`[CHG]` device and name/alias lines (`parseBtScanDevices()`), merges them with the persistent `bluetoothctl devices` list, powers the controller on when `bluetoothctl show` reports `Powered: no`, and falls back to a plain `scan on` if `--timeout` is unsupported. `isBtEnabledFast()` no longer depends solely on `/run/bluetoothd.pid`. `scripts/test-bluetooth-scan.py` validates the parser on the host and `check-rebuild.sh` guards the rebuilt `networks.so`. The `nokia-argon` path keeps the same paired-device and OBEX behaviour.
|
- **Scan found no devices**: the Bluetooth tab ran `bluetoothctl --timeout 15 scan on` with stdout discarded and then queried `bluetoothctl devices` from a second process. BlueZ discovery belongs to the D-Bus client that started it: when the scanning client exits, discovery stops and unpaired devices may be removed before the follow-up query, so a fresh scan legitimately produced an empty list on the 2720 Flip's WCNSS controller. `networks.so` now captures the discovery stream, parses ANSI-coloured `[NEW]`/`[CHG]` device and name/alias lines (`parseBtScanDevices()`), merges them with the persistent `bluetoothctl devices` list, powers the controller on when `bluetoothctl show` reports `Powered: no`, and falls back to a plain `scan on` if `--timeout` is unsupported. `isBtEnabledFast()` no longer depends solely on `/run/bluetoothd.pid`. `scripts/test-bluetooth-scan.py` validates the parser on the host and `check-rebuild.sh` guards the rebuilt `networks.so`. The `nokia-argon` path keeps the same paired-device and OBEX behaviour.
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ The **Xlibre** display server (`modesetting_drv.so`) uses **Glamor + DRI3 + GLX
|
|||||||
|
|
||||||
`chronyd` runs from the default runlevel with `pool pool.ntp.org iburst minpoll 12 maxpoll 16`: long polls keep Wi-Fi asleep, while `iburst` sets the clock within seconds whenever the pool resolves. Because NetworkManager installs `resolv.conf` after `chronyd` starts, a `bananarchy-time-sync` OpenRC service and `/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh` re-resolve the pool and request an immediate burst when a connection comes up (`up`, `dhcp4-change`, `dhcp6-change`, `dns-change`, `connectivity-change`, `vpn-up`). The helper uses chronyd's root-only Unix command socket, so `cmdport 0` keeps the UDP command port closed, and it throttles repeats with a monotonic uptime stamp so a decades-long clock step cannot confuse it. `/var/lib/chrony` is owned by the `chrony` user so the driftfile survives reboots.
|
`chronyd` runs from the default runlevel with `pool pool.ntp.org iburst minpoll 12 maxpoll 16`: long polls keep Wi-Fi asleep, while `iburst` sets the clock within seconds whenever the pool resolves. Because NetworkManager installs `resolv.conf` after `chronyd` starts, a `bananarchy-time-sync` OpenRC service and `/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh` re-resolve the pool and request an immediate burst when a connection comes up (`up`, `dhcp4-change`, `dhcp6-change`, `dns-change`, `connectivity-change`, `vpn-up`). The helper uses chronyd's root-only Unix command socket, so `cmdport 0` keeps the UDP command port closed, and it throttles repeats with a monotonic uptime stamp so a decades-long clock step cannot confuse it. `/var/lib/chrony` is owned by the `chrony` user so the driftfile survives reboots.
|
||||||
|
|
||||||
If the clock is still wrong after a connection comes up, use **Config -> Sync net time**. It runs `bananarchy-sync-net-time.sh`, forces an immediate burst over the same Unix socket, and shows a notification with the synced UTC date or a failure message. This is also handy after a long offline period, when the RTC has fallen back to 1970. After a confirmed sync, the helper calls `sxmo_hook_statusbar.sh refresh` as the X session user, so the status bar clock and charge icon are republished immediately instead of waiting for the next 300 s periodic tick. Charge events likewise refresh both the charge icon and the clock, and unlock forces a charge icon refresh even if the backlight is not yet bright.
|
If the clock is still wrong after a connection comes up, use **Config -> Sync net time**. It runs `bananarchy-sync-net-time.sh`, forces an immediate burst over the same Unix socket, and shows a notification with the synced UTC date or a failure message. This is also handy after a long offline period, when the RTC has fallen back to 1970. After a confirmed sync, the helper calls `sxmo_hook_statusbar.sh refresh` as the X session user, so the status bar clock and charge icon are republished immediately instead of waiting for the next 300 s periodic tick. Charge events likewise refresh both the charge icon and the clock, and unlock forces a charge icon refresh even if the backlight is not yet bright. Plugging or unplugging the USB cable is handled by `85-bananarchy-battery.rules` and `/usr/bin/bananarchy-battery-charge-event.sh`: the charger's `power_supply` uevent forces the icon immediately and once more after a two-second sysfs race window (with `flock` coalescing the burst of uevents), so the charge icon changes at the moment of the transition even when the reported capacity has not changed yet.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bananarchy-time-sync.sh status # chronyc tracking + sources (via doas)
|
bananarchy-time-sync.sh status # chronyc tracking + sources (via doas)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
- **High-brightness display and reliable flip handling**: the 2720 Flip internal panel uses a live-verified 25 MHz SPI clock to prevent corruption when backlight PWM exceeds the former 71% threshold, without reducing the brightness range. The compiled lid daemon combines event-driven `EV_SW` handling with 200 ms raw-hall reconciliation, so missed edges or stale switch state cannot leave the phone awake when closed.
|
- **High-brightness display and reliable flip handling**: the 2720 Flip internal panel uses a live-verified 25 MHz SPI clock to prevent corruption when backlight PWM exceeds the former 71% threshold, without reducing the brightness range. The compiled lid daemon combines event-driven `EV_SW` handling with 200 ms raw-hall reconciliation, so missed edges or stale switch state cannot leave the phone awake when closed.
|
||||||
- **Stock-signed Wi-Fi, Bluetooth, and modem firmware**: `msm-firmware-loader` mounts the phone's `modem` and `persist` partitions before udev, supplies `wcnss.mdt`, `mba.mbn`, and the device-specific WCNSS NV data to the mainline remote processors, and preserves the factory radio calibration and MAC addresses. The sysinit and boot service links are shipped explicitly so clean, `--no-scripts` image builds bring up both `wlan0`/`wcn36xx` and `hci0`/`btqcomsmd` without packaging device-specific firmware blobs.
|
- **Stock-signed Wi-Fi, Bluetooth, and modem firmware**: `msm-firmware-loader` mounts the phone's `modem` and `persist` partitions before udev, supplies `wcnss.mdt`, `mba.mbn`, and the device-specific WCNSS NV data to the mainline remote processors, and preserves the factory radio calibration and MAC addresses. The sysinit and boot service links are shipped explicitly so clean, `--no-scripts` image builds bring up both `wlan0`/`wcn36xx` and `hci0`/`btqcomsmd` without packaging device-specific firmware blobs.
|
||||||
- **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box.
|
- **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box.
|
||||||
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. The status bar clock is also refreshed synchronously on unlock and by dmenu itself, so it cannot show a stale pre-lock time. See `MANUAL.md` section 5.7.
|
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. The status bar clock is also refreshed synchronously on unlock and by dmenu itself, so it cannot show a stale pre-lock time. Plugging or unplugging the charger forces an immediate charge-icon republish plus a short delayed recheck, so the icon changes even when the reported capacity has not moved yet. See `MANUAL.md` section 5.7.
|
||||||
- **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead).
|
- **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead).
|
||||||
|
|
||||||
### Keypad-first user experience and native DWM plugins
|
### Keypad-first user experience and native DWM plugins
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
# Bananarchy battery/charger statusbar hook (U4).
|
# Bananarchy battery/charger statusbar hook (U4).
|
||||||
# Only the two PM8916 supplies exist on these devices; filtering avoids
|
# Only the PM8916 supplies exist on these devices; filtering avoids spawning a
|
||||||
# spawning a shell for unrelated power_supply change events.
|
# shell for unrelated power_supply change events.
|
||||||
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-bms-vm", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
|
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-bms-vm", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
|
||||||
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-lbc-chgr", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/share/sxmo/default_hooks/sxmo_hook_battery.sh udev >/dev/null 2>&1 &'"
|
# A VBUS plug/unplug changes the charger's online attribute, not necessarily
|
||||||
|
# the reported capacity. Force the charge icon immediately and re-read sysfs
|
||||||
|
# after the short race window so the icon actually changes at that moment.
|
||||||
|
SUBSYSTEM=="power_supply", ACTION=="change", KERNEL=="pm8916-lbc-chgr", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/bin/bananarchy-battery-charge-event.sh >/dev/null 2>&1 &'"
|
||||||
|
# Some PM8916 firmware revisions publish the VBUS transition on a separate
|
||||||
|
# USB/Mains supply instead of the charger node.
|
||||||
|
SUBSYSTEM=="power_supply", ACTION=="change", ENV{POWER_SUPPLY_ONLINE}=="0|1", KERNEL!="pm8916-bms-vm", RUN+="/bin/sh -c 'DISPLAY=:0 XDG_RUNTIME_DIR=/run/user/10000 /usr/bin/bananarchy-battery-charge-event.sh >/dev/null 2>&1 &'"
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Immediate charge-icon refresh on a USB/VBUS plug or unplug uevent.
|
||||||
|
#
|
||||||
|
# The battery hook's cache skips an unchanged state:percentage pair, and the
|
||||||
|
# charger's "online" / battery "status" sysfs attributes can still contain the
|
||||||
|
# old value when the uevent is delivered. A plain `sxmo_hook_battery.sh udev`
|
||||||
|
# therefore leaves the status bar icon unchanged at exactly the moment the
|
||||||
|
# user plugs or unplugs the cable. Force the icon once immediately, then
|
||||||
|
# re-read sysfs after a short delay. The lock coalesces the burst of uevents
|
||||||
|
# that the PM8916 charger emits for a single plug/unplug.
|
||||||
|
set -u
|
||||||
|
|
||||||
|
HOOK="${BANANARCHY_BATTERY_HOOK:-/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh}"
|
||||||
|
LOCK="${BANANARCHY_BATTERY_LOCK:-/run/bananarchy-battery-charge.lock}"
|
||||||
|
DELAY="${BANANARCHY_BATTERY_RECHECK_DELAY:-2}"
|
||||||
|
|
||||||
|
export DISPLAY="${DISPLAY:-:0}"
|
||||||
|
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
|
||||||
|
export HOME="${HOME:-/home/user}"
|
||||||
|
export SXMO_WM="${SXMO_WM:-dwm}"
|
||||||
|
export SXMO_STATUS_NAME="${SXMO_STATUS_NAME:-default}"
|
||||||
|
|
||||||
|
force_refresh() {
|
||||||
|
"$HOOK" force >/dev/null 2>&1 || true
|
||||||
|
}
|
||||||
|
|
||||||
|
force_refresh
|
||||||
|
|
||||||
|
exec 9>"$LOCK" 2>/dev/null || exit 0
|
||||||
|
if ! flock -n 9 2>/dev/null; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
(
|
||||||
|
sleep "$DELAY" 2>/dev/null || true
|
||||||
|
force_refresh
|
||||||
|
) >/dev/null 2>&1 &
|
||||||
|
exit 0
|
||||||
@@ -176,6 +176,7 @@ chmod 0644 "$TARGET_ROOTFS/etc/chrony/chrony.conf" 2>/dev/null || true
|
|||||||
chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-idle-lock.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-idle-lock.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-screen-wake.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-screen-wake.sh" \
|
||||||
|
"$TARGET_ROOTFS/usr/bin/bananarchy-battery-charge-event.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \
|
||||||
"$TARGET_ROOTFS/usr/bin/bananarchy-network-event.sh" \
|
"$TARGET_ROOTFS/usr/bin/bananarchy-network-event.sh" \
|
||||||
|
|||||||
@@ -1180,6 +1180,31 @@ if command -v g++ >/dev/null 2>&1 && \
|
|||||||
fail "host Bluetooth scan parser test failed"
|
fail "host Bluetooth scan parser test failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[check] Charger plug/unplug charge icon..."
|
||||||
|
BATTERY_RULES="$BASE_DIR/overlay/rootfs/etc/udev/rules.d/85-bananarchy-battery.rules"
|
||||||
|
CHARGE_EVENT="$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-battery-charge-event.sh"
|
||||||
|
if [ ! -x "$CHARGE_EVENT" ] || ! sh -n "$CHARGE_EVENT" 2>/dev/null; then
|
||||||
|
fail "bananarchy-battery-charge-event.sh is missing or has bad syntax"
|
||||||
|
fi
|
||||||
|
if ! grep -q 'bananarchy-battery-charge-event.sh' "$BATTERY_RULES" || \
|
||||||
|
! grep -q 'KERNEL=="pm8916-lbc-chgr"' "$BATTERY_RULES" || \
|
||||||
|
! grep -q 'POWER_SUPPLY_ONLINE' "$BATTERY_RULES"; then
|
||||||
|
fail "battery udev rules no longer force a charge icon refresh on VBUS events"
|
||||||
|
fi
|
||||||
|
if ! grep -q '"$HOOK" force' "$CHARGE_EVENT" || \
|
||||||
|
! grep -q 'flock -n 9' "$CHARGE_EVENT"; then
|
||||||
|
fail "charger event helper no longer forces and coalesces icon refreshes"
|
||||||
|
fi
|
||||||
|
if ! grep -q 'bananarchy-battery-charge-event.sh' \
|
||||||
|
"$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
|
||||||
|
fail "apply-bananarchy-overlay.sh no longer installs the charger event helper"
|
||||||
|
fi
|
||||||
|
if [ -x "$BASE_DIR/scripts/test-battery-charge-event.py" ] && \
|
||||||
|
command -v python3 >/dev/null 2>&1 && \
|
||||||
|
! "$BASE_DIR/scripts/test-battery-charge-event.py" >/dev/null 2>&1; then
|
||||||
|
fail "host charger plug/unplug event test failed"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$FAILURES" -ne 0 ]; then
|
if [ "$FAILURES" -ne 0 ]; then
|
||||||
echo "[check] $FAILURES check(s) failed."
|
echo "[check] $FAILURES check(s) failed."
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Executable
+80
@@ -0,0 +1,80 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Host integration test for the charger plug/unplug status bar refresh."""
|
||||||
|
import os
|
||||||
|
import pathlib
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
BASE = pathlib.Path(__file__).resolve().parent.parent
|
||||||
|
HELPER = BASE / "overlay/rootfs/usr/bin/bananarchy-battery-charge-event.sh"
|
||||||
|
RULES = BASE / "overlay/rootfs/etc/udev/rules.d/85-bananarchy-battery.rules"
|
||||||
|
HOOK = BASE / "overlay/rootfs/usr/share/sxmo/default_hooks/sxmo_hook_battery.sh"
|
||||||
|
|
||||||
|
HOOK_STUB = '''#!/bin/sh
|
||||||
|
printf '%s\\n' "$*" >> "$FAKE_ROOT/hook.log"
|
||||||
|
exit 0
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
for path in (HELPER, RULES, HOOK):
|
||||||
|
if not path.is_file():
|
||||||
|
sys.stderr.write("FAIL: missing %s\n" % path)
|
||||||
|
return 1
|
||||||
|
if subprocess.run(["sh", "-n", str(HELPER)]).returncode or \
|
||||||
|
subprocess.run(["sh", "-n", str(HOOK)]).returncode:
|
||||||
|
sys.stderr.write("FAIL: shell syntax\n")
|
||||||
|
return 1
|
||||||
|
rules = RULES.read_text(encoding="utf-8")
|
||||||
|
if "bananarchy-battery-charge-event.sh" not in rules or \
|
||||||
|
'KERNEL=="pm8916-lbc-chgr"' not in rules or \
|
||||||
|
"ENV{POWER_SUPPLY_ONLINE}" not in rules:
|
||||||
|
sys.stderr.write("FAIL: charger uevent rules are not wired\n")
|
||||||
|
return 1
|
||||||
|
hook = HOOK.read_text(encoding="utf-8")
|
||||||
|
if '"force"' not in hook or 'FORCE_UPDATE=1' not in hook or \
|
||||||
|
'rm -f "$ICON_FILE"' not in hook:
|
||||||
|
sys.stderr.write("FAIL: battery hook cannot force an icon republish\n")
|
||||||
|
return 1
|
||||||
|
print("[ok] udev rules and forced battery hook")
|
||||||
|
with tempfile.TemporaryDirectory(prefix="bananarchy-battery-") as tmp:
|
||||||
|
root = pathlib.Path(tmp)
|
||||||
|
stub = root / "hook.sh"
|
||||||
|
stub.write_text(HOOK_STUB, encoding="utf-8")
|
||||||
|
stub.chmod(0o755)
|
||||||
|
log = root / "hook.log"
|
||||||
|
env = dict(os.environ)
|
||||||
|
env.update({
|
||||||
|
"FAKE_ROOT": str(root),
|
||||||
|
"BANANARCHY_BATTERY_HOOK": str(stub),
|
||||||
|
"BANANARCHY_BATTERY_LOCK": str(root / "charge.lock"),
|
||||||
|
"BANANARCHY_BATTERY_RECHECK_DELAY": "0",
|
||||||
|
"DISPLAY": ":0",
|
||||||
|
"XDG_RUNTIME_DIR": str(root / "runtime"),
|
||||||
|
"HOME": str(root / "home"),
|
||||||
|
})
|
||||||
|
res = subprocess.run(["sh", str(HELPER)], env=env,
|
||||||
|
capture_output=True, text=True)
|
||||||
|
if res.returncode:
|
||||||
|
sys.stderr.write("FAIL: helper exited %d: %s\n" % (res.returncode, res.stderr))
|
||||||
|
return 1
|
||||||
|
deadline = time.time() + 3
|
||||||
|
calls = []
|
||||||
|
while time.time() < deadline:
|
||||||
|
calls = log.read_text().splitlines() if log.exists() else []
|
||||||
|
if len(calls) >= 2:
|
||||||
|
break
|
||||||
|
time.sleep(0.1)
|
||||||
|
if calls != ["force", "force"]:
|
||||||
|
sys.stderr.write("FAIL: expected an immediate and one delayed forced "
|
||||||
|
"refresh, got %r\n" % calls)
|
||||||
|
return 1
|
||||||
|
print("[ok] immediate + delayed forced charge icon refresh")
|
||||||
|
print("battery charger event: all checks passed")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
Reference in new issue
Block a user