diff --git a/AGENTS.md b/AGENTS.md index 0de51ac..96e2315 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -30,7 +30,7 @@ It uses a pure **X11 (`Xlibre` + `sxmo-de-dwm`)** stack (no Wayland) with **Adre - `nokia-beatles` boot chain: `images/boot-lk2nd-nokia-beatles.img` is built from upstream `msm8916-mainline/lk2nd` at pinned commit `cf45aefd22d744b2bf9b39455afae697ce430063` plus `bootloader/lk2nd/nokia-beatles.patch` (see `bootloader/lk2nd/README.md`; rebuild with `scripts/build-lk2nd-beatles.sh`). It keeps the upstream QCDT layout (both `0x14b` entries `0xb/0x100` and `0x1000b/0x100` sharing one `msm8905-qrd-skub` DTB, stock `qcom,board-id` order) with a compact `/lk2nd/nokia-beatles` node injected, and **adds `/cpus` with `cpu@0`..`cpu@3` and 4-byte `device_type` to the common `lk2nd.dtsi` so every QCDT DTB has it**. The 2720's MSM8905 is a partial-goods 2-core part and its aboot `ASSERT`s at `platform/msm_shared/partial_goods.c:80` when `/cpus`, `cpu@2` or `cpu@3` is missing — that was the actual "black screen / no fastboot" crash (Sahara MEMORY_DEBUG RLOG log, see `bootloader/lk2nd/README.md` and `backup/nokia-beatles-2720/crash-20261109/aboot-log.txt`). cmdline `lk2nd lk2nd.compatible=nokia,beatles`, `lk2nd,match-panel` for all three GC9305 panel names the aboot reports, and the single `qcom,mdss_spi_gc9305_v2_qvga_cmd` (the panel the live aboot reports) `lk2nd,panel-init` stream replayed on BLSP1 QUP5 (DC GPIO 110) only when aboot did not leave continuous splash enabled (or when `lk2nd.force-panel-init` is in the cmdline), so the 240x320 RGB565 main panel is initialized even without cont-splash. `spi-display.c` also paints the branded RGB565 boot splash into the framebuffer (without flushing during init): `DISABLE_SPLASH_PARTITION=1` plus `menu.c`'s bottom-only text means upstream lk2nd otherwise pushes a nearly black frame, which is what the "KaiOS logo then blank screen" is. `lk2nd/include/lk2nd/spi-panel-init.h` is shared with the host unit test; the repo copy is `bootloader/lk2nd/spi-panel-init.h` and `check-lk2nd-beatles.py` keeps them in sync and enforces that QCDT shape. Both the normal and diagnostic images carry `lk2nd.no-display` (RAM-only framebuffer, no QUP SPI before USB) because unbounded QUP/clock register polls used to wedge lk2nd with the boot vibrator stuck on. The port now bounds those polls (`QUP_FIFO_TIMEOUT`, `CLK_POLL_TIMEOUT`) and adds `oem display-init` / `oem display-test` / `oem scan-dtb` fastboot probes that run after USB is up, plus `oem screenshot` to verify the framebuffer. Live `oem display-init` confirmed the GC9305 v2 stream and the 240x320 RGB565 frame; a chain-loaded diagnostic falls back to the QCDT panel stream when aboot tags are absent, `oem scan-dtb` stages the final DTB after lk2nd DT updates, `oem ramoops console` validates and bounds pstore data, and the QUP per-word `SPEW` log is removed. The r3 port also makes `oem read-partition` block-safe: it rounds MMC reads up to the eMMC block size, rejects unaligned offsets and stages only the requested byte count. `images/boot-lk2nd-nokia-beatles-display.img` uses `lk2nd.display=on` for boot-time panel init via the downstream GC9305 v2 `lk2nd,panel-init` stream; flash it with `--lk2nd-image`. The diagnostic image additionally has `DEBUG=2 LK2ND_FORCE_FASTBOOT=1`. `check-lk2nd-beatles.py --expect-display` guards the display variant; `scripts/test-lk2nd-beatles-port.py` runs all three. lk2nd is confirmed working over live fastboot (`lk2nd:compatible=nokia,beatles`, `model=Nokia 2720 Flip`, panel `qcom,mdss_spi_gc9305_v2_qvga_cmd`, `unlocked=yes`). `flash-edl.py` defaults to `--method lk2nd` for every target; stock aboot accepts the port and lk2nd boots Bananarchy from `userdata` via `extlinux.conf` (`fdt /qcom-msm8905-nokia-beatles.dtb`). On `nokia-beatles` the default is now the Argon shape: lk2nd in `boot`, the standalone mainline `boot.img` in `recovery` (Volume Up fallback). `--method both` remains as a fallback that writes the standalone mainline `boot.img` to both slots. `--verify` reads back every slot and `--dump-diagnostics` saves small bootloader/config partitions for secure-boot analysis. `scripts/check-lk2nd-beatles.py` validates the boot header, both 2720 QCDT entries, `/cpus` in every QCDT DTB, the device node and the GC9305 v2 panel init stream; `scripts/test-lk2nd-beatles-port.py` adds the host C parser test. The stock 2720 aboot is locked (`devinfo.is_unlocked=0`) and verifies boot images against `Nokia_beatles ROOT CA0`; `flash-edl.py` therefore defaults to setting `devinfo.is_unlocked=1` on `nokia-beatles` via `unlock_devinfo()` before writing any boot image, saves `backup/devinfo-locked-.img`, and supports `--no-unlock-bootloader` to skip. `scripts/make-unlocked-devinfo.py` produces the same patched image offline. Correction: the GPT has `keystore` but no `keymaster`, so `target_get_vb_version()` returns `VB_L=1` while `VB_M=2`; aboot therefore reads `devinfo` from eMMC, not RPMB. The 21:25 dump confirms eMMC `is_unlocked=1`, so the unlock is effective and no stock fastboot / `oem unlock-go` step is required. `--only-unlock`, `enable_oem_unlock()` and `scripts/make-oem-unlock-config.py` remain as harmless optional prerequisites, not a boot requirement. The appended DTB must carry the exact stock `qcom,msm-id = <0x14b 0>`, `qcom,board-id = <0x1000b 0x100>` and `qcom,pmic-id = <0x1000d 0 0 0>` values; older aboot revisions read only the first `qcom,board-id` pair, so an extra `0x0b 0x100` variant ahead of it makes the DTB look like a different board (the lk2nd QCDT DTB keeps upstream's `0x0b` pair first). `/memory` keeps `device_type = "memory"` and a 512 MiB `reg = <0x80000000 0x20000000>` fallback, so a bootloader that fails to patch it still gives Linux usable RAM. `scripts/repack-beatles-bootimg.py` rebuilds only the standalone Android boot.img after a DTB change; `scripts/sync-beatles-bootfs.py` updates the boot.img, DTB and extlinux.conf inside the raw image's ext2 `pmOS_boot` filesystem (never write an Android boot.img at raw offset 1 MiB). The old binary-patched headless image and `scripts/make-beatles-lk2nd-bootimg.py` are gone. `check-beatles-bootimg.py`, `check-lk2nd-beatles.py` and `sync-beatles-bootfs.py --check` are all called by `check-rebuild.sh`, which also guards the port source files. The shipping kernel display stack keeps the verified single internal panel. The two-GC9305 `gpio-mux`/`spi-mux` layout lives in `devices/nokia-beatles/qcom-msm8905-nokia-beatles-cover.dts` and is opt-in via `scripts/build-beatles-cover-panel.py`: a live test produced `/dev/fb1` but darkened the main panel, so gpio13 mux polarity and gpio21/gpio23 DC/reset routing still need hardware sign-off. `scripts/build-beatles-no-cover-dtb.py` builds the single-panel rollback. The `mux-core`, `mux-gpio` and `spi-mux` modules and the external panel firmware are already provisioned in the initramfs for the opt-in layout, and Xorg pins `/dev/dri/card0`. The stock boot chain passes the Power-menu reboot reason in `PON_SOFT_RB_SPARE[1:0]`; the port reads those low bits and writes low-bit cookies so the visible Fastboot menu survives `Reboot to bootloader` and `fastboot reboot-bootloader`. - `bootloader/loaders/`: device-specific signed Firehose programmers; `DEVICE_LOADERS` in `flash-edl.py` maps each target codename to one (`8k.mbn` serves both `nokia-sparkler` and `nokia-leo`), and `DEVICE_LOADER_VARIANTS` maps `--variant us` on `nokia-beatles` to `2720v.mbn` (`Nokia_bts_us`). Never flash a different device's programmer: Sahara rejects the signature and `--list-loaders` shows the embedded attestation identity. - `vendor/edl/`: vendored, patched EDL client library (MIT) used by `flash-edl.py`; a local `edl/` checkout or `BANANARCHY_EDL_DIR` overrides it. -- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. It intentionally contains no `device-*` package; `scripts/apply-bananarchy-overlay.sh` installs the per-device `devices//modules-initfs` list as `/usr/share/mkinitfs/modules/00-device-.modules` (plus its `initramfs.load` mapping) so a clean-clone bootstrap still builds the correct initramfs. `scripts/check-rebuild.sh` guards this. The package set also includes `msm-firmware-loader`, its OpenRC companion and `msm-firmware-loader-wcnss`; explicit sysinit/boot links are required because packages are installed with `--no-scripts`. This mounts the stock `modem` and `persist` partitions before udev and supplies WCNSS/modem firmware plus factory Wi-Fi NV data, allowing both `wlan0` and `hci0` to enumerate. The package set explicitly contains `glib` and `gsettings-desktop-schemas`; because apk is invoked with `--no-scripts`, `apply-bananarchy-overlay.sh` must run `compile-gsettings-schemas.sh` to generate `gschemas.compiled`, otherwise WebKitGTK's network process aborts with an internal error. +- `scripts/rootfs-packages.txt`: single source of truth for the `armv7` rootfs package set, read by both `bootstrap-rootfs.sh` and `rebuild-image.sh`. It intentionally contains no `device-*` package; `scripts/apply-bananarchy-overlay.sh` installs the per-device `devices//modules-initfs` list as `/usr/share/mkinitfs/modules/00-device-.modules` (plus its `initramfs.load` mapping) so a clean-clone bootstrap still builds the correct initramfs. `scripts/check-rebuild.sh` guards this. The package set also includes `msm-firmware-loader`, its OpenRC companion and `msm-firmware-loader-wcnss`; explicit sysinit/boot links are required because packages are installed with `--no-scripts`. This mounts the stock `modem` and `persist` partitions before udev and supplies WCNSS/modem firmware plus factory Wi-Fi NV data, allowing both `wlan0` and `hci0` to enumerate. The package set explicitly contains `glib` and `gsettings-desktop-schemas`; because apk is invoked with `--no-scripts`, `apply-bananarchy-overlay.sh` must run `compile-gsettings-schemas.sh` to generate `gschemas.compiled`, otherwise WebKitGTK's network process aborts with an internal error. The package set also includes `util-linux-misc` for `script(1)`, which the live Bluetooth scan wrapper uses to keep a single interactive BlueZ client alive. - `scripts/rootfs-prune-packages.txt`: denylist of Wayland-only, Rust-based, and retired packages purged from existing rootfs trees by `bootstrap-rootfs-container.sh` and `rebuild-image.sh`. - `scripts/prune-rootfs-packages.sh`: two-phase rootfs pruner (`world` before `apk add`, `purge` after) that reads the denylist and pins `install_if` packages with negative `!pkg` world constraints plus `apk fix`; the `world` phase is required so apk can atomically replace Rust `sudo-rs` with C `sudo`. @@ -60,7 +60,7 @@ All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7` - `./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-beatles-cover-panel.py` — builds the opt-in two-panel DTB (and optionally a boot image / `pmOS_boot` patch) for the physical gpio13/reset sign-off. - `./scripts/build-beatles-no-cover-dtb.py` — builds the verified single-panel rollback DTB (and optionally a boot image / `pmOS_boot` patch). -- `./scripts/test-webarchy-renderer.py`, `./scripts/test-webkit-gsettings.py`, `./scripts/test-idle-blank-lock.py`, `./scripts/test-bluetooth-scan.py`, `./scripts/test-battery-charge-event.py`, `./scripts/test-gps-time-sync.py`, `./scripts/test-cover-idle.py` and `./scripts/test-cover-dt.py` — host unit/integration tests for the Webarchy renderer profile and GSettings schema build, the idle-blank screenlock wiring, the Bluetooth discovery parser, the charger plug/unplug icon refresh, the GPS-only time source, the cover display state machine and the external-panel DT wiring (all also run by `check-rebuild.sh`). +- `./scripts/test-webarchy-renderer.py`, `./scripts/test-webkit-gsettings.py`, `./scripts/test-idle-blank-lock.py`, `./scripts/test-bluetooth-scan.py`, `./scripts/test-bluetooth-live-scan.py`, `./scripts/test-battery-charge-event.py`, `./scripts/test-gps-time-sync.py`, `./scripts/test-cover-idle.py` and `./scripts/test-cover-dt.py` — host unit/integration tests for the Webarchy renderer profile and GSettings schema build, the idle-blank screenlock wiring, the Bluetooth discovery parser and live PTY wrapper, the charger plug/unplug icon refresh, the GPS-only time source, the cover display state machine and the external-panel DT wiring (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/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`. diff --git a/CHANGELOG.md b/CHANGELOG.md index 492f6a7..cff1203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,12 @@ Release versions follow the `
` 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. +### Live Bluetooth peripheral discovery + +- **Synthetic-only regression**: the previous Bluetooth fix could find an injected `BT_PROBE` line but not real peripherals. Live diagnostics showed non-interactive `bluetoothctl --timeout 15 scan on` emitted only discovery-filter/controller messages, a separate `bluetoothctl devices` query after the scan client exited was empty, and `scan off` from another client failed with `org.bluez.Error.InProgress` while the original client still owned discovery. The synthetic test had bypassed this whole BlueZ client-lifetime path. +- **Discovery path**: `overlay/rootfs/usr/local/bin/bluetoothctl` now intercepts only `scan on`/`scan bredr`/`scan le` and forwards every other command to `/usr/bin/bluetoothctl`. `bananarchy-bt-scan.sh` drives one interactive `bluetoothctl` session through `script(1)`, powers the controller on, sets `transport auto` and `duplicate-data on`, queries `devices` repeatedly while the same discovery client is active, then sends `scan off` and `quit`. The existing `networks.so` parser accepts both `[NEW] Device ...` stream lines and `Device ` list lines, so no plugin rebuild is needed. `util-linux-misc` is now explicit in the rootfs package set to provide `script(1)`. +- **Guards and live status**: `scripts/test-bluetooth-live-scan.py` exercises the wrapper with a stub real `bluetoothctl` under a real PTY and verifies device-list output, clean shutdown, and non-scan forwarding; `check-rebuild.sh` guards the package, overlay installation, helper syntax and host test. The wrapper was deployed to the live phone. Final confirmation with a physical peripheral in pairing mode is still required; no push was performed. + ### Live nokia-beatles plugin verification and WebKit GSettings schema fix - **Stale live runtime**: the phone was still running the pre-fix `webarchy.so` (`3e3c3ac7...`) and `networks.so` (`97eaae44...`) from the baseline image, while `prebuilt/`, `overlay/rootfs/` and the local `rootfs/` already carried the rebuilt artifacts (`8eb1b493...` and `e12103ee...`). That is why the earlier repository fixes were not visible on the device. The current binaries were deployed, their hashes verified, and both resident plugins restarted. diff --git a/MANUAL.md b/MANUAL.md index 8325c87..378bb56 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -216,7 +216,7 @@ All twenty-five phone applications are compiled as shared-object plugins (`/usr/ - **Three connectivity tabs (`Left`/`Right` or `1`–`3`)**: - **`1:Wi-Fi`**: toggle Wi-Fi radio, rescan (`*`), toggle **Wi-Fi Hotspot**, and connect to WPA2/open networks with a multi-tap password dialog (`*` toggles password visibility). - **`2:Cell/APN`**: toggle **Mobile Data** (configuring the QMI `bam-dmux` `wwan0` static IPv4 bearer, default route, and DNS automatically), inspect `wwan0` IPv4 status, edit **APN Configuration**, and toggle **USB Tethering**. - - **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`ON (Visible)` vs `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), monitor the live **OBEX File Receiver** widget (`#` opens `~/Downloads/` in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. The scan keeps the `bluetoothctl scan on` output and parses its `[NEW] Device ` / `[CHG] Device ... Name:` lines, because BlueZ stops client-scoped discovery when `bluetoothctl` exits and can drop unpaired devices before a separate `bluetoothctl devices` query runs; the controller is also powered on automatically if `bluetoothctl show` reports `Powered: no`. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Connect Device**, **Disconnect Device**, **Pair & Trust Device**, **Switch Audio (A2DP / HSP-HFP)**, and **Forget / Remove Device**. Supports Bluetooth **A2DP** (`sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`) and **HSP/HFP** (`mSBC` / `CVSD`) audio (routable via `xdrawer`, `dmenu Audio`, and `sxmo_audio.sh`), **HID keyboards** (automatically switching `fcitx5-t9` and NeoUI/plugin inputs to `[KBD]` direct QWERTY mode so `0-9`, `*`, `#`, `Shift+0-9`, and letters bypass T9 multi-tap and preedit popups), **HID mice** (automatically showing the X11 mouse cursor whenever a mouse is connected and hiding it when disconnected), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`). + - **`3:Bluetooth`**: toggle **Bluetooth Power** (showing a live `ON (N Active)` badge and starting `/usr/bin/bananarchy-bt-obex`), toggle **Discoverable** (`ON (Visible)` vs `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), monitor the live **OBEX File Receiver** widget (`#` opens `~/Downloads/` in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. The scan now drives one interactive `bluetoothctl` client through `script(1)` (`/usr/local/bin/bluetoothctl` -> `/usr/bin/bananarchy-bt-scan.sh`), sets auto transport and duplicate-data, asks the same client for `devices` three times while discovery is active, parses both `[NEW] Device ...` / `[CHG] Device ...` and `Device ` lines, and stops discovery cleanly before the client exits; the controller is also powered on automatically if `bluetoothctl show` reports `Powered: no`. Active connections are pinned to the top of the device list with a green border and live profile/battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and the device actions menu (`Center OK`) provides **Connect Device**, **Disconnect Device**, **Pair & Trust Device**, **Switch Audio (A2DP / HSP-HFP)**, and **Forget / Remove Device**. Supports Bluetooth **A2DP** (`sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`) and **HSP/HFP** (`mSBC` / `CVSD`) audio (routable via `xdrawer`, `dmenu Audio`, and `sxmo_audio.sh`), **HID keyboards** (automatically switching `fcitx5-t9` and NeoUI/plugin inputs to `[KBD]` direct QWERTY mode so `0-9`, `*`, `#`, `Shift+0-9`, and letters bypass T9 multi-tap and preedit popups), **HID mice** (automatically showing the X11 mouse cursor whenever a mouse is connected and hiding it when disconnected), and **HID gamepads** (automatically bridged to the phone's D-Pad, softkeys, and action keys via `/dev/uinput`). 13. **Ringtones, notification/SMS sounds, and ringer manager (`ringtones.so` / `xringtones`)**: - **Open**: select **Ringtones** from the System, Config, or Audio menu, select **Notification Sound** from the **Notifications (`Notifs`)** menu, or run `xringtones [--notif] [file]`. diff --git a/README.md b/README.md index c933893..659988c 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Instead of spawning slow shell scripts for everyday phone tasks, Bananarchy runs - **Phone dialer (`xdialer`), call log (`xcalllog`), and call screen (`xcallscreen`)**: press any digit on the home screen to start dialing with live T9 contact matching, run interactive carrier USSD codes (`*100#`, etc.), or type `*#06#` to inspect both IMEIs. When two SIM cards are active in Dual-SIM Dual Standby (DSDS), placing a call or running a USSD code prompts to choose between `SIM 1` and `SIM 2`. Incoming and active calls on either SIM (as well as incoming/active VoIP calls from `xsip` and `xtox`) open a dedicated call screen with an active `[SIM 1]`/`[SIM 2]`/`[SIP]`/`[TOX]` badge, earpiece/speaker switching, microphone mute, DTMF keypad, and one-key normalized WAV call recording (`~/Recordings/rec_HHMMSS_.wav`). The call log includes a 5-tab view (`All`, `Miss`, `In`, `Out`, `Spam`) with integrated anti-spam number blocking (`~/.config/sxmo/block.tsv`) that automatically hangs up blocked callers and logs them to the `Spam` tab without triggering missed-call notifications. - **Contacts (`xcontacts`) and SMS manager (`xsms`)**: full phonebook editor with direct Qualcomm QMI SIM card contact import and export across SIM 1 and SIM 2, paired with a threaded SMS conversation view that renders and scrolls full-length concatenated/Unicode (`UCS-2`) messages line by line, a multi-tap message composer with an encoding-aware GSM-7/UCS-2 segment counter and outgoing `SIM 1` / `SIM 2` selection when two SIMs are active, and built-in anti-spam blocklist / spam folder (`~/.local/share/sxmo/block`) with one-key thread blocking and restoration. - **Modem and Dual-SIM manager (`xmodem`)**: 4-tab cellular control center (`SIMs`, `Radio`, `AT`, `Log`) supporting Dual-SIM Dual Standby (DSDS) with simultaneous network registration on both SIM slots, instant default SIM switching (`Set as Default SIM (Calls/SMS)`), full Primary/Secondary GW (`4G/Data`) slot swapping (`Make Primary GW (4G/Data Swap)`), SIM PIN unlock and PUK unblock wizards, 2G/3G/4G radio mode selection, interactive USSD sessions, and a live AT command console. -- **Networks and Bluetooth manager (`xnetworks`) with OBEX file transfer (`bananarchy-bt-obex`)**: 3-tab connectivity manager for Wi-Fi networks, WPA2 password entry, Wi-Fi hotspot, USB tethering, 4G/LTE mobile data (`wwan0`) and APN editing, and Bluetooth pairing, with built-in Bluetooth OBEX Object Push file reception (`~/Downloads` status and receiver toggle in the `Bluetooth` tab) and **Send via Bluetooth** in `xfiles`. Bluetooth discovery parses the live `bluetoothctl scan on` stream instead of relying on a second `devices` query, so nearby unpaired devices survive the end of a scan. +- **Networks and Bluetooth manager (`xnetworks`) with OBEX file transfer (`bananarchy-bt-obex`)**: 3-tab connectivity manager for Wi-Fi networks, WPA2 password entry, Wi-Fi hotspot, USB tethering, 4G/LTE mobile data (`wwan0`) and APN editing, and Bluetooth pairing, with built-in Bluetooth OBEX Object Push file reception (`~/Downloads` status and receiver toggle in the `Bluetooth` tab) and **Send via Bluetooth** in `xfiles`. Bluetooth discovery runs through `/usr/local/bin/bluetoothctl` and `bananarchy-bt-scan.sh`, which keeps one interactive `bluetoothctl` PTY client alive, sets auto transport and duplicate-data, queries `devices` during active discovery, and stops discovery cleanly so unpaired peripherals are not dropped when the scan command exits. - **File manager (`xfiles`) with microSD automount (`sxmo_sdcard.sh`), Bluetooth file sharing, music and tracker player (`xmusic`), and camera (`xcamera`)**: keypad directory browser with automatic microSD card (`/dev/mmcblk1`) detection and `/media/sdcard` mounting/unmounting, **Send via Bluetooth** OBEX file push to paired/discovered devices, built-in text viewer, integrated GUI multi-tap text editor (`Edit in Text Editor`, available as an action on any file), image viewer, and dedicated monophonic ringtone viewer (`RingtoneView` for Nokia RTTTL `.nrt`/`.rtttl`/`.rtx`, Ericsson eMelody `.emy`, and IrDA iMelody `.imy` with graphical piano-roll pitch contour, note sequence viewer, live audio preview, and one-key assignment as call ringtone or notification/SMS sound — plus one-click actions to launch `.jar`/`.jad` MIDlets in the **ReMEdy (`remedy`)** J2ME emulator, launch `.gb`/`.gbc` ROMs in the Game Boy emulator, run `.yab` scripts in Yabasic inside the terminal, play audio, preview images, set any image as wallpaper, or install any audio, tracker, or monophonic melody file as call ringtone or notification/SMS sound), a 3-tab music and chiptune tracker module player (`WAV`, `MP3`, `OGG`, `FLAC`, `Opus`, `MOD`, `XM`, `IT`, `S3M`, `NRT`, `RTTTL`, `RTX`, `EMY`, `IMY`, and more), and a live V4L2 camera viewfinder with digital zoom, flash/torch control, self-timer, and photo gallery. - **Native NeoUI communication and internet suite (`xsip`, `xemail`, `xirc`, `xtox`, `xkopher`, `webarchy`)**: - **SIP VoIP client (`xsip` / `sip.so`)**: RFC 3261 SIP softphone (`Dialer`, `Accounts`, `History`) supporting both account-registered calling (with Digest MD5 authentication and standby `REGISTER` keepalive) and direct accountless P2P SIP URI calling (`user@host[:port]` or `sip:user@host[:port]`), RFC 3263 DNS `SRV` (`_sip._udp.`) proxy discovery and dialog routing, RFC 6189 **ZRTP** media-path Diffie-Hellman (`DH3k`/`DH2k`) key agreement and RFC 3711 **SRTP** (`AES-128-CM` + `HMAC-SHA1-80`) voice encryption with a 4-character `SAS` verification code, incoming `INVITE` ringing and call handling integrated with `xcallscreen` (`[SIP/]` / `[SIP/:]`), multi-codec wideband and narrowband RTP/SRTP audio (`Opus` 16 kHz / 48 kHz RTP clock with in-band FEC, `ITU-T G.722` 16 kHz wideband SB-ADPCM, `G.711 PCMU`/`PCMA` 8 kHz, `GSM 06.10` Full Rate 8 kHz, `ITU-T G.726-32` 8 kHz ADPCM, `IMA ADPCM DVI4` 8/16 kHz, and `L16` uncompressed 16-bit PCM 8/16 kHz) with per-account and direct-mode codec preference selection, and RFC 2833 / RFC 4733 DTMF. diff --git a/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh b/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh new file mode 100755 index 0000000..fe66db1 --- /dev/null +++ b/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# Keep one interactive bluetoothctl client alive for a full discovery window. +# BlueZ removes unpaired Device1 objects when the discovery client exits, and +# non-interactive "scan on" does not reliably print device events to a pipe. +# This helper drives bluetoothctl through a PTY via script(1), asks the same +# client for "devices" while discovery is active, then stops discovery cleanly. +REAL="${BANANARCHY_REAL_BLUETOOTHCTL:-/usr/bin/bluetoothctl}" +DURATION="${BANANARCHY_BT_SCAN_SECONDS:-13}" + +case "$DURATION" in + ''|*[!0-9]*) + DURATION=13 + ;; +esac +if [ "$DURATION" -lt 3 ]; then + DURATION=3 +elif [ "$DURATION" -gt 13 ]; then + DURATION=13 +fi + +q1=$((DURATION / 3)) +q2=$((DURATION * 2 / 3)) +q3=$((DURATION - 1)) +if [ "$q1" -lt 1 ]; then + q1=1 +fi +if [ "$q2" -le "$q1" ]; then + q2=$((q1 + 1)) +fi +if [ "$q3" -le "$q2" ]; then + q3=$((q2 + 1)) +fi + +{ + printf '%s\n' \ + 'menu scan' \ + 'transport auto' \ + 'duplicate-data on' \ + 'back' \ + 'power on' + sleep 1 + printf '%s\n' 'scan on' + sleep "$q1" + printf '%s\n' 'devices' + sleep "$((q2 - q1))" + printf '%s\n' 'devices' + sleep "$((q3 - q2))" + printf '%s\n' 'devices' 'scan off' + sleep 1 + printf '%s\n' 'quit' +} | timeout "$((DURATION + 2))" \ + script -q -c "$REAL" /dev/null + +exit 0 diff --git a/overlay/rootfs/usr/local/bin/bluetoothctl b/overlay/rootfs/usr/local/bin/bluetoothctl new file mode 100755 index 0000000..af97ea3 --- /dev/null +++ b/overlay/rootfs/usr/local/bin/bluetoothctl @@ -0,0 +1,16 @@ +#!/bin/sh +# Route bluetoothctl discovery through one live interactive BlueZ client. +# All other bluetoothctl calls go to the real package binary unchanged. +REAL="${BANANARCHY_REAL_BLUETOOTHCTL:-/usr/bin/bluetoothctl}" +HELPER="${BANANARCHY_BT_SCAN_HELPER:-/usr/bin/bananarchy-bt-scan.sh}" +export BANANARCHY_REAL_BLUETOOTHCTL="$REAL" + +case " $* " in + *" scan on "*|*" scan bredr "*|*" scan le "*) + "$HELPER" || true + exit 0 + ;; + *) + exec "$REAL" "$@" + ;; +esac diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index e5cff26..b1a30d7 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -166,6 +166,8 @@ chown 0:0 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \ "$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \ "$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \ "$TARGET_ROOTFS/usr/bin/bananarchy-network-event.sh" \ + "$TARGET_ROOTFS/usr/local/bin/bluetoothctl" \ + "$TARGET_ROOTFS/usr/bin/bananarchy-bt-scan.sh" \ "$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \ "$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \ "$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \ @@ -187,6 +189,8 @@ chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.sh" \ "$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \ "$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \ "$TARGET_ROOTFS/usr/bin/bananarchy-network-event.sh" \ + "$TARGET_ROOTFS/usr/local/bin/bluetoothctl" \ + "$TARGET_ROOTFS/usr/bin/bananarchy-bt-scan.sh" \ "$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \ "$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \ "$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/30-bananarchy-network-status.sh" \ diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index bb17cea..c06d89d 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -1209,6 +1209,45 @@ if command -v g++ >/dev/null 2>&1 && \ fail "host Bluetooth scan parser test failed" fi +echo "[check] Live Bluetooth discovery wrapper..." +BT_WRAPPER="$BASE_DIR/overlay/rootfs/usr/local/bin/bluetoothctl" +BT_HELPER="$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh" +for f in "$BT_WRAPPER" "$BT_HELPER"; do + if [ ! -x "$f" ]; then + fail "${f#$BASE_DIR/} is missing or not executable" + fi + if ! sh -n "$f" 2>/dev/null; then + fail "shell syntax: ${f#$BASE_DIR/}" + fi +done +for token in 'BANANARCHY_REAL_BLUETOOTHCTL' 'BANANARCHY_BT_SCAN_HELPER' \ + '" scan on "' 'exec "$REAL" "$@"'; do + if ! grep -qF "$token" "$BT_WRAPPER"; then + fail "bluetoothctl wrapper is missing $token" + fi +done +for token in 'script -q -c' 'transport auto' 'duplicate-data on' \ + 'scan off' 'BANANARCHY_BT_SCAN_SECONDS'; do + if ! grep -qF "$token" "$BT_HELPER"; then + fail "live Bluetooth scan helper is missing $token" + fi +done +if ! grep -q '^util-linux-misc$' "$PKGS_FILE"; then + fail "rootfs package set is missing util-linux-misc (script)" +fi +if ! grep -qF 'usr/local/bin/bluetoothctl' \ + "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \ + ! grep -qF 'usr/bin/bananarchy-bt-scan.sh' \ + "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then + fail "apply-bananarchy-overlay.sh no longer installs the live Bluetooth scan wrapper" +fi +if [ ! -x "$BASE_DIR/scripts/test-bluetooth-live-scan.py" ]; then + fail "missing host unit test scripts/test-bluetooth-live-scan.py" +fi +if ! "$BASE_DIR/scripts/test-bluetooth-live-scan.py" >/dev/null 2>&1; then + fail "host live Bluetooth discovery test failed" +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" diff --git a/scripts/rootfs-packages.txt b/scripts/rootfs-packages.txt index d342776..5172d80 100644 --- a/scripts/rootfs-packages.txt +++ b/scripts/rootfs-packages.txt @@ -83,6 +83,7 @@ soc-qcom-msm8916-ucm sudo tcl tor +util-linux-misc v4l-utils w3m webkit2gtk-4.1 diff --git a/scripts/test-bluetooth-live-scan.py b/scripts/test-bluetooth-live-scan.py new file mode 100755 index 0000000..8d1c0e3 --- /dev/null +++ b/scripts/test-bluetooth-live-scan.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python3 +"""Host test for the live BlueZ discovery wrapper. + +The parser test only proves that captured device lines can be merged. This +test drives the interactive bluetoothctl wrapper with a stub real binary and +checks that discovery-client commands, periodic device queries and clean +shutdown all happen through one PTY session. +""" +import os +import pathlib +import shutil +import subprocess +import sys +import tempfile + +BASE = pathlib.Path(__file__).resolve().parent.parent +WRAPPER = BASE / "overlay/rootfs/usr/local/bin/bluetoothctl" +HELPER = BASE / "overlay/rootfs/usr/bin/bananarchy-bt-scan.sh" +OVERLAY = BASE / "scripts/apply-bananarchy-overlay.sh" +PACKAGES = BASE / "scripts/rootfs-packages.txt" + +STUB = r'''#!/usr/bin/env python3 +import sys + +if len(sys.argv) > 1: + if sys.argv[1] == "show": + print("\tPowered: yes") + sys.exit(0) + +for line in sys.stdin: + command = line.strip() + if command == "scan on": + print("[NEW] Device AA:BB:CC:DD:EE:FF STUB_STREAM", flush=True) + elif command == "devices": + print("Device AA:BB:CC:DD:EE:FF STUB_LIST", flush=True) + elif command == "scan off": + print("Discovery stopped", flush=True) + elif command == "quit": + break +''' + + +def read(path): + return path.read_text(encoding="utf-8") + + +def main(): + for tool in ("script", "timeout"): + if not shutil.which(tool): + raise SystemExit("missing required host tool: %s" % tool) + if not WRAPPER.is_file() or not os.access(WRAPPER, os.X_OK): + raise SystemExit("missing executable overlay/usr/local/bin/bluetoothctl") + if not HELPER.is_file() or not os.access(HELPER, os.X_OK): + raise SystemExit("missing executable overlay/usr/bin/bananarchy-bt-scan.sh") + + wrapper = read(WRAPPER) + helper = read(HELPER) + overlay = read(OVERLAY) + packages = { + line.strip() + for line in read(PACKAGES).splitlines() + if line.strip() and not line.lstrip().startswith("#") + } + if "util-linux-misc" not in packages: + raise SystemExit("rootfs package set is missing util-linux-misc (script)") + for token in ("BANANARCHY_REAL_BLUETOOTHCTL", "BANANARCHY_BT_SCAN_HELPER", + '" scan on "', 'exec "$REAL" "$@"'): + if token not in wrapper: + raise SystemExit("bluetoothctl wrapper is missing %s" % token) + for token in ("script -q -c", "menu scan", "transport auto", + "duplicate-data on", "scan on", "devices", "scan off", + "quit", "BANANARCHY_BT_SCAN_SECONDS"): + if token not in helper: + raise SystemExit("live scan helper is missing %s" % token) + for token in ("usr/local/bin/bluetoothctl", "usr/bin/bananarchy-bt-scan.sh"): + if token not in overlay: + raise SystemExit("overlay application is not installing %s" % token) + print("[ok] live Bluetooth discovery wiring") + + with tempfile.TemporaryDirectory(prefix="bananarchy-bt-scan-") as tmp: + root = pathlib.Path(tmp) + stub = root / "bluetoothctl-stub" + stub.write_text(STUB, encoding="utf-8") + stub.chmod(0o755) + env = os.environ.copy() + env["BANANARCHY_REAL_BLUETOOTHCTL"] = str(stub) + env["BANANARCHY_BT_SCAN_HELPER"] = str(HELPER) + env["BANANARCHY_BT_SCAN_SECONDS"] = "4" + scan = subprocess.run( + [str(WRAPPER), "--timeout", "15", "scan", "on"], + env=env, capture_output=True, text=True, timeout=15) + if scan.returncode != 0: + raise SystemExit("wrapper scan failed:\n%s" % scan.stderr.strip()) + for token in ("STUB_STREAM", "STUB_LIST", "Discovery stopped"): + if token not in scan.stdout: + raise SystemExit("wrapper output is missing %s" % token) + forward = subprocess.run( + [str(WRAPPER), "show"], env=env, + capture_output=True, text=True, timeout=5) + if forward.returncode != 0 or "Powered: yes" not in forward.stdout: + raise SystemExit("wrapper did not forward show to the real binary") + if "STUB_" in forward.stdout: + raise SystemExit("wrapper incorrectly intercepted a non-scan command") + print("[ok] interactive Bluetooth scan session") + + +if __name__ == "__main__": + main()