Fix Bluetooth KeyboardDisplay pairing agent, MGMT flags, and refresh a1120 images
- Switch bananarchy-bt-obex Agent1 from NoInputNoOutput to KeyboardDisplay with /run/bananarchy/bt-obex/pair_{prompt,decision}.tsv and op_done.tsv IPC, auto-confirming Classic Audio headsets while prompting user confirmation, PIN, passkey, or keyboard display codes.
- Enforce bredr on, ssp on, linksec on, bondable on, advertising off, class 2 3, and le on in bananarchy-bt-le-enable.sh alongside PairableTimeout = 0 in main.conf (keeping DiscoverableTimeout = 60 hidden by default) and boot hook sync in sxmo_hook_start.sh.
- Fix root/user daemon UID collisions and sticky-/tmp status/PID writes, separate phones from Classic Audio headsets, increase Pair timeout to 50 s, and add non-blocking --async-ui pairing/connect plus NetModal::BtPairingPrompt in networks.so.
- Extend scripts/test-bluetooth-obex.py, scripts/test-bluetooth-headset.py, scripts/check-rebuild.sh, docs, and rebuild/pin a1120 (cocojamboo) images and archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler.
This commit is contained in:
1 parent
36a5f8cb8a
commit
1e1fe7c317
17 files changed
+1387
-326
No files matched your search
@@ -44,20 +44,24 @@ Keep this file short. Full details live in `README.md`, `MANUAL.md`, `SDK.md`, `
|
||||
|
||||
## Critical invariants
|
||||
|
||||
- Bluetooth requires `ControllerMode = dual` and `Class = 0x5a020c` (`btmgmt -i hci0 class 2 3`) in `etc/bluetooth/main.conf`
|
||||
and `bananarchy-bt-le-enable.sh`; BlueZ 5.87 rejects LE-only HOGP in `bredr` mode, and `a2dp_source` must stay out
|
||||
of `50-bluetooth.conf` so paired Android phones recognize Object Push rather than an audio sink. Keep `UserspaceHID=true`,
|
||||
`LEAutoSecurity=true`, `ClassicBondedOnly=false`, and `IdleTimeout=0` in `input.conf`. `bananarchy-bt-obex` must power on,
|
||||
enable LE, select the LE bearer (`PreferredBearer = "le"`) for HID-over-GATT devices, select the BR/EDR bearer
|
||||
(`PreferredBearer = "bredr"`, public address preference, `ConnectProfile` fallback) for Classic Audio / dual-mode
|
||||
BT 5.x/6.x headsets, pair unbonded devices, forward `(AVRCP)` media keys to `xmusic`, handle both L2CAP `SOCK_SEQPACKET`
|
||||
and RFCOMM via `ObexPacketReader` with `xnetworks` incoming confirmation / target folder (`~/.config/sxmo/bt_obex_dir`) IPC,
|
||||
and keep discoverability hidden-by-default with a 60 s timeout (`bt_discoverable=0`, never `discoverable-timeout 0`).
|
||||
Keep all four `50-bluetooth.conf` copies synced with `bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]`,
|
||||
`bluez5.enable-msbc = false`, `bluez5.enable-lc3-a127 = false`, `bluez5.dummy-avrcp-player = true`, and
|
||||
`bluez5.a2dp.ldac.quality = "auto"` (no `a2dp_source`, `bap_*`, `hsp_ag`, `hfp_ag`, or `lc3` — WCN3620 SCO routes internally
|
||||
at 8 kHz CVSD to QDSP6 `INTERNAL_BT_SCO_RX`/`TX`). `util-linux-misc` and `bluez-btmgmt` support the live PTY scan wrapper;
|
||||
guard `scripts/test-bluetooth-{hid,scan,live-scan,headset,obex}.py`.
|
||||
- Bluetooth requires `ControllerMode = dual`, `PairableTimeout = 0`, and `Class = 0x5a020c` (`btmgmt -i hci0 class 2 3`,
|
||||
`bredr on`, `ssp on`, `linksec on`, `bondable on`, `advertising off`, `le on`) in `etc/bluetooth/main.conf` and
|
||||
`bananarchy-bt-le-enable.sh`; BlueZ 5.87 rejects LE-only HOGP in `bredr` mode, and `a2dp_source` must stay out of
|
||||
`50-bluetooth.conf` so paired Android phones recognize Object Push rather than an audio sink. Keep `UserspaceHID=true`,
|
||||
`LEAutoSecurity=true`, `ClassicBondedOnly=false`, and `IdleTimeout=0` in `input.conf`. `bananarchy-bt-obex` must register
|
||||
a persistent `"KeyboardDisplay"` `Agent1` (never `"NoInputNoOutput"`) with `/run/bananarchy/bt-obex/pair_{prompt,decision}.tsv`
|
||||
and `xnetworks` `BtPairingPrompt` UI (auto-confirming Classic Audio headsets, prompting user confirmation/PIN/passkey
|
||||
for phones/keyboards, `50 s` `Pair` timeout, `--async-ui` non-blocking operations, phone `is_phone_or_computer_props` vs
|
||||
audio separation), power on, enable LE/SSP, select the LE bearer (`PreferredBearer = "le"`) for HID-over-GATT devices,
|
||||
select the BR/EDR bearer (`PreferredBearer = "bredr"`, public address preference, `ConnectProfile` fallback) for
|
||||
Classic Audio / dual-mode BT 5.x/6.x headsets, pair unbonded devices, forward `(AVRCP)` media keys to `xmusic`,
|
||||
handle both L2CAP `SOCK_SEQPACKET` and RFCOMM via `ObexPacketReader` with `xnetworks` incoming confirmation / target
|
||||
folder (`~/.config/sxmo/bt_obex_dir`) IPC, and keep discoverability hidden-by-default with a 60 s timeout
|
||||
(`bt_discoverable=0`, never `discoverable-timeout 0`). Keep all four `50-bluetooth.conf` copies synced with
|
||||
`bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]`, `bluez5.enable-msbc = false`, `bluez5.enable-lc3-a127 = false`,
|
||||
`bluez5.dummy-avrcp-player = true`, and `bluez5.a2dp.ldac.quality = "auto"` (no `a2dp_source`, `bap_*`, `hsp_ag`,
|
||||
`hfp_ag`, or `lc3` — WCN3620 SCO routes internally at 8 kHz CVSD to QDSP6 `INTERNAL_BT_SCO_RX`/`TX`).
|
||||
`util-linux-misc` and `bluez-btmgmt` support the live PTY scan wrapper; guard `scripts/test-bluetooth-{hid,scan,live-scan,headset,obex}.py`.
|
||||
- WebKit requires explicit `glib` and `gsettings-desktop-schemas` packages. Because apk uses `--no-scripts`,
|
||||
`apply-bananarchy-overlay.sh` must run `compile-gsettings-schemas.sh`; without `gschemas.compiled`, the WebKit network
|
||||
process aborts. Keep the Webarchy renderer fallback.
|
||||
|
||||
+5
-4
@@ -16,6 +16,7 @@ Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeti
|
||||
|
||||
### Bluetooth 5.x/6.x headset support (`A2DP` + `HSP/HFP`), Android OBEX file transfer, AVRCP controls, and power safeguards across all targets
|
||||
|
||||
- **Android SSP/PIN/Passkey pairing agent & NeoUI confirmation popup (`etc/bluetooth/main.conf`, `bananarchy-bt-le-enable.sh`, `sxmo_bluetoothtoggle.sh`, `sxmo_hook_start.sh`, `bananarchy-bt-obex`, `networks_plugin.cpp`)**: switched the persistent `Agent1` capability from dummy `"NoInputNoOutput"` (which replied `"0000"` / `0` with zero prompt and tripped BlueZ/WCNSS `"incorrect PIN or passkey"`) to `"KeyboardDisplay"` backed by `/run/bananarchy/bt-obex/{pair_prompt,pair_decision,op_done}.tsv` IPC and `NetModal::BtPairingPrompt` (`CONFIRM` 6-digit passkey match, keypad `PIN` / `PASSKEY` entry, `DISPLAY` keyboard code, and `Cancel`/`Close` rejection, while auto-confirming screenless Classic Audio headsets); enabled `bredr on`, `ssp on`, `linksec on`, `bondable on`, and `advertising off` alongside `class 2 3` and `le on` in `bananarchy-bt-le-enable.sh` (`PairableTimeout = 0` in `main.conf` while keeping `DiscoverableTimeout = 60` hidden by default); fixed root/`user` daemon UID collisions and sticky-`/tmp` PID/status writes (`errno != EPERM` + `doas -n bananarchy-bt-obex start` + boot hook restart when BT is enabled); made `networks_plugin.cpp` `Connect`/`Pair` non-blocking (`--async-ui`), prevented `cli_agent` hijacking and 8 s `Pair` aborts (`50 s` timeout), and fixed phone `Icon: phone`/`computer` (`OBEX/PAN`) vs Classic Audio classification across `queryBtDevices()` and `is_phone_or_computer_props()`.
|
||||
- **Android OBEX (`0x1105`) recognition, L2CAP `SOCK_SEQPACKET`, and incoming file Accept/Reject + Target Folder UI (`etc/bluetooth/main.conf`, `50-bluetooth.conf`, `bananarchy-bt-le-enable.sh`, `sxmo_bluetoothtoggle.sh`, `bananarchy-bt-obex`, `networks_plugin.cpp`)**: added `Class = 0x5a020c` (`Phone / Smartphone` with `Object Transfer`) in `main.conf`, set `btmgmt -i hci0 class 2 3` at power-on/LE-enable, and removed `a2dp_source` from `50-bluetooth.conf` (`bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]`) so paired Android phones recognize Bananarchy as a phone supporting OBEX Object Push rather than a Bluetooth audio sink; replaced `recv(3)` with `ObexPacketReader` handling full L2CAP `SOCK_SEQPACKET` (GOEP 2.0) datagrams alongside RFCOMM `SOCK_STREAM`; registered BlueZ `OPP_UUID` (`0x1105`) with retries before falling back to raw RFCOMM channel 9 bind; added `/run/bananarchy/bt-obex/{prompt,decision}.tsv` IPC with an interactive `networks.so` prompt (`Accept & Save File`, `Dir: ... [Set]`, `Reject Transfer` returning OBEX `0xC3` Forbidden) and interactive `ObexDirPicker` / `ObexActions` directory chooser (`~/.config/sxmo/bt_obex_dir`, supporting `/media/sdcard`, custom folders, and duress confinement); verified via `scripts/test-bluetooth-obex.py`.
|
||||
- **Dual-bearer BR/EDR audio selection & PipeWire role/codec fixes (`bananarchy-bt-obex`, all four `50-bluetooth.conf` copies)**: kept `ControllerMode = dual` and `PreferredBearer = "le"` for HOGP (`00001812-`) while adding Classic Audio (`0000110b-`/`0000111e-`/`00001108-`/`audio-*`) detection (`set_audio_preferred_bearer()` -> `PreferredBearer = "bredr"`), `public` BR/EDR ranking over `random` BLE beacons in `find_matching_device()`/`scan_for_device()`, and `ConnectProfile` fallback so dual-mode Bluetooth 5.x/6.x earbuds do not stop on a GATT-only BLE link; updated `50-bluetooth.conf` across `/etc/`, `/usr/share/`, `/home/user/`, and `/etc/skel/` to restrict roles to `[ a2dp_sink hsp_hs hfp_hf ]` (removing `a2dp_source`, `bap_sink`/`bap_source`, and `hsp_ag`/`hfp_ag`), disable `msbc` and `lc3-a127`/`lc3` so HFP locks to 8 kHz `cvsd` for QDSP6 `INTERNAL_BT_SCO`, fix `opus_05_dup` -> `opus_05_duplex`, set `bluez5.dummy-avrcp-player = true`, and enable `bluez5.a2dp.ldac.quality = "auto"` (ABR) + `aac.bitratemode = 0` for 2.4 GHz Wi-Fi coexistence.
|
||||
- **SCO keepalive race, missing `pkill` leak, headset `ATA` call pickup, AVRCP media keys, and `nokia-sparkler` haptic guard (`sxmo_audio.sh`, `sxmo_modemaudio.sh`, `callscreen_plugin.cpp`, `networks_plugin.cpp`, `music_plugin.cpp`, `sxmo_vibrate.c`)**: replaced missing `pkill` in `stop_bt_sco_keepalive()` with `/proc` + `ps` teardown and stopped keepalive unconditionally when switching off Bluetooth HFP (even mid-call); added bounded (`25 x 0.1 s` / `15 x 0.1 s`) sink readiness waits and direct `$bt_sink` volume/mute mirroring (`+VGS`/AVRCP); synced `/tmp/sxmo_in_call` and `.pickedupcall` in `callscreen_plugin.cpp` when calls transition active via headset `ATA` so hangup restores A2DP and avoids false Missed Call logs; forwarded BlueZ `(AVRCP)` input keys to `music.so` (`PLAYPAUSE`/`PLAY`/`PAUSE`/`STOP`/`NEXT`/`PREV`) via the 0%-CPU `select()` bridge in `bananarchy-bt-obex` and handled `XF86XK_AudioPlay`/`Pause`/`Stop`/`Next`/`Prev` in `music_plugin.cpp`; refreshed stale `targetBt` after `Pair`/`Connect` in `networks_plugin.cpp` with a 24-device `info` batch cap; added `/tmp/sxmo_bt_sco_mm_active` suppression in `sxmo_vibrate.c` so 157 Hz haptic audio cannot leak over non-call BT SCO on `nokia-sparkler`; and changed `bt_discoverable` defaults across `sxmo_bluetoothtoggle.sh`, `bananarchy-bt-obex`, and `networks_plugin.cpp` to hidden-by-default with a 60 s discoverable timeout. Verified via `scripts/test-bluetooth-headset.py` alongside `test-bluetooth-{hid,scan,live-scan}.py` and `scripts/check-rebuild.sh`.
|
||||
@@ -72,10 +73,10 @@ Upcoming release build (`a1120` / `cocojamboo` via `scripts/version.sh`) targeti
|
||||
### Image persistence and upcoming `a1120` (`cocojamboo`) release archives
|
||||
|
||||
- **Verified `a1120` / `cocojamboo` image set (`--mkinitfs`) and packaged archives**:
|
||||
- `images/bananarchy-nokia-argon.img`: SHA-256 `92b23d34180c157861c492e7c2ea848ea4580857f3c1674020ae6b9f6fbdd39f` (packaged in `bananarchy-nokia-argon-a1120-cocojamboo.zip`, SHA-256 `f3680c940ba95f063822e033c60fc18faa3fd20faab4dcec558445d6d1d828f0`, alongside `bootloader/lk2nd-msm8909.img`).
|
||||
- `images/bananarchy-nokia-beatles.img`: SHA-256 `5c284c314a378d09fda37e56ebe745ab557d45c77499206440e8c362c709e7a7`, `images/boot-bananarchy-nokia-beatles.img`: SHA-256 `80485ccf2af4f1d6107965ecde43d888c66ec19006e6feabc7fb63b6a7852391`, and `images/boot-lk2nd-nokia-beatles-display.img`: SHA-256 `b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d` (packaged in `bananarchy-nokia-beatles-a1120-cocojamboo.zip`, SHA-256 `1d2849c73dcf3d0bf8d0e2417778366bd726442556567ab9180e314951a5b993`).
|
||||
- `images/bananarchy-nokia-coconut.img`: SHA-256 `4e1d4799d42f56423f9cba8e175adf3b1f6c7fcd89965a7bc0b84a4f03ebc6e5`, `images/boot-bananarchy-nokia-coconut.img`: SHA-256 `1e22879fc0533f419dc98c88a1700d75101fda85669837d1457bb15b9ab4ed9c`, and `images/boot-lk2nd-nokia-coconut-display.img`: SHA-256 `e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a` (packaged in `bananarchy-nokia-coconut-a1120-cocojamboo.zip`, SHA-256 `af06ab7bbb3933732f644d24acb03d04ef066d59aae0c2009d0c9cf367bec4d1`).
|
||||
- `images/bananarchy-nokia-sparkler.img`: SHA-256 `6b40db4674821bdde80d6f7619acc5a6414df684201d3e4e2e7cc3ac6c25dcfd`, `images/boot-bananarchy-nokia-sparkler.img`: SHA-256 `8f41328f0197f5debba92eaffa9df46c530721719309024a4d9cd7bf79a722c7`, and `images/boot-lk2nd-nokia-sparkler-display.img`: SHA-256 `bc41c2ddd1079246a7e91a40222fcafb82b0b52965c8ee8081872767d006748f` (packaged in `bananarchy-nokia-sparkler-a1120-cocojamboo.zip`, SHA-256 `0ca08f7a58e517fce283028548ba6d7657c419e823782fe188c75b0fbd93d378`).
|
||||
- `images/bananarchy-nokia-argon.img`: SHA-256 `09c46d21b140b486e21ebed39740b57808f8f1f0045f1801af2a7f8eba72bb4d` (packaged in `bananarchy-nokia-argon-a1120-cocojamboo.zip`, SHA-256 `5a290c236aa85828fb0b8a9bf6e2a7afa8ebe10c9d2819617661e8c0cb53d3ff`, alongside `bootloader/lk2nd-msm8909.img`).
|
||||
- `images/bananarchy-nokia-beatles.img`: SHA-256 `5d8c50f89e257dbadd9050479d56c46b1902cb38707f6f692e3508b44aa4fd10`, `images/boot-bananarchy-nokia-beatles.img`: SHA-256 `f6c897f8e5fac17df38ac3d3222279f229b84c53ea73c323d06de5c40b26ccc0`, and `images/boot-lk2nd-nokia-beatles-display.img`: SHA-256 `b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d` (packaged in `bananarchy-nokia-beatles-a1120-cocojamboo.zip`, SHA-256 `a49d0d905af1ea5350bc1197e7970f59296359a913e3a09afc46c06aaf80d891`).
|
||||
- `images/bananarchy-nokia-coconut.img`: SHA-256 `836331fb3034d0527f8c03eb90aae25bc8c87a84cc56baf24459d2e81e7a28d1`, `images/boot-bananarchy-nokia-coconut.img`: SHA-256 `6e2fefec812594dc7b4dc322c68b1ab4c10b1c93abee4a0fbd11dfbf2dc59a0b`, and `images/boot-lk2nd-nokia-coconut-display.img`: SHA-256 `e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a` (packaged in `bananarchy-nokia-coconut-a1120-cocojamboo.zip`, SHA-256 `68af7997cbe1227d49e5238cabbbfcb44dcb728e8456b0fd0d416477307074b2`).
|
||||
- `images/bananarchy-nokia-sparkler.img`: SHA-256 `61a068ca432f064812a96356b0dc49f1a38102a717c8dccd31768f0cbd1d7639`, `images/boot-bananarchy-nokia-sparkler.img`: SHA-256 `4357d48ac069104495629f1f35e220a01cde3412950e73e3e47e5372649fb6a2`, and `images/boot-lk2nd-nokia-sparkler-display.img`: SHA-256 `bc41c2ddd1079246a7e91a40222fcafb82b0b52965c8ee8081872767d006748f` (packaged in `bananarchy-nokia-sparkler-a1120-cocojamboo.zip`, SHA-256 `73951ce01b3ff8f782488333767101d8e83701ae3822b1c7a0bef6ab8e96d1dc`).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -220,7 +220,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** (`OFF (Hidden)` by default to avoid continuous Inquiry Scan standby draw, or `ON (Visible for 60s)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), configure the **OBEX File Receiver** (`OBEX Dir: <folder> [Set]`, opening actions to **Set Target Directory...** via an interactive folder picker including `/media/sdcard`, **Open Folder in Files**, or **Reset to ~/Downloads**, persisted in `~/.config/sxmo/bt_obex_dir`; `#` quick-opens the folder in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. Incoming OBEX file pushes (over both L2CAP `SOCK_SEQPACKET` and RFCOMM, with Smartphone Class of Device `0x5a020c` and no `a2dp_source` role so paired Android phones recognize OPP rather than a headset) pop up an interactive confirmation dialog showing sender, filename, size, **Accept & Save File**, **Dir: ... [Set]** to pick a different destination folder on the spot, and **Reject Transfer**. 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 <MAC> <Name>` 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. BlueZ keeps `ControllerMode = dual`: `bredr` mode rejects the LE-only HOGP profile, so BLE HID devices would connect at the GATT level but never create a keyboard or mouse input node. **Connect Device** and **Pair & Trust Device** power the adapter on, enable LE, select the `le` bearer for HID-over-GATT devices, prefer public BR/EDR entries and the `bredr` bearer (`ConnectProfile` A2DP/HFP fallback) for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets, and automatically pair unpaired peripherals. 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`, `sbc_xq`, `aac`, `ldac` ABR `auto`, `aptx`, `aptx_hd`) with AVRCP hardware volume and Play/Pause/Next/Prev headset button control of `xmusic`, and **HSP/HFP** (`CVSD` 8 kHz over QDSP6 `INTERNAL_BT_SCO`, with `mSBC`/`LC3-A127`/`LC3` and unsupported LE Audio BAP roles disabled, plus headset `ATA` call answer/A2DP restore synchronization), **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** (`OFF (Hidden)` by default to avoid continuous Inquiry Scan standby draw, or `ON (Visible for 60s)`, persisted in `~/.config/sxmo/bt_discoverable`), edit the **Bluetooth Device Name** (`Name: <Alias> [Edit]`, persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname), configure the **OBEX File Receiver** (`OBEX Dir: <folder> [Set]`, opening actions to **Set Target Directory...** via an interactive folder picker including `/media/sdcard`, **Open Folder in Files**, or **Reset to ~/Downloads**, persisted in `~/.config/sxmo/bt_obex_dir`; `#` quick-opens the folder in `xfiles`), scan nearby devices (`*` or `Scan`, 15-second discovery scan), and manage paired/discovered devices. Pairing runs via a persistent `KeyboardDisplay` `Agent1` in `/usr/bin/bananarchy-bt-obex` (with `ssp on`, `bondable on`, `linksec on`, `advertising off`, Smartphone class `2 3`, and `PairableTimeout = 0`), popping up an interactive pairing dialog in `xnetworks` for 6-digit passkey confirmation (`Accept & Pair` / `Reject Pairing`), keypad PIN/passkey entry, or outgoing keyboard pairing codes (while auto-confirming screenless Classic Audio headsets). Incoming OBEX file pushes (over both L2CAP `SOCK_SEQPACKET` and RFCOMM, with Smartphone Class of Device `0x5a020c` and no `a2dp_source` role so paired Android phones recognize OPP rather than a headset) pop up an interactive confirmation dialog showing sender, filename, size, **Accept & Save File**, **Dir: ... [Set]** to pick a different destination folder on the spot, and **Reject Transfer**. 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 <MAC> <Name>` 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` alongside BR/EDR SSP/bondable flags before discovery because this WCNSS controller otherwise starts with LE and pairing flags unconfigured. BlueZ keeps `ControllerMode = dual`: `bredr` mode rejects the LE-only HOGP profile, so BLE HID devices would connect at the GATT level but never create a keyboard or mouse input node. **Connect Device** and **Pair & Trust Device** run non-blockingly (`--async-ui`), power the adapter on, enable LE/SSP, select the `le` bearer for HID-over-GATT devices, prefer public BR/EDR entries and the `bredr` bearer (`ConnectProfile` A2DP/HFP fallback) for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets or `OBEX/PAN` phones, and automatically pair unpaired peripherals. 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`, `sbc_xq`, `aac`, `ldac` ABR `auto`, `aptx`, `aptx_hd`) with AVRCP hardware volume and Play/Pause/Next/Prev headset button control of `xmusic`, and **HSP/HFP** (`CVSD` 8 kHz over QDSP6 `INTERNAL_BT_SCO`, with `mSBC`/`LC3-A127`/`LC3` and unsupported LE Audio BAP roles disabled, plus headset `ATA` call answer/A2DP restore synchronization), **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]`.
|
||||
|
||||
@@ -41,7 +41,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_<caller>.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 reception (advertising Smartphone CoD `0x5a020c` without `a2dp_source` headset spoofing, supporting both L2CAP `SOCK_SEQPACKET` GOEP 2.0 and RFCOMM, presenting an incoming Accept/Reject and folder-selection modal in `xnetworks` alongside configurable persistent target folder in `~/.config/sxmo/bt_obex_dir`) 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` (and sets Smartphone controller class `2 3`) before each scan because the WCNSS controller otherwise powers up with LE disabled and only performs BR/EDR inquiry. BlueZ runs in `dual` controller mode because `bredr` mode rejects the LE-only HOGP profile, leaving BLE keyboards and mice connected but without a usable input node. Pair/connect actions power the adapter on, enable LE, force the LE bearer for HID-over-GATT devices, prefer public BR/EDR bearers and A2DP/HFP `ConnectProfile` fallback for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets, keep controller visibility hidden by default with a 60 s discoverable timeout to save standby battery, and pair unbonded peripherals before connecting. WirePlumber restricts headset roles to `a2dp_sink hsp_hs hfp_hf`, locks HFP to 8 kHz `cvsd` (disabling `msbc` and `lc3-a127`/`lc3` to match QDSP6 `INTERNAL_BT_SCO`), enables LDAC ABR (`quality = "auto"`) and `dummy-avrcp-player` for hardware volume, and forwards headset AVRCP media keys through `bananarchy-bt-obex` to `xmusic`.
|
||||
- **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 reception (advertising Smartphone CoD `0x5a020c` without `a2dp_source` headset spoofing, supporting both L2CAP `SOCK_SEQPACKET` GOEP 2.0 and RFCOMM, presenting an incoming Accept/Reject and folder-selection modal in `xnetworks` alongside configurable persistent target folder in `~/.config/sxmo/bt_obex_dir`) 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` along with `bredr on`, `ssp on`, `linksec on`, `bondable on`, `advertising off`, and Smartphone controller class `2 3` so WCNSS pairs with Android phones and LE/Classic peripherals reliably (`PairableTimeout = 0`, while `DiscoverableTimeout = 60` stays off by default). BlueZ runs in `dual` controller mode because `bredr` mode rejects the LE-only HOGP profile, and `bananarchy-bt-obex` registers a persistent `KeyboardDisplay` `Agent1` that pops up interactive NeoUI pairing passkey confirmation, PIN/passkey keypad entry, and keyboard display codes inside `xnetworks` (while auto-confirming screenless Classic Audio headsets). Pair/connect actions run asynchronously (`--async-ui`), power the adapter on, enable LE/SSP, force the LE bearer for HID-over-GATT devices, prefer public BR/EDR bearers and A2DP/HFP `ConnectProfile` fallback for Classic Audio / dual-mode Bluetooth 5.x/6.x headsets, keep controller visibility hidden by default with a 60 s discoverable timeout to save standby battery, and pair unbonded peripherals before connecting. WirePlumber restricts headset roles to `a2dp_sink hsp_hs hfp_hf`, locks HFP to 8 kHz `cvsd` (disabling `msbc` and `lc3-a127`/`lc3` to match QDSP6 `INTERNAL_BT_SCO`), enables LDAC ABR (`quality = "auto"`) and `dummy-avrcp-player` for hardware volume, and forwards headset AVRCP media keys through `bananarchy-bt-obex` to `xmusic`.
|
||||
- **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`, `xquagr`, `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.<domain>`) 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/<codec>]` / `[SIP/<codec>:<sas>]`), 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.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# U5: BT is off by default (rfkill soft-block, daemon not started). When a
|
||||
# user enables it, do not leave the controller permanently discoverable.
|
||||
DiscoverableTimeout = 60
|
||||
PairableTimeout = 60
|
||||
PairableTimeout = 0
|
||||
ControllerMode = dual
|
||||
Class = 0x5a020c
|
||||
MultiProfile = multiple
|
||||
|
||||
@@ -145,5 +145,8 @@ superctl start sxmo_notificationmonitor
|
||||
(
|
||||
sxmo_hook_apps.sh >/dev/null 2>&1 || true
|
||||
sxmo_hook_scripts.sh >/dev/null 2>&1 || true
|
||||
if [ "$(/usr/bin/sxmo_bluetoothtoggle.sh status 2>/dev/null)" = "on" ]; then
|
||||
SXMO_OS=alpine doas -n /usr/bin/sxmo_bluetoothtoggle.sh on >/dev/null 2>&1 || true
|
||||
fi
|
||||
) &
|
||||
)
|
||||
@@ -144,5 +144,8 @@ superctl start sxmo_notificationmonitor
|
||||
(
|
||||
sxmo_hook_apps.sh >/dev/null 2>&1 || true
|
||||
sxmo_hook_scripts.sh >/dev/null 2>&1 || true
|
||||
if [ "$(/usr/bin/sxmo_bluetoothtoggle.sh status 2>/dev/null)" = "on" ]; then
|
||||
SXMO_OS=alpine doas -n /usr/bin/sxmo_bluetoothtoggle.sh on >/dev/null 2>&1 || true
|
||||
fi
|
||||
) &
|
||||
)
|
||||
@@ -1,12 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Enable the WCNSS controller's LE setting before BlueZ discovery.
|
||||
# The kernel management socket requires root for this write.
|
||||
# Enable BR/EDR + SSP + bondable + link security + Smartphone CoD + LE Central
|
||||
# (disable LE peripheral advertising so phones pair via BR/EDR SSP, not CTKD).
|
||||
set -eu
|
||||
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
echo "Error: bananarchy-bt-le-enable.sh must run as root" >&2
|
||||
echo "bananarchy-bt-le-enable.sh must run as root" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/usr/bin/btmgmt -i hci0 bredr on >/dev/null 2>&1 || true
|
||||
/usr/bin/btmgmt -i hci0 ssp on >/dev/null 2>&1 || true
|
||||
/usr/bin/btmgmt -i hci0 linksec on >/dev/null 2>&1 || true
|
||||
/usr/bin/btmgmt -i hci0 bondable on >/dev/null 2>&1 || true
|
||||
/usr/bin/btmgmt -i hci0 advertising off >/dev/null 2>&1 || true
|
||||
/usr/bin/btmgmt -i hci0 class 2 3 >/dev/null 2>&1 || true
|
||||
exec /usr/bin/btmgmt -i hci0 le on
|
||||
File diff suppressed because it is too large.
Load diff
@@ -25,8 +25,10 @@ on() {
|
||||
if [ -s /etc/bananarchy/bt_mac ] && [ -x /usr/bin/bananarchy-engmenu-ctl ]; then
|
||||
/usr/bin/bananarchy-engmenu-ctl apply-boot >/dev/null 2>&1 || true
|
||||
fi
|
||||
/usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true
|
||||
timeout 2 /usr/bin/btmgmt -i hci0 class 2 3 >/dev/null 2>&1 || true
|
||||
timeout 2 bluetoothctl power on >/dev/null 2>&1 || true
|
||||
/usr/bin/bananarchy-bt-le-enable.sh >/dev/null 2>&1 || true
|
||||
timeout 2 /usr/bin/btmgmt -i hci0 class 2 3 >/dev/null 2>&1 || true
|
||||
|
||||
bt_name=""
|
||||
@@ -44,10 +46,11 @@ on() {
|
||||
if [ -r /home/user/.config/sxmo/bt_discoverable ]; then
|
||||
IFS= read -r bt_disc < /home/user/.config/sxmo/bt_discoverable 2>/dev/null || true
|
||||
fi
|
||||
timeout 2 bluetoothctl pairable-timeout 0 >/dev/null 2>&1 || true
|
||||
timeout 2 bluetoothctl pairable on >/dev/null 2>&1 || true
|
||||
timeout 2 bluetoothctl discoverable-timeout 60 >/dev/null 2>&1 || true
|
||||
case "$bt_disc" in
|
||||
1|on|ON|yes|YES|true|TRUE)
|
||||
timeout 2 bluetoothctl pairable on >/dev/null 2>&1 || true
|
||||
timeout 2 bluetoothctl discoverable on >/dev/null 2>&1 || true
|
||||
;;
|
||||
*)
|
||||
@@ -55,7 +58,7 @@ on() {
|
||||
;;
|
||||
esac
|
||||
|
||||
/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1 &
|
||||
/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
off() {
|
||||
|
||||
Binary file not shown.
@@ -153,5 +153,8 @@ superctl start sxmo_notificationmonitor
|
||||
(
|
||||
sxmo_hook_apps.sh >/dev/null 2>&1 || true
|
||||
sxmo_hook_scripts.sh >/dev/null 2>&1 || true
|
||||
if [ "$(/usr/bin/sxmo_bluetoothtoggle.sh status 2>/dev/null)" = "on" ]; then
|
||||
SXMO_OS=alpine doas -n /usr/bin/sxmo_bluetoothtoggle.sh on >/dev/null 2>&1 || true
|
||||
fi
|
||||
) &
|
||||
)
|
||||
Binary file not shown.
@@ -557,15 +557,15 @@ fi
|
||||
|
||||
echo "[check] Known-good flashable image set..."
|
||||
for pair in \
|
||||
"92b23d34180c157861c492e7c2ea848ea4580857f3c1674020ae6b9f6fbdd39f images/bananarchy-nokia-argon.img" \
|
||||
"5c284c314a378d09fda37e56ebe745ab557d45c77499206440e8c362c709e7a7 images/bananarchy-nokia-beatles.img" \
|
||||
"80485ccf2af4f1d6107965ecde43d888c66ec19006e6feabc7fb63b6a7852391 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"09c46d21b140b486e21ebed39740b57808f8f1f0045f1801af2a7f8eba72bb4d images/bananarchy-nokia-argon.img" \
|
||||
"5d8c50f89e257dbadd9050479d56c46b1902cb38707f6f692e3508b44aa4fd10 images/bananarchy-nokia-beatles.img" \
|
||||
"f6c897f8e5fac17df38ac3d3222279f229b84c53ea73c323d06de5c40b26ccc0 images/boot-bananarchy-nokia-beatles.img" \
|
||||
"b5549698c20f4de7603fc746d32bb5baa96ec377e41e74407823c98506fc185d images/boot-lk2nd-nokia-beatles-display.img" \
|
||||
"4e1d4799d42f56423f9cba8e175adf3b1f6c7fcd89965a7bc0b84a4f03ebc6e5 images/bananarchy-nokia-coconut.img" \
|
||||
"1e22879fc0533f419dc98c88a1700d75101fda85669837d1457bb15b9ab4ed9c images/boot-bananarchy-nokia-coconut.img" \
|
||||
"836331fb3034d0527f8c03eb90aae25bc8c87a84cc56baf24459d2e81e7a28d1 images/bananarchy-nokia-coconut.img" \
|
||||
"6e2fefec812594dc7b4dc322c68b1ab4c10b1c93abee4a0fbd11dfbf2dc59a0b images/boot-bananarchy-nokia-coconut.img" \
|
||||
"e876424b38b0782f589756b4107337b24f27f7c37d624cc7d3907a5331df050a images/boot-lk2nd-nokia-coconut-display.img" \
|
||||
"6b40db4674821bdde80d6f7619acc5a6414df684201d3e4e2e7cc3ac6c25dcfd images/bananarchy-nokia-sparkler.img" \
|
||||
"8f41328f0197f5debba92eaffa9df46c530721719309024a4d9cd7bf79a722c7 images/boot-bananarchy-nokia-sparkler.img" \
|
||||
"61a068ca432f064812a96356b0dc49f1a38102a717c8dccd31768f0cbd1d7639 images/bananarchy-nokia-sparkler.img" \
|
||||
"4357d48ac069104495629f1f35e220a01cde3412950e73e3e47e5372649fb6a2 images/boot-bananarchy-nokia-sparkler.img" \
|
||||
"bc41c2ddd1079246a7e91a40222fcafb82b0b52965c8ee8081872767d006748f images/boot-lk2nd-nokia-sparkler-display.img"; do
|
||||
set -- $pair
|
||||
want=$1
|
||||
@@ -2043,11 +2043,19 @@ if ! "$BT_HEADSET_TEST" >/dev/null 2>&1; then
|
||||
fail "host Bluetooth headset verification failed"
|
||||
fi
|
||||
|
||||
echo "[check] Bluetooth OBEX phone CoD, L2CAP SEQPACKET, and confirmation dialog..."
|
||||
echo "[check] Bluetooth OBEX phone CoD, L2CAP SEQPACKET, pairing agent, and confirmation dialog..."
|
||||
BT_OBEX_TEST="$BASE_DIR/scripts/test-bluetooth-obex.py"
|
||||
if [ ! -x "$BT_OBEX_TEST" ]; then
|
||||
fail "missing host unit test scripts/test-bluetooth-obex.py"
|
||||
fi
|
||||
if ! grep -qF 'Class = 0x5a020c' "$BT_MAIN_CONF" || \
|
||||
! grep -qF 'PairableTimeout = 0' "$BT_MAIN_CONF" || \
|
||||
! grep -qF 'btmgmt -i hci0 ssp on' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-bt-le-enable.sh" || \
|
||||
! grep -qF '"KeyboardDisplay"' "$BT_OBEX" || \
|
||||
! grep -qF 'PAIR_PROMPT' "$BASE_DIR/src/dwm-plugins/networks_plugin.cpp" || \
|
||||
! grep -qF 'BtPairingPrompt' "$BASE_DIR/src/dwm-plugins/networks_plugin.cpp"; then
|
||||
fail "Bluetooth OBEX or KeyboardDisplay pairing dialog configuration is missing"
|
||||
fi
|
||||
if ! "$BT_OBEX_TEST" >/dev/null 2>&1; then
|
||||
fail "host Bluetooth OBEX verification failed"
|
||||
fi
|
||||
|
||||
@@ -60,6 +60,7 @@ def load_obex_pure_helpers():
|
||||
tree = ast.parse(src, filename=str(BT_OBEX))
|
||||
wanted_assigns = {"CLASSIC_AUDIO_UUID_PREFIXES"}
|
||||
wanted_defs = {
|
||||
"is_phone_or_computer_props",
|
||||
"is_hog_device_props",
|
||||
"is_classic_audio_props",
|
||||
"avrcp_fifo_command_for_key",
|
||||
@@ -107,6 +108,7 @@ def test_wireplumber_config():
|
||||
|
||||
def test_obex_bearer_and_avrcp():
|
||||
ns = load_obex_pure_helpers()
|
||||
is_phone = ns["is_phone_or_computer_props"]
|
||||
is_hog = ns["is_hog_device_props"]
|
||||
is_audio = ns["is_classic_audio_props"]
|
||||
map_avrcp = ns["avrcp_fifo_command_for_key"]
|
||||
@@ -122,11 +124,23 @@ def test_obex_bearer_and_avrcp():
|
||||
"Icon": "audio-headset",
|
||||
"Class": 0x240404,
|
||||
}
|
||||
android_phone = {
|
||||
"AddressType": "public",
|
||||
"Icon": "phone",
|
||||
"Class": 0x5a020c,
|
||||
"UUIDs": [
|
||||
"00001105-0000-1000-8000-00805f9b34fb",
|
||||
"0000110a-0000-1000-8000-00805f9b34fb",
|
||||
"0000111f-0000-1000-8000-00805f9b34fb",
|
||||
],
|
||||
}
|
||||
ble_beacon = {"AddressType": "random", "UUIDs": ["00001800-0000-1000-8000-00805f9b34fb"]}
|
||||
cod_only_speaker = {"Class": 0x200414}
|
||||
|
||||
require(is_hog(hog_kbd) and not is_audio(hog_kbd),
|
||||
"HOGP keyboard misclassified as Classic Audio")
|
||||
require(is_phone(android_phone) and not is_audio(android_phone),
|
||||
"Android phone with Audio Source/HFP-AG UUIDs misclassified as Classic Audio")
|
||||
require(is_audio(bt5_dual_buds) and not is_hog(bt5_dual_buds),
|
||||
"Dual-mode BT 5.x/6.x headset not recognized for BR/EDR bearer selection")
|
||||
require(is_audio({"Icon": "audio-headphones"}),
|
||||
@@ -163,14 +177,17 @@ def test_discoverability_and_power():
|
||||
obex_src = read(BT_OBEX)
|
||||
toggle_src = read(BT_TOGGLE)
|
||||
net_src = read(NETWORKS_CPP)
|
||||
main_src = read(BASE / "overlay/rootfs/etc/bluetooth/main.conf")
|
||||
|
||||
require('DiscoverableTimeout = 60' in main_src and 'PairableTimeout = 0' in main_src,
|
||||
"main.conf must enforce DiscoverableTimeout = 60 and PairableTimeout = 0")
|
||||
require('discoverable-timeout 0' not in toggle_src,
|
||||
"sxmo_bluetoothtoggle.sh still sets infinite discoverable-timeout 0")
|
||||
require('discoverable-timeout 60' in toggle_src and 'bt_disc="0"' in toggle_src,
|
||||
"sxmo_bluetoothtoggle.sh must default bt_disc=0 and timeout=60")
|
||||
require('"discoverable-timeout", "0"' not in obex_src and
|
||||
'("org.bluez.Adapter1", "PairableTimeout", ("u", 0))' not in obex_src,
|
||||
"bananarchy-bt-obex still forces infinite discoverable/pairable timeout 0")
|
||||
'("org.bluez.Adapter1", "PairableTimeout", ("u", 0))' in obex_src,
|
||||
"bananarchy-bt-obex must bound discoverable-timeout to 60 and keep PairableTimeout=0")
|
||||
require('"discoverable-timeout", "60"' in obex_src and 'bt_disc = "0"' in obex_src,
|
||||
"bananarchy-bt-obex must default bt_disc='0' and timeout=60")
|
||||
require("discoverable-timeout 0" not in net_src and
|
||||
|
||||
@@ -52,16 +52,24 @@ def load_obex_module():
|
||||
|
||||
def test_class_and_roles():
|
||||
main_conf = read(MAIN_CONF)
|
||||
le_src = read(LE_HELPER)
|
||||
toggle_src = read(BT_TOGGLE)
|
||||
require("ControllerMode = dual" in main_conf, "main.conf must keep ControllerMode = dual")
|
||||
require("Class = 0x5a020c" in main_conf, "main.conf missing Smartphone Class = 0x5a020c")
|
||||
require("btmgmt -i hci0 class 2 3" in read(LE_HELPER),
|
||||
"bananarchy-bt-le-enable.sh missing btmgmt class 2 3")
|
||||
require("btmgmt -i hci0 class 2 3" in read(BT_TOGGLE),
|
||||
require("PairableTimeout = 0" in main_conf, "main.conf must keep PairableTimeout = 0")
|
||||
for cmd in ("btmgmt -i hci0 bredr on", "btmgmt -i hci0 ssp on",
|
||||
"btmgmt -i hci0 linksec on", "btmgmt -i hci0 bondable on",
|
||||
"btmgmt -i hci0 advertising off", "btmgmt -i hci0 class 2 3",
|
||||
"btmgmt -i hci0 le on"):
|
||||
require(cmd in le_src, f"bananarchy-bt-le-enable.sh missing {cmd}")
|
||||
require("btmgmt -i hci0 class 2 3" in toggle_src,
|
||||
"sxmo_bluetoothtoggle.sh missing btmgmt class 2 3")
|
||||
require("pairable-timeout 0" in toggle_src and "pairable on" in toggle_src,
|
||||
"sxmo_bluetoothtoggle.sh must keep pairable on with timeout 0")
|
||||
wp = read(WP_CONF)
|
||||
require("a2dp_source" not in wp and "bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]" in wp,
|
||||
"50-bluetooth.conf must omit a2dp_source so phones do not treat us as an audio sink")
|
||||
print("[ok] Smartphone Class-of-Device and Phone/OPP SDP profile role gate")
|
||||
print("[ok] Smartphone Class-of-Device, MGMT SSP/bondable flags, and OPP role gate")
|
||||
|
||||
|
||||
def build_obex_put_headers(filename, total_len):
|
||||
@@ -243,24 +251,243 @@ def test_accept_and_reject_sessions(mod):
|
||||
print("[ok] Incoming OBEX Accept/Reject & custom target directory loopback sessions")
|
||||
|
||||
|
||||
def _ensure_jeepney_available():
|
||||
try:
|
||||
import jeepney # noqa: F401
|
||||
return None
|
||||
except ImportError:
|
||||
jmod = types.ModuleType("jeepney")
|
||||
|
||||
class MessageType:
|
||||
method_call = 1
|
||||
method_return = 2
|
||||
error = 3
|
||||
signal = 4
|
||||
|
||||
class Header:
|
||||
def __init__(self, mtype, fields=None, serial=1):
|
||||
self.message_type = mtype
|
||||
self.fields = dict(fields or {})
|
||||
self.serial = serial
|
||||
|
||||
class Message:
|
||||
def __init__(self, header, body=()):
|
||||
self.header = header
|
||||
self.body = body
|
||||
|
||||
class DBusAddress:
|
||||
def __init__(self, object_path, bus_name=None, interface=None):
|
||||
self.object_path = object_path
|
||||
self.bus_name = bus_name
|
||||
self.interface = interface
|
||||
|
||||
def new_method_call(addr, member, signature=None, body=()):
|
||||
fields = {1: addr.object_path, 2: addr.interface, 3: member}
|
||||
return Message(Header(MessageType.method_call, fields), body)
|
||||
|
||||
def new_method_return(parent_msg, signature=None, body=()):
|
||||
fields = {5: parent_msg.header.serial}
|
||||
if signature is not None:
|
||||
fields[8] = signature
|
||||
return Message(Header(MessageType.method_return, fields), body)
|
||||
|
||||
def new_error(parent_msg, error_name, signature=None, body=()):
|
||||
fields = {4: error_name, 5: parent_msg.header.serial}
|
||||
if signature is not None:
|
||||
fields[8] = signature
|
||||
return Message(Header(MessageType.error, fields), body)
|
||||
|
||||
jmod.MessageType = MessageType
|
||||
jmod.Header = Header
|
||||
jmod.Message = Message
|
||||
jmod.DBusAddress = DBusAddress
|
||||
jmod.new_method_call = new_method_call
|
||||
jmod.new_method_return = new_method_return
|
||||
jmod.new_error = new_error
|
||||
sys.modules["jeepney"] = jmod
|
||||
return jmod
|
||||
|
||||
|
||||
def _make_agent_call(member, dev_path, extra_args=(), serial=77):
|
||||
from jeepney import MessageType
|
||||
try:
|
||||
from jeepney.low_level import Header, Message
|
||||
hdr = Header(MessageType.method_call)
|
||||
hdr.serial = serial
|
||||
hdr.fields = {1: "/org/bananarchy/bt_agent", 3: member}
|
||||
return Message(hdr, (dev_path,) + extra_args)
|
||||
except ImportError:
|
||||
import jeepney
|
||||
return jeepney.Message(
|
||||
jeepney.Header(MessageType.method_call, {1: "/org/bananarchy/bt_agent", 3: member}, serial=serial),
|
||||
(dev_path,) + extra_args,
|
||||
)
|
||||
|
||||
|
||||
def test_keyboard_display_agent(mod):
|
||||
injected = _ensure_jeepney_available()
|
||||
from jeepney import MessageType
|
||||
old_no_ui = os.environ.get("BANANARCHY_OBEX_NO_UI")
|
||||
os.environ["BANANARCHY_OBEX_NO_UI"] = "1"
|
||||
orig_vals = (
|
||||
mod.OBEX_IPC_DIR,
|
||||
mod.PAIR_PROMPT_FILE,
|
||||
mod.PAIR_DECISION_FILE,
|
||||
)
|
||||
|
||||
class RecordingConn:
|
||||
def __init__(self):
|
||||
self.sent = []
|
||||
self.ev = threading.Event()
|
||||
|
||||
def send(self, msg, serial=None):
|
||||
self.sent.append(msg)
|
||||
self.ev.set()
|
||||
|
||||
def wait_sent(rc, min_count, timeout=3.0):
|
||||
deadline = time.monotonic() + timeout
|
||||
while len(rc.sent) < min_count and time.monotonic() < deadline:
|
||||
rc.ev.clear()
|
||||
rc.ev.wait(0.05)
|
||||
require(len(rc.sent) >= min_count, f"expected >= {min_count} sent replies, got {len(rc.sent)}")
|
||||
|
||||
def wait_prompt(p_path, timeout=3.0):
|
||||
deadline = time.monotonic() + timeout
|
||||
while not p_path.exists() and time.monotonic() < deadline:
|
||||
time.sleep(0.02)
|
||||
require(p_path.exists(), "pair_prompt.tsv was never created")
|
||||
return p_path.read_text(encoding="utf-8").strip().split("\t")
|
||||
|
||||
try:
|
||||
with tempfile.TemporaryDirectory(prefix="bananarchy-pair-test-") as tmp:
|
||||
root = pathlib.Path(tmp)
|
||||
ipc = root / "ipc"
|
||||
ipc.mkdir()
|
||||
mod.OBEX_IPC_DIR = str(ipc)
|
||||
mod.PAIR_PROMPT_FILE = str(ipc / "pair_prompt.tsv")
|
||||
mod.PAIR_DECISION_FILE = str(ipc / "pair_decision.tsv")
|
||||
p_file = pathlib.Path(mod.PAIR_PROMPT_FILE)
|
||||
d_file = pathlib.Path(mod.PAIR_DECISION_FILE)
|
||||
agent_path = "/org/bananarchy/bt_agent"
|
||||
phone_path = "/org/bluez/hci0/dev_11_22_33_44_55_66"
|
||||
buds_path = "/org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF"
|
||||
cache = {
|
||||
phone_path: {"Name": "Android Pixel", "Icon": "phone", "Class": 0x5a020c,
|
||||
"UUIDs": ["00001105-0000-1000-8000-00805f9b34fb"]},
|
||||
buds_path: {"Name": "Test Buds", "Icon": "audio-headset", "Class": 0x240404,
|
||||
"UUIDs": ["0000110b-0000-1000-8000-00805f9b34fb"]},
|
||||
}
|
||||
|
||||
# 1. RequestConfirmation for phone -> prompt & accept
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("RequestConfirmation", phone_path, (42719,), serial=10)
|
||||
require(mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache),
|
||||
"RequestConfirmation not handled")
|
||||
cols = wait_prompt(p_file)
|
||||
require(cols[1] == "CONFIRM" and cols[2] == "Android Pixel" and cols[4] == "042719",
|
||||
f"unexpected CONFIRM prompt: {cols}")
|
||||
d_file.write_text(f"{cols[0]}\tACCEPT\t\n", encoding="utf-8")
|
||||
wait_sent(rc, 2)
|
||||
require(rc.sent[0].header.message_type == MessageType.method_return,
|
||||
"accepted RequestConfirmation must reply method_return")
|
||||
require("Trusted" in str(rc.sent[1].body), "accepted phone must be trusted")
|
||||
|
||||
# 2. RequestConfirmation for phone -> reject
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("RequestConfirmation", phone_path, (991100,), serial=11)
|
||||
mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache)
|
||||
cols = wait_prompt(p_file)
|
||||
d_file.write_text(f"{cols[0]}\tREJECT\t\n", encoding="utf-8")
|
||||
wait_sent(rc, 1)
|
||||
require(rc.sent[0].header.message_type == MessageType.error and
|
||||
"Rejected" in str(rc.sent[0].header.fields),
|
||||
"rejected RequestConfirmation must return org.bluez.Error.Rejected")
|
||||
|
||||
# 3. RequestConfirmation for Classic Audio headset -> auto-confirm with no prompt
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("RequestConfirmation", buds_path, (0,), serial=12)
|
||||
mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache)
|
||||
wait_sent(rc, 2)
|
||||
require(not p_file.exists() and rc.sent[0].header.message_type == MessageType.method_return,
|
||||
"Classic Audio headset must auto-confirm without blocking prompt")
|
||||
|
||||
# 4. RequestPinCode -> custom user PIN
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("RequestPinCode", phone_path, (), serial=13)
|
||||
mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache)
|
||||
cols = wait_prompt(p_file)
|
||||
require(cols[1] == "PIN", f"expected PIN prompt, got {cols}")
|
||||
d_file.write_text(f"{cols[0]}\tACCEPT\t5829\n", encoding="utf-8")
|
||||
wait_sent(rc, 2)
|
||||
require(rc.sent[0].header.message_type == MessageType.method_return and
|
||||
rc.sent[0].body == ("5829",),
|
||||
f"RequestPinCode reply mismatch: {rc.sent[0].body}")
|
||||
|
||||
# 5. RequestPasskey -> custom user uint32 passkey
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("RequestPasskey", phone_path, (), serial=14)
|
||||
mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache)
|
||||
cols = wait_prompt(p_file)
|
||||
require(cols[1] == "PASSKEY", f"expected PASSKEY prompt, got {cols}")
|
||||
d_file.write_text(f"{cols[0]}\tACCEPT\t073412\n", encoding="utf-8")
|
||||
wait_sent(rc, 2)
|
||||
require(rc.sent[0].header.message_type == MessageType.method_return and
|
||||
rc.sent[0].body == (73412,),
|
||||
f"RequestPasskey reply mismatch: {rc.sent[0].body}")
|
||||
|
||||
# 6. DisplayPasskey & Cancel
|
||||
rc = RecordingConn()
|
||||
msg = _make_agent_call("DisplayPasskey", phone_path, (193847, 2), serial=15)
|
||||
mod.handle_agent_method_call(rc, msg, agent_path, dev_props_cache=cache)
|
||||
cols = wait_prompt(p_file)
|
||||
require(cols[1] == "DISPLAY" and cols[4] == "193847" and cols[5] == "2",
|
||||
f"unexpected DISPLAY prompt: {cols}")
|
||||
c_msg = _make_agent_call("Cancel", phone_path, (), serial=16)
|
||||
mod.handle_agent_method_call(rc, c_msg, agent_path, dev_props_cache=cache)
|
||||
require(not p_file.exists(), "Agent1.Cancel must clean up active pair_prompt.tsv")
|
||||
finally:
|
||||
(
|
||||
mod.OBEX_IPC_DIR,
|
||||
mod.PAIR_PROMPT_FILE,
|
||||
mod.PAIR_DECISION_FILE,
|
||||
) = orig_vals
|
||||
if old_no_ui is None:
|
||||
os.environ.pop("BANANARCHY_OBEX_NO_UI", None)
|
||||
else:
|
||||
os.environ["BANANARCHY_OBEX_NO_UI"] = old_no_ui
|
||||
if injected is not None:
|
||||
sys.modules.pop("jeepney", None)
|
||||
print("[ok] KeyboardDisplay Agent1 confirmation, PIN, passkey, and display flows")
|
||||
|
||||
|
||||
def test_networks_ui_wiring():
|
||||
src = read(NETWORKS_CPP)
|
||||
for tok in (
|
||||
"ObexActions",
|
||||
"ObexDirPicker",
|
||||
"ObexIncomingPrompt",
|
||||
"BtPairingPrompt",
|
||||
"OBEX_PROMPT",
|
||||
"PAIR_PROMPT",
|
||||
"PAIR_CANCEL",
|
||||
"BT_OP_DONE",
|
||||
"pair_prompt.tsv",
|
||||
"pair_decision.tsv",
|
||||
"--async-ui",
|
||||
"bt_obex_dir",
|
||||
"writeObexDecision",
|
||||
"readObexPromptFile",
|
||||
"openObexDirPicker",
|
||||
"tryPresentObexPrompt",
|
||||
"tryPresentPairPrompt",
|
||||
):
|
||||
require(tok in src, f"networks_plugin.cpp missing OBEX UI element {tok}")
|
||||
require(tok in src, f"networks_plugin.cpp missing OBEX/Pairing UI element {tok}")
|
||||
obex_src = read(BT_OBEX)
|
||||
require('"KeyboardDisplay"' in obex_src and '"NoInputNoOutput"' not in obex_src,
|
||||
"bananarchy-bt-obex must register KeyboardDisplay rather than NoInputNoOutput")
|
||||
require("if running and not opp_registered:\n rfcomm_listener = bind_rfcomm_fallback()" in obex_src,
|
||||
"bananarchy-bt-obex must register BlueZ OPP profile before fallback channel 9 bind")
|
||||
print("[ok] networks_plugin.cpp OBEX confirmation & directory picker UI wiring")
|
||||
print("[ok] networks_plugin.cpp OBEX & KeyboardDisplay pairing UI wiring")
|
||||
|
||||
|
||||
def main():
|
||||
@@ -268,6 +495,7 @@ def main():
|
||||
test_class_and_roles()
|
||||
test_seqpacket_and_stream_reader(mod)
|
||||
test_accept_and_reject_sessions(mod)
|
||||
test_keyboard_display_agent(mod)
|
||||
test_networks_ui_wiring()
|
||||
print("bluetooth obex verification: all checks passed")
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cerrno>
|
||||
#include <clocale>
|
||||
|
||||
#ifdef None
|
||||
@@ -44,6 +45,7 @@ enum class NetModal {
|
||||
ObexActions = 6,
|
||||
ObexDirPicker = 7,
|
||||
ObexIncomingPrompt = 8,
|
||||
BtPairingPrompt = 9,
|
||||
};
|
||||
|
||||
constexpr const char* kIconHeadphones = "\xef\x80\xa5"; // U+F025 headphones
|
||||
@@ -201,6 +203,9 @@ void writeSavedBtDiscoverable(bool disc) {
|
||||
constexpr const char* kObexIpcDir = "/run/bananarchy/bt-obex";
|
||||
constexpr const char* kObexPromptPath = "/run/bananarchy/bt-obex/prompt.tsv";
|
||||
constexpr const char* kObexDecisionPath = "/run/bananarchy/bt-obex/decision.tsv";
|
||||
constexpr const char* kPairPromptPath = "/run/bananarchy/bt-obex/pair_prompt.tsv";
|
||||
constexpr const char* kPairDecisionPath = "/run/bananarchy/bt-obex/pair_decision.tsv";
|
||||
constexpr const char* kBtOpDonePath = "/run/bananarchy/bt-obex/op_done.tsv";
|
||||
|
||||
std::string shortenHomePath(const std::string& p) {
|
||||
if (p.empty()) return "~/Downloads";
|
||||
@@ -307,6 +312,54 @@ void writeObexDecision(const std::string& reqId, bool accept, const std::string&
|
||||
::rename(tmpPath.c_str(), kObexDecisionPath);
|
||||
}
|
||||
|
||||
struct BtPairPromptInfo {
|
||||
bool active = false;
|
||||
std::string reqId;
|
||||
std::string mode; // CONFIRM, PIN, PASSKEY, DISPLAY
|
||||
std::string devName;
|
||||
std::string devMac;
|
||||
std::string code;
|
||||
int entered = 0;
|
||||
};
|
||||
|
||||
BtPairPromptInfo readPairPromptFile() {
|
||||
BtPairPromptInfo p;
|
||||
std::ifstream in(kPairPromptPath);
|
||||
std::string line;
|
||||
if (!in.is_open() || !std::getline(in, line)) return p;
|
||||
line = trimStr(line);
|
||||
if (line.empty()) return p;
|
||||
std::vector<std::string> cols;
|
||||
std::stringstream ss(line);
|
||||
std::string c;
|
||||
while (std::getline(ss, c, '\t')) {
|
||||
cols.push_back(c);
|
||||
}
|
||||
if (cols.size() < 4 || cols[0].empty() || cols[1].empty()) return p;
|
||||
p.active = true;
|
||||
p.reqId = cols[0];
|
||||
p.mode = cols[1];
|
||||
p.devName = cols[2];
|
||||
p.devMac = cols[3];
|
||||
if (cols.size() >= 5) p.code = cols[4];
|
||||
if (cols.size() >= 6) p.entered = std::atoi(cols[5].c_str());
|
||||
return p;
|
||||
}
|
||||
|
||||
void writePairDecision(const std::string& reqId, bool accept, const std::string& value) {
|
||||
if (reqId.empty()) return;
|
||||
::mkdir("/run/bananarchy", 0755);
|
||||
::mkdir(kObexIpcDir, 0755);
|
||||
std::string tmpPath = std::string(kPairDecisionPath) + ".tmp";
|
||||
{
|
||||
std::ofstream out(tmpPath, std::ios::trunc);
|
||||
if (out.is_open()) {
|
||||
out << reqId << "\t" << (accept ? "ACCEPT" : "REJECT") << "\t" << value << "\n";
|
||||
}
|
||||
}
|
||||
::rename(tmpPath.c_str(), kPairDecisionPath);
|
||||
}
|
||||
|
||||
bool isLidClosedState() {
|
||||
std::ifstream in("/run/bananarchy/lid-state");
|
||||
std::string line;
|
||||
@@ -778,18 +831,14 @@ std::vector<BtDeviceEntry> queryBtDevices(const std::string& scanRaw = "") {
|
||||
std::string nameLow = toLowerStr(d.name);
|
||||
|
||||
bool hasA2dp = (infoLow.find("0000110b-") != std::string::npos ||
|
||||
infoLow.find("0000110a-") != std::string::npos ||
|
||||
infoLow.find("audio sink") != std::string::npos ||
|
||||
infoLow.find("audio source") != std::string::npos);
|
||||
infoLow.find("audio sink") != std::string::npos);
|
||||
bool hasHfp = (infoLow.find("00001108-") != std::string::npos ||
|
||||
infoLow.find("00001112-") != std::string::npos ||
|
||||
infoLow.find("0000111e-") != std::string::npos ||
|
||||
infoLow.find("0000111f-") != std::string::npos ||
|
||||
infoLow.find("handsfree") != std::string::npos ||
|
||||
infoLow.find("headset") != std::string::npos);
|
||||
infoLow.find("0000111e-") != std::string::npos);
|
||||
bool hasHid = (infoLow.find("00001124-") != std::string::npos ||
|
||||
infoLow.find("00001812-") != std::string::npos ||
|
||||
infoLow.find("human interface device") != std::string::npos);
|
||||
bool isPhoneOrPc = (infoLow.find("icon: phone") != std::string::npos ||
|
||||
infoLow.find("icon: computer") != std::string::npos);
|
||||
|
||||
if (infoLow.find("icon: input-gaming") != std::string::npos ||
|
||||
infoLow.find("icon: input-joystick") != std::string::npos ||
|
||||
@@ -813,6 +862,9 @@ std::vector<BtDeviceEntry> queryBtDevices(const std::string& scanRaw = "") {
|
||||
nameLow.find("trackpad") != std::string::npos) {
|
||||
d.kind = BtDevKind::Mouse;
|
||||
d.profileLabel = "HID Mouse";
|
||||
} else if (isPhoneOrPc) {
|
||||
d.kind = BtDevKind::Phone;
|
||||
d.profileLabel = "OBEX/PAN";
|
||||
} else if (hasPaSink || hasPaSrc || hasA2dp || hasHfp ||
|
||||
infoLow.find("icon: audio-") != std::string::npos) {
|
||||
d.kind = BtDevKind::Audio;
|
||||
@@ -843,10 +895,6 @@ std::vector<BtDeviceEntry> queryBtDevices(const std::string& scanRaw = "") {
|
||||
} else if (hasHid) {
|
||||
d.kind = BtDevKind::Keyboard;
|
||||
d.profileLabel = "HID Input";
|
||||
} else if (infoLow.find("icon: phone") != std::string::npos ||
|
||||
infoLow.find("icon: computer") != std::string::npos) {
|
||||
d.kind = BtDevKind::Phone;
|
||||
d.profileLabel = "OBEX/PAN";
|
||||
}
|
||||
|
||||
size_t batPos = info.find("Battery Percentage:");
|
||||
@@ -1024,6 +1072,13 @@ int runNetworksApp(int argc, char** argv) {
|
||||
int obexPickerSel = 0;
|
||||
bool obexPickerForPrompt = false;
|
||||
|
||||
// Bluetooth pairing confirmation / PIN / passkey prompt state
|
||||
BtPairPromptInfo pairPrompt;
|
||||
int pairPromptSel = 0;
|
||||
std::string pairInput;
|
||||
bool openedForPairPrompt = false;
|
||||
bool pendingDeferredPairPrompt = false;
|
||||
|
||||
// Multi-tap state for text inputs
|
||||
TextMode textMode = TextMode::Lower;
|
||||
int lastTapDigit = -1;
|
||||
@@ -1062,8 +1117,8 @@ int runNetworksApp(int argc, char** argv) {
|
||||
std::string scanRaw;
|
||||
if (btOn) {
|
||||
int obexPid = readIntFile("/tmp/bananarchy_bt_obex.pid");
|
||||
if (obexPid <= 0 || ::kill(obexPid, 0) != 0) {
|
||||
runAsyncCmd("/usr/bin/bananarchy-bt-obex start >/dev/null 2>&1");
|
||||
if (obexPid <= 0 || (::kill(obexPid, 0) != 0 && errno != EPERM)) {
|
||||
runAsyncCmd("doas -n /usr/bin/bananarchy-bt-obex start >/dev/null 2>&1");
|
||||
}
|
||||
btRx = readBtRxStatus();
|
||||
if (forceScan) {
|
||||
@@ -1182,7 +1237,7 @@ int runNetworksApp(int argc, char** argv) {
|
||||
auto applyOpenArg = [&](const std::string& arg) {
|
||||
std::string a = toLowerStr(trimStr(arg));
|
||||
modal = NetModal::None;
|
||||
if (a == "bluetooth" || a == "bt" || a == "obex-prompt") {
|
||||
if (a == "bluetooth" || a == "bt" || a == "obex-prompt" || a == "pair-prompt") {
|
||||
activeTab = NetTab::Bluetooth;
|
||||
} else if (a == "cell" || a == "cellular" || a == "apn" || a == "hotspot") {
|
||||
activeTab = NetTab::Cellular;
|
||||
@@ -1802,6 +1857,101 @@ int runNetworksApp(int argc, char** argv) {
|
||||
drawPango(layoutSmall, fg, 20, ry, 34, pRows[i], kWinWidth - 40);
|
||||
}
|
||||
drawSoftkeyBar("Accept", "Select", "Reject");
|
||||
} else if (modal == NetModal::BtPairingPrompt) {
|
||||
XSetForeground(dpy, gc, pt.spec.bgOverlay);
|
||||
XFillRectangle(dpy, pix, gc, 8, 28, kWinWidth - 16, 232);
|
||||
XSetForeground(dpy, gc, pt.spec.accent);
|
||||
XDrawRectangle(dpy, pix, gc, 8, 28, kWinWidth - 17, 231);
|
||||
|
||||
std::string devLbl = pairPrompt.devName.empty() ? pairPrompt.devMac : pairPrompt.devName;
|
||||
if (pairPrompt.mode == "CONFIRM") {
|
||||
drawPango(layoutMain, &colYellow, 16, 34, 22, "Bluetooth Pairing", kWinWidth - 32);
|
||||
drawPango(layoutSmall, &colLight, 16, 58, 18,
|
||||
tailFitPangoText(layoutSmall, devLbl, kWinWidth - 32), kWinWidth - 32);
|
||||
XSetForeground(dpy, gc, pt.spec.bgInput);
|
||||
XFillRectangle(dpy, pix, gc, 16, 80, kWinWidth - 32, 42);
|
||||
XSetForeground(dpy, gc, pt.spec.border);
|
||||
XDrawRectangle(dpy, pix, gc, 16, 80, kWinWidth - 33, 41);
|
||||
drawPango(layoutMain, &colWhite, 24, 80, 42,
|
||||
"Code: " + (pairPrompt.code.empty() ? std::string("------") : pairPrompt.code),
|
||||
kWinWidth - 48);
|
||||
drawPango(layoutSmall, &colMuted, 16, 124, 18,
|
||||
"Confirm passkey matches", kWinWidth - 32);
|
||||
|
||||
const char* pOpts[2] = {"Accept & Pair", "Reject Pairing"};
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
int ry = 148 + i * 44;
|
||||
bool isSel = (pairPromptSel == i);
|
||||
XSetForeground(dpy, gc, isSel ? pt.spec.selBg : pt.spec.bgButton);
|
||||
XFillRectangle(dpy, pix, gc, 16, ry, kWinWidth - 32, 36);
|
||||
XftColor* fg = isSel ? &colWhite : ((i == 0) ? &colGreen : &colOrange);
|
||||
drawPango(layoutMain, fg, 24, ry, 36, pOpts[i], kWinWidth - 48);
|
||||
}
|
||||
drawSoftkeyBar("Pair", "Select", "Reject");
|
||||
} else if (pairPrompt.mode == "PIN" || pairPrompt.mode == "PASSKEY") {
|
||||
bool isPin = (pairPrompt.mode == "PIN");
|
||||
drawPango(layoutMain, &colYellow, 16, 34, 22,
|
||||
isPin ? "Enter BT PIN" : "Enter Passkey", kWinWidth - 80);
|
||||
if (isPin) {
|
||||
drawPango(layoutSmall, &colBlue, kWinWidth - 58, 36, 20,
|
||||
std::string("[") + textModeLabel() + "]");
|
||||
}
|
||||
drawPango(layoutSmall, &colLight, 16, 58, 18,
|
||||
tailFitPangoText(layoutSmall, devLbl, kWinWidth - 32), kWinWidth - 32);
|
||||
|
||||
XSetForeground(dpy, gc, pt.spec.bgInputFocus);
|
||||
XFillRectangle(dpy, pix, gc, 16, 86, kWinWidth - 32, 34);
|
||||
XSetForeground(dpy, gc, pt.spec.accent);
|
||||
XDrawRectangle(dpy, pix, gc, 16, 86, kWinWidth - 33, 33);
|
||||
drawPango(layoutMain, &colWhite, 22, 86, 34,
|
||||
tailFitPangoText(layoutMain, pairInput + "_", kWinWidth - 44), kWinWidth - 44);
|
||||
|
||||
if (isPin) {
|
||||
if (lastTapDigit >= 0 && lastTapDigit <= 9 && (nowMs() - lastTapMs) <= 850) {
|
||||
const char* seq = (textMode == TextMode::Sym)
|
||||
? kSymTapMap[lastTapDigit]
|
||||
: kMultiTapMap[lastTapDigit];
|
||||
std::string cand = formatMultiTapBar(
|
||||
std::to_string(lastTapDigit) + ":", seq, lastTapCycle,
|
||||
textMode == TextMode::Upper, 6, 19);
|
||||
drawPango(layoutSmall, &colYellow, 16, 130, 18, cand, kWinWidth - 32);
|
||||
} else {
|
||||
drawPango(layoutSmall, &colMuted, 16, 130, 18,
|
||||
"# Input mode (123/abc)", kWinWidth - 32);
|
||||
}
|
||||
drawPango(layoutSmall, &colMuted, 16, 152, 18,
|
||||
"Enter matching PIN on device", kWinWidth - 32);
|
||||
} else {
|
||||
drawPango(layoutSmall, &colMuted, 16, 130, 18,
|
||||
"Type 6-digit passkey shown", kWinWidth - 32);
|
||||
drawPango(layoutSmall, &colMuted, 16, 152, 18,
|
||||
"on the other device", kWinWidth - 32);
|
||||
}
|
||||
drawPango(layoutSmall, &colMuted, 16, 174, 18,
|
||||
"[0-9] Digits [BkSp] Delete", kWinWidth - 32);
|
||||
drawSoftkeyBar("Pair", "Pair", "Reject");
|
||||
} else {
|
||||
drawPango(layoutMain, &colYellow, 16, 34, 22, "Keyboard Pairing", kWinWidth - 32);
|
||||
drawPango(layoutSmall, &colLight, 16, 58, 18,
|
||||
tailFitPangoText(layoutSmall, devLbl, kWinWidth - 32), kWinWidth - 32);
|
||||
XSetForeground(dpy, gc, pt.spec.bgInput);
|
||||
XFillRectangle(dpy, pix, gc, 16, 86, kWinWidth - 32, 44);
|
||||
XSetForeground(dpy, gc, pt.spec.accent);
|
||||
XDrawRectangle(dpy, pix, gc, 16, 86, kWinWidth - 33, 43);
|
||||
drawPango(layoutMain, &colWhite, 22, 86, 44,
|
||||
"Code: " + (pairPrompt.code.empty() ? std::string("------") : pairPrompt.code),
|
||||
kWinWidth - 44);
|
||||
drawPango(layoutSmall, &colLight, 16, 140, 18,
|
||||
"Type this code on device", kWinWidth - 32);
|
||||
drawPango(layoutSmall, &colMuted, 16, 162, 18,
|
||||
"then press Enter to finish", kWinWidth - 32);
|
||||
if (pairPrompt.entered > 0) {
|
||||
drawPango(layoutSmall, &colGreen, 16, 186, 18,
|
||||
"Entered: " + std::to_string(pairPrompt.entered) + " digit(s)",
|
||||
kWinWidth - 32);
|
||||
}
|
||||
drawSoftkeyBar("OK", "OK", "Close");
|
||||
}
|
||||
}
|
||||
|
||||
if (!statusBanner.empty() && nowMs() < statusBannerUntilMs) {
|
||||
@@ -1850,7 +2000,16 @@ int runNetworksApp(int argc, char** argv) {
|
||||
writeObexDecision(obexPrompt.reqId, false, obexPrompt.targetDir);
|
||||
obexPrompt.active = false;
|
||||
}
|
||||
if (modal == NetModal::BtPairingPrompt && pairPrompt.active) {
|
||||
if (pairPrompt.mode == "DISPLAY") {
|
||||
::unlink(kPairPromptPath);
|
||||
} else {
|
||||
writePairDecision(pairPrompt.reqId, false, "");
|
||||
}
|
||||
pairPrompt.active = false;
|
||||
}
|
||||
openedForObexPrompt = false;
|
||||
openedForPairPrompt = false;
|
||||
int xfdLocal = ConnectionNumber(dpy);
|
||||
int64_t drainDeadline = nowMs() + 180;
|
||||
while (nowMs() < drainDeadline && querySoftkeysDown(dpy) != 0) {
|
||||
@@ -1920,6 +2079,67 @@ int runNetworksApp(int argc, char** argv) {
|
||||
render();
|
||||
};
|
||||
|
||||
auto resolvePairPrompt = [&](bool accept) {
|
||||
if (pairPrompt.active) {
|
||||
if (pairPrompt.mode == "DISPLAY") {
|
||||
::unlink(kPairPromptPath);
|
||||
} else {
|
||||
if (accept && (pairPrompt.mode == "PIN" || pairPrompt.mode == "PASSKEY") &&
|
||||
trimStr(pairInput).empty()) {
|
||||
setBanner(pairPrompt.mode == "PIN" ? "Enter PIN first" : "Enter passkey first");
|
||||
render();
|
||||
return;
|
||||
}
|
||||
writePairDecision(pairPrompt.reqId, accept, trimStr(pairInput));
|
||||
}
|
||||
pairPrompt.active = false;
|
||||
}
|
||||
modal = NetModal::None;
|
||||
if (openedForPairPrompt) {
|
||||
openedForPairPrompt = false;
|
||||
hideWindow();
|
||||
} else {
|
||||
refreshCurrentTab(false);
|
||||
if (pairPrompt.mode != "DISPLAY") {
|
||||
setBanner(accept ? "Pairing confirmed..." : "Pairing rejected");
|
||||
}
|
||||
render();
|
||||
}
|
||||
};
|
||||
|
||||
auto tryPresentPairPrompt = [&](bool forceMarkOpened = false) {
|
||||
BtPairPromptInfo p = readPairPromptFile();
|
||||
if (!p.active) {
|
||||
pendingDeferredPairPrompt = false;
|
||||
return;
|
||||
}
|
||||
if (isPhonePasscodeLocked() || isPidFileAlive(getRuntimeFile("xlocker.pid")) ||
|
||||
isCallActiveOrRingingFast() || isLidClosedState()) {
|
||||
pendingDeferredPairPrompt = true;
|
||||
return;
|
||||
}
|
||||
pendingDeferredPairPrompt = false;
|
||||
bool sameReq = (modal == NetModal::BtPairingPrompt && pairPrompt.reqId == p.reqId);
|
||||
bool wasVisible = visible;
|
||||
pairPrompt = p;
|
||||
if (!sameReq) {
|
||||
pairPromptSel = 0;
|
||||
pairInput.clear();
|
||||
textMode = TextMode::Num;
|
||||
lastTapDigit = -1;
|
||||
}
|
||||
if (!wasVisible) {
|
||||
openedForPairPrompt = true;
|
||||
showWindow("bluetooth");
|
||||
} else {
|
||||
if (forceMarkOpened) openedForPairPrompt = true;
|
||||
activeTab = NetTab::Bluetooth;
|
||||
}
|
||||
wakeDisplayForObex(dpy);
|
||||
modal = NetModal::BtPairingPrompt;
|
||||
render();
|
||||
};
|
||||
|
||||
auto connectWifiNow = [&](const std::string& ssid, const std::string& pass) {
|
||||
modal = NetModal::None;
|
||||
setBanner("Connecting to " + ssid + "...");
|
||||
@@ -2061,20 +2281,11 @@ int runNetworksApp(int argc, char** argv) {
|
||||
modal = NetModal::None;
|
||||
int rc = 0;
|
||||
if (act == 0) {
|
||||
setBanner("Connecting " + targetBt.name + "...");
|
||||
setBanner("Connecting " + targetBt.name + "...", 55000);
|
||||
render();
|
||||
runCaptureCmd("/usr/bin/bananarchy-bt-obex connect " +
|
||||
shellQuote(targetBt.mac) + " " +
|
||||
shellQuote(targetBt.name) + " >/dev/null 2>&1", &rc);
|
||||
refreshCurrentTab(false);
|
||||
refreshTargetBtFromList();
|
||||
bool isConn = (rc == 0) || targetBt.connected;
|
||||
if (isConn && targetBt.kind == BtDevKind::Audio) {
|
||||
std::ofstream ofs("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (ofs) ofs << "Bluetooth\n";
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
}
|
||||
setBanner(isConn ? ("Connected: " + targetBt.name) : "Connect failed");
|
||||
runAsyncCmd("doas -n /usr/bin/bananarchy-bt-obex --async-ui connect " +
|
||||
shellQuote(targetBt.mac) + " " +
|
||||
shellQuote(targetBt.name) + " >/dev/null 2>&1");
|
||||
} else if (act == 1) {
|
||||
setBanner("Disconnecting " + targetBt.name + "...");
|
||||
render();
|
||||
@@ -2087,21 +2298,11 @@ int runNetworksApp(int argc, char** argv) {
|
||||
refreshCurrentTab(false);
|
||||
setBanner("Disconnected " + targetBt.name);
|
||||
} else if (act == 2) {
|
||||
setBanner("Pairing " + targetBt.name + "...");
|
||||
setBanner("Pairing " + targetBt.name + "...", 55000);
|
||||
render();
|
||||
runCaptureCmd("/usr/bin/bananarchy-bt-obex pair " +
|
||||
shellQuote(targetBt.mac) + " " +
|
||||
shellQuote(targetBt.name) + " >/dev/null 2>&1", &rc);
|
||||
refreshCurrentTab(false);
|
||||
refreshTargetBtFromList();
|
||||
bool isPairedOrConn = (rc == 0) || targetBt.connected || targetBt.paired;
|
||||
if (isPairedOrConn && targetBt.kind == BtDevKind::Audio) {
|
||||
std::ofstream ofs("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (ofs) ofs << "Bluetooth\n";
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
}
|
||||
setBanner(isPairedOrConn ? ("Paired & connected: " + targetBt.name)
|
||||
: ("Pairing failed: " + targetBt.name));
|
||||
runAsyncCmd("doas -n /usr/bin/bananarchy-bt-obex --async-ui pair " +
|
||||
shellQuote(targetBt.mac) + " " +
|
||||
shellQuote(targetBt.name) + " >/dev/null 2>&1");
|
||||
} else if (act == 3) {
|
||||
std::string macU = targetBt.mac;
|
||||
for (char& c : macU) {
|
||||
@@ -2219,6 +2420,14 @@ int runNetworksApp(int argc, char** argv) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
if (pairPrompt.mode == "CONFIRM") {
|
||||
resolvePairPrompt(pairPromptSel == 0);
|
||||
} else {
|
||||
resolvePairPrompt(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (activeTab == NetTab::Wifi) {
|
||||
if (wifiRowSel == 0) {
|
||||
@@ -2350,6 +2559,10 @@ int runNetworksApp(int argc, char** argv) {
|
||||
resolveObexPrompt(true);
|
||||
return;
|
||||
}
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
resolvePairPrompt(true);
|
||||
return;
|
||||
}
|
||||
if (modal != NetModal::None) {
|
||||
handleEnterKey();
|
||||
return;
|
||||
@@ -2382,6 +2595,10 @@ int runNetworksApp(int argc, char** argv) {
|
||||
resolveObexPrompt(false);
|
||||
return;
|
||||
}
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
resolvePairPrompt(false);
|
||||
return;
|
||||
}
|
||||
if (modal == NetModal::ObexDirPicker) {
|
||||
modal = obexPickerForPrompt ? NetModal::ObexIncomingPrompt : NetModal::ObexActions;
|
||||
return;
|
||||
@@ -2395,8 +2612,11 @@ int runNetworksApp(int argc, char** argv) {
|
||||
|
||||
if (!isPreload) {
|
||||
showWindow(openArg);
|
||||
if (toLowerStr(trimStr(openArg)) == "obex-prompt") {
|
||||
std::string lowerOpen = toLowerStr(trimStr(openArg));
|
||||
if (lowerOpen == "obex-prompt") {
|
||||
tryPresentObexPrompt(true);
|
||||
} else if (lowerOpen == "pair-prompt") {
|
||||
tryPresentPairPrompt(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2459,6 +2679,8 @@ int runNetworksApp(int argc, char** argv) {
|
||||
if (sym == XF86XK_HangupPhone || sym == XK_Cancel) {
|
||||
if (modal == NetModal::ObexIncomingPrompt) {
|
||||
resolveObexPrompt(false);
|
||||
} else if (modal == NetModal::BtPairingPrompt) {
|
||||
resolvePairPrompt(false);
|
||||
} else {
|
||||
hideWindow();
|
||||
}
|
||||
@@ -2588,6 +2810,45 @@ int runNetworksApp(int argc, char** argv) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
if (pairPrompt.mode == "CONFIRM") {
|
||||
if (sym == XK_Up || sym == XK_KP_Up || sym == XK_Down || sym == XK_KP_Down) {
|
||||
pairPromptSel = (pairPromptSel + 1) % 2;
|
||||
render();
|
||||
} else if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
handleEnterKey();
|
||||
}
|
||||
} else if (pairPrompt.mode == "PIN" || pairPrompt.mode == "PASSKEY") {
|
||||
if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
resolvePairPrompt(true);
|
||||
continue;
|
||||
}
|
||||
if (pairPrompt.mode == "PASSKEY") {
|
||||
char kd = mapDialKey(sym, kc, ev.xkey.state);
|
||||
if (kd >= '0' && kd <= '9' && pairInput.size() < 6) {
|
||||
pairInput.push_back(kd);
|
||||
render();
|
||||
} else if ((sym == XK_BackSpace || sym == XK_Delete) && !pairInput.empty()) {
|
||||
pairInput.pop_back();
|
||||
render();
|
||||
}
|
||||
} else {
|
||||
if (pairInput.size() < 16 || sym == XK_BackSpace || sym == XK_Delete ||
|
||||
mapDialKey(sym, kc, ev.xkey.state) == '#') {
|
||||
if (handleMultiTapKey(pairInput, sym, kc, ev.xkey.state)) {
|
||||
if (pairInput.size() > 16) pairInput.resize(16);
|
||||
render();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (sym == XK_Return || sym == XK_KP_Enter) {
|
||||
resolvePairPrompt(true);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Main View Tab & Row Navigation
|
||||
char dch = mapDialKey(sym, kc, ev.xkey.state);
|
||||
if (dch == '#' && activeTab == NetTab::Bluetooth && btOn) {
|
||||
@@ -2687,7 +2948,8 @@ int runNetworksApp(int argc, char** argv) {
|
||||
}
|
||||
if (lastTapDigit != -1 &&
|
||||
(modal == NetModal::WifiPassword || modal == NetModal::ApnEditor ||
|
||||
modal == NetModal::BtNameEditor)) {
|
||||
modal == NetModal::BtNameEditor ||
|
||||
(modal == NetModal::BtPairingPrompt && pairPrompt.mode == "PIN"))) {
|
||||
int64_t tRem = (lastTapMs + 851) - now;
|
||||
if (tRem <= 0) {
|
||||
lastTapDigit = -1;
|
||||
@@ -2721,6 +2983,36 @@ int runNetworksApp(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (pendingDeferredPairPrompt) {
|
||||
tryPresentPairPrompt();
|
||||
if (pendingDeferredPairPrompt && (timeoutMs < 0 || timeoutMs > 250)) {
|
||||
timeoutMs = 250;
|
||||
}
|
||||
}
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
BtPairPromptInfo curP = readPairPromptFile();
|
||||
if (!curP.active || curP.reqId != pairPrompt.reqId) {
|
||||
if (curP.active && curP.reqId != pairPrompt.reqId) {
|
||||
tryPresentPairPrompt();
|
||||
} else {
|
||||
pairPrompt.active = false;
|
||||
modal = NetModal::None;
|
||||
if (openedForPairPrompt) {
|
||||
openedForPairPrompt = false;
|
||||
hideWindow();
|
||||
} else {
|
||||
refreshCurrentTab(false);
|
||||
if (pairPrompt.mode != "DISPLAY") {
|
||||
setBanner("Pairing ended");
|
||||
}
|
||||
render();
|
||||
}
|
||||
}
|
||||
} else if (timeoutMs < 0 || timeoutMs > 250) {
|
||||
timeoutMs = 250;
|
||||
}
|
||||
}
|
||||
|
||||
struct pollfd pfds[2];
|
||||
pfds[0].fd = xfd;
|
||||
pfds[0].events = POLLIN;
|
||||
@@ -2743,14 +3035,78 @@ int runNetworksApp(int argc, char** argv) {
|
||||
if (visible) render();
|
||||
} else if (cmd.rfind("OBEX_PROMPT", 0) == 0) {
|
||||
tryPresentObexPrompt();
|
||||
} else if (cmd.rfind("PAIR_PROMPT", 0) == 0) {
|
||||
tryPresentPairPrompt();
|
||||
} else if (cmd == "PAIR_CANCEL") {
|
||||
pendingDeferredPairPrompt = false;
|
||||
if (modal == NetModal::BtPairingPrompt) {
|
||||
pairPrompt.active = false;
|
||||
modal = NetModal::None;
|
||||
if (openedForPairPrompt) {
|
||||
openedForPairPrompt = false;
|
||||
hideWindow();
|
||||
} else {
|
||||
refreshCurrentTab(false);
|
||||
setBanner("Pairing cancelled");
|
||||
render();
|
||||
}
|
||||
}
|
||||
} else if (cmd == "BT_OP_DONE") {
|
||||
int opRc = 1;
|
||||
std::string opMode = "pair", opMac, opName;
|
||||
{
|
||||
std::ifstream in(kBtOpDonePath);
|
||||
std::string line;
|
||||
if (in.is_open() && std::getline(in, line)) {
|
||||
std::vector<std::string> cols;
|
||||
std::stringstream ss(line);
|
||||
std::string c;
|
||||
while (std::getline(ss, c, '\t')) cols.push_back(c);
|
||||
if (!cols.empty()) opRc = std::atoi(cols[0].c_str());
|
||||
if (cols.size() >= 2) opMode = cols[1];
|
||||
if (cols.size() >= 3) opMac = cols[2];
|
||||
if (cols.size() >= 4) opName = cols[3];
|
||||
}
|
||||
}
|
||||
::unlink(kBtOpDonePath);
|
||||
if (!opMac.empty()) targetBt.mac = opMac;
|
||||
if (!opName.empty()) targetBt.name = opName;
|
||||
refreshCurrentTab(false);
|
||||
refreshTargetBtFromList();
|
||||
if (opMode == "pair") {
|
||||
bool ok = (opRc == 0) || targetBt.connected || targetBt.paired;
|
||||
if (ok && targetBt.kind == BtDevKind::Audio) {
|
||||
std::ofstream ofs("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (ofs) ofs << "Bluetooth\n";
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
}
|
||||
if (modal != NetModal::BtPairingPrompt) {
|
||||
setBanner(ok ? ("Paired: " + targetBt.name)
|
||||
: ("Pairing failed: " + targetBt.name));
|
||||
}
|
||||
} else {
|
||||
bool ok = (opRc == 0) || targetBt.connected;
|
||||
if (ok && targetBt.kind == BtDevKind::Audio) {
|
||||
std::ofstream ofs("/tmp/sxmo_audio_out_device", std::ios::trunc);
|
||||
if (ofs) ofs << "Bluetooth\n";
|
||||
runAsyncCmd("sxmo_audio.sh device set Bluetooth >/dev/null 2>&1");
|
||||
}
|
||||
if (modal != NetModal::BtPairingPrompt) {
|
||||
setBanner(ok ? ("Connected: " + targetBt.name) : "Connect failed");
|
||||
}
|
||||
}
|
||||
if (visible) render();
|
||||
} else if (cmd == "TOGGLE") {
|
||||
if (visible) hideWindow();
|
||||
else showWindow();
|
||||
} else if (cmd.rfind("OPEN", 0) == 0) {
|
||||
std::string arg = (cmd.size() > 5) ? trimStr(cmd.substr(5)) : "";
|
||||
showWindow(arg);
|
||||
if (toLowerStr(arg) == "obex-prompt") {
|
||||
std::string lowArg = toLowerStr(arg);
|
||||
if (lowArg == "obex-prompt") {
|
||||
tryPresentObexPrompt(true);
|
||||
} else if (lowArg == "pair-prompt") {
|
||||
tryPresentPairPrompt(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user