Fix Bluetooth 5.x/6.x headsets, Android OBEX prompts, and refresh a1120 images
- Scope WirePlumber 50-bluetooth.conf roles to [ a2dp_sink hsp_hs hfp_hf ], lock HFP to 8 kHz CVSD for QDSP6 INTERNAL_BT_SCO, enable dummy AVRCP player, and set LDAC ABR quality. - Select BR/EDR bearer and ConnectProfile fallback for Classic Audio headsets while preserving LE bearer for HOGP devices, forward AVRCP media keys to music.so, bound discoverability to 60 s, fix SCO keepalive teardown/readiness and ATA call state sync, and suppress nokia-sparkler speaker haptic audio during BT SCO. - Advertise Smartphone Class of Device (0x5a020c / btmgmt class 2 3), handle OBEX over both L2CAP SOCK_SEQPACKET and RFCOMM SOCK_STREAM via ObexPacketReader, and add NeoUI incoming file Accept/Reject dialog and configurable target folder picker in networks.so. - Add scripts/test-bluetooth-headset.py and scripts/test-bluetooth-obex.py, and rebuild/pin verified a1120 (cocojamboo) images and release archives for nokia-argon, nokia-beatles, nokia-coconut, and nokia-sparkler.
This commit is contained in:
1 parent
0030dc3910
commit
36a5f8cb8a
29 files changed
+2011
-190
No files matched your search
Executable
+242
@@ -0,0 +1,242 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Host regression tests for Bluetooth 5.x/6.x headset support (A2DP + HSP/HFP).
|
||||
|
||||
Covers:
|
||||
- WirePlumber 50-bluetooth.conf consistency across all overlay/user templates
|
||||
(cvsd-only HFP without mSBC/lc3-a127/lc3_swb/bap/hfp_ag, dummy-avrcp-player,
|
||||
LDAC auto ABR and AAC CBR defaults).
|
||||
- Dual-mode BR/EDR vs BLE bearer selection in bananarchy-bt-obex without
|
||||
regressing LE HOGP keyboards/mice/gamepads, plus AVRCP media key dispatch.
|
||||
- SCO keepalive race handling, zero pkill dependency, hardware volume routing,
|
||||
headset ATA call pickup synchronization, and n-sparkler SCO haptic guard.
|
||||
- Off-by-default discoverability with bounded 60s timeout across toggle,
|
||||
daemon, and xnetworks UI.
|
||||
- All four target DTBs (argon, beatles, coconut, sparkler) exposing WCNSS-BT
|
||||
and QDSP6 INTERNAL_BT_SCO DAIs.
|
||||
"""
|
||||
import ast
|
||||
import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
BASE = pathlib.Path(__file__).resolve().parent.parent
|
||||
|
||||
WP_CONFS = (
|
||||
BASE / "overlay/rootfs/etc/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
BASE / "overlay/rootfs/usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
BASE / "overlay/rootfs/home/user/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
BASE / "overlay/rootfs/etc/skel/.config/wireplumber/wireplumber.conf.d/50-bluetooth.conf",
|
||||
)
|
||||
|
||||
BT_OBEX = BASE / "overlay/rootfs/usr/bin/bananarchy-bt-obex"
|
||||
BT_TOGGLE = BASE / "overlay/rootfs/usr/bin/sxmo_bluetoothtoggle.sh"
|
||||
AUDIO_SH = BASE / "overlay/rootfs/usr/bin/sxmo_audio.sh"
|
||||
MODEMAUDIO_SH = BASE / "overlay/rootfs/usr/bin/sxmo_modemaudio.sh"
|
||||
CALLSCREEN_CPP = BASE / "src/dwm-plugins/callscreen_plugin.cpp"
|
||||
NETWORKS_CPP = BASE / "src/dwm-plugins/networks_plugin.cpp"
|
||||
MUSIC_CPP = BASE / "src/dwm-plugins/music_plugin.cpp"
|
||||
VIBRATE_C = BASE / "src/dwm-plugins/sxmo_vibrate.c"
|
||||
|
||||
TARGET_DTBS = (
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-argon.dtb",
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-beatles.dtb",
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8905-nokia-coconut.dtb",
|
||||
BASE / "prebuilt/kernel-6.12.1-msm8916/dtbs/qcom-msm8909-nokia-sparkler.dtb",
|
||||
)
|
||||
|
||||
|
||||
def require(cond, msg):
|
||||
if not cond:
|
||||
raise SystemExit("FAIL: " + msg)
|
||||
|
||||
|
||||
def read(path):
|
||||
return path.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def load_obex_pure_helpers():
|
||||
src = read(BT_OBEX)
|
||||
tree = ast.parse(src, filename=str(BT_OBEX))
|
||||
wanted_assigns = {"CLASSIC_AUDIO_UUID_PREFIXES"}
|
||||
wanted_defs = {
|
||||
"is_hog_device_props",
|
||||
"is_classic_audio_props",
|
||||
"avrcp_fifo_command_for_key",
|
||||
}
|
||||
selected = []
|
||||
for node in tree.body:
|
||||
if isinstance(node, ast.Assign):
|
||||
names = [t.id for t in node.targets if isinstance(t, ast.Name)]
|
||||
if any(n in wanted_assigns for n in names):
|
||||
selected.append(ast.get_source_segment(src, node))
|
||||
elif isinstance(node, ast.FunctionDef) and node.name in wanted_defs:
|
||||
selected.append(ast.get_source_segment(src, node))
|
||||
require(len(selected) == len(wanted_assigns) + len(wanted_defs),
|
||||
"missing pure audio/AVRCP helpers in bananarchy-bt-obex")
|
||||
ns = {}
|
||||
exec("\n\n".join(selected), ns)
|
||||
return ns
|
||||
|
||||
|
||||
def test_wireplumber_config():
|
||||
texts = [read(p) for p in WP_CONFS]
|
||||
for idx, t in enumerate(texts[1:], 1):
|
||||
require(t == texts[0],
|
||||
f"50-bluetooth.conf copy {WP_CONFS[idx]} drifted from etc/wireplumber copy")
|
||||
cfg = texts[0]
|
||||
for forbidden in ("bap_sink", "bap_source", "a2dp_source", "hsp_ag", "hfp_ag",
|
||||
"opus_05_dup ", "opus_05_51", "opus_05_71", "opus_05_pro",
|
||||
" lc3 "):
|
||||
require(forbidden not in cfg,
|
||||
f"50-bluetooth.conf still contains incompatible token {forbidden!r}")
|
||||
for required in (
|
||||
"bluez5.roles = [ a2dp_sink hsp_hs hfp_hf ]",
|
||||
"opus_05_duplex",
|
||||
"bluez5.enable-msbc = false",
|
||||
"bluez5.enable-lc3-a127 = false",
|
||||
"bluez5.enable-hw-volume = true",
|
||||
"bluez5.dummy-avrcp-player = true",
|
||||
'bluez5.a2dp.ldac.quality = "auto"',
|
||||
"bluez5.a2dp.aac.bitratemode = 0",
|
||||
'bluez5.hfphsp-backend = "native"',
|
||||
):
|
||||
require(required in cfg, f"50-bluetooth.conf missing {required!r}")
|
||||
print("[ok] WirePlumber 50-bluetooth.conf profiles, codecs, AVRCP, and CVSD lock")
|
||||
|
||||
|
||||
def test_obex_bearer_and_avrcp():
|
||||
ns = load_obex_pure_helpers()
|
||||
is_hog = ns["is_hog_device_props"]
|
||||
is_audio = ns["is_classic_audio_props"]
|
||||
map_avrcp = ns["avrcp_fifo_command_for_key"]
|
||||
|
||||
hog_kbd = {"UUIDs": ["00001812-0000-1000-8000-00805f9b34fb"]}
|
||||
bt5_dual_buds = {
|
||||
"AddressType": "public",
|
||||
"UUIDs": [
|
||||
"0000110b-0000-1000-8000-00805f9b34fb",
|
||||
"0000111e-0000-1000-8000-00805f9b34fb",
|
||||
"0000184e-0000-1000-8000-00805f9b34fb",
|
||||
],
|
||||
"Icon": "audio-headset",
|
||||
"Class": 0x240404,
|
||||
}
|
||||
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_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"}),
|
||||
"audio-headphones Icon not recognized as Classic Audio")
|
||||
require(is_audio(cod_only_speaker),
|
||||
"Audio CoD speaker not recognized as Classic Audio")
|
||||
require(not is_audio(ble_beacon),
|
||||
"Generic BLE beacon falsely matched Classic Audio")
|
||||
|
||||
require(map_avrcp(164) == "PLAYPAUSE", "KEY_PLAYPAUSE mapping wrong")
|
||||
require(map_avrcp(200) == "PLAY", "KEY_PLAYCD mapping wrong")
|
||||
require(map_avrcp(201) == "PAUSE", "KEY_PAUSECD mapping wrong")
|
||||
require(map_avrcp(166) == "STOP", "KEY_STOPCD mapping wrong")
|
||||
require(map_avrcp(163) == "NEXT", "KEY_NEXTSONG mapping wrong")
|
||||
require(map_avrcp(165) == "PREV", "KEY_PREVIOUSSONG mapping wrong")
|
||||
require(map_avrcp(30) is None, "unrelated key mapped as AVRCP")
|
||||
|
||||
obex_src = read(BT_OBEX)
|
||||
for tok in (
|
||||
"set_hog_preferred_bearer(",
|
||||
"set_audio_preferred_bearer(",
|
||||
'("s", "bredr")',
|
||||
"ConnectProfile",
|
||||
"has_media_transport(",
|
||||
"is_tentative_ble_non_hog(",
|
||||
"avrcp_devs",
|
||||
"dispatch_avrcp_key(",
|
||||
):
|
||||
require(tok in obex_src, f"bananarchy-bt-obex missing {tok}")
|
||||
print("[ok] Dual-bearer BR/EDR headset selection, HOGP preservation, and AVRCP bridge")
|
||||
|
||||
|
||||
def test_discoverability_and_power():
|
||||
obex_src = read(BT_OBEX)
|
||||
toggle_src = read(BT_TOGGLE)
|
||||
net_src = read(NETWORKS_CPP)
|
||||
|
||||
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")
|
||||
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
|
||||
"discoverable-timeout 60" in net_src,
|
||||
"networks_plugin.cpp must use 60s discoverable timeout")
|
||||
print("[ok] Bounded 60s discoverability and hidden-by-default battery safeguard")
|
||||
|
||||
|
||||
def test_sco_audio_call_and_haptics():
|
||||
audio_src = read(AUDIO_SH)
|
||||
maudio_src = read(MODEMAUDIO_SH)
|
||||
cs_src = read(CALLSCREEN_CPP)
|
||||
net_src = read(NETWORKS_CPP)
|
||||
music_src = read(MUSIC_CPP)
|
||||
vib_src = read(VIBRATE_C)
|
||||
|
||||
require("pkill" not in audio_src,
|
||||
"sxmo_audio.sh must not invoke missing pkill binary")
|
||||
require("launch_bt_sco_pacat" in audio_src and
|
||||
"/tmp/sxmo_bt_sco_wait.pid" in audio_src and
|
||||
"apply_bt_sink_volume" in audio_src,
|
||||
"sxmo_audio.sh missing bounded SCO keepalive retry or $bt_sink volume control")
|
||||
require("elif [ ! -r /tmp/sxmo_in_call ]; then\n stop_bt_sco_keepalive" not in audio_src,
|
||||
"sxmo_audio.sh leaks SCO pacat keepalive when switching off BT mid-call")
|
||||
require("bluez_output\\." in maudio_src and "switch_bt_card_hfp" in maudio_src,
|
||||
"sxmo_modemaudio.sh missing synchronous BT SCO sink readiness wait")
|
||||
require('.pickedupcall' in cs_src and
|
||||
'writeIntFile("/tmp/sxmo_in_call", 1)' in cs_src,
|
||||
"callscreen_plugin.cpp missing headset ATA .pickedupcall / sxmo_in_call sync")
|
||||
require("refreshTargetBtFromList" in net_src and "infoCount >= 24" in net_src,
|
||||
"networks_plugin.cpp missing stale targetBt refresh or info cap bump")
|
||||
for tok in ("XF86XK_AudioPlay", "XF86XK_AudioNext", "XF86XK_AudioPrev",
|
||||
'cmd == "PLAYPAUSE"', 'cmd == "NEXT"', 'cmd == "PREV"'):
|
||||
require(tok in music_src, f"music_plugin.cpp missing AVRCP handler {tok}")
|
||||
require("/tmp/sxmo_bt_sco_mm_active" in vib_src,
|
||||
"sxmo_vibrate.c missing /tmp/sxmo_bt_sco_mm_active haptic suppression")
|
||||
print("[ok] SCO keepalive, ATA call sync, AVRCP music control, and Sparkler SCO haptic guard")
|
||||
|
||||
|
||||
def test_target_dtbs():
|
||||
dtc = shutil.which("dtc")
|
||||
if not dtc:
|
||||
print("[skip] dtc not installed; skipping DTB inspection")
|
||||
return
|
||||
for dtb in TARGET_DTBS:
|
||||
require(dtb.is_file(), f"missing shipped DTB: {dtb}")
|
||||
dts = subprocess.check_output(
|
||||
[dtc, "-q", "-I", "dtb", "-O", "dts", str(dtb)],
|
||||
text=True,
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
for node in ('compatible = "qcom,wcnss-bt"', "dai@136", "dai@137",
|
||||
'link-name = "Internal BT-SCO RX"',
|
||||
'link-name = "Internal BT-SCO TX"'):
|
||||
require(node in dts, f"{dtb.name} missing BT/QDSP6 node {node!r}")
|
||||
print("[ok] All 4 target DTBs include WCNSS-BT and INTERNAL_BT_SCO DAIs")
|
||||
|
||||
|
||||
def main():
|
||||
test_wireplumber_config()
|
||||
test_obex_bearer_and_avrcp()
|
||||
test_discoverability_and_power()
|
||||
test_sco_audio_call_and_haptics()
|
||||
test_target_dtbs()
|
||||
print("bluetooth headset verification: all checks passed")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user