From e4358665f7bde3764bc65ef3771d3c820da01b7f Mon Sep 17 00:00:00 2001 From: Luxferre Date: Tue, 10 Nov 2026 16:15:50 +0200 Subject: [PATCH] Enable WCNSS LE before Bluetooth discovery Live btmgmt/btmon showed hci0 powered with le absent from current settings; BlueZ issued only BR/EDR Inquiry, so BLE peripherals were invisible. Add a narrow doas helper to run btmgmt -i hci0 le on before each interactive scan, make bluez-btmgmt explicit, add the doas rule, host guards and docs. With real peripherals in pairing mode the plugin UI reported 5 devices and retained BT KeyBoard / LE-QC Ultra entries. --- AGENTS.md | 2 +- CHANGELOG.md | 9 +++++---- MANUAL.md | 2 +- README.md | 2 +- .../etc/doas.d/60-bananarchy-bluetooth.conf | 2 ++ .../rootfs/usr/bin/bananarchy-bt-le-enable.sh | 11 +++++++++++ overlay/rootfs/usr/bin/bananarchy-bt-scan.sh | 3 +++ scripts/apply-bananarchy-overlay.sh | 4 ++++ scripts/check-rebuild.sh | 14 ++++++++++++++ scripts/rootfs-packages.txt | 1 + scripts/test-bluetooth-live-scan.py | 17 +++++++++++++++-- 11 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 overlay/rootfs/etc/doas.d/60-bananarchy-bluetooth.conf create mode 100755 overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh diff --git a/AGENTS.md b/AGENTS.md index 96e2315..0e66f27 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. 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-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)` and `bluez-btmgmt` for `btmgmt`, which the live Bluetooth scan wrapper uses to keep a single interactive BlueZ client alive and enable LE discovery on the WCNSS controller. - `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`. diff --git a/CHANGELOG.md b/CHANGELOG.md index cff1203..55bf51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,15 +15,16 @@ Work since `a1108` has focused on reliable 2720 Flip hardware support and a repr ### 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. +- **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. +- **Actual hardware root cause**: `btmgmt -i hci0 info` showed `le` supported but absent from `current settings`; `btmon` showed only BR/EDR `Inquiry` commands and no `LE Set Scan Enable`. Running `btmgmt -i hci0 le on` produced `LE Set Scan Parameters`, `LE Set Scan Enable`, LE advertising reports, and real `Device Found` events. The WCNSS controller was simply being powered up with LE disabled, so BLE peripherals were invisible. +- **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` powers the controller on, calls the narrow `doas` helper `bananarchy-bt-le-enable.sh` (`btmgmt -i hci0 le on`), then drives one interactive `bluetoothctl` session through `script(1)` with `transport auto` and `duplicate-data on`; it 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` and `bluez-btmgmt` are explicit in the rootfs package set. +- **Guards and live verification**: `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 packages, doas rule, overlay installation, helper syntax and host test. With a real peripheral in pairing mode, the live PTY scan found `BT KeyBoard`, `M7` and two `LE-QC Ultra` advertisements; the wrapper then found four unique real devices with no `Failed`/`InProgress` errors. ### 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. - **Actual WebKit root cause**: with the current `webarchy.so`, `G_MESSAGES_DEBUG=all` exposed `GLib-GIO-ERROR **: No GSettings schemas are installed on the system` in `WebKitNetworkProcess`, immediately followed by `ERROR: WebKit encountered an internal error ... WebLoaderStrategy.cpp(679)`. The rootfs had the `gsettings-desktop-schemas` XML files but no `gschemas.compiled`, because packages are installed with `--no-scripts` and the apk trigger never ran. The earlier renderer-profile fix was necessary but not sufficient. The package set now explicitly contains `glib` and `gsettings-desktop-schemas`; both image containers install host `glib` tools; and `apply-bananarchy-overlay.sh` calls `compile-gsettings-schemas.sh` to produce `usr/share/glib-2.0/schemas/gschemas.compiled`. `scripts/test-webkit-gsettings.py` guards the wiring and compiles a synthetic schema. Live verification: after compiling the schemas, the WebKit internal error disappeared and an HTTP probe rendered 51,420 green pixels in the 240x217 browser viewport. -- **Live Bluetooth verification**: starting from `Powered: no`, the deployed `networks.so` powered the WCNSS controller on, ran `bluetoothctl --timeout 15 scan on`, and merged an injected `[NEW] Device AA:BB:CC:DD:EE:FF BT_PROBE` discovery line even though the persistent `bluetoothctl devices` list was deliberately empty. The plugin reported `Found 1 device(s)` and retained `BT_PROBE` in its device list. The controller ended `Powered: yes`. +- **Live Bluetooth verification**: starting from `Powered: no`, the deployed `networks.so` powered the WCNSS controller on, ran `bluetoothctl --timeout 15 scan on`, and merged an injected `[NEW] Device AA:BB:CC:DD:EE:FF BT_PROBE` discovery line even though the persistent `bluetoothctl devices` list was deliberately empty. The plugin reported `Found 1 device(s)` and retained `BT_PROBE` in its device list. The controller ended `Powered: yes`. This was later shown to be parser-only and superseded by the live LE-discovery fix above. - **Final live state**: the phone has the current plugin binaries, the compiled `gschemas.compiled` database, normal plugin environments with no Bluetooth stub in `PATH`, and no debug-only WebKit environment. Webarchy and Networks were returned to their normal preloaded state; the Bluetooth controller was powered back off. ### Live 2720 Flip verification and cover DT gating diff --git a/MANUAL.md b/MANUAL.md index 378bb56..532f084 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 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`). + - **`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`. A narrow `doas` helper runs `btmgmt -i hci0 le on` before discovery because this WCNSS controller otherwise starts with LE disabled and only performs BR/EDR inquiry. 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 659988c..ca3dc27 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 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. +- **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. A narrow `doas` helper runs `btmgmt -i hci0 le on` before each scan because the WCNSS controller otherwise powers up with LE disabled and only performs BR/EDR inquiry. - **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/etc/doas.d/60-bananarchy-bluetooth.conf b/overlay/rootfs/etc/doas.d/60-bananarchy-bluetooth.conf new file mode 100644 index 0000000..b5db452 --- /dev/null +++ b/overlay/rootfs/etc/doas.d/60-bananarchy-bluetooth.conf @@ -0,0 +1,2 @@ +permit nopass :wheel as root cmd /usr/bin/bananarchy-bt-le-enable.sh +permit nopass :wheel as root cmd bananarchy-bt-le-enable.sh diff --git a/overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh b/overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh new file mode 100755 index 0000000..36338ba --- /dev/null +++ b/overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Enable the WCNSS controller's LE setting before BlueZ discovery. +# The kernel management socket requires root for this write. +set -eu + +if [ "$(id -u)" -ne 0 ]; then + echo "Error: bananarchy-bt-le-enable.sh must run as root" >&2 + exit 1 +fi + +exec /usr/bin/btmgmt -i hci0 le on diff --git a/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh b/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh index fe66db1..44649ef 100755 --- a/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh +++ b/overlay/rootfs/usr/bin/bananarchy-bt-scan.sh @@ -18,6 +18,9 @@ elif [ "$DURATION" -gt 13 ]; then DURATION=13 fi +"$REAL" power on >/dev/null 2>&1 || true +doas -n /usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true + q1=$((DURATION / 3)) q2=$((DURATION * 2 / 3)) q3=$((DURATION - 1)) diff --git a/scripts/apply-bananarchy-overlay.sh b/scripts/apply-bananarchy-overlay.sh index b1a30d7..c66c835 100755 --- a/scripts/apply-bananarchy-overlay.sh +++ b/scripts/apply-bananarchy-overlay.sh @@ -168,6 +168,7 @@ chown 0:0 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \ "$TARGET_ROOTFS/usr/bin/bananarchy-network-event.sh" \ "$TARGET_ROOTFS/usr/local/bin/bluetoothctl" \ "$TARGET_ROOTFS/usr/bin/bananarchy-bt-scan.sh" \ + "$TARGET_ROOTFS/usr/bin/bananarchy-bt-le-enable.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" \ @@ -191,6 +192,7 @@ chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-idle-blank.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/usr/bin/bananarchy-bt-le-enable.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" \ @@ -453,6 +455,8 @@ fi chmod 644 "$TARGET_ROOTFS/etc/pam.d/sshd" \ "$TARGET_ROOTFS/etc/ssh/sshd_config.d/90-bananarchy-access.conf" \ 2>/dev/null || true +chown 0:0 "$TARGET_ROOTFS/etc/doas.d/60-bananarchy-bluetooth.conf" 2>/dev/null || true +chmod 0644 "$TARGET_ROOTFS/etc/doas.d/60-bananarchy-bluetooth.conf" 2>/dev/null || true chown 0:0 "$TARGET_ROOTFS/etc/pam.d/sshd" \ "$TARGET_ROOTFS/etc/ssh/sshd_config.d/90-bananarchy-access.conf" \ 2>/dev/null || true diff --git a/scripts/check-rebuild.sh b/scripts/check-rebuild.sh index c06d89d..67c8de4 100755 --- a/scripts/check-rebuild.sh +++ b/scripts/check-rebuild.sh @@ -1235,6 +1235,20 @@ done if ! grep -q '^util-linux-misc$' "$PKGS_FILE"; then fail "rootfs package set is missing util-linux-misc (script)" fi +if ! grep -q '^bluez-btmgmt$' "$PKGS_FILE"; then + fail "rootfs package set is missing bluez-btmgmt (LE enable)" +fi +LE_HELPER="$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh" +BT_DOAS="$BASE_DIR/overlay/rootfs/etc/doas.d/60-bananarchy-bluetooth.conf" +if [ ! -x "$LE_HELPER" ] || ! sh -n "$LE_HELPER" 2>/dev/null; then + fail "bananarchy-bt-le-enable.sh is missing or has bad syntax" +fi +if ! grep -qF 'btmgmt -i hci0 le on' "$LE_HELPER" || \ + ! grep -qF 'bananarchy-bt-le-enable.sh' "$BT_HELPER" || \ + [ ! -f "$BT_DOAS" ] || \ + ! grep -qF 'bananarchy-bt-le-enable.sh' "$BT_DOAS"; then + fail "live Bluetooth scan is missing the LE enable helper or doas rule" +fi if ! grep -qF 'usr/local/bin/bluetoothctl' \ "$BASE_DIR/scripts/apply-bananarchy-overlay.sh" || \ ! grep -qF 'usr/bin/bananarchy-bt-scan.sh' \ diff --git a/scripts/rootfs-packages.txt b/scripts/rootfs-packages.txt index 5172d80..04a1c87 100644 --- a/scripts/rootfs-packages.txt +++ b/scripts/rootfs-packages.txt @@ -15,6 +15,7 @@ alpine-base alsa-utils bash bc +bluez-btmgmt brightnessctl coreutils curl diff --git a/scripts/test-bluetooth-live-scan.py b/scripts/test-bluetooth-live-scan.py index 8d1c0e3..344af8f 100755 --- a/scripts/test-bluetooth-live-scan.py +++ b/scripts/test-bluetooth-live-scan.py @@ -18,6 +18,8 @@ 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" +LE_HELPER = BASE / "overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh" +DOAS_RULE = BASE / "overlay/rootfs/etc/doas.d/60-bananarchy-bluetooth.conf" STUB = r'''#!/usr/bin/env python3 import sys @@ -52,6 +54,8 @@ def main(): 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") + if not LE_HELPER.is_file() or not os.access(LE_HELPER, os.X_OK): + raise SystemExit("missing executable overlay/usr/bin/bananarchy-bt-le-enable.sh") wrapper = read(WRAPPER) helper = read(HELPER) @@ -63,18 +67,27 @@ def main(): } if "util-linux-misc" not in packages: raise SystemExit("rootfs package set is missing util-linux-misc (script)") + if "bluez-btmgmt" not in packages: + raise SystemExit("rootfs package set is missing bluez-btmgmt (LE enable)") 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"): + "quit", "BANANARCHY_BT_SCAN_SECONDS", + "bananarchy-bt-le-enable.sh"): 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"): + for token in ("usr/local/bin/bluetoothctl", "usr/bin/bananarchy-bt-scan.sh", + "usr/bin/bananarchy-bt-le-enable.sh", + "etc/doas.d/60-bananarchy-bluetooth.conf"): if token not in overlay: raise SystemExit("overlay application is not installing %s" % token) + if not DOAS_RULE.is_file() or "bananarchy-bt-le-enable.sh" not in read(DOAS_RULE): + raise SystemExit("doas rule is missing the LE enable helper") + if "btmgmt -i hci0 le on" not in read(LE_HELPER): + raise SystemExit("LE enable helper lost its btmgmt command") print("[ok] live Bluetooth discovery wiring") with tempfile.TemporaryDirectory(prefix="bananarchy-bt-scan-") as tmp: