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:
Luxferre committed 2026-11-17 11:30:42 +02:00
1 parent 36a5f8cb8a
commit 1e1fe7c317
17 files changed
+1387 -326

No files matched your search

+16 -8
View File
@@ -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
+19 -2
View File
@@ -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
+234 -6
View File
@@ -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")