- Default CPU_RPM_SLEEP=0, CPU_L2_SLEEP=0, and MODEM_DRX_MODE=0 across bananarchy-power-policy.conf, bananarchy-power-policy.sh, bananarchy-display-power-sync, and kernel patch 0010 so closed-flip incoming calls wake APSS promptly via smd-edge without AT port contention. - Serialize sxmo_modem.sh incoming/finished call checks, expire stale /tmp/sxmo_hangup_requested flags, re-verify live ModemManager call state before ringing/raising callscreen, guard idle/flip-open HANGUP_CLOSE paths in locker.so, callscreen.so, bananarchy-idle-lock.sh, and bananarchy-lid, preserve calls on flip-open (UNGRAB/RAISE), and add closed-flip cover call controls (bananarchy-cover-idle, bananarchy-cover-event.sh, bananarchy-volume-keys). - Propagate live network/manual timezone updates across statusbar, locker.so, bananarchy-cover-idle, bananarchy-dsds, callscreen.so, and bananarchy-run-aligned without reboot (scripts/test-time-timezone-sync.py), remove non-functional Logout from the Power menu, ignore post-call sxmo_calls markers, add scripts/build-dwm-plugins.sh, and update a1114 (carbonara) hashes and docs.
506 lines
20 KiB
Python
Executable File
506 lines
20 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Host integration test for the 2720 Flip cover display behaviour.
|
|
|
|
Compiles bananarchy-cover-idle.c on the host, runs it against a fake
|
|
framebuffer/backlight, and drives its real IPC protocol to verify:
|
|
- flip open => fully off (black frame, backlight 0);
|
|
- flip closed + external BUTTON => clock, date and network indicators;
|
|
- no button => the main Screen blank timeout blanks the cover again;
|
|
- blank_timeout = auto follows Config -> Screen blank (0 = never).
|
|
"""
|
|
import hashlib
|
|
import os
|
|
import pathlib
|
|
import socket
|
|
import struct
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import time
|
|
|
|
BASE = pathlib.Path(__file__).resolve().parent.parent
|
|
SRC = BASE / "src/bananarchy-daemons/bananarchy-cover-idle.c"
|
|
VOL_SRC = BASE / "src/bananarchy-daemons/bananarchy-volume-keys.c"
|
|
COMMON_H = BASE / "src/bananarchy-daemons/common.h"
|
|
FB_WIDTH, FB_HEIGHT, FB_BPP = 240, 240, 32
|
|
FRAME_SIZE = FB_WIDTH * FB_HEIGHT * (FB_BPP // 8)
|
|
|
|
|
|
class Cover:
|
|
def __init__(self, root, exe, config, main_cfg, lid_state=None, extra_env=None):
|
|
self.root = root
|
|
self.sock_path = root / "cover.sock"
|
|
self.fb = root / "fb1"
|
|
self.backlight = root / "backlight"
|
|
self.fb.write_bytes(b"\x00" * FRAME_SIZE)
|
|
self.backlight.write_text("0")
|
|
self.env = dict(os.environ)
|
|
self.env.update({
|
|
"BANANARCHY_COVER_LOCK": str(root / "daemon.lock"),
|
|
"BANANARCHY_COVER_FB_GEOM": "%d,%d,%d" % (FB_WIDTH, FB_HEIGHT, FB_BPP),
|
|
"BANANARCHY_COVER_MAIN_BLANK_CFG": str(main_cfg),
|
|
"BANANARCHY_COVER_NOIDLE_PATH": str(root / "sxmo.noidle"),
|
|
})
|
|
if lid_state is not None:
|
|
self.env["BANANARCHY_COVER_LID_STATE"] = str(lid_state)
|
|
if extra_env:
|
|
self.env.update(extra_env)
|
|
self.proc = subprocess.Popen([str(exe), "--config", str(config)],
|
|
env=self.env, stdout=subprocess.DEVNULL,
|
|
stderr=subprocess.DEVNULL)
|
|
self.client_path = root / "client.sock"
|
|
if self.client_path.exists():
|
|
self.client_path.unlink()
|
|
self.client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM)
|
|
self.client.bind(str(self.client_path))
|
|
self.client.settimeout(2)
|
|
deadline = time.time() + 3
|
|
while time.time() < deadline and not self.sock_path.exists():
|
|
time.sleep(0.05)
|
|
|
|
def send(self, command):
|
|
self.client.sendto(command.encode(), str(self.sock_path))
|
|
try:
|
|
return self.client.recv(512).decode().strip()
|
|
except socket.timeout:
|
|
return ""
|
|
|
|
def frame(self):
|
|
data = self.fb.read_bytes()
|
|
return hashlib.sha256(data).hexdigest(), any(data)
|
|
|
|
def backlight_value(self):
|
|
return self.backlight.read_text().strip()
|
|
|
|
def close(self):
|
|
try:
|
|
self.send("QUIT")
|
|
except OSError:
|
|
pass
|
|
self.client.close()
|
|
try:
|
|
self.proc.wait(timeout=3)
|
|
except subprocess.TimeoutExpired:
|
|
self.proc.kill()
|
|
self.proc.wait()
|
|
if self.client_path.exists():
|
|
self.client_path.unlink()
|
|
|
|
|
|
def wait_for(predicate, timeout=3.0):
|
|
end = time.time() + timeout
|
|
while time.time() < end:
|
|
if predicate():
|
|
return True
|
|
time.sleep(0.05)
|
|
return False
|
|
|
|
|
|
def main():
|
|
if not SRC.is_file() or not VOL_SRC.is_file():
|
|
sys.stderr.write("FAIL: missing daemon sources\n")
|
|
return 1
|
|
with tempfile.TemporaryDirectory(prefix="bananarchy-cover-") as tmp:
|
|
root = pathlib.Path(tmp)
|
|
exe = root / "cover-idle"
|
|
build = subprocess.run(
|
|
["gcc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror",
|
|
"-I" + str(SRC.parent), str(SRC), "-o", str(exe)],
|
|
capture_output=True, text=True)
|
|
if build.returncode:
|
|
sys.stderr.write(build.stderr)
|
|
return 1
|
|
vbuild = subprocess.run(
|
|
["gcc", "-std=c11", "-O2", "-Wall", "-Wextra", "-Werror",
|
|
"-I" + str(VOL_SRC.parent), str(VOL_SRC), "-o", str(root / "volume-keys")],
|
|
capture_output=True, text=True)
|
|
if vbuild.returncode:
|
|
sys.stderr.write(vbuild.stderr)
|
|
return 1
|
|
source = SRC.read_text(encoding="utf-8")
|
|
for token in ("FBIOBLANK", "FB_BLANK_POWERDOWN", "cover_is_lit",
|
|
"set_backlight"):
|
|
if token not in source:
|
|
sys.stderr.write("FAIL: cover daemon lost %s\n" % token)
|
|
return 1
|
|
common_src = COMMON_H.read_text(encoding="utf-8")
|
|
if "struct timeval time;" in common_src or \
|
|
"unsigned long tv_sec;" not in common_src or \
|
|
"ba_input_event_abi" not in common_src:
|
|
sys.stderr.write(
|
|
"FAIL: struct input_event in common.h regressed to time64 timeval\n")
|
|
return 1
|
|
print("[ok] host build of the compiled cover and volume-key daemons")
|
|
|
|
main_cfg = root / "idle_blank_timeout"
|
|
main_cfg.write_text("300\n")
|
|
config = root / "cover.conf"
|
|
config.write_text(
|
|
"socket_path = %s\nfb_device = %s\nbacklight_path = %s\n"
|
|
"brightness = 160\nblank_timeout = 2\n" %
|
|
(root / "cover.sock", root / "fb1", root / "backlight"),
|
|
encoding="utf-8")
|
|
daemon = Cover(root, exe, config, main_cfg)
|
|
try:
|
|
if "pong" not in daemon.send("PING"):
|
|
sys.stderr.write("FAIL: cover daemon did not answer PING\n")
|
|
return 1
|
|
_, lit = daemon.frame()
|
|
if lit or daemon.backlight_value() != "0":
|
|
sys.stderr.write("FAIL: a boot-open flip must leave the cover fully off\n")
|
|
return 1
|
|
print("[ok] open flip: cover is fully off")
|
|
|
|
daemon.send("LID CLOSED")
|
|
if not wait_for(lambda: not daemon.frame()[1]):
|
|
sys.stderr.write("FAIL: closing the flip did not blank the cover\n")
|
|
return 1
|
|
if "visible=1" in daemon.send("STATUS"):
|
|
sys.stderr.write("FAIL: closing the flip lit the cover without a button\n")
|
|
return 1
|
|
print("[ok] closed flip: cover waits for an external button")
|
|
|
|
daemon.send("NETWORK 4G SIG75 WIFI")
|
|
daemon.send("BATTERY 82")
|
|
before, _ = daemon.frame()
|
|
daemon.send("BUTTON")
|
|
if not wait_for(lambda: daemon.frame()[1]):
|
|
sys.stderr.write("FAIL: BUTTON did not show the clock/indicators\n")
|
|
return 1
|
|
if daemon.backlight_value() != "160" or "visible=1" not in daemon.send("STATUS"):
|
|
sys.stderr.write("FAIL: BUTTON did not enable the backlight\n")
|
|
return 1
|
|
with_clock, _ = daemon.frame()
|
|
if before == with_clock:
|
|
sys.stderr.write("FAIL: no frame was drawn on BUTTON\n")
|
|
return 1
|
|
raw_fb = daemon.fb.read_bytes()
|
|
bg = struct.pack("<I", (8 << 16) | (12 << 8) | 26)
|
|
for band_name, y0, y1 in (("header", 20, 40),
|
|
("clock", 85, 130),
|
|
("date", 135, 160)):
|
|
xs = [x for y in range(y0, y1) for x in range(FB_WIDTH)
|
|
if raw_fb[(y * FB_WIDTH + x) * 4:(y * FB_WIDTH + x + 1) * 4] != bg]
|
|
if not xs:
|
|
sys.stderr.write("FAIL: missing %s ink on 240x240 frame\n" % band_name)
|
|
return 1
|
|
left_margin = min(xs)
|
|
right_margin = FB_WIDTH - 1 - max(xs)
|
|
if abs(left_margin - right_margin) > 1:
|
|
sys.stderr.write(
|
|
"FAIL: %s is off-center on 240x240 (left=%d right=%d)\n" %
|
|
(band_name, left_margin, right_margin))
|
|
return 1
|
|
print("[ok] external button: centered clock/date, battery and backlight on")
|
|
|
|
daemon.send("NETWORK 3G SIG20")
|
|
if not wait_for(lambda: daemon.frame()[0] != with_clock):
|
|
sys.stderr.write("FAIL: network indicators are not rendered\n")
|
|
return 1
|
|
if "network=3G SIG20" not in daemon.send("STATUS"):
|
|
sys.stderr.write("FAIL: NETWORK command was not stored\n")
|
|
return 1
|
|
print("[ok] network indicators are republished on the cover")
|
|
|
|
if not wait_for(lambda: not daemon.frame()[1], timeout=5):
|
|
sys.stderr.write("FAIL: cover did not respect the blank timeout\n")
|
|
return 1
|
|
if daemon.backlight_value() != "0" or "visible=0" not in daemon.send("STATUS"):
|
|
sys.stderr.write("FAIL: blank timeout did not switch the cover fully off "
|
|
"(backlight=%r status=%r)\n" %
|
|
(daemon.backlight_value(), daemon.send("STATUS")))
|
|
return 1
|
|
print("[ok] blank timeout: cover blanks with no further button")
|
|
|
|
daemon.send("BUTTON")
|
|
wait_for(lambda: daemon.frame()[1])
|
|
daemon.send("LID OPEN")
|
|
if not wait_for(lambda: not daemon.frame()[1]):
|
|
sys.stderr.write("FAIL: opening the flip did not switch the cover off\n")
|
|
return 1
|
|
daemon.send("BUTTON")
|
|
time.sleep(0.3)
|
|
if daemon.frame()[1] or "visible=1" in daemon.send("STATUS"):
|
|
sys.stderr.write("FAIL: BUTTON was honoured while the flip was open\n")
|
|
return 1
|
|
print("[ok] open flip overrides BUTTON and keeps the cover off")
|
|
finally:
|
|
daemon.close()
|
|
|
|
# A second daemon follows Config -> Screen blank (auto); 0 = never blank.
|
|
sub = root / "auto"
|
|
sub.mkdir()
|
|
config2 = root / "cover-auto.conf"
|
|
config2.write_text(
|
|
"socket_path = %s\nfb_device = %s\nbacklight_path = %s\n"
|
|
"brightness = 160\nblank_timeout = auto\n" %
|
|
(sub / "cover.sock", sub / "fb1", sub / "backlight"),
|
|
encoding="utf-8")
|
|
main_cfg.write_text("0\n")
|
|
auth_lid = sub / "lid-state"
|
|
auth_lid.write_text("closed\n")
|
|
daemon2 = Cover(sub, exe, config2, main_cfg, lid_state=auth_lid)
|
|
try:
|
|
daemon2.send("LID CLOSED")
|
|
daemon2.send("BUTTON")
|
|
if not wait_for(lambda: daemon2.frame()[1]):
|
|
sys.stderr.write("FAIL: auto timeout daemon did not light the cover\n")
|
|
return 1
|
|
# A bogus LID OPEN (such as dwm misreading SW_KEYPAD_SLIDE=1 on close)
|
|
# must be ignored while bananarchy-lid's state file reports "closed".
|
|
daemon2.send("LID OPEN")
|
|
time.sleep(0.15)
|
|
if not daemon2.frame()[1] or "visible=1" not in daemon2.send("STATUS") or \
|
|
"lid=closed" not in daemon2.send("STATUS"):
|
|
sys.stderr.write(
|
|
"FAIL: bogus LID OPEN blanked the cover while lid-state=closed\n")
|
|
return 1
|
|
time.sleep(2.5)
|
|
if not daemon2.frame()[1] or "visible=1" not in daemon2.send("STATUS"):
|
|
sys.stderr.write("FAIL: Screen blank = 0 should keep the cover on\n")
|
|
return 1
|
|
if "blank_ms=0" not in daemon2.send("STATUS"):
|
|
sys.stderr.write("FAIL: auto timeout did not read the main Screen blank config\n")
|
|
return 1
|
|
print("[ok] auto timeout follows Config -> Screen blank (0 = never)")
|
|
|
|
# Changing Config -> Screen blank at runtime updates the live daemon.
|
|
noidle = sub / "sxmo.noidle"
|
|
main_cfg.write_text("1\n")
|
|
daemon2.send("REFRESH")
|
|
if not wait_for(lambda: not daemon2.frame()[1], timeout=3):
|
|
sys.stderr.write("FAIL: runtime Screen blank update did not blank cover\n")
|
|
return 1
|
|
if "blank_ms=1000" not in daemon2.send("STATUS") or \
|
|
"visible=0" not in daemon2.send("STATUS"):
|
|
sys.stderr.write("FAIL: runtime Screen blank update did not refresh blank_ms\n")
|
|
return 1
|
|
noidle.write_text("")
|
|
if "blank_ms=0" not in daemon2.send("STATUS"):
|
|
sys.stderr.write("FAIL: sxmo.noidle did not disable cover blanking\n")
|
|
return 1
|
|
noidle.unlink()
|
|
daemon2.send("BUTTON")
|
|
if not wait_for(lambda: daemon2.frame()[1]):
|
|
sys.stderr.write("FAIL: BUTTON after runtime config update did not wake cover\n")
|
|
return 1
|
|
if not wait_for(lambda: not daemon2.frame()[1], timeout=3):
|
|
sys.stderr.write("FAIL: cover did not blank after updated 1 s main timeout\n")
|
|
return 1
|
|
print("[ok] runtime Screen blank changes and sxmo.noidle apply live")
|
|
|
|
# End-to-end evdev binary record -> bananarchy-volume-keys -> cover wake.
|
|
ev_fifo = sub / "event0"
|
|
os.mkfifo(ev_fifo)
|
|
keep_w = os.open(ev_fifo, os.O_RDWR | os.O_NONBLOCK)
|
|
lid_file = sub / "lid-state"
|
|
lid_file.write_text("closed\n")
|
|
vol_env = dict(os.environ)
|
|
vol_env.update({
|
|
"BANANARCHY_VOLUME_LOCK": str(sub / "volume.lock"),
|
|
"BANANARCHY_LID_STATE": str(lid_file),
|
|
"BANANARCHY_COVER_SOCKET": str(sub / "cover.sock"),
|
|
"BANANARCHY_VOLUME_CLIENT_SOCKET": str(sub / "vol-client.sock"),
|
|
"BANANARCHY_INPUT_GLOB": str(ev_fifo),
|
|
})
|
|
vol_proc = subprocess.Popen(
|
|
[str(root / "volume-keys")], env=vol_env,
|
|
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
try:
|
|
main_cfg.write_text("0\n")
|
|
daemon2.send("REFRESH")
|
|
time.sleep(0.15)
|
|
os.write(keep_w, struct.pack("LLHHi", 1, 0, 1, 115, 1))
|
|
if not wait_for(lambda: daemon2.frame()[1], timeout=3):
|
|
sys.stderr.write(
|
|
"FAIL: evdev KEY_VOLUMEUP did not wake cover via volume-keys\n")
|
|
return 1
|
|
daemon2.send("BLANK")
|
|
if not wait_for(lambda: not daemon2.frame()[1], timeout=3):
|
|
sys.stderr.write("FAIL: BLANK did not clear cover before camera key\n")
|
|
return 1
|
|
os.write(keep_w, struct.pack("LLHHi", 2, 0, 1, 212, 1))
|
|
if not wait_for(lambda: daemon2.frame()[1], timeout=3):
|
|
sys.stderr.write(
|
|
"FAIL: evdev KEY_CAMERA did not wake cover via volume-keys\n")
|
|
return 1
|
|
print("[ok] evdev outer side buttons wake cover end-to-end")
|
|
finally:
|
|
vol_proc.kill()
|
|
vol_proc.wait()
|
|
os.close(keep_w)
|
|
finally:
|
|
daemon2.close()
|
|
|
|
sub3 = root / "run3"
|
|
sub3.mkdir()
|
|
main_cfg3 = sub3 / "sxmo.noidle"
|
|
main_cfg3.write_text("1\n")
|
|
events_log = sub3 / "cover-events.log"
|
|
event_stub = sub3 / "cover-event-stub.sh"
|
|
event_stub.write_text(
|
|
"#!/bin/sh\n"
|
|
f'printf "%s\\n" "$*" >> "{events_log}"\n',
|
|
encoding="utf-8",
|
|
)
|
|
event_stub.chmod(0o755)
|
|
lt_path = sub3 / "localtime"
|
|
tz_file = sub3 / "timezone"
|
|
utc_zi = pathlib.Path("/usr/share/zoneinfo/UTC")
|
|
ny_zi = pathlib.Path("/usr/share/zoneinfo/America/New_York")
|
|
lt_path.symlink_to(utc_zi)
|
|
tz_file.write_text("UTC\n", encoding="utf-8")
|
|
cfg3 = sub3 / "cover.conf"
|
|
cfg3.write_text(
|
|
"enabled = 1\n"
|
|
"backend = fb\n"
|
|
"blank_timeout = 1\n"
|
|
f"socket_path = {sub3 / 'cover.sock'}\n"
|
|
f"fb_device = {sub3 / 'fb1'}\n"
|
|
f"backlight_path = {sub3 / 'backlight'}\n"
|
|
"brightness = 160\n",
|
|
encoding="utf-8",
|
|
)
|
|
daemon3 = Cover(
|
|
sub3,
|
|
exe,
|
|
cfg3,
|
|
main_cfg3,
|
|
extra_env={
|
|
"BANANARCHY_COVER_EVENT_CMD": str(event_stub),
|
|
"BANANARCHY_TZ_LOCALTIME": str(lt_path),
|
|
"BANANARCHY_TZ_FILE": str(tz_file),
|
|
},
|
|
)
|
|
try:
|
|
daemon3.send("LID CLOSED")
|
|
daemon3.send("CALL incoming|+380501234567|Alice|SIM1")
|
|
if not wait_for(
|
|
lambda: "call=incoming" in daemon3.send("STATUS") and
|
|
"visible=1" in daemon3.send("STATUS"),
|
|
timeout=3,
|
|
):
|
|
sys.stderr.write("FAIL: CALL incoming did not wake cover cleanly\n")
|
|
return 1
|
|
# Cover must stay lit past the 1 s blank timeout while incoming call rings.
|
|
time.sleep(1.25)
|
|
if not daemon3.frame()[1] or "visible=1" not in daemon3.send("STATUS"):
|
|
sys.stderr.write("FAIL: cover blanked during active incoming call\n")
|
|
return 1
|
|
daemon3.send("BUTTON VOLUP")
|
|
if not wait_for(lambda: "call=muted" in daemon3.send("STATUS"), timeout=3):
|
|
sys.stderr.write("FAIL: BUTTON VOLUP did not mute incoming call\n")
|
|
return 1
|
|
if not wait_for(
|
|
lambda: events_log.exists() and "mute-ring" in events_log.read_text(),
|
|
timeout=2,
|
|
):
|
|
sys.stderr.write("FAIL: BUTTON VOLUP did not invoke mute-ring bridge\n")
|
|
return 1
|
|
daemon3.send("BUTTON POWER")
|
|
if not wait_for(lambda: "call=none" in daemon3.send("STATUS"), timeout=3):
|
|
sys.stderr.write("FAIL: BUTTON POWER did not hang up incoming call\n")
|
|
return 1
|
|
if not wait_for(
|
|
lambda: "hangup-call" in events_log.read_text(),
|
|
timeout=2,
|
|
):
|
|
sys.stderr.write("FAIL: BUTTON POWER did not invoke hangup-call bridge\n")
|
|
return 1
|
|
# Late CALL muted|-|-|- arriving after hangup must not resurrect call=muted.
|
|
daemon3.send("CALL muted|-|-|-")
|
|
if "call=none" not in daemon3.send("STATUS"):
|
|
sys.stderr.write("FAIL: stale CALL muted overwrote call=none\n")
|
|
return 1
|
|
main_cfg3.write_text("0\n")
|
|
daemon3.send("BUTTON")
|
|
if not wait_for(lambda: daemon3.frame()[1], timeout=3):
|
|
sys.stderr.write("FAIL: cover did not show idle clock after call hangup\n")
|
|
return 1
|
|
frame_utc = daemon3.frame()[0]
|
|
lt_path.unlink()
|
|
lt_path.symlink_to(ny_zi)
|
|
tz_file.write_text("America/New_York\n", encoding="utf-8")
|
|
daemon3.send("REFRESH")
|
|
if not wait_for(lambda: daemon3.frame()[0] != frame_utc, timeout=3):
|
|
sys.stderr.write("FAIL: live timezone change + REFRESH did not update cover clock\n")
|
|
return 1
|
|
if daemon3.backlight_value() == "0":
|
|
sys.stderr.write("FAIL: expected lit backlight before SIGTERM test\n")
|
|
return 1
|
|
daemon3.proc.terminate()
|
|
rc = daemon3.proc.wait(timeout=3)
|
|
if rc != 0:
|
|
sys.stderr.write(f"FAIL: cover daemon exited {rc} on SIGTERM\n")
|
|
return 1
|
|
if daemon3.backlight_value() != "0":
|
|
sys.stderr.write(f"FAIL: SIGTERM did not blank backlight (got {daemon3.backlight_value()!r})\n")
|
|
return 1
|
|
print("[ok] closed-flip incoming call UI, side-key mute/hangup, and live TZ refresh")
|
|
finally:
|
|
daemon3.close()
|
|
|
|
sub4 = pathlib.Path(tmp) / "cover_event_bridge"
|
|
sub4.mkdir()
|
|
cover_event_sh = pathlib.Path(__file__).resolve().parents[1] / "overlay/rootfs/usr/bin/bananarchy-cover-event.sh"
|
|
lid_profile = sub4 / "lid-profile"
|
|
lid_profile.write_text("flip\n", encoding="utf-8")
|
|
contacts = sub4 / "contacts.tsv"
|
|
contacts.write_text("+380501234567\tAlice\n", encoding="utf-8")
|
|
ctl_log = sub4 / "coverctl.log"
|
|
fake_ctl = sub4 / "coverctl"
|
|
fake_ctl.write_text(
|
|
f"#!/bin/sh\nprintf '%s\\n' \"$*\" >> {ctl_log}\n",
|
|
encoding="utf-8",
|
|
)
|
|
fake_ctl.chmod(0o755)
|
|
ring_file = sub4 / "sxmo_call_ringing"
|
|
ring_file.write_text("+380501234567\n", encoding="utf-8")
|
|
fifo_path = sub4 / "callscreen.fifo"
|
|
os.mkfifo(fifo_path)
|
|
fifo_fd = os.open(fifo_path, os.O_RDWR | os.O_NONBLOCK)
|
|
try:
|
|
bridge_env = os.environ.copy()
|
|
bridge_env.update({
|
|
"BANANARCHY_LID_PROFILE_FILE": str(lid_profile),
|
|
"BANANARCHY_COVERCTL_BIN": str(fake_ctl),
|
|
"BANANARCHY_CALLSCREEN_FIFO": str(fifo_path),
|
|
"BANANARCHY_RINGING_FILE": str(ring_file),
|
|
"BANANARCHY_ACTIVE_CALL_FILE": str(sub4 / "sxmo_active_call"),
|
|
"SXMO_CONTACTFILE": str(contacts),
|
|
"BANANARCHY_COVER_TEST_USER_SH": "1",
|
|
})
|
|
for args in (
|
|
["ring", "+380501234567", "SIM1"],
|
|
["ring", "Alice"],
|
|
["mute-ring"],
|
|
["hangup-call"],
|
|
):
|
|
res = subprocess.run([str(cover_event_sh), *args], env=bridge_env, check=False)
|
|
if res.returncode != 0:
|
|
sys.stderr.write(f"FAIL: bananarchy-cover-event.sh {args} exited {res.returncode}\n")
|
|
return 1
|
|
ctl_lines = ctl_log.read_text(encoding="utf-8").splitlines()
|
|
if "CALL incoming|+380501234567|Alice|SIM1" not in ctl_lines:
|
|
sys.stderr.write(f"FAIL: unexpected ring contact resolution: {ctl_lines!r}\n")
|
|
return 1
|
|
if "CALL incoming|-|Alice|-" not in ctl_lines:
|
|
sys.stderr.write(f"FAIL: unexpected contact-only ring payload: {ctl_lines!r}\n")
|
|
return 1
|
|
if ring_file.exists():
|
|
sys.stderr.write("FAIL: hangup-call did not remove sxmo_call_ringing\n")
|
|
return 1
|
|
fifo_data = os.read(fifo_fd, 4096).decode("utf-8", errors="replace")
|
|
if "MUTE_RING" not in fifo_data or "HANGUP_CLOSE" not in fifo_data:
|
|
sys.stderr.write(f"FAIL: callscreen FIFO missing mute/hangup commands: {fifo_data!r}\n")
|
|
return 1
|
|
print("[ok] cover event bridge resolves contacts and dispatches mute/hangup")
|
|
finally:
|
|
os.close(fifo_fd)
|
|
print("cover display behaviour: all checks passed")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|