From 7dda5d81e376307ce945a3b5e874ad0aa640d441 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:46:19 -0647 Subject: [PATCH 1/7] omamobile-shell 0.2.33: NFC polls only while the screen is lit A poll loop is the NFC radio searching for cards. On the Pixel 9a it costs about 60 mA with the screen off (252 mA against 315 mA, awake, 10-27), and stock Android polls only while the screen is on. omamobile-nfc-open now stops neard's poll loop once every display connector has been DPMS off for 4 s, and starts it again when the screen lights, unless the NFC switch is off. Tested on the 9a: no controller interrupts with the screen off, polling again within 2 s of it lighting. --- .../omamobile-shell/bin/omamobile-nfc-open | 65 +++++++++++++++++++ packages/omamobile-shell/test/all | 1 + packages/omamobile-shell/version | 2 +- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-shell/bin/omamobile-nfc-open b/packages/omamobile-shell/bin/omamobile-nfc-open index 734ea024f..39d8eb2c0 100644 --- a/packages/omamobile-shell/bin/omamobile-nfc-open +++ b/packages/omamobile-shell/bin/omamobile-nfc-open @@ -15,6 +15,11 @@ told when the kernel blocks the radio, so on a block the adapter is powered off through neard (on a kernel that already did, neard's view stays stale), and on an unblock neard is restarted: it finds the adapter again, powers it (DefaultPowered), and a new poll loop starts. + +And it polls only while the screen is lit, as stock Android does: with every +display connector off (DPMS) for SCREEN_OFF_SECONDS, the poll loop stops, +and it starts again when the screen comes on. A poll loop is the radio +searching for cards, which costs the Pixel 9a about 60 mA. """ import glob import subprocess @@ -30,6 +35,7 @@ NEARD = "org.neard" RECORD = "org.neard.Record" ADAPTER = "org.neard.Adapter" REPEAT_SECONDS = 3.0 +SCREEN_OFF_SECONDS = 4 last = {"uri": None, "time": 0.0} @@ -141,6 +147,61 @@ def set_powered(bus, powered): rfkill = {"blocked": None} +screen = {"lit": True, "dark_for": 0} + + +def screen_lit(): + """True unless every connected display connector reports DPMS off.""" + states = [] + for path in glob.glob("/sys/class/drm/card*-*"): + try: + with open(f"{path}/status") as f: + if f.read().strip() != "connected": + continue + with open(f"{path}/dpms") as f: + states.append(f.read().strip()) + except OSError: + continue + return not states or any(state == "On" for state in states) + + +def stop_polling(bus): + try: + objects = bus.call_sync(NEARD, "/", "org.freedesktop.DBus.ObjectManager", + "GetManagedObjects", None, None, + Gio.DBusCallFlags.NONE, -1, None).unpack()[0] + except GLib.Error: + return + for path, interfaces in objects.items(): + adapter = interfaces.get(ADAPTER) + if adapter is None or not adapter.get("Polling"): + continue + try: + bus.call_sync(NEARD, path, ADAPTER, "StopPollLoop", None, None, + Gio.DBusCallFlags.NONE, -1, None) + log(f"screen off: polling stopped on {path}") + except GLib.Error as error: + log(f"could not stop polling on {path}: {error.message}") + + +def follow_screen(bus): + """Every 2 s: stop the poll loop once the screen has been off for a while, + start it again when the screen lights (unless NFC is switched off).""" + lit = screen_lit() + if lit: + screen["dark_for"] = 0 + if not screen["lit"]: + screen["lit"] = True + if not rfkill["blocked"]: + log("screen on: polling again") + start_polling(bus) + return True + screen["dark_for"] += 2 + if screen["lit"] and screen["dark_for"] >= SCREEN_OFF_SECONDS: + screen["lit"] = False + if not rfkill["blocked"]: + stop_polling(bus) + return True def follow_rfkill(bus): @@ -154,6 +215,9 @@ def follow_rfkill(bus): elif previous is not None: log("NFC switched on: restarting neard") restart_neard(bus) + if not screen["lit"]: + # neard powers the adapter and polls by itself: stop it again + GLib.timeout_add_seconds(4, lambda: stop_polling(bus) or False) return True @@ -172,6 +236,7 @@ def main(): # earlier run of it): start from a fresh neard. restart_neard(bus) GLib.timeout_add_seconds(2, follow_rfkill, bus) + GLib.timeout_add_seconds(2, follow_screen, bus) GLib.MainLoop().run() diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 37dc8b355..b202a8128 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -376,6 +376,7 @@ grep -c 'Quickshell.execDetached(HomeModel.urlLaunchArgv(text))' plugins/omamobi grep -c 'HomeModel.commandLaunchArgv(\["sh", "-c", tap\])' plugins/omamobile.home/CommandWidget.qml >/dev/null || fail "the text widget's tap goes through omamobile-launch" grep -c '"omamobile-launch", "url", uri' bin/omamobile-nfc-open >/dev/null || fail "NFC links open through omamobile-launch" grep -c 'GLib.timeout_add_seconds(2, follow_rfkill, bus)' bin/omamobile-nfc-open >/dev/null || fail "the NFC service follows the rfkill switch" +grep -c 'GLib.timeout_add_seconds(2, follow_screen, bus)' bin/omamobile-nfc-open >/dev/null || fail "the NFC service stops polling with the screen off" grep -c '"systemctl", "restart", "neard"' bin/omamobile-nfc-open >/dev/null || fail "an NFC unblock restarts neard" grep -c '^Requires=neard' systemd/omamobile-nfc-open.service >/dev/null && fail "omamobile-nfc-open restarts neard, so it must not Require= it (the restart would loop)" grep -c '"omamobile-launch", "empty"' bin/omamobile-widget >/dev/null || fail "the widget agent's terminal gets an empty workspace" diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index a8498651b..d9955e456 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.32 +0.2.33 From 24d50df330627046e8f239fd04d1c1983c94dae2 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 07:47:19 -0647 Subject: [PATCH 2/7] omamobile-shell 0.2.33: the screen-off stop holds while the screen stays dark The stop was a single shot on the lit-to-dark transition, so anything that started polling afterwards kept it on until the next screen cycle: the unblock path's start_polling retries, the 9a's sleep hook after a wake, or neard restarted by systemd. Now every 2 s check stops any poll loop once the screen has been dark for 4 s, and start_polling powers the adapter but leaves the loop off while it's dark. The one-shot stop after an unblock is gone. test/nfc-screen.py checks screen_lit() against temporary sysfs trees. --- .../omamobile-shell/bin/omamobile-nfc-open | 19 ++++++------ packages/omamobile-shell/test/all | 3 ++ packages/omamobile-shell/test/nfc-screen.py | 31 +++++++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 packages/omamobile-shell/test/nfc-screen.py diff --git a/packages/omamobile-shell/bin/omamobile-nfc-open b/packages/omamobile-shell/bin/omamobile-nfc-open index 39d8eb2c0..193f9ee4a 100644 --- a/packages/omamobile-shell/bin/omamobile-nfc-open +++ b/packages/omamobile-shell/bin/omamobile-nfc-open @@ -102,7 +102,9 @@ def start_polling(bus): bus.call_sync(NEARD, path, "org.freedesktop.DBus.Properties", "Set", GLib.Variant("(ssv)", (ADAPTER, "Powered", GLib.Variant("b", True))), None, Gio.DBusCallFlags.NONE, -1, None) - if not adapter.get("Polling"): + if not adapter.get("Polling") and not screen["lit"]: + log(f"screen off: {path} powered, polling waits for the screen") + elif not adapter.get("Polling"): try: bus.call_sync(NEARD, path, ADAPTER, "StartPollLoop", GLib.Variant("(s)", ("Initiator",)), None, @@ -150,10 +152,10 @@ rfkill = {"blocked": None} screen = {"lit": True, "dark_for": 0} -def screen_lit(): +def screen_lit(drm="/sys/class/drm"): """True unless every connected display connector reports DPMS off.""" states = [] - for path in glob.glob("/sys/class/drm/card*-*"): + for path in glob.glob(f"{drm}/card*-*"): try: with open(f"{path}/status") as f: if f.read().strip() != "connected": @@ -185,8 +187,10 @@ def stop_polling(bus): def follow_screen(bus): - """Every 2 s: stop the poll loop once the screen has been off for a while, - start it again when the screen lights (unless NFC is switched off).""" + """Every 2 s: once the screen has been off for a while, stop any poll loop + (each time, so one that neard, a restart or the sleep hook started while + the screen was dark stops too); start it again when the screen lights + (unless NFC is switched off).""" lit = screen_lit() if lit: screen["dark_for"] = 0 @@ -197,7 +201,7 @@ def follow_screen(bus): start_polling(bus) return True screen["dark_for"] += 2 - if screen["lit"] and screen["dark_for"] >= SCREEN_OFF_SECONDS: + if screen["dark_for"] >= SCREEN_OFF_SECONDS: screen["lit"] = False if not rfkill["blocked"]: stop_polling(bus) @@ -215,9 +219,6 @@ def follow_rfkill(bus): elif previous is not None: log("NFC switched on: restarting neard") restart_neard(bus) - if not screen["lit"]: - # neard powers the adapter and polls by itself: stop it again - GLib.timeout_add_seconds(4, lambda: stop_polling(bus) or False) return True diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index b202a8128..64beb8250 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -377,6 +377,9 @@ grep -c 'HomeModel.commandLaunchArgv(\["sh", "-c", tap\])' plugins/omamobile.hom grep -c '"omamobile-launch", "url", uri' bin/omamobile-nfc-open >/dev/null || fail "NFC links open through omamobile-launch" grep -c 'GLib.timeout_add_seconds(2, follow_rfkill, bus)' bin/omamobile-nfc-open >/dev/null || fail "the NFC service follows the rfkill switch" grep -c 'GLib.timeout_add_seconds(2, follow_screen, bus)' bin/omamobile-nfc-open >/dev/null || fail "the NFC service stops polling with the screen off" +python3 -B test/nfc-screen.py >/dev/null || { python3 -B test/nfc-screen.py | grep -v '^ok'; fail "screen_lit reads the connectors"; } +grep -c 'polling waits for the screen' bin/omamobile-nfc-open >/dev/null || fail "start_polling leaves the loop off while the screen is dark" +grep -c 'timeout_add_seconds(4' bin/omamobile-nfc-open >/dev/null && fail "the one-shot stop is gone: the screen check stops polling every time" grep -c '"systemctl", "restart", "neard"' bin/omamobile-nfc-open >/dev/null || fail "an NFC unblock restarts neard" grep -c '^Requires=neard' systemd/omamobile-nfc-open.service >/dev/null && fail "omamobile-nfc-open restarts neard, so it must not Require= it (the restart would loop)" grep -c '"omamobile-launch", "empty"' bin/omamobile-widget >/dev/null || fail "the widget agent's terminal gets an empty workspace" diff --git a/packages/omamobile-shell/test/nfc-screen.py b/packages/omamobile-shell/test/nfc-screen.py new file mode 100644 index 000000000..0c0f63010 --- /dev/null +++ b/packages/omamobile-shell/test/nfc-screen.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: MIT +# omamobile-nfc-open's screen_lit() against temporary sysfs trees: connected +# and disconnected connectors, DPMS On and Off, and no connectors at all. +import importlib.machinery, importlib.util, os, sys, tempfile, types +sys.dont_write_bytecode = True # never a __pycache__ next to bin/omamobile-nfc-open + +gi = types.ModuleType("gi"); gi.require_version = lambda *a: None +repo = types.ModuleType("gi.repository"); repo.Gio = repo.GLib = types.SimpleNamespace() +sys.modules.update({"gi": gi, "gi.repository": repo}) +loader = importlib.machinery.SourceFileLoader("nfc_open", os.path.join(os.path.dirname(__file__), "..", "bin", "omamobile-nfc-open")) +nfc = importlib.util.module_from_spec(importlib.util.spec_from_loader("nfc_open", loader)); loader.exec_module(nfc) + +fails = 0 +def case(name, connectors, want): + global fails + with tempfile.TemporaryDirectory() as drm: + for conn, (status, dpms) in connectors.items(): + os.makedirs(f"{drm}/{conn}") + open(f"{drm}/{conn}/status", "w").write(status + "\n") + open(f"{drm}/{conn}/dpms", "w").write(dpms + "\n") + got = nfc.screen_lit(drm) + print(("ok" if got == want else "not ok") + f" - {name}") + fails += got != want + +case("panel on", {"card1-DSI-1": ("connected", "On")}, True) +case("panel off", {"card1-DSI-1": ("connected", "Off")}, False) +case("panel off, a disconnected output on", {"card1-DSI-1": ("connected", "Off"), "card1-DP-1": ("disconnected", "On")}, False) +case("two connected, one on", {"card1-DSI-1": ("connected", "Off"), "card1-HDMI-A-1": ("connected", "On")}, True) +case("only a disconnected output", {"card1-DP-1": ("disconnected", "Off")}, True) +case("no connectors at all", {}, True) +sys.exit(1 if fails else 0) From 891ecb977c70fff6d1d7778632b7636b616c539e Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 03:56:03 -0647 Subject: [PATCH 3/7] omamobile-shell 0.2.34: home widgets see the phone they run on The OWL host answered every device and system query as a Pixel 7 Pro (gs201, 1440x3120, codename cheetah), so a widget on the Pixel 9a or any other port showed the wrong phone. The model and the compatible list now come from the device tree; known boards add the panel's size, rate and density, and an unknown one reports its model and SoC with no display. --- .../plugins/omamobile.home/OwlPhoneHost.qml | 15 ++++++--- .../plugins/omamobile.home/owl/phone.js | 32 ++++++++++++++++--- packages/omamobile-shell/test/owl-core.js | 11 +++++++ packages/omamobile-shell/version | 2 +- 4 files changed, 50 insertions(+), 10 deletions(-) diff --git a/packages/omamobile-shell/plugins/omamobile.home/OwlPhoneHost.qml b/packages/omamobile-shell/plugins/omamobile.home/OwlPhoneHost.qml index 1b241627b..cd283e662 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/OwlPhoneHost.qml +++ b/packages/omamobile-shell/plugins/omamobile.home/OwlPhoneHost.qml @@ -151,16 +151,23 @@ QtObject { if (kind === "media") { fromCommand("playerctl metadata --format " + JSON.stringify(Phone.MEDIA_FORMAT) + " 2>/dev/null", Phone.mediaFrom); return } if (kind === "modes") { fromCommand("brightnessctl --device=white:torch get 2>/dev/null || echo; makoctl mode 2>/dev/null", Phone.modesFrom); return } if (kind === "system") { - fromCommand("cat /proc/meminfo; echo '@@'; cat /proc/uptime; echo '@@'; uname -r; echo '@@'; df -B1 --output=size,used / | tail -1", function(t) { - const parts = t.split("@@\n") - return Phone.systemFrom(parts[0], parts[1], parts[2], parts[3]) + fromCommand("cat /proc/meminfo; echo '@@'; cat /proc/uptime; echo '@@'; uname -r; echo '@@'; df -B1 --output=size,used / | tail -1; echo '@@@'; " + Phone.DEVICE_COMMAND, function(t) { + const halves = t.split("@@@\n") + const parts = halves[0].split("@@\n") + return Phone.systemFrom(parts[0], parts[1], parts[2], parts[3], Phone.boardFrom(halves[1])) }) return } if (kind === "battery") { fromCommand(Phone.BATTERY_COMMAND, Phone.batteryFrom); return } if (kind === "alarm") { done({ value: { set: false, time: null, app: null } }); return } if (kind === "notifications") { done({ value: { available: false, count: 0, items: [] } }); return } - if (kind === "device") { done({ value: { model: "Pixel 7 Pro", maker: "Google", android: null, sdk: null, soc: "gs201" } }); return } + if (kind === "device") { + fromCommand(Phone.DEVICE_COMMAND, function(t) { + const b = Phone.boardFrom(t) + return { model: b.model, maker: b.maker, android: null, sdk: null, soc: b.soc } + }) + return + } done({ value: null }) } diff --git a/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js b/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js index 50a334ff7..e2254a946 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js +++ b/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js @@ -305,14 +305,35 @@ function batteryFrom(text) { temp: null, voltage: null, health: null, plugged: null, technology: null, cycles: null } } -// /proc/meminfo, /proc/uptime, uname and df -> android.system. -function systemFrom(meminfo, uptime, kernel, df) { +// The board from the device tree: "model" and the "compatible" list, read by +// DEVICE_COMMAND as "\n@@\n". +var DEVICE_COMMAND = "tr -d '\\0' < /proc/device-tree/model 2>/dev/null; echo; echo '@@'; tr '\\0' '\\n' < /proc/device-tree/compatible 2>/dev/null" +// What the device tree doesn't say, for the boards Omarchy Mobile runs on. +var BOARDS = { + cheetah: { model: "Pixel 7 Pro", soc: "gs201", display: { width: 1440, height: 3120, hz: 120, dpi: 512 } }, + tegu: { model: "Pixel 9a", soc: "zumapro", display: { width: 1080, height: 2424, hz: 120, dpi: 422 } } +} +// "google,gs201-cheetah" or "google,zumapro-tegu" -> codename and SoC. +function boardFrom(text) { + var parts = String(text || "").split("@@\n") + var model = String(parts[0] || "").trim() + var compat = String(parts[1] || "").split("\n").map(function(c) { return c.trim() }).filter(function(c) { return c }) + var m = /^[^,]+,([^-]+)-(.+)$/.exec(compat[0] || "") + var codename = m ? m[2] : null + var known = (codename && BOARDS[codename]) || {} + return { model: known.model || model.replace(/^Google\s+/, "") || null, maker: /^Google\b/.test(model) || /^google,/.test(compat[0] || "") ? "Google" : null, + codename: codename, soc: known.soc || (m ? m[1] : null), display: known.display || null } +} + +// /proc/meminfo, /proc/uptime, uname and df (and the board) -> android.system. +function systemFrom(meminfo, uptime, kernel, df, board) { + var b = board || {} var kb = function(name) { var m = new RegExp("^" + name + ":\\s+(\\d+)", "m").exec(meminfo || ""); return m ? parseInt(m[1], 10) * 1024 : null } var total = kb("MemTotal"), available = kb("MemAvailable") return { kernel: String(kernel || "").trim() || null, uptime: Math.floor(parseFloat(uptime) || 0), memory: { total: total, used: total !== null && available !== null ? total - available : null, available: available }, - storage: storageFrom(df), cpu: { soc: "gs201", maker: "Google", hardware: null, cores: 8, abi: "arm64-v8a", maxMhz: null }, - display: { width: 1440, height: 3120, hz: 120, dpi: 512 }, build: null, codename: "cheetah", patch: null, + storage: storageFrom(df), cpu: { soc: b.soc || null, maker: b.maker || null, hardware: null, cores: 8, abi: "arm64-v8a", maxMhz: null }, + display: b.display || null, build: null, codename: b.codename || null, patch: null, locale: null, timezone: null, launcher: "omamobile", theme: null, apps: 0 } } @@ -345,6 +366,7 @@ if (typeof module !== "undefined") { sourceLimits: sourceLimits, LIMITS: LIMITS, hostOf: hostOf, OWL_CELL_DP: OWL_CELL_DP, actionArgv: actionArgv, volumeFrom: volumeFrom, mediaFrom: mediaFrom, MEDIA_FORMAT: MEDIA_FORMAT, modesFrom: modesFrom, systemFrom: systemFrom, storageFrom: storageFrom, - batteryFrom: batteryFrom, BATTERY_COMMAND: BATTERY_COMMAND, panelOff: panelOff, DEVICE_ACTIONS: DEVICE_ACTIONS + batteryFrom: batteryFrom, BATTERY_COMMAND: BATTERY_COMMAND, + boardFrom: boardFrom, DEVICE_COMMAND: DEVICE_COMMAND, BOARDS: BOARDS, panelOff: panelOff, DEVICE_ACTIONS: DEVICE_ACTIONS } } diff --git a/packages/omamobile-shell/test/owl-core.js b/packages/omamobile-shell/test/owl-core.js index 56d320703..836014a70 100644 --- a/packages/omamobile-shell/test/owl-core.js +++ b/packages/omamobile-shell/test/owl-core.js @@ -341,6 +341,17 @@ test("phone actions and android.* answers, with mocks", () => { eq([sys.kernel, sys.uptime, sys.memory], ["7.3.0", 123, { total: 8192000, used: 5120000, available: 3072000 }]) eq(P.systemFrom("", "1", "7.3.0\n", " 116041613312 16160268288\n").storage, { total: 116041613312, used: 16160268288, available: 99881345024 }) eq([sys.storage, P.storageFrom("Size Used"), P.storageFrom("0 0")], [null, null, null]) + // the board comes from the device tree, not a fixed Pixel 7 Pro + const tegu = P.boardFrom("Google Pixel 9a\n@@\ngoogle,zumapro-tegu\ngoogle,zumapro\n") + eq([tegu.model, tegu.maker, tegu.codename, tegu.soc, tegu.display.width], ["Pixel 9a", "Google", "tegu", "zumapro", 1080]) + const cheetah = P.boardFrom("Google Pixel 7 Pro\n@@\ngoogle,gs201-cheetah\ngoogle,gs201\n") + eq([cheetah.model, cheetah.codename, cheetah.soc, cheetah.display.height], ["Pixel 7 Pro", "cheetah", "gs201", 3120]) + const other = P.boardFrom("OnePlus 13\n@@\noneplus,sm8750-dodge\nqcom,sm8750\n") + eq([other.model, other.maker, other.codename, other.soc, other.display], ["OnePlus 13", null, "dodge", "sm8750", null]) + eq([P.boardFrom("").model, P.boardFrom("").codename], [null, null]) + const s9 = P.systemFrom("", "1", "7.3.0\n", "", tegu) + eq([s9.codename, s9.cpu.soc, s9.display.dpi], ["tegu", "zumapro", 422]) + eq([P.systemFrom("", "1", "7.3.0\n").codename, P.systemFrom("", "1", "7.3.0\n").display], [null, null]) eq([P.batteryFrom("97\nCharging\n").level, P.batteryFrom("97\nCharging\n").charging, P.batteryFrom("97\nCharging\n").status], [97, true, "charging"]) eq([P.batteryFrom("").level, P.batteryFrom("").status], [null, null]) eq([P.panelOff("0\n"), P.panelOff("4\n"), P.panelOff("")], [false, true, false]) diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index d9955e456..69ca21255 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.33 +0.2.34 From 76a75ded80b903db3c2abd50da88ae1b6232c7df Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:51:09 -0647 Subject: [PATCH 4/7] omamobile-audio tests: the fake mixer and PipeWire write their state atomically The watchdog's jump test changes a control from a background job while the watchdog reads the fake mixer's state file, and CI once caught the read halfway through the write (JSONDecodeError, the test failed). Both fakes now write a temporary file and rename it over the state. --- packages/omamobile-audio/test/fake-amixer | 6 +++++- packages/omamobile-audio/test/fake-pw | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-audio/test/fake-amixer b/packages/omamobile-audio/test/fake-amixer index 79d6b8776..fd00ead52 100755 --- a/packages/omamobile-audio/test/fake-amixer +++ b/packages/omamobile-audio/test/fake-amixer @@ -76,8 +76,12 @@ def load(): def save(c): - with open(state_path, 'w') as f: + # write and rename, so a reader running at the same moment (the + # watchdog while a test changes a control) never sees half a file + tmp = f'{state_path}.{os.getpid()}' + with open(tmp, 'w') as f: json.dump(c, f) + os.replace(tmp, state_path) def show(name, ctl): diff --git a/packages/omamobile-audio/test/fake-pw b/packages/omamobile-audio/test/fake-pw index 2577c4e6c..7a23b7c54 100755 --- a/packages/omamobile-audio/test/fake-pw +++ b/packages/omamobile-audio/test/fake-pw @@ -62,8 +62,10 @@ if me == 'pw-cli': if k not in vals or os.environ.get('FAKE_PW_IGNORE') == '1': continue # the filter ignores unknown controls vals[k] = float(v) - with open(state, 'w') as f: + tmp = f'{state}.{os.getpid()}' + with open(tmp, 'w') as f: json.dump(vals, f) + os.replace(tmp, state) log(args[3]) sys.exit(0) if me == 'wpctl': From f61052e0b6a04e3b4f0dbf435ab3eb1bd4473109 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:34:35 -0647 Subject: [PATCH 5/7] omamobile-audio 0.5.5: the tests' control backend writes atomically too The flake had a second writer: JsonCtl, the json: control backend the tests run the speaker code against, rewrites the fake mixer's state on every heartbeat read, in place. The fake mixer reading at that moment saw an empty file. JsonCtl now writes a temporary file and renames it, as the fakes do. Nothing changes on the palmtop: JsonCtl is used only with OMAMOBILE_CTL_BACKEND=json:. --- packages/omamobile-audio/lib/speaker_dsp.py | 14 ++++++++++---- packages/omamobile-audio/version | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/omamobile-audio/lib/speaker_dsp.py b/packages/omamobile-audio/lib/speaker_dsp.py index 162bde627..6842cf3ee 100644 --- a/packages/omamobile-audio/lib/speaker_dsp.py +++ b/packages/omamobile-audio/lib/speaker_dsp.py @@ -221,6 +221,14 @@ def _load(self): except (OSError, ValueError): return {} + def _save(self, state): + # rename over the file, so the fake mixer reading it at the same + # moment never sees half of it + tmp = f'{self.path}.{os.getpid()}' + with open(tmp, 'w') as f: + json.dump(state, f) + os.replace(tmp, self.path) + def names(self): return list(self._load()) @@ -238,8 +246,7 @@ def read(self, name): if name.endswith('HALO_HEARTBEAT') and os.environ.get('FAKE_HB_STUCK') != '1' and not frozen: v += 1 # the firmware's heartbeat moves while it runs c['v'] = list(v.to_bytes(4, 'big')) - with open(self.path, 'w') as f: - json.dump(state, f) + self._save(state) return v if t == 'ENUMERATED': return c['items'][c['v']] @@ -274,8 +281,7 @@ def write_bytes(self, name, data): if log_path: with open(log_path, 'a') as f: f.write(name + '\n') - with open(self.path, 'w') as f: - json.dump(state, f) + self._save(state) return True diff --git a/packages/omamobile-audio/version b/packages/omamobile-audio/version index 7d8568351..d1d899fa3 100644 --- a/packages/omamobile-audio/version +++ b/packages/omamobile-audio/version @@ -1 +1 @@ -0.5.4 +0.5.5 From 7dce509daacceb405fe4796b481357a46d18dde3 Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 00:55:29 -0647 Subject: [PATCH 6/7] omamobile-audio tests: the temperature jump comes after the watchdog's first reading The jump tests changed the estimate 0.4 s after starting the watchdog. On a slow CI runner the watchdog wasn't reading yet, took the raised value as its baseline, saw no jump and didn't mute. The jump now waits for the watchdog's start line and a few intervals, and the watchdog runs 60 iterations. --- packages/omamobile-audio/test/all | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/omamobile-audio/test/all b/packages/omamobile-audio/test/all index 4b17bed90..a694a0928 100755 --- a/packages/omamobile-audio/test/all +++ b/packages/omamobile-audio/test/all @@ -351,8 +351,12 @@ pass "watchdog: mutes on DSP errors, bypass, levels, runtime PM, a stuck heartbe # level drop, so a jump there must not mute; OMAMOBILE_SPK_TEMP_JUMP brings it back. jump() { # name [wprep...]: watchdog on a running stream; the bottom's estimate goes 25 -> 40 C a moment in local n=$1; shift; echo 'state: RUNNING' > "$r/asound/card0/pcm5p/sub0/status"; wprep=("$@") - ( sleep 0.4; amx cset "name=Bottom DSP1 Protection cd CSPL_TEMPERATURE" 0x00,0x0a,0x00,0x00 >/dev/null ) & - watchrun; wait + # the jump comes once the watchdog has its first reading (its start line, + # then a few intervals), not at a fixed time: a slow runner started it late + rm -f "$r/watch.out" + ( for _ in $(seq 1 100); do grep -c 'watchdog: watching' "$r/watch.out" >/dev/null 2>&1 && break; sleep 0.05; done + sleep 0.3; amx cset "name=Bottom DSP1 Protection cd CSPL_TEMPERATURE" 0x00,0x0a,0x00,0x00 >/dev/null ) & + WATCH_N=60 watchrun; wait } startok w-jump8; jump w-jump8 ((rc == 0)) && ! muted && grep -c 'jump rule off' "$r/watch.out" >/dev/null || { cat "$r/watch.out" >&2; fail "watchdog: at analog 10 or below a 15 C jump of the estimate does not mute (C9j)"; } From e1f3e73175dcd0c91a10fe2d019875625116d88e Mon Sep 17 00:00:00 2001 From: W4HO <87742609+W4HO-ham@users.noreply.github.com> Date: Wed, 28 Oct 2026 07:52:58 -0647 Subject: [PATCH 7/7] omamobile-shell 0.2.34: say that the board table's hz is the panel's top rate As asked on the pull request: display.hz is what the panel can do, not the rate it runs at now (the 9a's published kernel still runs it at 60 Hz). --- packages/omamobile-shell/plugins/omamobile.home/owl/phone.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js b/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js index e2254a946..47ba624e3 100644 --- a/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js +++ b/packages/omamobile-shell/plugins/omamobile.home/owl/phone.js @@ -308,7 +308,9 @@ function batteryFrom(text) { // The board from the device tree: "model" and the "compatible" list, read by // DEVICE_COMMAND as "\n@@\n". var DEVICE_COMMAND = "tr -d '\\0' < /proc/device-tree/model 2>/dev/null; echo; echo '@@'; tr '\\0' '\\n' < /proc/device-tree/compatible 2>/dev/null" -// What the device tree doesn't say, for the boards Omarchy Mobile runs on. +// What the device tree doesn't say, for the boards Omarchy Mobile runs on: +// the panel's size, density and top refresh rate (what it can do, not the +// rate it runs at now). var BOARDS = { cheetah: { model: "Pixel 7 Pro", soc: "gs201", display: { width: 1440, height: 3120, hz: 120, dpi: 512 } }, tegu: { model: "Pixel 9a", soc: "zumapro", display: { width: 1080, height: 2424, hz: 120, dpi: 422 } }