diff --git a/device/cheetah/MODEM-CLIENT.md b/device/cheetah/MODEM-CLIENT.md index a1f504861..95a809fb2 100644 --- a/device/cheetah/MODEM-CLIENT.md +++ b/device/cheetah/MODEM-CLIENT.md @@ -112,10 +112,15 @@ registration indication), unless `ims_required = yes`. - **Outgoing SMS** carry a durable 32-hex request id; an interrupted or uncertain send is marked `unknown`, never repeated automatically. - **Calls**: a hangup whose release isn't confirmed within 12 s, or a call - left over from a previous run, stops the modem unit (CP off, then rfsd): - the only way to be sure the radio isn't still carrying a call. That is a - CP power-off (one UFS handler pass) and is the one place the RIL powers - the modem off. + left over from a previous run, turns the radio off (best effort, AT+CFUN=0) + and stops sitd with the call still recorded as its own, for an attended + reboot. The journal says "Call release not confirmed: ", the radio + and CP states, and "attended reboot required". The RIL no longer stops the + modem unit or powers the CP off: an in-place power-off reset the 9a once, + and on the 7 Pro every power-off costs a UFS error-handler pass. The unit + has `Restart=no`, so a manual restart in the same boot finds the recorded + call, turns the radio off again and exits. This path has run only in the + simulator. - **Storage**: received SMS in `/var/lib/omamobile-sit` (0700, files 0600): numbers and text, never to be copied into the repository. diff --git a/device/cheetah/MODEM-PLAN.md b/device/cheetah/MODEM-PLAN.md index 417a82c15..a8068aad2 100644 --- a/device/cheetah/MODEM-PLAN.md +++ b/device/cheetah/MODEM-PLAN.md @@ -1527,7 +1527,8 @@ tools/phone-ssh 'omamobile-sit hangup; sleep 2; omamobile-sit status; # "AoC call routes restored". Then the human calls the phone: `omamobile-sit answer`, talk, hangup # stop: no audio either way (record the journal: "voice PCM ... failed" means the AoC card; check that # PipeWire does not hold PCM 4/11), distorted or loud audio (hang up at once), a release that is -# never confirmed (the RIL stops the modem unit by design after 12 s: one UFS pass; reboot after) +# never confirmed (after 12 s the RIL turns the radio off and exits: "Call release not confirmed", +# "attended reboot required"; reboot, which powers the CP off: one UFS pass) # rollback: omamobile-sit hangup # M4.6 at boot (asks the human: reboots; risk: medium: from now on every boot powers the modem on, @@ -2645,8 +2646,8 @@ tools/phone-ssh 'omamobile-sit answer; sleep 10; omamobile-sit status | grep -E # outgoing, to the human's other phone (international form); answer it there, hang up there after ~10 s: tools/phone-ssh 'omamobile-sit dial ; sleep 30; omamobile-sit status | grep -E "^call"' # pass: the other phone rings and connects (silent), then "terminated" after the remote hang-up -# stop: "Call release was not confirmed; modem stopped" (the RIL powered the CP off by design: one UFS -# pass; reboot before anything else); a CP crash; any sound from the phone's speakers (stop at once: +# stop: "Call release not confirmed" and "attended reboot required" (the RIL turned the radio off and +# exited, leaving the CP on; reboot before anything else, one UFS pass on the way down); a CP crash; any sound from the phone's speakers (stop at once: # nothing should route audio: record `amixer -c cget name="TDM_0_RX Mixer EP5"`) # rollback: omamobile-sit hangup # Never dial an emergency number to test (refused anyway; TELEPHONY-APPS-PLAN 3.3) diff --git a/device/tegu/CALL-AUDIO-TUNING.md b/device/tegu/CALL-AUDIO-TUNING.md new file mode 100644 index 000000000..a9b3c1c5f --- /dev/null +++ b/device/tegu/CALL-AUDIO-TUNING.md @@ -0,0 +1,186 @@ + +# Pixel 9a: call tuning and the first earpiece route + +Status, 2026-11-03: **implemented and tested offline, no phone trial**. +Branch `tegu-call-audio-aec-earpiece` builds on `sitd-tegu-call-audio` +(`d826388`); omamobile-modem-sit 0.3.13. AEC is off by default and call +audio still defaults to `card = none`. The earpiece mode below is a +conservative top-speaker route, not a reproduction of every stock codec +profile setting. This note records the remaining distinction explicitly. + +## Sources and the tuning transport + +Read the owner's saved 9a audio HAL, its AoC utility library, mixer paths, +platform configuration and factory-image `/vendor/etc/aoc` files as data. +No vendor program was run or copied into the repository. Compare the +functional interface with our GPL kernel at +[`253ddb231a89792ea845549c55fb0f04536c9317`](https://github.com/derekross/linux-omarchy-mobile/tree/253ddb231a89792ea845549c55fb0f04536c9317): +`drivers/soc/google/aoc/aoc-interface-gs201.h`, `aoc_char_dev.c`, +`alsa/aoc_alsa_ctl.c`, `alsa/aoc_alsa_hw.c`, and +`sound/soc/codecs/tas2781-{i2c,fmwlib}.c` / `include/sound/tas2x20-tlv.h`. +The kernel worktree is `~/android/mainline/wt-call-test`. + +Stock uses the `fmapmg3hybrid` telephony tuner. Its APMg3 adapter wraps +an unchanged protobuf with this **12-byte little-endian envelope**: + +| Offset | Type | Meaning used by the adapter | +| --- | --- | --- | +| 0 | u16 | 2 (envelope tag; its semantic name is not established here) | +| 2 | u16 | Total envelope plus protobuf length | +| 4 | u32 | 19 for uplink tuning, 20 for downlink tuning | +| 8 | u32 | Protobuf length | +| 12 | bytes | Original protobuf | + +Both operations use AoC address **block 19, component 24, address type 0**. +In `AocTuningCommands::SetParameterBulk`, type 0 selects +**`audio_output_tuning`**, not `audio_input_tuning`: block/component names +do not select the character channel. Write the envelope padded to a full +**16384-byte block** to `/dev/acd-audio_bulk_tx`, then send a **22-byte** +CMD_AUDIO_OUTPUT_SET_PARAMETER_BULK (ID 210 / `0x00d2`) record on +`/dev/acd-audio_output_tuning`: + +| Bytes | Field | +| --- | --- | +| 0, 1 | CMD type 0, counter | +| 2–3 | u16 length 22 | +| 4–5, 6–7 | u16 command ID 210, signed i16 reply initially 0 | +| 8, 9 | u8 block 19, component 24 | +| 10–13, 14–17 | u32 TX offset 0, TX address 0 | +| 18–21 | u32 envelope length, not the padding length | + +Stock's utility has a separate type-1 family using `audio_input_tuning`, +`audio_input_bulk_tx/rx`, ID 234 and a 5120-byte staging buffer. That is +not the APMg3 upload described above. Stock opens the output bulk RX service +as part of its generic descriptor set; this write-only implementation +needs no bulk RX read. The tuning reply comes back on the tuning service. + +`aoc_tuning.py` implements only the two uplink/downlink operations, with +bounded nonblocking writes, one-second readiness/acknowledgement deadlines, +exact record lengths, command/counter matching and a zero reply required. +It never resumes a short record, retries an unknown command, maps SRAM or +opens the CP/AoC shared voice window. `aoc_char_dev` makes the service +opens exclusive. An uncertain write/reply leaves the private RAM marker +`/run/omamobile-sit/aoc-voice-tuning-uncertain`; later tuning attempts refuse. +The unit already preserves its runtime directory. Do not delete the marker +to retry on the same AoC session. + +**Echo reference is a separate ALSA step.** +`VoiceCall::EchoReferencePath::Set` selects **FT AEC Reference Source = +SPEAKER** for the speaker and handset paths. Our kernel's setter caches +that choice; `aoc_audio_modem_mic_input()` uses it as the reference input +when constructing MODEM_INPUT_START_2. Set it before EP4 capture starts. +Its saved value is restored after the PCMs stop. There is no additional SIT +request. The existing EP4/EP5 preparation starts the modem voice path. + +`SendCommonCommand` is not the AEC protobuf transport. Its observed caller +here toggles **microphone compensation** with input-family command 355/356, +using an eight-byte CMD_HDR. Sending those would enable a different feature; +the implementation does not send them. The complete stock hybrid tuner's +band, volume and processing-mode policy is outside this first loader. +Actual echo cancellation still needs a far-end listening test. + +## Files and lifecycle + +`tools/extract-vendor-firmware -d tegu` now copies these six owner files +unchanged into **`usr/lib/firmware/updates/omamobile/tegu/aoc/`** in its +output tree, included in `vendor-firmware.sha256`: + +| Route | Uplink on | Uplink cleanup | Downlink | +| --- | --- | --- | --- | +| Speakerphone | `uplink_speaker_aec_on_config.pb` | `uplink_speaker_aec_off_config.pb` | `downlink_speaker_config.pb` | +| Earpiece | `uplink_handset_aec_on_config.pb` | `uplink_handset_aec_off_config.pb` | `downlink_handset_config.pb` | + +The source is `/vendor/etc/aoc/` in the owner's own 9a image. Do not use +another device's protobufs. HAC, wired, Bluetooth, dock and external-speaker +configs are unnecessary for these two routes. Missing any of these six +fails extraction. The loader requires the selected route's on, off and +downlink files before any upload. Files are not shipped in the package. + +With `[audio] tegu_aec = yes`, the route first saves the mixer state and +verifies sink mute, sets the echo reference, uploads uplink-on and downlink, +and starts capture/playback once with the existing voice parameters. It +then applies and reads back the amplifier attenuation before unmuting. +Hang-up mutes, stops both PCMs, sends the same route's uplink-off package, +closes the tuning services and restores the mixers. **This turns AEC off; +it does not claim to restore an unknown previous protobuf**, and leaves the +selected downlink tuning resident in the inactive telephony component. + +A missing or refused tuning setup refuses audio while call signalling +continues. Unknown setup or failed cleanup leaves the sink muted; the CP +is never stopped or reset. Tests cover cleanup, stale/mismatched/negative +acknowledgements, short writes and an unknown outcome blocking another call. + +## Earpiece mapping and the limit of the stock comparison + +The stock GPL TAS parser is +[Google amplifiers `33976d763bc0ace11603e7ecb207fc2b6e3f2608`](https://android.googlesource.com/kernel/google-modules/amplifiers/+/33976d763bc0ace11603e7ecb207fc2b6e3f2608/tas25xx/src/tas25xx-regbin-parser.c). +It builds playback-volume controls from the image's KCNTR table; values +are table indices, not decibels. A bounded private inspection of the owner's +table, following that parser, established: + +| Stock setting | Mainline mapping / implementation | +| --- | --- | +| PLAYBACK_VOLUME_LEFT = 55 | Its coefficient matches **tas2x20 DVC index 220 (unity)**, not index 55. Use a lower first-test level: **Top Speaker Digital Volume = 160 (-30 dB)** | +| Top amplifier only | **Bottom Speaker Digital Volume = 0**, read back before unmuting. This is the table's minimum (-110 dB), not power-off or a hardware mute | +| CODEC PROFILE = voice | Mainline exposes per-amplifier **Speaker Profile Id**, not the vendor enum. The examined native RCA's index **4** is `case05-voice-handset`, but that case contains only one power-state write. It lacks profile 0's full initialization. Selecting 4 on a fresh, uninitialized amplifier is not a complete voice route | +| EM LEFT/RIGHT = OFF | Mainline has **no EM mixer control**. The stock driver writes bits 7:6 of register 0:0:3. The examined full native profile 0 writes EM off; no userspace register write or invented control is added | +| AoC Modem Sink Channel Bitmap | **Read-only**: its SOC_SINGLE_EXT has a get handler and NULL put. It reports a sink's active channel bitmap; it is not a writable TDM-slot selector in this kernel | + +For the first usable top-only mode, retain the existing **full profile 0** +on both amplifiers, load handset AEC/downlink tuning, and attenuate/mute as +above. Refuse earpiece audio if the selected amplifier profiles are not 0, +or AEC was not enabled. This keeps startup on the already working native +initialization instead of treating a profile label as sufficient evidence. +Only the top is intended to be audible; the bottom still powers up. +Exact stock voice-profile and per-amplifier EM control remain a separate +firmware/kernel task if needed after this route is qualified. Gains have +not been acoustically qualified at the ear. + +Configuration (changes apply on the next **fresh CP** session): + +```ini +[audio] +card = none +tegu_aec = no +tegu_route = speaker +``` + +The attended trial chooses `card = auto`, `tegu_aec = yes`, then `speaker` +or `earpiece`. The earpiece mode does not affect the 7 Pro's CS35L41 route; +there is no mid-call route switch in this change. Do not enable it globally. + +## Verification and the attended gate + +Laptop checks, risk **low**, with synthetic service records and an ext4 +fixture containing fictional data only: + +```sh +tests/packages omamobile-modem-sit +tests/extract-tegu-call-tuning +tools/pr-check d826388 +``` + +Expect: all package tests, including the existing cheetah route and sit-sim +calls/SMS, pass; six synthetic tuning files are copied byte-for-byte and +checksummed; missing cleanup tuning fails; the PR gate passes. Stop on a +failure. Rollback is the parent branch or removal of this isolated +worktree. Nothing contacts the phone or executes the saved HAL. + +Before any phone trial, the human reviews a device-specific runbook and +approves the install and fresh boot. First **read-only**, confirm the NV +backup checksums, exact daily kernel/modules, mixer control availability, +profile files and their checksums, and no active call/PCMs. Keep the modem's +sleep inhibitor and once-per-boot rule. Record the actual `uname -r` with +results; no phone kernel release is claimed for these offline checks. + +Then test **speaker AEC only first**, with live kmsg streamed to the laptop, +a watchdog and the human ready to recover. Check command replies, gain +readbacks, two-way audio and the far end's echo before trying the earpiece +on another approved fresh session. Risk **medium**: new AoC tuning and an +unqualified acoustic path. Begin the earpiece test away from the ear at the +fixed attenuation. Stop on an AoC timeout/reset, any NV/UFS error, +unexpected gain, feedback, missing bottom attenuation or unconfirmed +cleanup. Hang up and retain the mute/uncertainty state. Never retry or reset +the running CP in place. Rollback is the previous package/config on an +attended fresh boot; no automatic unit restart, warm modem restart or +manual marker deletion. Hardware results: **not run**. diff --git a/device/tegu/CALL-AUDIO-WINDOW.md b/device/tegu/CALL-AUDIO-WINDOW.md new file mode 100644 index 000000000..b6a4324e7 --- /dev/null +++ b/device/tegu/CALL-AUDIO-WINDOW.md @@ -0,0 +1,46 @@ + +# Pixel 9a: AoC voice-window audit + +2026-11-02, offline. This supports TELEPHONY-PLAN section 1 (PR #360); +no call, memory access or phone operation was performed. + +**The firmware voice path has a shared SRAM window; the Linux call-audio +route does not need a new CPU mapping of it.** The checked CPIF and AoC +paths provide no evidence that adding the omitted CPIF region is required +to start a PCIe call. Whether the running firmware's path works remains +unqualified until the attended call test. + +Where it comes from: + +- MODEM-PLAN F3 records tegu's own stock DT capture: `cp_aoc_rmem` is + 12 KiB at AP physical address `0x197fd000`. The stock `cp_shmem` node's + fourth `memory-region` references it; `VSS_AOC` selects `SHMEM_VSS` + (index 1), rmem index 3, offset 0, size `0x3000`, uncached. This is AoC + SRAM, not a buffer for userspace to allocate. Google's + [GPL reservation](https://android.googlesource.com/kernel/devices/google/zuma/+/eb90f2862e78b4c409ff992e116c44e81f836e9e/dts/zuma-rmem.dtsi) + and [shared-memory description](https://android.googlesource.com/kernel/devices/google/zuma/+/b0dfdfc378dd37d7c1662bbd942240d55db83d68/dts/zuma-cp-s5300-sit.dtsi) + describe the same resource; tegu's capture is the board-specific evidence. +- Our tegu `zumapro-reserved-memory.dtsi` already reserves this range as + `cp-aoc@197fd000`, with `no-map`. Omitting the CPIF region from the + bring-up overlay does not remove that reservation. +- In the GPL CPIF port, `init_shmem_maps()` maps VSS only in the + `LINKDEV_SHMEM` case; tegu uses `LINKDEV_PCIE`. Its PCIe path does not + require `vss_base` to start. Google's + [GPL implementation](https://android.googlesource.com/kernel/google-modules/radio/samsung/s5300/+/refs/tags/android-16.0.0_r0.10/link_device.c) + preserves that distinction. Diagnostic accessors/dump support are not + the voice-stream transport. +- `aoc_alsa_voice.c` prepares the voice PCM through `prepare_phonecall()` + in `aoc_alsa_hw.c`. For playback PCM 4 it sends + `CMD_AUDIO_OUTPUT_TELEPHONY_MODEM_START_ID` (256); close sends STOP + (257). Both are header-only AoC commands, with no supplied memory + address (also confirmed in the saved GPL Zuma interface header). + The speech stays between the modem and AoC; sitd owns the PCM handles + and mixers, not the SRAM. + +Keep the reservation and leave the window CPU-unmapped. This change adds +no DT region, PCIe translation, S2MPU permission or userspace memory +access. If a later call establishes a missing firmware-side window, trace +the stock tegu firmware/translation setup separately before any kernel +change; do not substitute another board's address or map the SRAM to +inspect it. The first call still needs the plan's gain checks, log stream, +watchdog, stop conditions and attended recovery. diff --git a/device/tegu/MODEM-PLAN.md b/device/tegu/MODEM-PLAN.md index 1ad0c50db..785238b49 100644 --- a/device/tegu/MODEM-PLAN.md +++ b/device/tegu/MODEM-PLAN.md @@ -1779,7 +1779,7 @@ Preconditions, as SLEEP-PLAN's: | Piece | State | What it means here | | --- | --- | --- | -| Modem to ONLINE | `/usr/local/bin/omamobile-tegu-modem-up` (M5, once per boot; refuses a second start; arms the sleep inhibitor `omamobile-tegu-modem-nosleep`; its source is [bringup/omamobile-tegu-modem-up](bringup/omamobile-tegu-modem-up)) | the start is this script, not `omamobile-modem.service`, which is `masked-runtime` on the palmtop; the transient unit's ExecStop (the profile's stop, which powers the CP off) runs at shutdown, so the way to stop the modem is an attended reboot, never a stop by hand | +| Modem to ONLINE | `omamobile-tegu-modem-up` from `omamobile-device-tegu` (#372; before it, a bring-up copy in `/usr/local/bin`): once per boot, refuses a second start and a boot that finds the latch, arms the sleep inhibitor `omamobile-tegu-modem-nosleep`; `omamobile-tegu-modem-boot` runs it at boot when enabled (TELEPHONY-PLAN 2.7) | the start is this script, not `omamobile-modem.service`, which is `masked-runtime` on the palmtop; the transient unit's ExecStop (the profile's stop, which powers the CP off) runs at shutdown, so the way to stop the modem is an attended reboot, never a stop by hand | | NV safety | `pacman -Q` says `omamobile-modem` 0.1.4, but the profile files under `/usr/lib/omamobile-vendor` were copied by hand from newer trees (the 27th GNSS try ran 0.1.9's watcher; 0.1.4 predates the 9a's chroot support), so `pacman -Qkk omamobile-modem` is not clean; `/etc/omamobile/modem-nv.sha256` from the 2026-10-28 backup; the profile's `check` runs inside the start script | the NV checks live in that profile, so SIM-1 installs the package from main for real and records the version and the profile's sha256; a stock boot since 2026-10-28 would make `check` refuse; then a fresh read-only backup and a new checksum file come first (AGENTS.md §1) | | The RIL | `omamobile-modem-sit` 0.3.3 installed 2026-10-29 (SIM-1), both units disabled; 0.3.4 () reads the CP state on one open file | 0.3.3's watcher opens and closes the boot device about thirty times a minute, and that cycles the CP link on the 9a (the 10-29 hangs); the run uses 0.3.4 (SIM-1). Its unit `Requires=omamobile-modem.service`, which is masked here, so `systemctl start omamobile-sitd` would fail until SIM-2's unit copy removes that requirement (done 2026-10-29) | | The bridge for apps | `omamobile-mmd` not installed | not part of this test (T2 follows a passing run) | @@ -1935,9 +1935,10 @@ tools/phone-ssh 'omamobile-sit sms send "omamobile test"' # SIM-10 calls: NOT in this test. No audio route exists on the 9a (table above). A signalling-only call # (ring, answer, hang up, silence both ways, as cheetah's S10) is its own later step, after this runbook passes. -# Nobody calls the palmtop's number during the test: an incoming call that sitd can't release makes its -# safety stop target omamobile-modem.service, which is masked on the 9a, so it would only time out. If the -# journal says a call release wasn't confirmed ("call release not confirmed" or the stop timing out): don't +# Nobody calls the palmtop's number during the test: an incoming call that sitd can't release makes it +# turn the radio off and exit for an attended reboot (since #364; before it, its safety stop targeted +# omamobile-modem.service, masked on the 9a). If the journal says "Call release not confirmed" or +# "attended reboot required": don't # stop anything by hand; "omamobile-sit radio off", record the journal lines (states and codes), and end # the session with SIM-11's attended reboot. @@ -2013,11 +2014,38 @@ is a US MVNO on a large LTE network. (`omamobile-sit sms send`) reached the owner's phone. A text sent to the palmtop's own number was accepted ("sent") and never came back, which is common on this network. -- **SIM-10:** no call; the 9a has no audio route. +- **SIM-10:** no call on 11-02; the 9a had no audio route. See "Calls" + below. - **SIM-11 passed:** radio off, the RIL stopped, an attended reboot (the unit's stop powered the CP off during shutdown), then M0.1: the six partitions unchanged, `cpif` not loaded, UFS error handler 0. +#### Calls (2026-11-03) + +With `omamobile-modem-sit` 0.3.11 (speakerphone audio for the 9a's AoC +card, omarchy-mobile #367, on #364 and #356) and `[audio] card = auto`: + +- **On the daily kernel:** an outgoing call to the owner's phone, answered; + the far end's voice came out of the palmtop's speaker, and the palmtop's + microphone carried it back (heard at the far end as an echo: there is no + echo cancellation yet). A second outgoing call and an incoming call + (`omamobile-sit answer` while it rang) behaved the same. sitd logged + "AoC tegu speakerphone prepared at conservative TAS gain" at each start + and "AoC call routes restored" after each hang-up; UFS error handler 0. +- **On in-tree drivers end to end** (`7.3.0-rc6-omamobile-push1-g253ddb231a89`: + `omamobile` plus the open kernel PRs: the modem link #187 with its PCIe + stack, GNSS #185, and #162's AoC, GSA and Trusty from the device tree): + the AoC up with 93 services and the `google,tegu-aoc-snd-card` card, + CPIF and the in-tree host booted the CP to ONLINE, and then an outgoing + and an incoming call with audio both ways, mobile data over `rmnet0` + (pings, HTTPS 200) and a text that arrived. The TAS gains read back at + -20 dB during the calls, the mixer routes matched their saved state + after, the AoC kept 93 services with nothing in its log, the same boot + throughout, no oops or WARN, no UFS errors. + +Left for calls: echo cancellation on speakerphone, an earpiece mode, the +Phone app (through `omamobile-mmd`), and starting the modem at boot. + The run kept the full refused record (292 bytes: status 36, CID 1, the IPC extension version at 132, an unidentified extension byte at 133, the suggested retry time at 235-242 as an s64) and the raw indications of the passing run in diff --git a/device/tegu/TELEPHONY-APPS-PLAN.md b/device/tegu/TELEPHONY-APPS-PLAN.md new file mode 100644 index 000000000..074335381 --- /dev/null +++ b/device/tegu/TELEPHONY-APPS-PLAN.md @@ -0,0 +1,202 @@ + +# Pixel 9a: connect Phone and Messages to sitd + +Status (2026-11-03): Phone and Messages ran on the palmtop on 2026-11-02 +through this path (results at the end). The optional +`omamobile-telephony-tegu` package installs mmd, the agent, an active-RIL +bridge policy and `omamobile-tegu-mmd-attach --check|--attach`, and enables +nothing. sitd's unit gets its modem dependency from a device-owned drop-in: +tegu uses Requisite on its already running starter, while cheetah and raven +keep Requires on their modem unit, and the virtual `omamobile-sitd-policy` +makes the drop-ins come along with a RIL upgrade. It builds on #363 (the +device modem policy). [Package/runbook](../../packages/omamobile-telephony-tegu/README.md). + +Two ways start the bridge, each for its own case: at boot, #372's opt-in +`omamobile-tegu-modem-boot` starts the modem, sitd and mmd once the CP is +ONLINE (daily use); and `omamobile-tegu-mmd-attach --attach` attaches mmd +and the agent to a modem and sitd already started by hand (bring-up and +tests, where nothing should start the modem for you). The helper refuses +when sitd isn't running and never starts the modem itself. + +Offline: the seven affected package suites pass, the attach package has 21 +tests (including systemd verification of all three device policies), and +the architecture-independent package builds with makepkg. One bridge API +comparison skips when ModemManager's reference XML is missing. + +The sections below are the investigation this started from, on `origin/main` +at `31fbcf9`, before #363 and the attach package. The owner then had texts +both ways and calls through `omamobile-sit`; this was the plan for the apps +on top. + +The app protocol already exists. The immediate missing layer in the +recorded tegu setup is `omamobile-mmd`, installed and running. A normal +package install is blocked by the cheetah-only dependency still on main; +sitd's packaged modem-unit dependency also needs the tegu startup work. +Those are existing, separate changes. Do not duplicate them or install +with dependency checks disabled. The first app test can use an already +running, attended sitd; it need not wait for modem startup at boot. + +## The existing path + +```text +Phone / Messages + | session bus: org.omamobile.Phone1, org.omamobile.Messages1 +omatel-agent (the logged-in user's service) + | system bus: org.freedesktop.ModemManager1 +omamobile-mmd (root, ModemManager-compatible API) + | /run/omamobile-sit/socket: JSON requests and status subscription +omamobile-sitd (the only owner of the modem channels) + | SIT / AT +modem +``` + +| Layer | What the repository already supplies | +| --- | --- | +| Apps | `omamobile-apps` depends on `omaphone` and `omamessages`; both pull in `omatel-agent`. Contacts is supplied with Phone and does not need a modem. #361 puts all three packages in the image. | +| Agent | `packages/omatel` packages the agent, its user unit and both session-bus activation files. Its session-bus activation files are meant to start it when an app opens; on the palmtop that didn't happen (results below), and the user unit had to be started and enabled. The disabled user unit is intentional; no root agent and no generic enablement change are needed. | +| Bridge | `packages/omamobile-mmd` owns the system-bus name normally used by ModemManager, exports modem/call/SMS objects, and checks polkit for operations. It conflicts with the real `modemmanager`; installing both is not the solution. | +| Commands | `Voice.CreateCall` plus `Call.Start` maps to sitd `dial`; `Accept`, `Hangup` and `SendDtmf` map to sitd requests. `Messaging.Create` plus `Sms.Send` maps to `sms-send` with a durable request ID. | +| Incoming events | The bridge subscribes to sitd, exports calls, reads `sms-list`, and maps deletion to `sms-delete`. The agent stores SMS before deleting them from the bridge and handles notifications and call history. | +| Privileges | Apps and agent use D-Bus. Only the bridge needs sitd's private socket. Keep socket permissions and the current polkit policy; no wheel-group workaround is needed for app access. | + +Sources: [app package](../../packages/omamobile-apps/PKGBUILD), +[agent packaging and activation](../../packages/omatel/README.md), +[bridge mappings](../../packages/omamobile-mmd/lib/bridge.py), +[socket subscription](../../packages/omamobile-mmd/lib/sitd_link.py), and +[the shared telephony plan](../../docs/TELEPHONY-APPS-PLAN.md), especially +sections 1.5 and 10.1b. + +Contacts uses the shared local vCard address book; it does not need a modem +or an additional cellular service. + +## What tegu is missing + +1. **A dependency-correct install.** `omamobile-mmd` depends on + `omamobile-modem-sit`, which depends on `omamobile-modem`, which still + depends on `omamobile-device-cheetah`. That conflicts with tegu's device + package. #363 (merged) replaces that last dependency with the virtual + `omamobile-modem-policy` and adds tegu's provider. +2. **The bridge package and its start.** The common rootfs list deliberately + omits mmd and modem-sit. Tegu's `ROOTFS_PACKAGES` does not include them. + `omamobile-mmd.service` ships disabled, has no D-Bus activation file, + and its installer creates no wants link. Merely opening an app cannot + start it. The recorded SIM runbook says mmd was not installed; current + hardware state must be checked by the human rather than inferred here. +3. **The right modem service for later automatic integration.** The shipped + `omamobile-sitd.service` requires `omamobile-modem.service`; the recorded + tegu run uses its own starter and an `/etc` copy of sitd's unit that + removes this dependency. A bridge-only test must retain the already + qualified, running stack. Do not start or restart the stock sitd unit + to attach the bridge. Package tegu's starter/order separately before + making this an image default. +4. **The tested tegu RIL and release safety.** Main still carries the older + RIL; use the independently reviewed tegu SIM fixes and safe unconfirmed + call-release behavior. Do not replace a running test RIL as part of + installing the bridge. An unconfirmed hang-up must not stop the tegu + modem in place. Call audio remains its separate route/qualification. + +There is no evidence that SMS needs an mmd APN, a tegu-specific socket +path, an extra bridge SMS transport, or a second modem daemon. The bridge +forwards SMS through sitd; sitd chooses the transport. Its modem state is +based on SIM/radio/registration and can be REGISTERED without a data bearer. +The hard-coded MM model string `Exynos Modem 5300` is misleading on tegu, +but is display metadata, not a routing selector or a reason to block SMS. + +## The smallest durable changes after the prerequisites + +- Keep `omamobile-apps` modem-independent, as #361 intends. Do not make all + images depend on the modem stack to get Phone or Contacts. +- After tegu's packaged modem start is qualified, add mmd and modem-sit to + tegu's board package list (and its packaged descriptor copy), with a + test that the descriptors agree and resolve against tegu's policy + provider without installing the cheetah device package. +- Enable only the bridge's existing relationship to sitd: + `systemctl enable omamobile-mmd.service` creates + `omamobile-sitd.service.wants/omamobile-mmd.service`. This follows a sitd + start without enabling sitd or starting the CP. Tegu's setup can do this + conditionally when mmd is installed; it need not use `--now`. +- Preserve mmd's one-way relationship: `After=omamobile-sitd.service`, no + `Requires=`, `Wants=` or activation path from the bridge to sitd or the + CP. An app opening or a bridge restart must never power the modem on. +- Test the conditional enablement with a fake systemctl, absent-package + handling, and a scratch unit root. Starting the bridge alone must not + request a CP start; starting qualified sitd must pull in the bridge. + +For the already running palmtop, the manual steps below are enough once +package dependencies are correct. The durable boot/image changes are not +prerequisites for that test. + +## Attended first test (ran on 2026-11-02) + +Keep the existing modem sleep inhibitor throughout; suspend with the CP on +is not qualified by this work. Keep the existing once-per-boot start and +NV checks. No step below starts, stops or restarts the CP or sitd. +Run user commands in the existing graphical user's terminal, root commands +in the attended administrative session. + +| Step / risk | Commands or action | Expect / pass | Stop condition | Rollback | +| --- | --- | --- | --- | --- | +| 1. Read-only / none | `uname -r`; `pacman -Q omaphone omamessages omatel-agent omamobile-mmd omamobile-modem-sit omamobile-modem`; `systemctl is-active omamobile-sitd omamobile-mmd ModemManager`; `systemctl cat omamobile-sitd`; `systemd-inhibit --list` | Record kernel/package versions, actual sitd unit, active inhibitor and existing running sitd. Missing bridge is expected initially. | No confirmed running sitd, wrong starter, competing ModemManager, or no inhibitor. | None; end this session without starting the modem. | +| 2. Install bridge / low | First review `pacman -Sp --print-format '%n %v' omamobile-mmd`. After the dependency fix is available, `pacman -S omamobile-mmd`, only if the transaction adds the bridge/dependencies without changing the running RIL, modem or device package. | No cheetah package, no tegu removal, no modem/RIL upgrade, and nothing starts the CP. | Resolver conflict or any unexpected upgrade/removal. Never use `-dd`. | Cancel before accepting the transaction; if installed, remove only the bridge after stopping it. | +| 3. Start bridge / low | Root: `systemctl start omamobile-mmd.service`; `busctl --system list --no-pager org.freedesktop.ModemManager1`; use `packages/omamobile-mmd/test/libmm-status.py` for states only. | Bus name owned by mmd, a modem object with SIM ready and expected registration; sitd/CP remain the same running instances. | Bridge cannot own the name/connect; sitd exits; hardware warning. | `systemctl stop omamobile-mmd.service`. Do not restart sitd or stop the modem. | +| 4. Agent and apps / low, screen changes | Announce first, then open Phone and Messages as the session user. `systemctl --user is-active omatel-agent`; `busctl --user list --no-pager org.omamobile.Phone1 org.omamobile.Messages1`. | Agent activates, apps see the modem instead of no-modem; Contacts opens without requiring a live modem. | Activation or authorization error. Do not weaken polkit/socket permissions. | Close apps; stop the user agent if it was started only for this test; stop mmd. | +| 5. SMS / carrier charge possible | Human sends one agreed test text in Messages, then sends one back from the other device; reopen the conversation. | One send, one received message, preserved after closing/reopening; no duplicate send on retry/reconnect. | Duplicate, uncertain delivery, or missing inbound text. Do not retry an uncertain send automatically. | Stop testing and stop the bridge; keep private message stores for diagnosis. | +| 6. Calls / medium, screen and sound | Only after the separate safe-release and call-audio checks: announce, place one ordinary agreed call from Phone, receive one, answer/decline and hang up. | UI state follows the call, release is confirmed, and the approved audio route behaves as qualified separately. | Unconfirmed release, unexpected audio level, CP/AoC/UFS fault. No emergency-number test. | Follow the attended safe-release runbook; no modem stop or second start. A reboot needs separate approval. | +| 7. Optional persistence / low | After passing, root: `systemctl enable omamobile-mmd.service` without `--now`. Inspect the resulting sitd wants link. | Bridge follows future *approved* sitd starts; sitd and modem remain disabled at boot. | Any change enabling the modem or sitd itself. | Disable only mmd if this step enabled it, then stop mmd if ending the test. | + +SMS/call numbers, contents, operator identities and object dumps remain +private. Record only states, counts, errors and test outcomes in this plan. +The read-only libmm status helper deliberately prints states and counts. + +A session that has never opened either app needs an additional activation +check before claiming always-on incoming notifications. The shell's call +watcher checks whether the agent owns its name and does not itself start +it. For this first test, open an app before arranging incoming traffic. +Keep #361's app-triggered activation policy until cold-session reception +has a separate test and an explicit decision about login activation. + +App mute/speaker controls are also separate: the shared plan records that +the agent uses callaudiod for those, while sitd owns its own voice PCMs. +A successful dial through mmd does not prove those controls affect tegu's +route. MMS and mobile-data control through ModemManager are outside this +SMS/basic-call integration; keep the existing sitd data ownership. + +## Offline evidence + +`packages/omamobile-mmd/test/all` passed on this base with private D-Bus +and local simulator sockets. This covers API/bridge/libmm clients, the +real sitd-to-sit-sim call and SMS chain, and staged unit checks. One test +was skipped because ModemManager's reference introspection XML is absent. +The suite verifies that the bridge has no unit dependency that pulls in +the modem and no system-bus activation file. + +`packages/omamobile-apps/test/all` also passed all 12 checks, including +Phone/Messages dependencies and the absence of a common modem dependency. + +This does not run the packaged Rust agent or either GUI, does not test +tegu hardware or the current private carrier configuration, and does not +qualify polkit for the actual graphical session. The earlier full agent +chain result is recorded in the shared plan; it was not rerun here. + +## Results on the palmtop, 2026-11-02 + +The daily kernel (`7.3.0-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty`), +the modem started by hand and sitd running (built from this stack, 0.3.12 +at the time), `omamobile-mmd` 0.1.0 started with `systemctl start`. + +- Steps 1 to 3 passed: the bridge owned `org.freedesktop.ModemManager1` + and exported the modem with the SIM ready; sitd and the CP stayed the + same running instances. +- Step 4: opening Messages did *not* start the agent, and it showed + "service isn't running" until `systemctl --user enable --now + omatel-agent`. After that both apps saw the modem. Cold-session + activation stays open, as above. +- Step 5: texts both ways from Messages, with no duplicate. +- Step 6: calls out from Phone and in, with speakerphone audio (#367), + released cleanly. +- The status bar showed airplane mode until sitd mapped radio state 10 to + on (now on main with #381). + +A `tools/phone-smoke` report from the palmtop is still to come, with the +next run. + diff --git a/docs/DEVICES.md b/docs/DEVICES.md index e5056f945..6dd1fcfdc 100644 --- a/docs/DEVICES.md +++ b/docs/DEVICES.md @@ -25,7 +25,7 @@ The status of each device, as verified on real hardware. Rows in the matrix have | Pixel 6 | oriole | gs101 (Tensor G1) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); native test image on one phone; slot B marked successful and `vbmeta_b` verification turned off, both without project approval; see notes) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); guarded `userdata` root on test image) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); connected output on test image) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); Panfrost render node present) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); touchscreen detected; input not checked by smoke) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); gpio-keys detected; input not checked by smoke) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); USB network and SSH on test image) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); link up; traffic not checked by smoke) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); controller powered; pairing not checked) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); charge and temperature reported) | WIP ([unpublished kernel/packages](../device/oriole/NOTES.md#2026-10-31-build-provenance-and-recovery-limits); charging reported; control not checked) | no | no | no | no | no | no | no | no | no | no | no | | Pixel 4 | flame | SM8150 (Snapdragon 855) | testing (temporary RAM boot; [notes](../device/flame/BRINGUP-M1.md)) | testing (RAM probe; all UFS read-only) | testing (1080x2280 console; software desktop in separate Arch payload) | testing (separate Arch payload; FD640 contexts, llvmpipe desktop) | testing (separate Arch payload; events and PIN unlock verified) | no | testing (NCM + ACM + SSH; sustained transfers can disconnect) | testing (guarded RAM scan; association untested) | no | no | no | no | no | no | - | no | no | no | no | no | no | - | | Pixel 4 XL ([notes](../device/coral/NOTES.md)) | coral | SM8150 (Snapdragon 855) | WIP (direct ABL v2 boot on the test handset's slot A; slot-B install and §3.1 entry pending; [notes](../device/coral/BRINGUP-M1.md)) | testing (read-only `blockdev` guard + RAM `overlayfs`) | testing (1440x3040@60Hz S6E3HC2 DSC 1.1 KMS, DPMS, brightness) | testing (Adreno 640 / FD640 Mesa Freedreno, Hyprland) | testing (FTS SPI multitouch + read-only flash guard) | testing (power via `qcom-pon` + volume via `gpio-keys`) | testing (CDC ECM + ACM + SSH; stays up with host USB switched off) | testing (`WCN3990` `ath10k_snoc` + `rmtfs -r`, WPA2/DHCP/HTTPS; radio sessions ran before the modem baseline) | WIP (`WCN3990` `hci_qca` `hci0` up + BLE scan; audio/pairing open) | WIP (PM8150B ADC `VBAT_SNS` voltage + FG temp; aftermarket pack on test unit: no reply from `1-0036`) | testing (PM8150B SMB5 charger with `4.20 V` / `500 mA` kernel clamp) | testing (`CS40L25A` I2C click waveform) | testing (PM8150L flash LEDs + quick-settings tile) | no | - | testing (QDSP6 + dual `CS35L36` amps capped at `-26 dB` + `IA8508` SPI mic DSP) | testing (`SLPI` + `fastrpc` + RAM-backed `hexagonrpcd` + QMI SSC: 7 sensors + Soli radar) | WIP (`MPSS` boots with `rmtfs -r` + patched `tqftpserv`, SIM detected; no IPA/voice yet; radio sessions ran before the modem baseline) | no | testing (`CAMSS` + `IMX363`, `IMX481`, `IMX520`, dual `OV7251` NIR; `libcamera` softISP) | no | - | -| Pixel 9a ([notes](../device/tegu/NOTES.md)) | tegu | zumapro (Tensor G4) | works ([#28](https://github.com/derekross/omarchy-mobile/issues/28): native boot from slot B, the Arch root on `userdata`, `omamobile-device-tegu`; slot B was marked successful by hand on 2026-10-28 with the `devinfo` write approved on 2026-10-22, now on hold ([#125](https://github.com/derekross/omarchy-mobile/pull/125)), unmarked by the 10-31 fastboot recovery and marked again on 2026-10-31 during the hold ([record](../device/tegu/NOTES.md#2026-10-31-a-fastboot-flash-of-slot-b-cleared-its-successful-mark-and-b-was-marked-again)), and the package does not mark it; unpublished kernel: the SoC and board device tree is [kernel #81](https://github.com/derekross/linux-omarchy-mobile/pull/81), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (UFS behind the read-only guard; unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (120 Hz through gs-decon; the panel driver [kernel #89](https://github.com/derekross/linux-omarchy-mobile/pull/89), 120 Hz [kernel #88](https://github.com/derekross/linux-omarchy-mobile/pull/88), merged, the display DT, merged with [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96); brightness, DPMS off and on and the 60/120 Hz switch on the boot of [kernel #125](https://github.com/derekross/linux-omarchy-mobile/pull/125), merged, which also checks the panel's ID; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on), [brightness record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) | works (Panthor, the desktop renders, runtime suspend when idle; this boot runs at a fixed 160 MHz, so frequency scaling and the GPU thermal zone count as in review, [kernel #85](https://github.com/derekross/linux-omarchy-mobile/pull/85) in review, [kernel #87](https://github.com/derekross/linux-omarchy-mobile/pull/87) in review; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (Synaptics S3908 over SPI, [kernel #81](https://github.com/derekross/linux-omarchy-mobile/pull/81), merged; survives sleep, [kernel #82](https://github.com/derekross/linux-omarchy-mobile/pull/82), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (gpio-keys: power and volume; the power key wakes from sleep; unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (CDC NCM and SSH; reconnects after a replug, `omamobile-tegu-usb-rescue`, also after a replug the gadget didn't see ([#280](https://github.com/derekross/omarchy-mobile/pull/280); [the replug record](../device/tegu/NOTES.md#2026-10-28-what-the-device-tables-claims-rest-on)); [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (BCM4383 on PCIe channel 1 through the shared gs201 host and zuma PHY, [kernel #178](https://github.com/derekross/linux-omarchy-mobile/pull/178) on [kernel #156](https://github.com/derekross/linux-omarchy-mobile/pull/156), in review, and brcmfmac, [kernel #56](https://github.com/derekross/linux-omarchy-mobile/pull/56) in review; started at boot by `omamobile-device-tegu` 0.2.4 ([#238](https://github.com/derekross/omarchy-mobile/pull/238)) with the extractor's firmware; WPA2 with iwd, kept loaded across sleep by the package's sleep hook; [record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) | works (hci_uart on the bootloader's address, BlueZ, A2DP; [kernel #94](https://github.com/derekross/linux-omarchy-mobile/pull/94); unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (MAX77779 gauge with temperature, current and time estimates through UPower; [kernel #66](https://github.com/derekross/linux-omarchy-mobile/pull/66); unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (the MAX77779 charger binds from the device tree, [kernel #161](https://github.com/derekross/linux-omarchy-mobile/pull/161), merged, built by [#227](https://github.com/derekross/omarchy-mobile/pull/227); the charge limit in `omamobile-device-tegu` 0.2.3 holds charging off at the limit through `charge_behaviour` and lets it run again 5 below; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (CS40L26A through feedbackd, with brownout prevention, [kernel #95](https://github.com/derekross/linux-omarchy-mobile/pull/95); its DT [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (LM3644, 25 steps to 75 mA, quick-settings tile; its DT [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | testing (Omarchy's Location switch serves fixes from GPS, Galileo, BeiDou and GLONASS once the modem is up, started by hand: a 30-minute session through the switch on 2026-11-01 (omamobile-gnss 0.2.5's start, the modem link left to cycle) ran clean, 1763 of 1765 GGA sentences fixed, first fix 37 s after a client connected; needs [kernel #150](https://github.com/derekross/linux-omarchy-mobile/pull/150), merged, the PERIC0 clock fix [kernel #172](https://github.com/derekross/linux-omarchy-mobile/pull/172) in review (without it the modem link hung the palmtop within minutes) and [#114](https://github.com/derekross/omarchy-mobile/pull/114); [plan](../device/tegu/MODEM-PLAN.md), record with [#202](https://github.com/derekross/omarchy-mobile/pull/202)) | works (audio and sensor DSP through the GSA and Trusty, 93 services, started at boot by `omamobile-device-tegu` 0.2.3 from the device tree, [kernel #162](https://github.com/derekross/linux-omarchy-mobile/pull/162) in review; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (the TAS2572 amplifiers and the microphone through the AoC card and PipeWire, at boot with the AoC: a tone from the speaker, the microphone at -32 dBFS; speakers at a -10 dB ceiling; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (accelerometer, light, proximity, compass and gyroscope through the AoC and the sensor proxy, at boot with the AoC; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | WIP (on the owner's kernel, 2026-11-02: registered on LTE, mobile data over `rmnet0` and texts both ways with `omamobile-modem-sit` 0.3.8 ([#356](https://github.com/derekross/omarchy-mobile/pull/356)); the package doesn't start the modem, CPIF isn't in the published kernel, and calls have no audio route; [plan](../device/tegu/MODEM-PLAN.md), [record](../device/tegu/MODEM-PLAN.md#sim-test-results-2026-11-02-730-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty)) | works (NXP ST54L through nxp-nci, its clock pad from the PMU ([kernel #104](https://github.com/derekross/linux-omarchy-mobile/pull/104) and [kernel #105](https://github.com/derekross/linux-omarchy-mobile/pull/105), merged, with [kernel #131](https://github.com/derekross/linux-omarchy-mobile/pull/131), merged), loaded at boot by `omamobile-device-tegu` 0.2.3 with neard and the link opener: polls with no I2C errors and read a payment card; polling stops before sleep; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (main, ultrawide and front from the device tree, [kernel #164](https://github.com/derekross/linux-omarchy-mobile/pull/164) in review, with [kernel #63](https://github.com/derekross/linux-omarchy-mobile/pull/63) and [kernel #103](https://github.com/derekross/linux-omarchy-mobile/pull/103) in review: their drivers load at boot with nothing by hand, libcamera lists all three, and each streams, main at 19 fps and the others at 30 fps at 1280x960; basic picture quality through libcamera's software ISP; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | testing (s2idle when asked for, or through the shell's auto-sleep with the `omamobile-sleep` toggle on, which ships off; the power key lights the lock screen on the first press ([#268](https://github.com/derekross/omarchy-mobile/pull/268), [#275](https://github.com/derekross/omarchy-mobile/pull/275)), and the RTC wakes it; on 2026-11-01 thirty attended 120 s sleeps ([plan](../device/tegu/SLEEP-PLAN.md) S1) and a day of real use with auto-sleep on ([record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) all woke, but five test sleeps from 10-28 to the morning of 11-01 did not (one in 21 on the clock-fix kernel), so sleep tests stay attended ([plan](../device/tegu/SLEEP-PLAN.md) S1); the drain is about 300 mA asleep, the same as awake with the screen off, because nothing below the CPUs sleeps yet; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (opt-in) (enrolls, matches, refuses other fingers and unlocks the lock screen through Trusty and `omamobile-fingerprint`, 2026-10-29; the sensor binds from the device tree, [kernel #165](https://github.com/derekross/linux-omarchy-mobile/pull/165) in review, with [kernel #126](https://github.com/derekross/linux-omarchy-mobile/pull/126), merged; opt-in as on the 7 Pro, because the service's first run writes Trusty's secure storage; [plan](../device/tegu/FINGERPRINT-PLAN.md), [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | +| Pixel 9a ([notes](../device/tegu/NOTES.md)) | tegu | zumapro (Tensor G4) | works ([#28](https://github.com/derekross/omarchy-mobile/issues/28): native boot from slot B, the Arch root on `userdata`, `omamobile-device-tegu`; slot B was marked successful by hand on 2026-10-28 with the `devinfo` write approved on 2026-10-22, now on hold ([#125](https://github.com/derekross/omarchy-mobile/pull/125)), unmarked by the 10-31 fastboot recovery and marked again on 2026-10-31 during the hold ([record](../device/tegu/NOTES.md#2026-10-31-a-fastboot-flash-of-slot-b-cleared-its-successful-mark-and-b-was-marked-again)), and the package does not mark it; unpublished kernel: the SoC and board device tree is [kernel #81](https://github.com/derekross/linux-omarchy-mobile/pull/81), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (UFS behind the read-only guard; unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (120 Hz through gs-decon; the panel driver [kernel #89](https://github.com/derekross/linux-omarchy-mobile/pull/89), 120 Hz [kernel #88](https://github.com/derekross/linux-omarchy-mobile/pull/88), merged, the display DT, merged with [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96); brightness, DPMS off and on and the 60/120 Hz switch on the boot of [kernel #125](https://github.com/derekross/linux-omarchy-mobile/pull/125), merged, which also checks the panel's ID; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on), [brightness record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) | works (Panthor, the desktop renders, runtime suspend when idle; this boot runs at a fixed 160 MHz, so frequency scaling and the GPU thermal zone count as in review, [kernel #85](https://github.com/derekross/linux-omarchy-mobile/pull/85) in review, [kernel #87](https://github.com/derekross/linux-omarchy-mobile/pull/87) in review; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (Synaptics S3908 over SPI, [kernel #81](https://github.com/derekross/linux-omarchy-mobile/pull/81), merged; survives sleep, [kernel #82](https://github.com/derekross/linux-omarchy-mobile/pull/82), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (gpio-keys: power and volume; the power key wakes from sleep; unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (CDC NCM and SSH; reconnects after a replug, `omamobile-tegu-usb-rescue`, also after a replug the gadget didn't see ([#280](https://github.com/derekross/omarchy-mobile/pull/280); [the replug record](../device/tegu/NOTES.md#2026-10-28-what-the-device-tables-claims-rest-on)); [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (BCM4383 on PCIe channel 1 through the shared gs201 host and zuma PHY, [kernel #178](https://github.com/derekross/linux-omarchy-mobile/pull/178) on [kernel #156](https://github.com/derekross/linux-omarchy-mobile/pull/156), in review, and brcmfmac, [kernel #56](https://github.com/derekross/linux-omarchy-mobile/pull/56) in review; started at boot by `omamobile-device-tegu` 0.2.4 ([#238](https://github.com/derekross/omarchy-mobile/pull/238)) with the extractor's firmware; WPA2 with iwd, kept loaded across sleep by the package's sleep hook; [record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) | works (hci_uart on the bootloader's address, BlueZ, A2DP; [kernel #94](https://github.com/derekross/linux-omarchy-mobile/pull/94); unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (MAX77779 gauge with temperature, current and time estimates through UPower; [kernel #66](https://github.com/derekross/linux-omarchy-mobile/pull/66); unpublished kernel; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (the MAX77779 charger binds from the device tree, [kernel #161](https://github.com/derekross/linux-omarchy-mobile/pull/161), merged, built by [#227](https://github.com/derekross/omarchy-mobile/pull/227); the charge limit in `omamobile-device-tegu` 0.2.3 holds charging off at the limit through `charge_behaviour` and lets it run again 5 below; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (CS40L26A through feedbackd, with brownout prevention, [kernel #95](https://github.com/derekross/linux-omarchy-mobile/pull/95); its DT [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (LM3644, 25 steps to 75 mA, quick-settings tile; its DT [kernel #96](https://github.com/derekross/linux-omarchy-mobile/pull/96), merged; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | testing (Omarchy's Location switch serves fixes from GPS, Galileo, BeiDou and GLONASS once the modem is up, started by hand: a 30-minute session through the switch on 2026-11-01 (omamobile-gnss 0.2.5's start, the modem link left to cycle) ran clean, 1763 of 1765 GGA sentences fixed, first fix 37 s after a client connected; needs [kernel #150](https://github.com/derekross/linux-omarchy-mobile/pull/150), merged, the PERIC0 clock fix [kernel #172](https://github.com/derekross/linux-omarchy-mobile/pull/172) in review (without it the modem link hung the palmtop within minutes) and [#114](https://github.com/derekross/omarchy-mobile/pull/114); [plan](../device/tegu/MODEM-PLAN.md), record with [#202](https://github.com/derekross/omarchy-mobile/pull/202)) | works (audio and sensor DSP through the GSA and Trusty, 93 services, started at boot by `omamobile-device-tegu` 0.2.3 from the device tree, [kernel #162](https://github.com/derekross/linux-omarchy-mobile/pull/162) in review; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (the TAS2572 amplifiers and the microphone through the AoC card and PipeWire, at boot with the AoC: a tone from the speaker, the microphone at -32 dBFS; speakers at a -10 dB ceiling; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (accelerometer, light, proximity, compass and gyroscope through the AoC and the sensor proxy, at boot with the AoC; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | WIP (registered on LTE, mobile data over `rmnet0`, texts both ways and speakerphone calls in and out with `omamobile-modem-sit` ([#356](https://github.com/derekross/omarchy-mobile/pull/356), [#367](https://github.com/derekross/omarchy-mobile/pull/367)), on the owner's kernel and on in-tree drivers from the open kernel PRs ([kernel #187](https://github.com/derekross/linux-omarchy-mobile/pull/187), [kernel #162](https://github.com/derekross/linux-omarchy-mobile/pull/162)); the package doesn't start the modem, the kernel PRs aren't merged, and calls have no echo cancellation or earpiece yet; [plan](../device/tegu/MODEM-PLAN.md), [record](../device/tegu/MODEM-PLAN.md#sim-test-results-2026-11-02-730-rc6-omamobile-tegu-s2mpg15-m1-g991042e2eff3-dirty)) | works (NXP ST54L through nxp-nci, its clock pad from the PMU ([kernel #104](https://github.com/derekross/linux-omarchy-mobile/pull/104) and [kernel #105](https://github.com/derekross/linux-omarchy-mobile/pull/105), merged, with [kernel #131](https://github.com/derekross/linux-omarchy-mobile/pull/131), merged), loaded at boot by `omamobile-device-tegu` 0.2.3 with neard and the link opener: polls with no I2C errors and read a payment card; polling stops before sleep; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | works (main, ultrawide and front from the device tree, [kernel #164](https://github.com/derekross/linux-omarchy-mobile/pull/164) in review, with [kernel #63](https://github.com/derekross/linux-omarchy-mobile/pull/63) and [kernel #103](https://github.com/derekross/linux-omarchy-mobile/pull/103) in review: their drivers load at boot with nothing by hand, libcamera lists all three, and each streams, main at 19 fps and the others at 30 fps at 1280x960; basic picture quality through libcamera's software ISP; [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | testing (s2idle when asked for, or through the shell's auto-sleep with the `omamobile-sleep` toggle on, which ships off; the power key lights the lock screen on the first press ([#268](https://github.com/derekross/omarchy-mobile/pull/268), [#275](https://github.com/derekross/omarchy-mobile/pull/275)), and the RTC wakes it; on 2026-11-01 thirty attended 120 s sleeps ([plan](../device/tegu/SLEEP-PLAN.md) S1) and a day of real use with auto-sleep on ([record](../device/tegu/NOTES.md#2026-11-01-afternoon-and-evening-wi-fi-from-the-package-the-wake-and-the-replug-storage-idle-the-panel-id)) all woke, but five test sleeps from 10-28 to the morning of 11-01 did not (one in 21 on the clock-fix kernel), so sleep tests stay attended ([plan](../device/tegu/SLEEP-PLAN.md) S1); the drain is about 300 mA asleep, the same as awake with the screen off, because nothing below the CPUs sleeps yet; [record](../device/tegu/NOTES.md#2026-10-29-the-device-package-boot-and-what-this-row-rests-on)) | works (opt-in) (enrolls, matches, refuses other fingers and unlocks the lock screen through Trusty and `omamobile-fingerprint`, 2026-10-29; the sensor binds from the device tree, [kernel #165](https://github.com/derekross/linux-omarchy-mobile/pull/165) in review, with [kernel #126](https://github.com/derekross/linux-omarchy-mobile/pull/126), merged; opt-in as on the 7 Pro, because the service's first run writes Trusty's secure storage; [plan](../device/tegu/FINGERPRINT-PLAN.md), [record](../device/tegu/NOTES.md#2026-10-31-and-11-01-every-testing-row-on-a-published-style-kernel)) | | Pixel 8 Pro ([notes](../device/husky/NOTES.md)) | husky | zuma (Tensor G3) | WIP ([#1](https://github.com/derekross/omarchy-mobile/issues/1): slot B, not marked successful; Omarchy's image from the signed repository boots to the lock screen; the zuma device tree is merged ([kernel #13](https://github.com/derekross/linux-omarchy-mobile/pull/13), [#53](https://github.com/derekross/linux-omarchy-mobile/pull/53))) | testing (UFS at HS-G4 behind the read-only guard; Arch on `userdata`; [UFS-PLAN](../device/husky/UFS-PLAN.md)) | WIP (simple-framebuffer: console and Omarchy's lock screen) | no | testing (ST FTM5 over SPI, merged, [kernel #153](https://github.com/derekross/linux-omarchy-mobile/pull/153); [NOTES](../device/husky/NOTES.md)) | testing (power and volume through `gpio-keys`, merged, [kernel #148](https://github.com/derekross/linux-omarchy-mobile/pull/148); [NOTES](../device/husky/NOTES.md)) | testing (USB and SSH) | testing (BCM4398 on a test kernel, [kernel #156](https://github.com/derekross/linux-omarchy-mobile/pull/156); firmware from the owner's image, [#214](https://github.com/derekross/omarchy-mobile/pull/214); [NOTES](../device/husky/NOTES.md)) | no | testing (gauge with Google's ATL model through a bring-up overlay, temperature, MFD, on a test kernel, [kernel #163](https://github.com/derekross/linux-omarchy-mobile/pull/163); [notes](../device/husky/BATTERY-NOTES.md)) | testing (the charger driver by hand under a dead-man tool, slow on plain 5 V, on a test kernel, [kernel #163](https://github.com/derekross/linux-omarchy-mobile/pull/163); [notes](../device/husky/BATTERY-NOTES.md)) | no | no | no | no | no | no | no | no | no | no | no | | Pixel 7 ([notes](../device/panther/NOTES.md)) | panther | gs201 (Tensor G2) | WIP (slot B, not marked successful; Arch and Hyprland boot; [BRINGUP-M1](../device/panther/BRINGUP-M1.md); board file merged, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | testing (UFS behind the read-only guard; Arch on `userdata`; merged, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | WIP (simple-framebuffer: console and the Hyprland desktop; brightness and display off/on over DCS through the S6E3FC3 panel driver and device-panther 0.1.4, in review, [kernel #177](https://github.com/derekross/linux-omarchy-mobile/pull/177); [DISPLAY-PLAN](../device/panther/DISPLAY-PLAN.md)) | testing (Panthor on the Mali-G710; Hyprland renders on it; merged through [kernel #134](https://github.com/derekross/linux-omarchy-mobile/pull/134), with the always-on rule in device-panther 0.1.1, [#145](https://github.com/derekross/omarchy-mobile/pull/145); [notes](../device/panther/NOTES.md#2026-10-28-the-gpu-and-the-haptics-power-off-and-usb-after-a-replug)) | WIP (FocalTech FT3658: touches drive Hyprland and unlock the PIN screen on a test kernel; the driver, [kernel #109](https://github.com/derekross/linux-omarchy-mobile/pull/109), and the touch node, [kernel #134](https://github.com/derekross/linux-omarchy-mobile/pull/134), are merged; stock's interrupt pull-up and CS delay, [kernel #166](https://github.com/derekross/linux-omarchy-mobile/pull/166), the driver's review fixes, [kernel #133](https://github.com/derekross/linux-omarchy-mobile/pull/133), and the kernel option with the touch notes, [#149](https://github.com/derekross/omarchy-mobile/pull/149), are merged) | testing (gpio-keys: power, volume; merged, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108)) | testing (USB and SSH; merged, [kernel #108](https://github.com/derekross/linux-omarchy-mobile/pull/108); a replug comes back through `omamobile-usb-rescue` in device-panther 0.1.3, on the MAX77759's I2C bus, merged, [kernel #167](https://github.com/derekross/linux-omarchy-mobile/pull/167); [notes](../device/panther/NOTES.md#2026-10-29-usb-comes-back-after-a-replug-u1)) | no | no | WIP (MAX77759 fuel gauge with stock's battery model on a test kernel: percentage, capacity and temperature in upower and the bar; in review, [kernel #171](https://github.com/derekross/linux-omarchy-mobile/pull/171) and the driver fix [#170](https://github.com/derekross/linux-omarchy-mobile/pull/170); [BATTERY-PLAN](../device/panther/BATTERY-PLAN.md)) | no | testing (CS40L26 with the phone's own firmware, `tools/extract-vendor-firmware -d panther`; merged through [kernel #134](https://github.com/derekross/linux-omarchy-mobile/pull/134), with the feedbackd rule in device-panther 0.1.1, [#145](https://github.com/derekross/omarchy-mobile/pull/145); [notes](../device/panther/NOTES.md#2026-10-28-the-gpu-and-the-haptics-power-off-and-usb-after-a-replug)) | no | no | no | no | no | no | no | no | no (s2idle by default since [kernel #134](https://github.com/derekross/linux-omarchy-mobile/pull/134) and device-panther 0.1.1; not run yet) | no | | OnePlus 13 ([notes](../device/dodge/NOTES.md)) | dodge | sm8750 (Snapdragon 8 Elite) | testing (kernel [mrlund/linux-omarchy-mobile `dodge-v3-20261101`](https://github.com/mrlund/linux-omarchy-mobile/tree/dodge-v3-20261101); [kernel #115](https://github.com/derekross/linux-omarchy-mobile/pull/115) closed; [BRINGUP](../device/dodge/BRINGUP-M1.md), [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing ([notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (msm/dpu; warm-boot drop fixed; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (Adreno 830 / gpu2; Vulkan untested; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing ([notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing ([notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (CDC NCM + SSH; gadget stuck after replug until reboot; kernel [mrlund/linux-omarchy-mobile `dodge-v3-20261101`](https://github.com/mrlund/linux-omarchy-mobile/tree/dodge-v3-20261101); [kernel #115](https://github.com/derekross/linux-omarchy-mobile/pull/115) closed; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (WCN7860 / ath12k; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (pairing; A2DP untested; kernel [mrlund/linux-omarchy-mobile `dodge-v3-20261101`](https://github.com/mrlund/linux-omarchy-mobile/tree/dodge-v3-20261101); [kernel #115](https://github.com/derekross/linux-omarchy-mobile/pull/115) closed; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (gauge; charging path not claimed; kernel [mrlund/linux-omarchy-mobile `dodge-v3-20261101`](https://github.com/mrlund/linux-omarchy-mobile/tree/dodge-v3-20261101); [kernel #115](https://github.com/derekross/linux-omarchy-mobile/pull/115) closed; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | no | no | no | no | - | testing (speakers, earpiece, mics; headset plug untested; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (accel, prox, compass; autorotate; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | testing (LTE data; calls/SMS untested; opt-in flag; [modem](../device/dodge/modem/README.md), [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | no | no | WIP (s2idle not default; [notes](../device/dodge/NOTES.md#2026-10-28-matrix-evidence)) | no | diff --git a/docs/TELEPHONY-APPS-PLAN.md b/docs/TELEPHONY-APPS-PLAN.md index 148163675..974336f95 100644 --- a/docs/TELEPHONY-APPS-PLAN.md +++ b/docs/TELEPHONY-APPS-PLAN.md @@ -134,7 +134,7 @@ shell status / quick settings ──────────────── └─ AoC voice PCMs (EP5/EP4), rmnet0 ``` -- **Why a separate process.** `omamobile-sitd` holds the safety model: the allow-list, the do-not-send list, durable SMS sends that never repeat, and power-off when a hangup isn't confirmed. Keeping D-Bus out of it keeps that code small and keeps its tests (`tools/sit-sim`) as they are. A crash in the bridge can't drop a call, and the bridge can restart freely, which the RIL can't (a second start-up on the same CP isn't supported). +- **Why a separate process.** `omamobile-sitd` holds the safety model: the allow-list, the do-not-send list, durable SMS sends that never repeat, and radio-off recovery for unconfirmed call release. Keeping D-Bus out of it keeps that code small and keeps its tests (`tools/sit-sim`) as they are. A crash in the bridge can't drop a call, and the bridge can restart freely, which the RIL can't (a second start-up on the same CP isn't supported). - **Why Python, with dbus-fast.** This differs from the apps, and it is Q3. The RIL is Python, and ofono2mm shows that Python with dbus-fast carries MM's whole API. The bridge is a translation layer with no performance load, and the same team reads both sides. Read Droidian's BSD-3-Clause original for structure (compatible with our MIT tree), and FuriLabs' GPL-2.0 fork for reference only. Rust with zbus is the alternative if the owner wants one language for everything new. It would add a toolchain to the system side, and the apps wouldn't share code with it anyway, since they use MM's public API. - **Changes to `omamobile-sitd`'s socket API** (T0, offline, against `tools/sit-sim`): - `subscribe`: a long-lived connection that receives one JSON event per change, with call, SMS, registration, signal and SIM events. The bridge then doesn't poll `state.json`. @@ -144,6 +144,7 @@ shell status / quick settings ──────────────── - **Packaging, as built (T1, `packages/omamobile-mmd` 0.1.0; [MODEM-PLAN](../device/cheetah/MODEM-PLAN.md) "T0/T1: the ModemManager bridge"):** - Its own package, `omamobile-mmd`, with `conflicts=(modemmanager)` and **no `provides=`**: nothing in Arch or Arch Linux ARM hard-depends on `modemmanager` (gnome-calls, chatty, networkmanager and geoclue need only libmm-glib; mmsd-tng is AUR-only and also needs only libmm-glib). - It ships `omamobile-mmd.service`, not `ModemManager.service`, with no `dbus-org.freedesktop.ModemManager1.service` alias: `Type=dbus`, `BusName=org.freedesktop.ModemManager1`, `Conflicts=ModemManager.service`, `WantedBy=omamobile-sitd.service`, and not enabled by the package. It also ships the D-Bus bus policy (only root owns the name) and MM's polkit actions. + - Since mmd 0.1.1, the unit has no `Conflicts=ModemManager.service`: starting the bridge must not stop another modem daemon. Package conflicts and exclusive D-Bus name ownership still provide exclusion. The optional tegu integration adds Requisite on an already active sitd, a read-only service check, and an attended attachment helper; it enables neither modem nor RIL. - **No D-Bus activation file**, so no client can start the bridge. Enabled, it starts with `omamobile-sitd`. - No `mmcli` and no CLI of our own. Phone runbooks read the modem through libmm-glib with `test/libmm-status.py`; mmcli runs only in the conformance container (`test/conformance`). - **Packaging, superseded (the design before T1, kept for history; not built):** a package named `omamobile-mm` with `provides=(modemmanager)` and `conflicts=(modemmanager)`, shipping `ModemManager.service` aliased `dbus-org.freedesktop.ModemManager1.service`, the bus policy, a D-Bus activation file, and `mmcli` or a small `omamobile-mm-cli`. T1 dropped `provides=` (no package needs it), the activation file (so no client can start the bridge) and the takeover of ModemManager's unit name. @@ -162,8 +163,8 @@ Today `omamobile-sit-data` puts `rmnet0` behind Wi-Fi with metric 700, and Netwo | Need | How | Ready? | | --- | --- | --- | -| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up | No: the codec keeps the bytes but nothing passes them on (T0, T3) | -| An APN that carries MMS | mmsd-tng's `MMS_APN` must match the connected bearer's APN. mmsd-tng supports no separate MMS bearer ("limitations of Modem Manager", its README), so the carrier must allow MMS on the internet APN. Many US carriers do; check ours (Q8) | Our config has one APN (`[network] apn`) | +| WAP push (the MMS notification) arrives as a binary SMS | sitd passes the PDU's user data through; the bridge exports an `Sms` with `Data` set and `Text` empty, which mmsd-tng picks up | Implemented in T0/T1: binary WAP bytes reach Sms.Data; mmsd-tng integration remains T3 | +| An APN that carries MMS | mmsd-tng's `MMS_APN` must match the connected bearer's APN. mmsd-tng does not create a separate MMS bearer. Source review shows it can select an already connected second APN; see §1.7a for the 9a design and the remaining qualification (Q8) | Our config has one APN (`[network] apn`) | | Fetch from the MMSC over mobile data, even with Wi-Fi up | mmsd-tng binds HTTP to the bearer's interface (`SO_BINDTODEVICE`, `src/service.c:3720-3732`) and resolves through that interface's DNS (c-ares or systemd-resolved with the ifindex). Needs `CarrierMMSC`, `CarrierMMSProxy`, or `http://mms.invalid` to look them up in mobile-broadband-provider-info | **Depends on M4.3:** rmnet0 is configured IPv4 only (MODEM-CLIENT §1.3). If the carrier's bearer is IPv6-only (common on T-Mobile's network [I]), MMS needs IPv6 on rmnet0 first. The packet processor (MODEM-PLAN 6.3) is built but untested on hardware; the legacy buffers carry data meanwhile | | Sending MMS | mmsd-tng posts the M-Send.req to the MMSC the same way | as above | | Storage and UI | mmsd-tng stores messages and serves `org.ofono.mms` on the session bus; Chatty and our app are its clients | install `mmsd-tng` (T3) | @@ -171,6 +172,199 @@ Today `omamobile-sit-data` puts `rmnet0` behind Wi-Fi with metric 700, and Netwo **What our data path still lacks for MMS** (MODEM-PLAN 6.3 and MODEM-CLIENT §1.3): M4.3 passing on the phone, IPv6 on `rmnet0` (or proof that the carrier gives IPv4), and the bearer exported as a Bearer object. Throughput isn't an issue for MMS (messages are a few hundred kB), so the packet processor isn't a prerequisite. +### 1.7a T3 on the Pixel 9a: a separate MMS bearer (2026-11-03) + +**Status: offline design, with the first sitd primitive implemented in +omamobile-modem-sit 0.3.13. MMS in Messages is not implemented or tested on a +phone.** This follows T3; it does not require changing the working internet +or IMS APN. Carrier settings belong in private configuration, never here. + +**Source check.** Read mmsd-tng **2.6.4**, upstream commit +[`341117141f8d30949fb1294cc71ee44af9b4c90f`](https://gitlab.com/kop316/mmsd/-/tree/341117141f8d30949fb1294cc71ee44af9b4c90f), +as data only (no upstream scripts or build run). Its GPL-2.0 +[`plugins/modemmanager.c`](https://gitlab.com/kop316/mmsd/-/blob/341117141f8d30949fb1294cc71ee44af9b4c90f/plugins/modemmanager.c) +provides a narrower result than the README's “no multiple APNs” warning: +`set_context()` (lines 1406–1532) **iterates all listed bearers** and selects +one whose `Properties.apn` matches `MMS_APN`, case-insensitively, whose +`Connected` is true, and whose modem has state `CONNECTED`. It takes that +bearer's interface and IPv4/IPv6 DNS. It **never creates or connects a +missing MMS bearer**; that branch is a stub. Thus an already connected +second APN supplied by our stack is a viable design, not an upstream or +hardware qualification. Only one MMS context is used at a time. + +#### The SIT bearer + +The saved stock library check identified MMS as supported-types bit +**`0x00000002`**, alongside default `0x01` and IMS `0x40`. The implementation +uses the existing setup builder; no vendor bytes or disassembly are copied +into this repository. The 983-byte request carries that little-endian +bitmap at **full-request offset `0xf1`** (payload `0xe5`). Its separate, +legacy APN selector at full offset `0x0f` stays **0**, not 2: that selector +distinguishes default/IMS/emergency. The APN, IP family and credentials are +separate fields. Current code supports unauthenticated APNs only; a carrier +requiring PAP/CHAP needs a separate, tested extension. + +Reserve **CID 3 / rmnet2** for MMS, leaving CID 1 / rmnet0 for internet and +CID 2 / rmnet1 for IMS. This is the driver's existing CID-to-interface +convention; confirm rmnet2 exists and carries CID 3 in the attended phase. +“Second bearer” means the second application data bearer; IMS may also be +active. Leave the cellular PDU session ID at **0**, as for internet and IMS. +Do not send ALLOC_PDU_SESSION. Do not rewrite SET_INITIAL_ATTACH_APN, +SET_DATA_PROFILE, SET_MOBILE_DATA_STATE or SET_PS_SERVICE for MMS. Those +permission writes have caused re-attachment in the SIM investigation. +`bringup.py` continues to provision only the internet attach/default profile +and IMS; this change does not move its existing permission writes. + +**Implemented here:** `data_call.activate(client, mms_apn, mms=True, +ip_type=...)` and `deactivate(client, 3)`. MMS requires registration, an +owned and currently active internet bearer with a successful saved response, +already enabled PS permission, and exact agreement between listed and owned +CIDs. It refuses an occupied or uncertain target and unknown bearers. Private +RAM files `mms-session.json` and `mms-response.bin` keep its ownership and +response apart from internet/IMS. An outright refusal clears only the MMS +reservation; a timeout keeps it and blocks a blind retry. Release requires +rmnet2 down, confirms CID 3 is absent, and preserves other bearer records. +Existing internet/IMS activation remains unchanged. MMS is deliberately a +**library entry point**, not a new socket command, boot request, CLI or host +network route. Its caller must remain sitd's sole IPC0 owner. + +**Next sitd work is larger than a payload flag:** add a bounded MMS lifecycle +request to the authenticated socket, driven by explicitly configured +`[mms] apn` and `ip_type`, disabled by default. Do not accept arbitrary APNs, +CIDs or raw SIT from an app. Schedule the operation in the IPC0 owner while +continuing call/SMS handling; a 45-second setup cannot simply block +`Service.dispatch()`, and a bridge worker must not open another IPC0 channel. +Serialize setup/release, distinguish reserved/active/host-configured/unknown, +and handle IND_DATA_CALL_LIST_CHANGED plus a confirming list query. Publish +per-bearer changes, not just the current `modem.data` flag (which is inferred +from an ownership file and is insufficient proof of connectivity). Expose +addresses/DNS only on the authorized socket; the public state file gets +states/counts, not addresses, APNs or identifiers. An MMS failure never +releases internet/IMS, retries an unknown setup, stops the CP or restarts sitd. + +If the carrier supports MMS on the internet APN, **reuse the configured +internet bearer** instead of manufacturing a second connection to the same +APN. Do not assume APN equality alone proves carrier permission. A separate +MMS APN uses CID 3; carrier allowance of simultaneous contexts remains to be +qualified. Keep an existing voice call responsive throughout either path. + +#### The bridge, host network and MMS proxy + +| Component | Present on this branch | T3 change | +| --- | --- | --- | +| `Modem.Bearers`, `ListBearers`, ObjectManager | One rmnet0 object; maximum one bearer | Export stable per-bearer objects for internet and MMS, matching APNs, `Connected`, interface and real supported capacity; emit object/property changes on setup, loss and release. IMS stays internal. Do not advertise unqualified hardware capacity as established fact | +| `Bearer.Ip4Config`, `Ip6Config` | Empty defaults; configured APN/IP type only | Export actual address, prefix, DNS and supported MTU from validated private setup responses. A reservation is not a connected bearer; do not publish `Connected` until host configuration succeeds | +| Bearer control | `CreateBearer`, `DeleteBearer`, `Connect`, `Disconnect` and `Simple.Connect/Disconnect` unsupported | First expose a prepared MMS bearer; a bounded agent-to-bridge request may prepare it. A later MM connection implementation must map only allowed profiles to sitd's lifecycle and return MM errors without altering the internet bearer. mmsd-tng itself needs **ListBearers**, not CreateBearer | +| `Modem.Messaging` and `Sms` | List/Messages, Added/Deleted, Delete and binary `Data` already implemented | Retain `PduType=DELIVER`, `State=RECEIVED`, **empty Text and nonempty Data** for complete WAP pushes, including joined multipart messages. Codec/bridge tests already cover this. Let mmsd-tng consume and delete them; omatel's SMS handler already leaves them alone | +| Modem state | CONNECTED derived from the internet reservation flag | Derive connectivity from confirmed, host-configured application bearers. MMS must be discoverable even if internet routing is disabled; SIM/radio/registration state still takes precedence | +| Host networking | `data_network.py` owns only rmnet0, IPv4 /32, fallback default route and DNS | Own rmnet2 separately, with returned IPv4 and/or IPv6 configuration and per-interface DNS. Do not call rmnet0's helper for MMS or change the system default route/resolver. Add routes or an output-interface policy table for MMSC/proxy **and DNS**, so interface-bound sockets have a route even while Wi-Fi is preferred. Revert only resources created for MMS | + +The **carrier MMS proxy is not another ModemManager interface**. mmsd-tng +owns it: `CarrierMMSC`, `CarrierMMSProxy` (`host:port` or `NULL`) and +`MMS_APN` live in its per-user settings at `~/.mms/modemmanager/mms`. +`org.ofono.mms.ModemManager` on the **session bus**, object `/org/ofono/mms`, +provides `ViewSettings`, `ChangeSettings(s,v)`, `ChangeAllSettings(a{sv})` +and `ProcessMessageQueue()`. Use the source's introspection signatures, +not the older prose signature for ChangeSettings. Once the MMS bearer is +ready, the agent calls ProcessMessageQueue: adding a bearer need not change +the modem from CONNECTED to CONNECTED, so a Modem.StateChanged hook alone +cannot wake the queue. mmd owns the **system-bus** MM service; omatel gets a +separate session-bus MMS proxy and coordinates preparation through the bridge. + +[`src/service.c`](https://gitlab.com/kop316/mmsd/-/blob/341117141f8d30949fb1294cc71ee44af9b4c90f/src/service.c) +binds HTTP to the selected interface (`SO_BINDTODEVICE`, lines 3720–3742), +uses the bearer's DNS through c-ares or resolved's link index, and configures +the HTTP proxy in `mms_service_bearer_notify()`. It configures neither IP +addresses nor routes. Its socket-bind failure only logs and continues; +package/integration work must make a failed bind fail the transfer and test +that MMSC/proxy traffic cannot escape over Wi-Fi. Check the actual target +kernel's bind permissions before choosing packaging; do not run the session +daemon as root to hide a permission failure. + +Start mmsd-tng as the same session user as omatel, with no modem-start side +effect. Set `AutoProcessSMSWAP` for mmsd-tng to be the one WAP consumer and +`AutoProcessOnConnection` as desired; the agent must not also PushNotify the +same SMS. The plugin looks up SIM IMSI and own numbers, currently redacted +by mmd: test empty values and explicitly configured MMSC/APN/E.164 own +number, rather than exposing identifiers or relying on provider lookup. +The examined code's own-number fallback is inside the OwnNumbers loop; +an empty array needs a regression test and possibly a small upstream fix. +This matters for stripping oneself from group recipients. Do not log MMS +URLs, phone numbers, settings, WAP bytes or attachments (upstream debug +output includes these). + +#### Messages and omatel + +Messages 0.2.1 has a disabled attachment button and an MMS settings +placeholder; accepting an `mms:` URI is not a transport. The locally cached +omatel 0.2.1 source has `transport`, `mms_path` and a `parts` table, but only +SMS ingestion/sending. The package pins omatel-agent 0.2.4; recheck that tag +before implementation rather than treating the older cached source as a +current release audit. + +Add typed session-bus proxies for mmsd-tng's **Manager, Service and Message** +APIs, following +[`src/dbus.h`](https://gitlab.com/kop316/mmsd/-/blob/341117141f8d30949fb1294cc71ee44af9b4c90f/src/dbus.h) +and [`doc/message-api.txt`](https://gitlab.com/kop316/mmsd/-/blob/341117141f8d30949fb1294cc71ee44af9b4c90f/doc/message-api.txt). +Discover services with GetServices/ServiceAdded; reconcile existing messages +with GetMessages, then follow MessageAdded, MessageRemoved and each +Message.PropertyChanged. Reconcile again after a daemon restart. Keep +mmsd-tng's store authoritative for the transfer, with durable, deduplicated +omatel references and `transport=mms`. Incoming attachments name a PDU file +**plus offset and length**, not necessarily standalone image files. Validate +bounds, materialize private parts as needed, and keep MMS deletion/read +state coordinated with Message.Delete/MarkRead. + +Sending calls `Service.SendMessage(as recipients, v options, a(sss) +attachments) -> o path`: options may contain Subject/DeliveryReport/SMIL; +attachments contain content ID, MIME type and an absolute filename readable +by the session daemon. Text is a text attachment, not a normal SMS Send. +Persist the returned MMS path and follow its state; a timeout must reconcile +rather than blindly submit again. Add an attachment chooser, previews and +bounded decoding, carrier size/count checks, incoming text/image bubbles, +download/failure state, retry behavior, notifications and persistent +multi-recipient threads. Obtain size/count limits from Service.GetProperties; +never silently send a group message to only its first recipient. Enable the +attach control only when this backend exists. Stop/restart either app or +agent without losing or duplicating an MMS. + +#### Offline tests and attended acceptance + +| Layer | Test, with fictional payloads only | +| --- | --- | +| Implemented sitd primitive | Stock-sized MMS request with bit 2/selector 0 and each IP family; separate CID ownership; refusal/unknown setup/unknown release; unknown bearer, inactive internet, permission off and host-link-up guards; internet/IMS records remain byte-identical | +| Implemented sit-sim integration | One IPC0 owner creates internet, IMS and MMS, lists all three, then releases only MMS. Transcript asserts CID/bitmap/selector/session and absence of permission/attach/profile/PDU allocation writes after the IMS setup | +| Next sitd/bridge tests | Slow or timed-out MMS setup while incoming call/SMS remains responsive; bearer-list loss, stale responses and daemon/bridge restart; libmm-glib sees both APNs, addresses/DNS and correct signals; a prepared second bearer is selected without CreateBearer. Cover MMS added while modem remains CONNECTED | +| Next mmsd integration | On private buses, use a packaged test binary (do not run fetched source scripts). WAP on port 2948, multipart/out-of-order/duplicate pushes; empty IMSI/OwnNumbers; one deleting consumer; matching second APN behind an unrelated first bearer; ProcessMessageQueue after prepare; queue survives mmd/mmsd restart | +| Next HTTP/UI tests | Fake MMSC and HTTP proxy in an isolated laptop network namespace, separate simulated Wi-Fi/MMS interfaces and DNS, IPv4/IPv6. Assert GET/POST and DNS leave through MMS, bind failure fails closed, group recipients and image parts round-trip; store/import limits and app/agent restarts preserve messages | + +Current laptop commands (risk **low**, no phone or upstream scripts): + +```sh +packages/omamobile-modem-sit/test/all +tests/packages omamobile-modem-sit +tools/pr-check sitd-tegu-call-audio +``` + +Expect: all touched-package tests and the PR gate pass. Stop on a failure; +rollback is the parent branch or removal of this isolated worktree. These +checks validate protocol/lifecycle behavior only, not carrier acceptance, +rmnet2 mapping, MTU, simultaneous contexts or actual HTTP routing. + +**Future phone gate, not authorized or run here:** after the full bridge, +network and app pieces pass offline, write a separately reviewed runbook +with the actual commands and kernel release. First read-only NV checksum, +CP/registration, existing bearers and rmnet links; retain the existing sleep +inhibitor and attended modem restrictions. Then one authorized MMS setup +with a laptop log stream/watchdog, confirming internet/IMS/call state and +partitions unchanged, followed by one image received/sent while Wi-Fi is up +and one group exchange. Risk **medium**: a new PDN may disturb registration. +Stop on re-attachment, call/SMS regression, unknown setup/release, interface +mismatch or any NV/UFS error; do not retry automatically. Roll back only +owned MMS host resources, then confirmed CID 3 release if safe. An uncertain +outcome remains owned for an attended reboot; never stop/reset the running +CP in place. No startup unit or automatic retries until qualification. + ### 1.8 Requirements against MODEM-PLAN | Requirement | MODEM-PLAN / other plan | State (2026-10-14) | @@ -206,6 +400,9 @@ On gs201 the voice path never passes through the application processor. **The Ao Beyond the mixer paths, the working stack on this phone model sets `Voice Call Audio Enable`, `Voice Call Mic Source` 1, `Incall Sink Mute` 0, `AoC Modem Downlink ASRC Mode` 1 and a mic gain of 130 cB plus 6 dB. It opens **PCM 4 playback (EP5)** and **PCM 11 capture (EP4)** (MODEM-PLAN 6.1). Our card numbers its PCMs as stock does (AGENTS.md), so those numbers hold. `omamobile-sitd`'s `voice_audio.py` does exactly this and restores every control after the call. Our sound card already describes the back ends these paths need: `BT_RX`/`BT_TX`, `USB_RX`/`USB_TX` and `INCALL_RX`/`INCALL_TX` (`device/cheetah/overlays/aoc-sound-test.dtso`). +The 9a's opt-in AEC upload and conservative earpiece route have a separate +[offline implementation and qualification note](../device/tegu/CALL-AUDIO-TUNING.md). + ### 2.2 The work, per audio route | Route | What's needed | Depends on | Effort | diff --git a/packages/omamobile-device-cheetah/PKGBUILD b/packages/omamobile-device-cheetah/PKGBUILD index 932d52227..1c8f5d065 100644 --- a/packages/omamobile-device-cheetah/PKGBUILD +++ b/packages/omamobile-device-cheetah/PKGBUILD @@ -9,7 +9,7 @@ url="https://github.com/derekross/omarchy-mobile" license=(MIT Apache-2.0) depends=(bash systemd util-linux omamobile-keyring i2c-tools) # Keep CPIF and its link driver behind the modem's guarded startup. -provides=(omamobile-modem-policy) +provides=(omamobile-modem-policy omamobile-sitd-policy) backup=(etc/pacman.d/omamobile-mirrorlist) install=omamobile-device-cheetah.install optdepends=('omamobile-boot-update: writes kernel package updates to slot B from the boot files this package ships') diff --git a/packages/omamobile-device-cheetah/test/all b/packages/omamobile-device-cheetah/test/all index 03efe732f..dda308413 100755 --- a/packages/omamobile-device-cheetah/test/all +++ b/packages/omamobile-device-cheetah/test/all @@ -146,3 +146,9 @@ net=vendor/systemd/network/20-usb-gadget.network metric=$(sed -n '/^\[Route\]/,/^\[/{s/^Metric=//p}' "$net") [[ ${metric:-0} -gt 700 ]] || fail "usb0's gateway goes after Wi-Fi (600) and mobile data (700)" pass "USB is the last gateway" + +# The canonical sitd unit gets its modem dependency from this device policy. +[[ -f $tmp/root/usr/lib/systemd/system/omamobile-sitd.service.d/10-device-modem.conf ]] \ + || fail "the device sitd policy is staged" +grep -q 'omamobile-sitd-policy' PKGBUILD || fail "the package provides its sitd policy capability" +pass "the device sitd policy is staged and provided" diff --git a/packages/omamobile-device-cheetah/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf b/packages/omamobile-device-cheetah/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf new file mode 100644 index 000000000..bfa4628f3 --- /dev/null +++ b/packages/omamobile-device-cheetah/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +# Preserve this device's modem-start dependency for the canonical sitd unit. +[Unit] +Requires=omamobile-modem.service +After=omamobile-modem.service diff --git a/packages/omamobile-device-cheetah/version b/packages/omamobile-device-cheetah/version index 528bd040e..7172442a1 100644 --- a/packages/omamobile-device-cheetah/version +++ b/packages/omamobile-device-cheetah/version @@ -1 +1 @@ -0.1.39 +0.1.40 diff --git a/packages/omamobile-device-raven/PKGBUILD b/packages/omamobile-device-raven/PKGBUILD index 3ab38fb4d..5ed38b3cf 100644 --- a/packages/omamobile-device-raven/PKGBUILD +++ b/packages/omamobile-device-raven/PKGBUILD @@ -8,7 +8,7 @@ url="https://github.com/derekross/omarchy-mobile" license=(MIT Apache-2.0) depends=(bash iproute2 jq systemd util-linux i2c-tools) # The modem's drivers stay blacklisted until its runtime loads them -provides=(omamobile-modem-policy) +provides=(omamobile-modem-policy omamobile-sitd-policy) # The [omamobile] entry in pacman.conf and its mirror list, as cheetah's # package does (rootfs/pacman.conf includes the mirror list). backup=(etc/pacman.d/omamobile-mirrorlist) diff --git a/packages/omamobile-device-raven/test/all b/packages/omamobile-device-raven/test/all index 83c5fdc01..050b045b3 100755 --- a/packages/omamobile-device-raven/test/all +++ b/packages/omamobile-device-raven/test/all @@ -70,6 +70,10 @@ done || fail "the sleep hook is linked into system-sleep" [[ $(readlink "$tmp/root/usr/lib/systemd/user/graphical-session.target.wants/omamobile-sleepd.service") == ../omamobile-sleepd.service ]] \ || fail "the sleep watcher is enabled by a vendor wants link" +# The canonical sitd unit gets its modem dependency from this device policy. +[[ -f $tmp/root/usr/lib/systemd/system/omamobile-sitd.service.d/10-device-modem.conf ]] \ + || fail "the device sitd policy is staged" +grep -q 'omamobile-sitd-policy' PKGBUILD || fail "the package provides its sitd policy capability" pass "install stages the package" # omamobile-wlan-mac only ever sets a unicast, globally administered address diff --git a/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf new file mode 100644 index 000000000..bfa4628f3 --- /dev/null +++ b/packages/omamobile-device-raven/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: MIT +# Preserve this device's modem-start dependency for the canonical sitd unit. +[Unit] +Requires=omamobile-modem.service +After=omamobile-modem.service diff --git a/packages/omamobile-device-raven/version b/packages/omamobile-device-raven/version index 5ef49d2f0..013adb716 100644 --- a/packages/omamobile-device-raven/version +++ b/packages/omamobile-device-raven/version @@ -1 +1 @@ -0.1.29 +0.1.30 diff --git a/packages/omamobile-device-tegu/PKGBUILD b/packages/omamobile-device-tegu/PKGBUILD index da1e2b777..2732b538d 100644 --- a/packages/omamobile-device-tegu/PKGBUILD +++ b/packages/omamobile-device-tegu/PKGBUILD @@ -8,7 +8,8 @@ arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) depends=(bash systemd kmod bluez-utils omamobile-keyring) -provides=(omamobile-device omamobile-modem-policy) +optdepends=('omamobile-telephony-tegu: attach Phone and Messages to an attended running sitd') +provides=(omamobile-device omamobile-modem-policy omamobile-sitd-policy) conflicts=(omamobile-device) backup=(etc/pacman.d/omamobile-mirrorlist) install=omamobile-device-tegu.install diff --git a/packages/omamobile-device-tegu/README.md b/packages/omamobile-device-tegu/README.md index 5d9dafe74..250c784af 100644 --- a/packages/omamobile-device-tegu/README.md +++ b/packages/omamobile-device-tegu/README.md @@ -149,3 +149,69 @@ that loaded them, from its own staged copies, not the package: the package blacklists both and starts neither. Licence: MIT. + +## The modem at boot (opt-in) + +`omamobile-tegu-modem-up` starts the CP once per boot: the kernel's own +drivers when it carries them (`cpif`, `pcie_gs201_cp` and the device tree's +`cpif` node), else the bring-up modules in `/var/lib/omamobile-tegu/modem`. +In order, it: + +1. takes a sleep inhibitor (suspend with the CP up isn't qualified on the + 9a, so nothing sleeps until the reboot); +2. writes and syncs a latch, `/var/lib/omamobile/modem-bringup-started`; +3. loads the drivers (refusing a `pcie_gs201_cp` already loaded without + `allow_hw`); +4. runs the modem profile's read-only NV check, which needs CPIF loaded; +5. starts the profile and waits for CP ONLINE; +6. with `--phone`, starts `omamobile-sitd` and, when installed, + `omamobile-mmd` for Phone and Messages. + +The latch stays from step 2 until the profile's unit stops cleanly at +shutdown. A start that never reached ONLINE, or a boot that hung or reset +with the modem up, leaves it, and every later start refuses until you've +read `/var/log/omamobile/modem.log` and the last boot's journal and removed +it. It also refuses a second start in a boot that already loaded CPIF. +Never stop the modem by hand; the reboot's shutdown stops it. + +The in-tree driver branch (the kernel's `cpif` and `pcie_gs201_cp`) hasn't +run through this script yet; the in-tree drivers have run from the +bring-up runners. + +### Starting it at boot + +`omamobile-tegu-modem-boot.service` runs `omamobile-tegu-modem-up --phone` +at boot. The package installs it disabled. Before enabling it: + +- **Slot B marked successful.** Otherwise every reset spends one of ABL's + three tries, and at zero it boots stock on slot A, which has overwritten + `userdata`. +- **A kernel with linux-omarchy-mobile#172** (the PERIC0 GPIO bus clock + kept on). Without it the modem's GPIO writes hang the palmtop within + minutes. +- **The charger in** for the first boots. + +Then `systemctl enable omamobile-tegu-modem-boot`. With it on the battery +drains as if awake, since the palmtop no longer suspends. + +**Rollback:** `systemctl disable omamobile-tegu-modem-boot`, then reboot. +If the palmtop resets before you can log in, the latch does the work: the +boot after a reset with the modem up finds it and doesn't start the modem, +so log in then, disable the unit and remove the latch. If it still doesn't +come up, hold Volume Down + Power for fastboot and boot a known-good image +set. + +## Optional Phone and Messages attachment + +`omamobile-telephony-tegu` is an opt-in companion package; it installs the +ModemManager-compatible bridge and session agent without enabling or +starting the radio. Its attended helper attaches only to a running tegu +modem and sitd. See its [runbook](../omamobile-telephony-tegu/README.md). + +This device package supplies sitd's modem-unit policy under +`omamobile-sitd.service.d/10-device-modem.conf`: Requisite and ordering on +`omamobile-tegu-modem.service`, with a CP ONLINE check before any future +sitd start. It supplies no CP starter and enables neither service. It +also prevents the generic modem runtime unit from starting on tegu. +Remove any old full sitd unit copy in `/etc` using the runbook's attended +migration; the package does not delete human overrides. diff --git a/packages/omamobile-device-tegu/bin/omamobile-tegu-modem-up b/packages/omamobile-device-tegu/bin/omamobile-tegu-modem-up new file mode 100644 index 000000000..eea71db48 --- /dev/null +++ b/packages/omamobile-device-tegu/bin/omamobile-tegu-modem-up @@ -0,0 +1,138 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# omamobile-tegu-modem-up: start the Pixel 9a's modem once per boot and, with +# --phone, the phone service on top (device/tegu MODEM-PLAN M5 and M-SIM, +# TELEPHONY-PLAN section 2). +# +# omamobile-tegu-modem-up [--gnss] [--phone] +# --gnss gnssd too (OMAMOBILE_MODEM_GNSS=1) +# --phone after CP ONLINE, start omamobile-sitd, and omamobile-mmd when +# it's installed (Phone and Messages); omamobile-tegu-modem.service +# runs it this way at boot when the owner has enabled it +# +# The CP drivers come from the running kernel when it carries them (cpif and +# pcie_gs201_cp, with the device tree's cpif node: the published kernel), else +# from the bring-up modules in /var/lib/omamobile-tegu/modem (the owner's +# integration kernel). The modem profile runs as the transient unit +# omamobile-tegu-modem, whose stop powers the CP off before rfsd goes. +# +# Rules this script keeps (AGENTS.md, "Suspend and modem"): +# - one CP start per boot: a second start in the same boot stalled in the +# ROM, so a boot that loaded CPIF refuses (reboot to start again); +# - never stop the modem by hand: the attended reboot's shutdown stops it; +# - a latch (/var/lib/omamobile/modem-bringup-started) is written before any +# driver loads and removed only when the modem profile's unit stops +# cleanly at shutdown: a start that never reached ONLINE, or a boot that +# hung or reset with the modem up, leaves it, and later boots refuse until +# a human removes it (TELEPHONY-PLAN section 2.4); +# - no system suspend once the CP is up: a sleep inhibitor, its own unit, is +# taken before any driver loads and lasts until the reboot. +set -euo pipefail +# The overrides are for test/modem-up's scratch root only. +B=${OMAMOBILE_MODEM_MODULES:-/var/lib/omamobile-tegu/modem} +LATCH=${OMAMOBILE_MODEM_LATCH:-/var/lib/omamobile/modem-bringup-started} +CP_STATE=${OMAMOBILE_MODEM_CP:-/usr/lib/omamobile-vendor/omamobile-modem-cp} +CHROOT=${OMAMOBILE_VENDOR_CHROOT:-/usr/lib/omamobile-vendor/omamobile-vendor-chroot} +SYS=${OMAMOBILE_SYS:-/sys} +DT=${OMAMOBILE_DT:-/proc/device-tree} +LOG=${OMAMOBILE_MODEM_LOG:-/var/log/omamobile} +say() { printf 'omamobile-tegu-modem-up: %s\n' "$*"; } +gnss=0 phone=0 +for a in "$@"; do + case $a in + --gnss) gnss=1 ;; + --phone) phone=1 ;; + *) say "usage: omamobile-tegu-modem-up [--gnss] [--phone]"; exit 2 ;; + esac +done +[[ $EUID -eq 0 || -n ${OMAMOBILE_MODEM_TEST:-} ]] || { say "run as root"; exit 1; } + +phone_up() { + ((phone)) || return 0 + systemctl start omamobile-sitd.service + say "phone service started" + if systemctl cat omamobile-mmd.service >/dev/null 2>&1; then + systemctl start omamobile-mmd.service && say "Phone and Messages bridge started" + fi +} + +if systemctl is-active -q omamobile-tegu-modem; then + say "already running: $($CP_STATE state 2>/dev/null || echo unknown)" + phone_up + exit 0 +fi +if [[ -d $SYS/module/cpif ]]; then + say "CPIF was loaded earlier this boot; reboot before starting the modem again"; exit 1 +fi +if [[ -e $LATCH ]]; then + say "an earlier start never reached ONLINE, or its boot didn't shut down cleanly ($LATCH, $(cat "$LATCH" 2>/dev/null)): look at /var/log/omamobile/modem.log and the last boot's journal, then remove it to try again" + exit 1 +fi +[[ -e $SYS/bus/platform/devices/154e0000.pinctrl ]] || { say "no FAR_ALIVE pinctrl (old device tree)"; exit 1; } + +# Which drivers: the kernel's own, or the bring-up modules +if [[ -e $DT/cpif ]] && modinfo -n cpif >/dev/null 2>&1 && modinfo -n pcie_gs201_cp >/dev/null 2>&1; then + in_tree=1 +else + in_tree=0 + for f in tegu-modem-cpif-activate.ko tegu-pcie0-cp.ko shm_ipc.ko cpif.ko cpif-keep-link.ko gnss_spi.ko gnssif.ko; do + [[ -f $B/$f ]] || { say "no in-kernel CP drivers and no $B/$f"; exit 1; } + done +fi + +# No system suspend while the CP has been up this boot: a suspend with it +# ONLINE never woke (2026-10-27). Taken before the drivers load, kept until +# the reboot; systemctl suspend and logind's suspend then refuse. +systemctl is-active -q omamobile-tegu-modem-nosleep || + systemd-run -q --unit=omamobile-tegu-modem-nosleep \ + systemd-inhibit --what=sleep --who=omamobile-tegu-modem \ + --why="suspend with the modem up isn't qualified on the Pixel 9a" --mode=block sleep infinity + +mkdir -p "$(dirname "$LATCH")" "$LOG" +date -Is > "$LATCH"; sync "$LATCH" 2>/dev/null || sync + +if ((in_tree)); then + say "drivers: the running kernel's" + # allow_hw is fixed at load time: a copy loaded without it refuses the + # CP's power-on, so it needs a reboot (as omamobile-modem-start checks). + if [[ -d $SYS/module/pcie_gs201_cp ]]; then + [[ $(cat "$SYS/module/pcie_gs201_cp/parameters/allow_hw" 2>/dev/null) == Y ]] || + { say "pcie_gs201_cp is loaded without allow_hw=1: reboot first"; exit 1; } + fi + modprobe pcie_gs201_cp allow_hw=1 + modprobe shm_ipc + modprobe cpif + modprobe gnss_spi 2>/dev/null || true + modprobe gnssif 2>/dev/null || true +else + say "drivers: the bring-up modules in $B" + insmod $B/tegu-modem-cpif-activate.ko activate=1 + insmod $B/tegu-pcie0-cp.ko allow_hw=1 + insmod $B/shm_ipc.ko + # cpif with keep_link_up off at load, or the CP never reaches ONLINE + insmod $B/cpif-keep-link.ko keep_link_up=0 + # stock's GNSS SPI setup: mode 0, 32-bit words swapped in gnss_spi, 64-byte reads + insmod $B/gnss_spi.ko word32=2 piece=64 spi_mode=0 + insmod $B/gnssif.ko +fi +echo performance > $SYS/module/pcie_aspm/parameters/policy 2>/dev/null || true + +# The profile's preconditions (read-only): the NV partitions read-only, +# unmounted and matching their checksums, and CPIF's ports present, so this +# comes after the drivers. A refusal keeps the latch: a human looks first. +$CHROOT modem check + +# A clean stop of the profile's unit (the reboot's shutdown) is the only +# thing that removes the latch; a failed or killed profile leaves it. +systemd-run -q --unit=omamobile-tegu-modem -p KillSignal=SIGINT -p TimeoutStopSec=60 \ + -p "ExecStop=$CHROOT modem stop" \ + -p "ExecStopPost=/bin/sh -c '[ \"\$\$SERVICE_RESULT\" = success ] && rm -f $LATCH && sync'" \ + --setenv=OMAMOBILE_MODEM_GNSS=$gnss \ + bash -c "exec $CHROOT modem start >> $LOG/modem.log 2>&1" +if ! $CP_STATE wait-online 60 >/dev/null 2>&1; then + s=$($CP_STATE state 2>/dev/null || echo unknown) + say "modem not ONLINE ($s); see /var/log/omamobile/modem.log. The latch stays: reboot, read the log, then remove $LATCH" + exit 1 +fi +say "modem OK: CP ONLINE (log /var/log/omamobile/modem.log); the latch stays until a clean shutdown" +phone_up diff --git a/packages/omamobile-device-tegu/test/all b/packages/omamobile-device-tegu/test/all index 3a55ebd03..172c71631 100755 --- a/packages/omamobile-device-tegu/test/all +++ b/packages/omamobile-device-tegu/test/all @@ -104,6 +104,11 @@ for unit in omamobile-tegu-graphics omamobile-tegu-usb-rescue; do [[ $(readlink "$tmp/root/usr/lib/systemd/system/multi-user.target.wants/$unit.service") == ../$unit.service ]] \ || fail "$unit is enabled by a vendor wants link" done +# The modem's boot start is opt-in: installed, never enabled by the package +[[ -f $tmp/root/usr/lib/systemd/system/omamobile-tegu-modem-boot.service ]] || fail "install stages the modem's boot start" +[[ -e $tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-tegu-modem-boot.service ]] \ + && fail "the modem's boot start is enabled by the package (it must be opt-in)" +grep -q 'omamobile-tegu-modem-boot' omamobile-device-tegu.install && fail "the install scriptlet must not enable the modem's boot start" # The AoC start runs at every boot (its condition skips a DTB without the # node), and answers to omamobile-aoc.service for the sensor and fp units. [[ $(readlink "$tmp/root/usr/lib/systemd/system/multi-user.target.wants/omamobile-tegu-aoc.service") == ../omamobile-tegu-aoc.service ]] \ @@ -147,6 +152,14 @@ for absent in usr/bin/omamobile-boot-success usr/bin/omamobile-bootctl \ usr/lib/udev/rules.d/20-omamobile-gpu-always-on.rules; do [[ ! -e $tmp/root/$absent ]] || fail "install includes $absent" done +# The canonical sitd unit gets its modem dependency from this device policy. +[[ -f $tmp/root/usr/lib/systemd/system/omamobile-sitd.service.d/10-device-modem.conf ]] \ + || fail "the device sitd policy is staged" +grep -q 'omamobile-sitd-policy' PKGBUILD || fail "the package provides its sitd policy capability" +grep -qx 'Environment=OMAMOBILE_SIT_SCREEN_ON_AT_START=1' vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf \ + || fail "the 9a's sitd tells its modem the screen is on at start-up (signal reports)" +! grep -rq OMAMOBILE_SIT_SCREEN_ON_AT_START ../omamobile-device-cheetah ../omamobile-device-raven \ + || fail "only the 9a sets the start-up screen-on" pass "install stages the package, enables only the guards, and nothing that marks a slot" for m in cpif shm_ipc pcie_gs201_cp; do @@ -188,7 +201,7 @@ pass "the Bluetooth address is read at run time" grep -c '^for unit in omamobile-sensor-proxy.service omamobile-nfc-open.service; do$' bin/omamobile-setup-system >/dev/null || fail "setup-system enables the sensor proxy and the NFC opener" grep -qE 'omamobile-(fp|gnss-nmea|speaker-protection)' <(grep '^for unit' bin/omamobile-setup-system) && fail "setup-system must not enable fingerprint, GNSS or speaker protection on the 9a" -for t in test/graphics-start test/aoc-start test/usb-rescue test/sleep-hooks test/charge-limit; do +for t in test/graphics-start test/aoc-start test/usb-rescue test/sleep-hooks test/charge-limit test/modem-up; do "$t" || fail "$t" done pass "the scripts behave in a scratch root" diff --git a/packages/omamobile-device-tegu/test/modem-up b/packages/omamobile-device-tegu/test/modem-up new file mode 100755 index 000000000..ef19fb738 --- /dev/null +++ b/packages/omamobile-device-tegu/test/modem-up @@ -0,0 +1,101 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# omamobile-tegu-modem-up in a scratch root with fake commands: no phone, no +# modem. The refusals (CPIF already loaded, the latch, a link driver loaded +# without allow_hw), the choice of the kernel's drivers over the bring-up +# modules, the latch written before any driver and kept past ONLINE for the +# profile's clean stop to remove, the sleep inhibitor taken before the +# drivers, and --phone starting sitd and the bridge. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +fail() { printf 'not ok - %s\n' "$1" >&2; exit 1; } +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +F=$t/bin; mkdir -p "$F" +fake() { printf '#!/bin/bash\n%s\n' "$2" > "$F/$1"; chmod +x "$F/$1"; } +# Every call goes to $t/calls in order; the CP turns ONLINE once the profile runs +fake systemctl 'echo "systemctl $*" >> "$T/calls" +case "$*" in + "is-active -q omamobile-tegu-modem") [[ -e $T/profile ]] ;; + "is-active -q omamobile-tegu-modem-nosleep") false ;; + "cat omamobile-mmd.service") [[ -n ${MMD:-} ]] ;; + *) true ;; +esac' +fake systemd-run 'echo "systemd-run $*" >> "$T/calls"; [[ "$*" == *"--unit=omamobile-tegu-modem "* ]] && touch "$T/profile"; true' +fake modinfo 'echo "modinfo $*" >> "$T/calls"; [[ -n ${IN_TREE:-} ]]' +# The drivers record whether the latch was already on disk when they loaded +fake modprobe 'echo "modprobe $* latch=$([[ -e $OMAMOBILE_MODEM_LATCH ]] && echo yes || echo no)" >> "$T/calls"' +fake insmod 'echo "insmod $* latch=$([[ -e $OMAMOBILE_MODEM_LATCH ]] && echo yes || echo no)" >> "$T/calls"' +fake sync 'true' +printf '#!/bin/bash\nif [[ -e $T/profile && -z ${NEVER:-} ]]; then echo ONLINE; else echo OFFLINE; [[ $1 == wait-online ]] && exit 1; fi; exit 0\n' > "$t/cp"; chmod +x "$t/cp" +printf '#!/bin/bash\necho "chroot $*" >> "$T/calls"\n' > "$t/chroot"; chmod +x "$t/chroot" + +run() { # NAME [env...]: a fresh scratch root, then the script + local r=$t/$1; shift + rm -rf "$r"; mkdir -p "$r/sys/bus/platform/devices/154e0000.pinctrl" "$r/sys/module/pcie_aspm/parameters" "$r/dt" "$r/mods" "$r/log" + for m in tegu-modem-cpif-activate tegu-pcie0-cp shm_ipc cpif cpif-keep-link gnss_spi gnssif; do : > "$r/mods/$m.ko"; done + : > "$r/calls" + env -i PATH="$F:/usr/bin:/bin" T="$r" OMAMOBILE_MODEM_TEST=1 OMAMOBILE_SYS="$r/sys" OMAMOBILE_DT="$r/dt" \ + OMAMOBILE_MODEM_MODULES="$r/mods" OMAMOBILE_MODEM_LATCH="$r/latch" OMAMOBILE_MODEM_CP="$t/cp" \ + OMAMOBILE_VENDOR_CHROOT="$t/chroot" OMAMOBILE_MODEM_LOG="$r/log" OMAMOBILE_MODEM_POLL=0 "$@" \ + bash bin/omamobile-tegu-modem-up --phone > "$r/out" 2>&1 +} + +# The kernel's drivers when it has them and the DT names cpif +run_tree() { local r=$t/$1; shift; rm -rf "$r"; mkdir -p "$r/sys/bus/platform/devices/154e0000.pinctrl" "$r/sys/module/pcie_aspm/parameters" "$r/dt/cpif" "$r/mods" "$r/log"; : > "$r/calls" + env -i PATH="$F:/usr/bin:/bin" T="$r" OMAMOBILE_MODEM_TEST=1 OMAMOBILE_SYS="$r/sys" OMAMOBILE_DT="$r/dt" \ + OMAMOBILE_MODEM_MODULES="$r/mods" OMAMOBILE_MODEM_LATCH="$r/latch" OMAMOBILE_MODEM_CP="$t/cp" \ + OMAMOBILE_VENDOR_CHROOT="$t/chroot" OMAMOBILE_MODEM_LOG="$r/log" OMAMOBILE_MODEM_POLL=0 "$@" \ + bash bin/omamobile-tegu-modem-up --phone > "$r/out" 2>&1; } +run_tree k2 IN_TREE=1 MMD=1 || { cat "$t/k2/out"; fail "a start with the kernel's drivers succeeds"; } +c=$t/k2/calls +grep -qx 'modprobe pcie_gs201_cp allow_hw=1 latch=yes' "$c" || fail "the kernel's link driver is loaded with its hardware steps allowed, after the latch is on disk" +grep -q 'latch=no' "$c" && fail "no driver loads before the latch is written" +grep -q '^insmod' "$c" && fail "no bring-up module is loaded when the kernel has the drivers" +grep -q 'drivers: the running kernel' "$t/k2/out" || fail "the start says which drivers it used" +n_inhibit=$(grep -n 'unit=omamobile-tegu-modem-nosleep' "$c" | cut -d: -f1) +n_driver=$(grep -n '^modprobe pcie_gs201_cp' "$c" | cut -d: -f1) +n_check=$(grep -n '^chroot modem check' "$c" | cut -d: -f1) +(( n_inhibit < n_driver && n_driver < n_check )) || fail "the sleep inhibitor, then the drivers, then the profile check (it needs CPIF loaded)" +[[ -e $t/k2/latch ]] || fail "the latch stays past ONLINE" +grep -q 'ExecStopPost=.*SERVICE_RESULT.*rm -f .*latch' "$c" || fail "the profile's clean stop removes the latch" +grep -qx 'systemctl start omamobile-sitd.service' "$c" || fail "--phone starts the phone service" +grep -qx 'systemctl start omamobile-mmd.service' "$c" || fail "--phone starts the bridge when it's installed" +printf 'ok - %s\n' "modem-up: the kernel's drivers, the order, the latch kept for a clean stop, the phone service and the bridge" + +# The bring-up modules when the kernel lacks the drivers; no bridge without it +run b || { cat "$t/b/out"; fail "a start with the bring-up modules succeeds"; } +grep -q '^insmod .*/tegu-pcie0-cp.ko allow_hw=1 latch=yes$' "$t/b/calls" || fail "the bring-up link driver is loaded, after the latch" +grep -q '^modprobe' "$t/b/calls" && fail "no kernel driver is modprobed without the kernel's drivers" +grep -qx 'systemctl start omamobile-mmd.service' "$t/b/calls" && fail "no bridge start when it isn't installed" +printf 'ok - %s\n' "modem-up: the bring-up modules otherwise, and no bridge when it isn't installed" + +# Refusals: CPIF already loaded this boot, and the latch of a start that never reached ONLINE +run_c() { local r=$t/c2; rm -rf "$r"; mkdir -p "$r/sys/module/cpif" "$r/sys/bus/platform/devices/154e0000.pinctrl" "$r/dt/cpif" "$r/log"; : > "$r/calls" + env -i PATH="$F:/usr/bin:/bin" T="$r" OMAMOBILE_MODEM_TEST=1 OMAMOBILE_SYS="$r/sys" OMAMOBILE_DT="$r/dt" \ + OMAMOBILE_MODEM_LATCH="$r/latch" OMAMOBILE_MODEM_CP="$t/cp" OMAMOBILE_VENDOR_CHROOT="$t/chroot" OMAMOBILE_MODEM_LOG="$r/log" \ + IN_TREE=1 bash bin/omamobile-tegu-modem-up --phone > "$r/out" 2>&1; } +run_c && fail "a second start in a boot that loaded CPIF is refused" +grep -q 'reboot before starting the modem again' "$t/c2/out" || fail "the refusal says to reboot" +grep -qE '^(modprobe|insmod)' "$t/c2/calls" && fail "nothing loads after the refusal" +run_tree n IN_TREE=1 NEVER=1 && fail "a start that never reaches ONLINE fails" +[[ -e $t/n/latch ]] || fail "the latch stays after a start that never reached ONLINE" +grep -q 'omamobile-sitd' "$t/n/calls" && fail "no phone service without ONLINE" +mkdir -p "$t/l"; date > "$t/l/latch" +run_l() { local r=$t/l; mkdir -p "$r/sys/bus/platform/devices/154e0000.pinctrl" "$r/dt/cpif" "$r/log"; : > "$r/calls" + env -i PATH="$F:/usr/bin:/bin" T="$r" OMAMOBILE_MODEM_TEST=1 OMAMOBILE_SYS="$r/sys" OMAMOBILE_DT="$r/dt" \ + OMAMOBILE_MODEM_LATCH="$r/latch" OMAMOBILE_MODEM_CP="$t/cp" OMAMOBILE_VENDOR_CHROOT="$t/chroot" OMAMOBILE_MODEM_LOG="$r/log" \ + IN_TREE=1 bash bin/omamobile-tegu-modem-up --phone > "$r/out" 2>&1; } +run_l && fail "a start with the latch set is refused" +grep -q 'never reached ONLINE' "$t/l/out" || fail "the refusal names the latch" +grep -qE '^(modprobe|insmod|systemd-run)' "$t/l/calls" && fail "nothing starts while the latch is set" +printf 'ok - %s\n' "modem-up: refuses a second start and a latched boot, and keeps the latch when ONLINE never comes" + +# A link driver already loaded without allow_hw: refuse before loading anything +r=$t/hw; mkdir -p "$r/sys/bus/platform/devices/154e0000.pinctrl" "$r/sys/module/pcie_gs201_cp/parameters" "$r/dt/cpif" "$r/log" +echo N > "$r/sys/module/pcie_gs201_cp/parameters/allow_hw"; : > "$r/calls" +env -i PATH="$F:/usr/bin:/bin" T="$r" OMAMOBILE_MODEM_TEST=1 OMAMOBILE_SYS="$r/sys" OMAMOBILE_DT="$r/dt" \ + OMAMOBILE_MODEM_LATCH="$r/latch" OMAMOBILE_MODEM_CP="$t/cp" OMAMOBILE_VENDOR_CHROOT="$t/chroot" OMAMOBILE_MODEM_LOG="$r/log" \ + IN_TREE=1 bash bin/omamobile-tegu-modem-up --phone > "$r/out" 2>&1 && fail "a link driver loaded without allow_hw is refused" +grep -q 'without allow_hw=1: reboot first' "$r/out" || fail "the refusal says to reboot" +grep -qE '^(modprobe|insmod)' "$r/calls" && fail "nothing loads after the allow_hw refusal" +printf 'ok - %s\n' "modem-up: refuses a link driver loaded without allow_hw" diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-modem.service.d/10-tegu-no-start.conf b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-modem.service.d/10-tegu-no-start.conf new file mode 100644 index 000000000..67efa018a --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-modem.service.d/10-tegu-no-start.conf @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: MIT +# The tegu starter is attended and separate. Never run the generic profile. +[Unit] +ConditionPathExists=!/usr/share/omamobile/device-tegu/version diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf new file mode 100644 index 000000000..6bfc2218e --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: MIT +# Requisite checks the attended starter without pulling it into a start job. +# A missing/inactive tegu modem must fail, never start cheetah's modem unit. +[Unit] +Requisite=omamobile-tegu-modem.service +After=omamobile-tegu-modem.service omamobile-tegu-aoc.service + +[Service] +# Active alone is insufficient: the CP must already report ONLINE. +ExecStartPre=/usr/lib/omamobile-vendor/omamobile-modem-cp state +# The 9a's modem sends signal reports only after it's told the screen is on, +# and nothing sends the screen state yet: sitd tells it once at start-up. +Environment=OMAMOBILE_SIT_SCREEN_ON_AT_START=1 diff --git a/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-modem-boot.service b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-modem-boot.service new file mode 100644 index 000000000..3d6e113a6 --- /dev/null +++ b/packages/omamobile-device-tegu/vendor/systemd/system/omamobile-tegu-modem-boot.service @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: MIT +# The Pixel 9a's modem at boot, opt-in: not enabled by the package. The owner +# turns it on with `systemctl enable omamobile-tegu-modem-boot`. It starts the +# CP once (omamobile-tegu-modem-up keeps the once-per-boot rule, the NV +# checks, the failure latch and the sleep inhibitor), then the phone service +# and, when installed, the Phone and Messages bridge. With it on the palmtop +# doesn't suspend (the modem blocks sleep until suspend with the CP up is +# qualified), so the battery drains as if awake. +# +# Before enabling it (README, "Starting it at boot"): slot B marked +# successful, a kernel with linux-omarchy-mobile#172, and the charger in for +# the first boots. Rollback: systemctl disable omamobile-tegu-modem-boot and +# reboot; after a reset with the modem up, the latch keeps the next boot +# from starting it. +[Unit] +Description=Start the Pixel 9a's modem and phone service (opt-in) +Documentation=file:///usr/share/doc/omamobile-device-tegu/README.md +After=omamobile-tegu-aoc.service omamobile-tegu-graphics.service network.target +Wants=network.target +ConditionPathExists=/usr/lib/omamobile-vendor/omamobile-vendor-chroot + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/omamobile-tegu-modem-up --phone +TimeoutStartSec=300 + +[Install] +WantedBy=multi-user.target diff --git a/packages/omamobile-device-tegu/version b/packages/omamobile-device-tegu/version index a45be4627..f2722b133 100644 --- a/packages/omamobile-device-tegu/version +++ b/packages/omamobile-device-tegu/version @@ -1 +1 @@ -0.2.8 +0.2.12 diff --git a/packages/omamobile-mmd/systemd/omamobile-mmd.service b/packages/omamobile-mmd/systemd/omamobile-mmd.service index 6b41f159a..81fccf220 100644 --- a/packages/omamobile-mmd/systemd/omamobile-mmd.service +++ b/packages/omamobile-mmd/systemd/omamobile-mmd.service @@ -7,7 +7,8 @@ [Unit] Description=Omarchy Mobile ModemManager-compatible bridge (omamobile-sitd on D-Bus) After=dbus.service omamobile-sitd.service -Conflicts=ModemManager.service +# Bus-name ownership and package conflicts provide exclusion. Do not stop +# another modem daemon as a side effect of starting this bridge. [Service] Type=dbus diff --git a/packages/omamobile-mmd/test/all b/packages/omamobile-mmd/test/all index 3b555a4bb..f53ffa2c2 100755 --- a/packages/omamobile-mmd/test/all +++ b/packages/omamobile-mmd/test/all @@ -38,7 +38,8 @@ python3 "$stage/usr/bin/omamobile-mmd" --help >/dev/null || fail "the staged dae # the modem side, no D-Bus activation file. grep -E '^(Requires|Wants|BindsTo|Requisite)=' systemd/omamobile-mmd.service && fail "the unit pulls something in" [[ -z $(find "$stage" -path '*dbus-1/system-services*' -print -quit) ]] || fail "no D-Bus activation file" -grep -qx 'Conflicts=ModemManager.service' systemd/omamobile-mmd.service || fail "the unit conflicts with ModemManager" +! grep -qx 'Conflicts=ModemManager.service' systemd/omamobile-mmd.service \ + || fail "starting the bridge must not stop another modem daemon" if command -v systemd-analyze >/dev/null; then systemd-analyze verify --man=no "$stage/usr/lib/systemd/system/omamobile-mmd.service" 2>&1 | grep -v -e 'not executable' -e 'No such file' -e 'omamobile-sitd.service' -e '^$' && fail "unit verify" || true diff --git a/packages/omamobile-mmd/version b/packages/omamobile-mmd/version index 17e51c385..d917d3e26 100644 --- a/packages/omamobile-mmd/version +++ b/packages/omamobile-mmd/version @@ -1 +1 @@ -0.1.1 +0.1.2 diff --git a/packages/omamobile-modem-sit/PKGBUILD b/packages/omamobile-modem-sit/PKGBUILD index 24355e6da..edb2214e5 100644 --- a/packages/omamobile-modem-sit/PKGBUILD +++ b/packages/omamobile-modem-sit/PKGBUILD @@ -7,7 +7,7 @@ pkgdesc="Omarchy Mobile SIT RIL for the Pixel 7 Pro's S5300: LTE registration, I arch=(aarch64) url="https://github.com/derekross/omarchy-mobile" license=(MIT) -depends=(python iproute2 iputils systemd alsa-lib alsa-utils omamobile-modem) +depends=(python iproute2 iputils systemd alsa-lib alsa-utils 'omamobile-modem>=0.1.11' omamobile-sitd-policy) backup=(etc/omamobile/modem-sit.conf) install=omamobile-modem-sit.install diff --git a/packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf b/packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf index b4996d613..a5d006e50 100644 --- a/packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf +++ b/packages/omamobile-modem-sit/etc/omamobile/modem-sit.conf @@ -84,10 +84,23 @@ group = wheel # The AoC sound card for call audio: "none" (the default until the earpiece # mode exists, MODEM-PLAN M5) connects calls without routing any audio; # "auto" finds the AoC card in /proc/asound/cards. With a card, call audio +# on the 9a selects an experimental TAS2572 speakerphone route, held muted +# until both gains read back -20 dB after PCM startup. The 7 Pro's audio # is refused unless speaker protection runs at stage media or c8 with the # top amplifier (the earpiece) at analog 6 or less and both within the # media stage's ceilings (digital 737, analog 10). card = none # Microphone gain above stock's 130 cB during calls: 6 (default, judged -# louder and clean in calls on this phone) or 0 (stock). +# louder and clean in calls on the 7 Pro) or 0 (stock). The 9a always uses +# stock's 130 cB, with no boost. mic_boost_db = 6 + +# Experimental 9a call tuning, from this phone's own factory image. +# Keep off until an attended trial; card = none still disables all audio. +# AEC uploads owner files from /usr/lib/firmware/updates/omamobile/tegu/aoc. +tegu_aec = no +# speaker: both amplifiers at -20 dB; earpiece: top at -30 dB, bottom at +# the minimum digital gain. Earpiece requires tegu_aec = yes and the full +# amplifier profile 0; the stock voice profile has no standalone native +# equivalent. Changing routes mid-call is not implemented. +tegu_route = speaker diff --git a/packages/omamobile-modem-sit/lib/aoc_tuning.py b/packages/omamobile-modem-sit/lib/aoc_tuning.py new file mode 100644 index 000000000..0115c76f6 --- /dev/null +++ b/packages/omamobile-modem-sit/lib/aoc_tuning.py @@ -0,0 +1,121 @@ +# SPDX-License-Identifier: MIT +"""Bounded AoC telephony tuning upload, using the owner's tegu protobufs. + +Only the APMg3 telephony component on audio_output_tuning is addressed. +The GPL AoC interface defines CMD_HDR / SET_PARAMETER_BULK; the route +adapter adds an envelope with tag 2 around each unchanged protobuf. No +vendor executable, shared memory mapping, or arbitrary command API. +""" +import os +from pathlib import Path +import select +import struct + +from paths import RUN + +ROOT = Path('/usr/lib/firmware/updates/omamobile/tegu/aoc') +BULK_SIZE = 16384 +HEADER = struct.Struct('; data_network.find_device checks which device -really carries the internet bearer (it differed when the attach bearer was on -another APN). +owned bearer lifecycle: CID 1 (internet), CID 2 (IMS) and opt-in CID 3 +(MMS). Stock names a bearer's device rmnet; data_network.find_device +checks which device really carries the internet bearer (it differed when the +attach bearer was on another APN). MMS is a library primitive only: start-up +does not request it and no socket method exposes it yet. The APN comes from /etc/omamobile/modem-sit.conf. Ownership is recorded in RAM before a setup is sent: a setup or release with an unknown outcome @@ -35,8 +36,9 @@ def paths(cid): if cid == 1: return STATE, RESPONSE - if cid == 2: - return STATE.with_name('ims-session.json'), RESPONSE.with_name('ims-response.bin') + if cid in (2, 3): + name = 'ims' if cid == 2 else 'mms' + return STATE.with_name(name + '-session.json'), RESPONSE.with_name(name + '-response.bin') raise ValueError('unsupported bearer CID') @@ -71,7 +73,7 @@ def check_apn(apn): return apn -def call_ids(payload): +def call_ids(payload, *, active_only=False): # Stock DataCallUtil::DetermineDCTypeBySize. Reject variable # traffic-descriptor records until their full framing is implemented. if not payload or payload[0] > 15: @@ -87,12 +89,16 @@ def call_ids(payload): cids = [payload[1 + index * size + 2] for index in range(count)] if len(set(cids)) != count or any(not 1 <= cid <= 15 for cid in cids): raise RuntimeError('invalid or duplicate data-call CID') + if active_only: + return {cid for index, cid in enumerate(cids) + if struct.unpack_from(' self.hangup_deadline: - cp.stop_modem('a call release was not confirmed') - raise RuntimeError('Call release was not confirmed; modem stopped') + self.release_unconfirmed = True + unconfirmed_release(self.client, 'hangup deadline expired') def send_sms(self, request): key = request.get('request_id', '') @@ -512,7 +550,8 @@ def status(self, *, public=False): received = [r[0] for r in self.db.execute('SELECT id FROM received WHERE consumed=0 ORDER BY rowid')] return dict(modem=modem, calls=calls, sms=dict(received=['sit:' + i for i in received]), audio=dict(available=True, running=self.audio is not None, mute=self.muted, - speaker=False, speaker_available=False, error='')) + speaker=getattr(self.audio, 'tegu', False) is True, + speaker_available=False, error='')) def subscribe(self, connection): """Keep an authorised connection for status events; refuse beyond @@ -757,6 +796,9 @@ def serve_one(service, connection, clients): return True result = service.dispatch(request) response = dict(ok=True, result=result) + except UnconfirmedRelease: + connection.close() + raise except (ValueError, KeyError, TypeError, RuntimeError, OSError) as error: # Errors from wire data must never expose raw values. response = dict(ok=False, error=str(error) if isinstance(error, RuntimeError) @@ -830,8 +872,7 @@ def stop(*_): try: marker = paths.RUN / 'active.json' if marker.exists() and json.loads(marker.read_text()): - cp.stop_modem('a call from the previous service run was never released') - raise RuntimeError('Previous call ownership unresolved; modem stopped') + unconfirmed_release(client, 'a call from the previous service run was never released') service = Service(client, database(paths.STATE / 'apps.db'), settings) service.publish() for sms in paths.INBOX.glob('*.sit'): @@ -854,6 +895,12 @@ def stop(*_): SOCKET.chmod(0o660) notify('READY=1\nSTATUS=registered') print('Calls and SMS service ready', flush=True) + # Set by a device whose modem sends signal reports only after it's + # told the screen is on (the Pixel 9a's drop-in), while nothing else + # sends the screen state yet. Never set on the 7 Pro. + if args.bringup and os.environ.get('OMAMOBILE_SIT_SCREEN_ON_AT_START') == '1' \ + and service.screen_on is None: + service.dispatch(dict(action='screen-state', on=True)) next_cp_check = 0 while not stopping: service.pump() @@ -878,7 +925,7 @@ def stop(*_): service.broadcast() finally: try: - if service and service.live(): + if service and service.live() and not service.release_unconfirmed: for call in service.live(): if call['modem_id'] is not None: try: @@ -891,17 +938,20 @@ def stop(*_): if packet: service.event(packet) if service.live(): - cp.stop_modem('a call release was not confirmed at service stop') - if service: - service.audio_stop() + service.release_unconfirmed = True + unconfirmed_release(client, 'a call release was not confirmed at service stop') finally: - if service: - for connection in list(service.subscribers): - service.drop(connection) - client.close() - server.close() - SOCKET.unlink(missing_ok=True) - (paths.RUN / 'state.json').unlink(missing_ok=True) + try: + if service: + service.audio_stop() + finally: + if service: + for connection in list(service.subscribers): + service.drop(connection) + client.close() + server.close() + SOCKET.unlink(missing_ok=True) + (paths.RUN / 'state.json').unlink(missing_ok=True) if __name__ == '__main__': diff --git a/packages/omamobile-modem-sit/lib/voice_audio.py b/packages/omamobile-modem-sit/lib/voice_audio.py index 35a688750..d09aefd15 100644 --- a/packages/omamobile-modem-sit/lib/voice_audio.py +++ b/packages/omamobile-modem-sit/lib/voice_audio.py @@ -4,16 +4,18 @@ Uses the AoC card's voice endpoints: PCM 4 playback (EP5) and PCM 11 capture (EP4), whose numbers are the AoC entry points (AGENTS.md: the card numbers its PCMs as stock does). AoC and CP exchange audio directly; no host -recording or SRAM mapping. Amplifier protection, calibration and gain stay -with omamobile-audio: the downlink plays through TDM 0, so it needs the -amplifiers set up (stock's TDM 0 format, protection service running). +recording or SRAM mapping. On cheetah, amplifier protection, calibration +and gain stay with omamobile-audio: TDM 0 needs its amplifiers set up and +the protection service running. TDM 0 feeds both amplifiers, and the top one is the earpiece. Until the protection service has an earpiece mode (TELEPHONY-APPS-PLAN T4), routing is refused unless the protection service reports itself running at stage media or c8 and the amplifiers are at or below the earpiece ceiling (top analog <= 6, AUDIO-PLAN.md section 4) and the media stage's (digital <= 737, -analog <= 10, AGENTS.md). The default config routes no call audio at all. +analog <= 10, AGENTS.md). Tegu instead uses its TAS2572 speakerphone path, +muted until both amplifiers read back a conservative gain after PCM start. +The default config routes no call audio at all. """ import ctypes as C import os @@ -21,6 +23,8 @@ import re import subprocess +from aoc_tuning import TuningError, VoiceTuning + # omamobile-speaker-protection's status line ("ok: stage , ..."). PROTECTION = Path(os.environ.get('OMAMOBILE_SPK_STATUS', '/run/omamobile/speaker-protection')) STAGES = ('media', 'c8') @@ -28,6 +32,40 @@ # stage's for both (AUDIO-PLAN.md section 4, AGENTS.md "Speakers"). CEILINGS = (('Top Analog PCM Volume', 6), ('Bottom Analog PCM Volume', 10), ('Top Digital PCM Volume', 737), ('Bottom Digital PCM Volume', 737)) +TEGU_CARD = 'google,tegu-aoc-snd-card' +# tas2x20_dvc_table in include/sound/tas2x20-tlv.h: index 220 is unity, +# index 180 is -20 dB. Use the index, not the control's misleading dB TLV. +TEGU_GAIN = '180' +TEGU_EARPIECE_GAIN = '160' # -30 dB; stock index 55 maps to unity (220) +TEGU_GAINS = ('Top Speaker Digital Volume', 'Bottom Speaker Digital Volume') +TEGU_ROUTE = ( + ('Incall Sink Mute', '1'), + ('TDM_0_RX Chan', 'Four'), ('TDM_0_RX Format', 'S32_LE'), + ('TDM_0_RX Sample Rate', 'SR_48K'), + ('TDM_0_TX Chan', 'Four'), ('TDM_0_TX Format', 'S32_LE'), + ('TDM_0_TX Sample Rate', 'SR_48K'), + ('BUILDIN MIC ID CAPTURE LIST', '0,1,-1,-1'), ('MIC DC Blocker', '1'), + ('Voice Call Audio Enable', '1'), ('Voice Call Mic Source', '1'), + ('Voice Call Mic Mute', '0'), ('Incall Mic Mute', '0'), + ('AoC Modem Downlink ASRC Mode', '1'), + ('MIC HW Gain At High Power Mode (cB)', '130'), + ('MIC Record Soft Gain (dB)', '0'), + ('TDM_0_RX Mixer EP5', '1'), ('EP4 TX Mixer INTERNAL_MIC_TX', '1')) + + +class AudioRefused(RuntimeError): + """A tegu route was safely unwound; signalling may continue silently.""" + + +def is_tegu_card(card): + try: + for line in Path('/proc/asound/cards').read_text().splitlines(): + match = re.match(r'\s*(\d+)\s+\[[^]]+\]:\s*.*? - (\S+)\s*$', line) + if match and int(match[1]) == card: + return match[2] == TEGU_CARD + except OSError: + pass + return False def aoc_card(setting='auto'): @@ -52,12 +90,18 @@ def aoc_card(setting='auto'): class VoiceAudio: card = 0 - def __init__(self, *, mic_boost_db=6, card=None): + def __init__(self, *, mic_boost_db=6, card=None, tegu_route='speaker', tegu_aec=False): if mic_boost_db not in (0, 6): raise ValueError('unsupported voice microphone boost') self.mic_boost_db = mic_boost_db if card is not None: self.card = card + self.tegu = is_tegu_card(self.card) + if tegu_route not in ('speaker', 'earpiece'): + raise ValueError('unsupported tegu call route') + self.tegu_route = tegu_route + self.tegu_aec = tegu_aec + self.tuning = None self.saved = [] self.pcms = [] self.alsa = C.CDLL('libasound.so.2') @@ -66,6 +110,18 @@ def __init__(self, *, mic_boost_db=6, card=None): C.c_uint, C.c_uint, C.c_int, C.c_uint] for name in ('snd_pcm_prepare', 'snd_pcm_start', 'snd_pcm_drop', 'snd_pcm_close', 'snd_pcm_state'): getattr(self.alsa, name).argtypes = [C.c_void_p] + if self.tegu: + self.alsa.snd_pcm_hw_params_malloc.argtypes = [C.POINTER(C.c_void_p)] + self.alsa.snd_pcm_hw_params_free.argtypes = [C.c_void_p] + for name in ('snd_pcm_hw_params_any', 'snd_pcm_hw_params'): + getattr(self.alsa, name).argtypes = [C.c_void_p, C.c_void_p] + for name in ('access', 'format', 'channels', 'rate_resample'): + getattr(self.alsa, 'snd_pcm_hw_params_set_' + name).argtypes = [ + C.c_void_p, C.c_void_p, C.c_uint] + for name in ('rate', 'periods', 'period_size'): + getattr(self.alsa, 'snd_pcm_hw_params_set_' + name).argtypes = [ + C.c_void_p, C.c_void_p, C.c_ulong if name == 'period_size' else C.c_uint, + C.c_int] def mixer(self, action, name, value=None): args = ['amixer', '-c', str(self.card), action, 'name='+name] @@ -99,6 +155,8 @@ def check_levels(self): '(the earpiece ceiling needs the top amplifier at analog 6 or less)') def __enter__(self): + if getattr(self, 'tegu', False): + return self.tegu_enter() self.check_levels() try: for name, value in ( @@ -134,14 +192,127 @@ def __enter__(self): self.__exit__(None, None, None) raise + def mixer_value(self, name): + match = re.search(r'^\s*: values=([0-9,\-]+|on|off)$', self.mixer('cget', name), re.M) + if match is None: + raise RuntimeError('voice mixer state unavailable: ' + name) + return match[1] + + def tegu_params(self, pcm): + params = C.c_void_p() + self.check(self.alsa.snd_pcm_hw_params_malloc(C.byref(params)), 'params allocation') + try: + self.check(self.alsa.snd_pcm_hw_params_any(pcm, params), 'params reset') + for name, value, direction in ( + ('access', 3, None), ('format', 2, None), ('channels', 1, None), + ('rate_resample', 0, None), ('rate', 8000, 0), + ('period_size', 80, 0), ('periods', 2, 0)): + args = (pcm, params, value) + (() if direction is None else (direction,)) + self.check(getattr(self.alsa, 'snd_pcm_hw_params_set_' + name)(*args), name) + # hw_params prepares automatically. Never prepare a second time: + # preparing EP5 sends TELEPHONY_MODEM_START to the AoC. + self.check(self.alsa.snd_pcm_hw_params(pcm, params), 'params') + if self.alsa.snd_pcm_state(pcm) != 2: + raise RuntimeError('voice PCM was not prepared by hardware parameters') + finally: + self.alsa.snd_pcm_hw_params_free(params) + + def tegu_enter(self): + if self.pcms: + return self + # Read everything before changing anything. Mute is first so its + # original value is restored last, after closing the voice PCMs. + route = list(TEGU_ROUTE) + aec = getattr(self, 'tegu_aec', False) + earpiece = getattr(self, 'tegu_route', 'speaker') == 'earpiece' + if earpiece: + if not aec: + raise AudioRefused('tegu earpiece needs the handset AEC tuning enabled') + # The supplied RCA voice-handset case is only a delta, not a + # standalone initialization. Retain the full profile 0 for + # this conservative top-only route, never guess profile 4. + try: + profiles = [self.mixer_value(amp + ' Speaker Profile Id') for amp in ('Top', 'Bottom')] + except (OSError, RuntimeError, subprocess.TimeoutExpired) as error: + raise AudioRefused('tegu earpiece amplifier profile unavailable') from error + if profiles != ['0', '0']: + raise AudioRefused('tegu earpiece requires the full amplifier profile 0') + if aec: + route.insert(1, ('FT AEC Reference Source', 'SPEAKER')) + names = [name for name, _ in route] + list(TEGU_GAINS) + try: + saved = [(name, self.mixer_value(name)) for name in names] + except (OSError, RuntimeError, subprocess.TimeoutExpired) as error: + raise AudioRefused('tegu call mixer state unavailable') from error + self.saved = saved + try: + for name, value in route: + self.mixer('cset', name, value) + if name == 'Incall Sink Mute' and self.mixer_value(name) not in ('1', 'on'): + raise AudioRefused('tegu call audio refused: sink mute read-back mismatch') + if aec: + try: + self.tuning = VoiceTuning(self.tegu_route) + self.tuning.start() + except (OSError, TuningError) as error: + raise AudioRefused('tegu call audio refused: AoC tuning unavailable or unconfirmed') from error + # Capture is ready before playback prepare starts the modem. + for device, direction in ((11, 1), (4, 0)): + pcm = C.c_void_p() + self.check(self.alsa.snd_pcm_open(C.byref(pcm), f'hw:{self.card},{device}'.encode(), + direction, 0), 'open') + self.pcms.append(pcm) + self.tegu_params(pcm) + self.check(self.alsa.snd_pcm_start(pcm), 'start') + # The codec profile resets gain at playback start. These must + # happen afterwards, while the modem downlink remains muted. + gains = ((TEGU_GAINS[1], '0'), (TEGU_GAINS[0], TEGU_EARPIECE_GAIN)) if earpiece else tuple( + (name, TEGU_GAIN) for name in TEGU_GAINS) + for name, gain in gains: + self.mixer('cset', name, gain) + for name, expected in gains: + try: + gain = self.mixer_value(name) + except (OSError, RuntimeError, subprocess.TimeoutExpired) as error: + raise AudioRefused('tegu call audio refused: TAS gain read-back unavailable') from error + if gain != expected: + raise AudioRefused('tegu call audio refused: TAS gain read-back mismatch') + self.mixer('cset', 'Incall Sink Mute', '0') + print('AoC tegu ' + ('earpiece' if earpiece else 'speakerphone') + + ' prepared at conservative TAS gain', flush=True) + return self + except BaseException as error: + try: + self.__exit__(None, None, None) + except RuntimeError as cleanup: + if isinstance(error, AudioRefused): + raise AudioRefused('tegu call audio refused; cleanup unconfirmed, sink remains muted') from cleanup + raise + raise + def __exit__(self, *args): failures = [] + if getattr(self, 'tegu', False) and self.saved: + try: + self.mixer('cset', 'Incall Sink Mute', '1') + except (OSError, RuntimeError, subprocess.TimeoutExpired): + failures.append('Incall Sink Mute') for pcm in reversed(self.pcms): - self.alsa.snd_pcm_drop(pcm) + if self.alsa.snd_pcm_drop(pcm) < 0 and getattr(self, 'tegu', False): + failures.append('PCM drop') if self.alsa.snd_pcm_close(pcm) < 0: failures.append('PCM close') self.pcms.clear() + if getattr(self, 'tuning', None) is not None: + try: + self.tuning.close() + except (OSError, TuningError): + failures.append('AoC tuning cleanup') + finally: + self.tuning = None for name, value in reversed(self.saved): + if getattr(self, 'tegu', False) and name == 'Incall Sink Mute' and failures: + continue # uncertain cleanup must leave the call sink muted try: self.mixer('cset', name, value) except (OSError, RuntimeError, subprocess.TimeoutExpired): diff --git a/packages/omamobile-modem-sit/systemd/omamobile-sitd.service b/packages/omamobile-modem-sit/systemd/omamobile-sitd.service index 83879c44e..f235d22a7 100644 --- a/packages/omamobile-modem-sit/systemd/omamobile-sitd.service +++ b/packages/omamobile-modem-sit/systemd/omamobile-sitd.service @@ -6,8 +6,9 @@ # own: a second start-up on the same CP is not supported (reboot instead). [Unit] Description=Omarchy Mobile SIT RIL (S5300 calls, SMS, registration) -Requires=omamobile-modem.service -After=omamobile-modem.service omamobile-audio.service +# The device modem-policy package supplies its modem dependency as a drop-in. +# Tegu checks an already running modem; cheetah/raven retain their starter. +After=omamobile-audio.service ConditionPathExists=/dev/umts_ipc0 [Service] diff --git a/packages/omamobile-modem-sit/test/all b/packages/omamobile-modem-sit/test/all index 3e1f74bc1..cb8b3d72c 100755 --- a/packages/omamobile-modem-sit/test/all +++ b/packages/omamobile-modem-sit/test/all @@ -45,4 +45,7 @@ if command -v systemd-analyze >/dev/null; then -e 'omamobile-sitd.service' -e '^$' && fail "$u verify" || true done fi +! grep -qx 'Requires=omamobile-modem.service' systemd/omamobile-sitd.service \ + || fail "the base unit must use the device's sitd policy" +grep -q 'omamobile-sitd-policy' PKGBUILD || fail "the RIL needs an installed device sitd policy" pass "staged layout, config and units" diff --git a/packages/omamobile-modem-sit/test/test_aoc_tuning.py b/packages/omamobile-modem-sit/test/test_aoc_tuning.py new file mode 100644 index 000000000..e7b34c18b --- /dev/null +++ b/packages/omamobile-modem-sit/test/test_aoc_tuning.py @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: MIT +"""Synthetic AoC service records only; never open a device or use a blob.""" +import env # noqa: F401 +from pathlib import Path +import struct +import tempfile +import unittest +from unittest.mock import patch + +import aoc_tuning as tuning + + +class Services: + def __init__(self): + self.opened = [] + self.closed = [] + self.written = [] + self.reply = None + self.pending = False + self.timeout = False + self.short_fd = None + self.refuse = False + self.bad_reply = False + + def open(self, path, flags): + self.opened.append((path, flags)) + return 10 if path.endswith('output_tuning') else 11 + + def close(self, fd): + self.closed.append(fd) + + def select(self, read, write, errors, timeout): + if write: + return [], write, [] + return (read if (self.pending if timeout == 0 else not self.timeout) else []), [], [] + + def write(self, fd, data): + self.written.append((fd, data)) + if fd == 10: + reply = bytearray(data) + if self.refuse: + struct.pack_into('=0.2.9' + 'omamobile-modem-sit>=0.3.12' 'omamobile-mmd>=0.1.1' 'omatel-agent>=0.2.4') +install=omamobile-telephony-tegu.install + +check() { + "$startdir/test/all" +} + +package() { + "$startdir/install" "$pkgdir" +} diff --git a/packages/omamobile-telephony-tegu/README.md b/packages/omamobile-telephony-tegu/README.md new file mode 100644 index 000000000..20ed62607 --- /dev/null +++ b/packages/omamobile-telephony-tegu/README.md @@ -0,0 +1,127 @@ + +# Pixel 9a: attach Phone and Messages to a running sitd + +This opt-in package installs `omamobile-mmd`, `omatel-agent`, and the tegu +bridge policy. It enables and starts no services. It does not package a +modem starter: the attended tegu modem and RIL must already be running. +Apps speak to the session agent, the agent speaks ModemManager's system +D-Bus API, and mmd forwards requests to sitd's private socket. + +Install the built `omamobile-telephony-tegu` package with ordinary pacman +dependency checking. Inspect the transaction first. Its device/RIL minima +carry the packaged unit policies, the dependency fix, the tegu SIM fixes, +safe unconfirmed-release handling and the opt-in tegu audio route. Prepare +those upgrades before a modem session; never replace a running test RIL +with older code. No firmware or private provisioning comes in this package. + +The common `omamobile-sitd.service` name is preserved for the CLI, bridge +and data helper. Its modem dependency now comes from the device package: + +- Cheetah and raven retain `Requires=omamobile-modem.service` and its order. +- Tegu uses `Requisite=omamobile-tegu-modem.service` plus ordering, and + checks CP ONLINE with the existing state helper before starting sitd. + Requisite fails if that starter is inactive; it never starts it. +- The device packages provide `omamobile-sitd-policy`, which the RIL now + requires, so an upgrade cannot silently omit its device unit dependency. +- The opt-in bridge uses `Requisite=omamobile-sitd.service` and a read-only + service preflight. Starting the bridge cannot pull in sitd or either modem unit. + +## Migrate the old sitd unit (attended preparation) + +The old `/etc/systemd/system/omamobile-sitd.service` copy overrides the +packaged base unit. The attach script refuses it. The package never deletes +or rewrites a human's unit. Prefer migration with the modem off, before +starting the next approved session. For an already running session, only +continue after checking the versions, active tegu starter and unchanged +process IDs; `daemon-reload` changes definitions without restarting them. + +1. Read-only: `systemctl cat omamobile-sitd.service` and + `systemctl show omamobile-sitd.service omamobile-tegu-modem.service -p ActiveState -p MainPID`. + Save those PIDs privately. Stop if the service/starter differs from the + approved tegu setup, or if a call is in progress. Risk: none; rollback: + none. +2. After the new packages are installed, inspect + `/usr/lib/systemd/system/omamobile-sitd.service` and its + `omamobile-sitd.service.d/10-device-modem.conf`. Expect tegu Requisite, + no cheetah Requires, CP ONLINE precheck, and `Restart=no`. Stop on a + mismatch. Risk: none; rollback: none. +3. Only for the legacy full copy, root: + `install -d -m700 /var/lib/omamobile-telephony-tegu`, then + `mv -n /etc/systemd/system/omamobile-sitd.service /var/lib/omamobile-telephony-tegu/omamobile-sitd.service.before-attach`. + Verify the source is gone (an existing backup makes `mv -n` skip; do + not overwrite it), then `systemctl daemon-reload`. Do not use restart, + enable or `--now`. Risk: low (unit definitions). Expect the same PIDs + and `FragmentPath=/usr/lib/systemd/system/omamobile-sitd.service`. + Stop if a PID changes or a service leaves active. Rollback: restore + the saved file and daemon-reload, without restarting the modem or RIL. + +The attach script also refuses pending daemon-reload, unexpected start +relationships, an inactive tegu starter/RIL, another ModemManager, a +non-ready SIM, an unregistered radio, and a live call. It obtains a live +status RPC; it never trusts the public state.json as proof of readiness. +It reads no modem device and sends no radio-control request. IMS or a +mobile-data bearer is not required just to attach. The unit's separate +`--service-check` permits an existing call or registration loss, so the +bridge can recover without dropping call visibility. The attended initial +attachment keeps the stricter no-live-call and registered-SIM checks. + +Mmd 0.1.1 removes the service-level `Conflicts=ModemManager.service`: a +bridge start must not stop another modem daemon. Package conflicts and +exclusive D-Bus name ownership still prevent two managers from serving the +same API; tegu's preflight refuses another owner before starting mmd. + +## Attach (human in the graphical user's terminal) + +Keep the existing, approved sleep inhibitor for the modem session. This +package does not qualify CP-on suspend or change auto-sleep. Confirm the +NV checks and once-per-boot rule from the modem startup runbook; nothing +here repeats the modem start or accesses NV partitions. + +Read-only preflight: + +```sh +omamobile-tegu-mmd-attach --check +``` + +Expect existing running tegu modem and sitd, a registered SIM and no live +calls. This uses sudo for read-only system checks and the private sitd +socket. Stop on any failure; it never attempts recovery. Risk: low; no +rollback is needed because no service is changed. + +Attach, after announcing that incoming calls and message notifications may +now appear on the screen and sound: + +```sh +omamobile-tegu-mmd-attach --attach +``` + +Run as the existing graphical user, not root, in a terminal. Type `ATTACH` +at its prompt. The complete set of service-start commands is: + +```sh +sudo -- systemctl start omamobile-mmd.service +systemctl --user start omatel-agent.service +``` + +The script rechecks the modem/RIL PIDs immediately before the bridge start, +after it, and after the agent start. Repeating it starts already active +services without restarting them. It never enables services or starts, +restarts or stops the modem/RIL. Risk: low (apps begin importing SMS into +the user's store and observing incoming calls). Expect both services +active and unchanged modem/RIL PIDs. Stop on any failure and inspect; +there is no automatic retry or modem recovery. + +Open Messages, then do one agreed SMS each way. Record only outcomes and +counts; number, text and network identities stay private. Stop on duplicate +or uncertain delivery; do not resend automatically. Calls follow the +separate safe-release/audio qualification. This package does not qualify +speech, mute/speaker controls, MMS, emergency calls or suspend. + +Rollback for services started by this test, once there is no live call: +close the apps, `systemctl --user stop omatel-agent.service`, then +`sudo systemctl stop omamobile-mmd.service`. Leave either service running +if it was already active before the test. A partial failure intentionally +leaves a started bridge in place for inspection. Never stop the modem or +restart sitd to recover an app failure. Any reboot is separately attended +and approved. Removing this package also requires stopping the bridge +first; it removes only the opt-in policy/helper, not private message data. diff --git a/packages/omamobile-telephony-tegu/bin/omamobile-tegu-mmd-attach b/packages/omamobile-telephony-tegu/bin/omamobile-tegu-mmd-attach new file mode 100755 index 000000000..10fb3d8ee --- /dev/null +++ b/packages/omamobile-telephony-tegu/bin/omamobile-tegu-mmd-attach @@ -0,0 +1,192 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Attended attachment of the bridge and session agent to an existing RIL. + +--check: read-only preflight (sudo is used for the private sitd socket). +--attach: preflight, an explicit terminal confirmation, then start only + omamobile-mmd.service and this user's omatel-agent.service. +--system-check: root preflight for the attended script. +--service-check: root unit preflight; permits an existing call or registration loss. +No modem/RIL start, restart, stop, enable, radio request or device ioctl. +""" +import json +import os +from pathlib import Path +import socket +import subprocess +import sys + +SITD = 'omamobile-sitd.service' +MODEM = 'omamobile-tegu-modem.service' +BRIDGE = 'omamobile-mmd.service' +AGENT = 'omatel-agent.service' +BUS = 'org.freedesktop.ModemManager1' +# Only systemd's basic implicit dependencies may start with the bridge. +BASIC = {'sysinit.target', 'basic.target', 'system.slice', 'dbus.socket', 'dbus.service'} + + +class Refused(RuntimeError): + pass + + +def run(args, *, safe_error=False): + try: + result = subprocess.run(args, check=True, capture_output=True, text=True, timeout=30) + return result.stdout.strip() + except subprocess.CalledProcessError as error: + if safe_error and error.stderr.startswith('Attach refused: '): + raise Refused(error.stderr.removeprefix('Attach refused: ').strip()) from None + raise Refused('a required service/bus check failed; no modem recovery attempted') from None + except (OSError, subprocess.SubprocessError): + raise Refused('a required service/bus check failed; no modem recovery attempted') from None + + +def properties(unit): + result = run(['systemctl', 'show', unit, '--property=ActiveState,MainPID,FragmentPath,Requires,Wants,BindsTo,Requisite,Conflicts,NeedDaemonReload']) + return dict(line.split('=', 1) for line in result.splitlines() if '=' in line) + + +def require_active(unit): + props = properties(unit) + if props.get('ActiveState') != 'active' or not props.get('MainPID', '').isdigit() or int(props['MainPID']) <= 0: + raise Refused(f'{unit} must already be active with a running process; start nothing here') + return props + + +def socket_status(path): + # A live read-only RPC, never the potentially stale public state.json. + try: + with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client: + client.settimeout(5) + client.connect(str(path)) + client.sendall(b'{"action":"status"}\n') + with client.makefile('rb') as stream: + line = stream.readline((1 << 20) + 1) + if len(line) > 1 << 20 or not line.endswith(b'\n'): + raise ValueError + reply = json.loads(line) + if reply.get('ok') is not True: + raise ValueError + return reply['result'] + except (OSError, ValueError, KeyError, TypeError, AttributeError): + raise Refused('cannot read a live sitd status; no modem recovery attempted') from None + + +def system_check(*, require_ready=True): + if os.geteuid() != 0: + raise Refused('--system-check requires root') + root = Path(os.environ.get('OMAMOBILE_TEGU_ROOT', '/')) + if not root.is_absolute() or not root.is_dir(): + raise Refused('invalid preflight root') + descriptor = root / 'usr/share/omamobile/device.conf' + try: + tegu = 'CODENAME=tegu' in descriptor.read_text().splitlines() + installed = (root / 'usr/share/omamobile/device-tegu/version').is_file() + except OSError: + tegu = installed = False + if not tegu or not installed: + raise Refused('requires the tegu device package and descriptor') + ril = require_active(SITD) + modem = require_active(MODEM) + if ril.get('FragmentPath') != '/usr/lib/systemd/system/' + SITD: + raise Refused('migrate the legacy /etc sitd unit to the packaged unit first; see the README') + bridge = properties(BRIDGE) + if any(p.get('NeedDaemonReload') != 'no' for p in (ril, bridge)): + raise Refused('unit files need daemon-reload; inspect them before attaching') + if bridge.get('FragmentPath') != '/usr/lib/systemd/system/' + BRIDGE: + raise Refused('requires the packaged bridge unit') + if MODEM not in ril.get('Requisite', '').split() or SITD not in bridge.get('Requisite', '').split(): + raise Refused('tegu attach policy is not loaded; inspect the packaged drop-ins') + for unit in (ril, bridge): + for key in ('Requires', 'Wants', 'BindsTo'): + if set(unit.get(key, '').split()) - BASIC: + raise Refused('bridge or sitd has an unexpected start dependency; inspect its unit before attaching') + if set(bridge.get('Conflicts', '').split()) - {'shutdown.target'}: + raise Refused('bridge has an unexpected stop dependency; inspect its unit before attaching') + # Neither the script nor a direct unit start may stop a real modem daemon. + owner = run(['busctl', '--system', 'call', 'org.freedesktop.DBus', '/org/freedesktop/DBus', + 'org.freedesktop.DBus', 'NameHasOwner', 's', BUS]) + if owner == 'b true' and bridge.get('ActiveState') != 'active': + raise Refused('ModemManager bus name is already owned by another service') + if owner not in ('b true', 'b false'): + raise Refused('cannot determine the ModemManager bus owner') + competing = properties('ModemManager.service') + if competing.get('ActiveState') in ('active', 'activating', 'reloading'): + raise Refused('another ModemManager service is running; it will not be stopped here') + status = socket_status(root / 'run/omamobile-sit/socket') + try: + m = status['modem'] + ready = (m.get('present') is True and m.get('sim', {}).get('state') == 'ready' + and m.get('radio') == 'on' and m.get('registration') in ('home', 'roaming')) + calls = status['calls'] + if not isinstance(calls, list): + raise TypeError + live = any(c.get('state') != 'terminated' for c in calls) + except (AttributeError, KeyError, TypeError): + raise Refused('invalid live sitd status') from None + if require_ready and (not ready or live): + raise Refused('sitd must have a ready SIM, registered radio and no live calls') + # PIDs are used only to detect an unexpected RIL/CP service replacement. + # Never return the private RPC's numbers, network identities or messages. + return {'sitd_pid': ril['MainPID'], 'modem_pid': modem['MainPID']} + + +def user_check(): + if os.geteuid() == 0: + raise Refused('run --check/--attach as the graphical user, not root') + state = run(['systemctl', '--user', 'show', AGENT, '--property=LoadState', '--value']) + if state != 'loaded': + raise Refused('omatel-agent user unit is not installed') + + +def root_check(): + reply = run(['sudo', '--', str(Path(__file__).resolve()), '--system-check'], safe_error=True) + try: + result = json.loads(reply) + if set(result) != {'sitd_pid', 'modem_pid'}: + raise ValueError + return result + except (TypeError, ValueError): + raise Refused('root preflight returned an invalid result') from None + + +def main(argv=None): + argv = sys.argv[1:] if argv is None else argv + if argv in ([], ['--help'], ['-h']): + print(__doc__) + return 0 + try: + if argv in (['--system-check'], ['--service-check']): + print(json.dumps(system_check(require_ready=argv == ['--system-check']))) + return 0 + if argv not in (['--check'], ['--attach']): + raise Refused('use --check or --attach') + if argv == ['--attach'] and not (sys.stdin.isatty() and sys.stdout.isatty()): + raise Refused('--attach needs an attended terminal') + user_check() + before = root_check() + print('Preflight passed: existing tegu modem and sitd, registered SIM, no live calls.') + if argv == ['--check']: + return 0 + print('This starts only the ModemManager bridge and your Phone/Messages agent.') + if input('Type ATTACH to continue: ') != 'ATTACH': + raise Refused('attachment cancelled') + if root_check() != before: + raise Refused('modem or sitd changed during confirmation; no services started') + run(['sudo', '--', 'systemctl', 'start', BRIDGE]) + if root_check() != before: + raise Refused('modem or sitd changed while attaching; stop testing and inspect') + run(['systemctl', '--user', 'start', AGENT]) + run(['systemctl', '--user', 'is-active', '--quiet', AGENT]) + run(['systemctl', 'is-active', '--quiet', BRIDGE]) + if root_check() != before: + raise Refused('modem or sitd changed while attaching; stop testing and inspect') + print('Bridge and session agent active. Open Phone or Messages for the attended test.') + return 0 + except (Refused, EOFError, KeyboardInterrupt) as error: + print(f'Attach refused: {error}', file=sys.stderr) + return 1 + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/packages/omamobile-telephony-tegu/install b/packages/omamobile-telephony-tegu/install new file mode 100755 index 000000000..df5c69d86 --- /dev/null +++ b/packages/omamobile-telephony-tegu/install @@ -0,0 +1,12 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Stage the opt-in bridge integration. No service activation or wants links. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")" +d=${1:?Usage: ./install DESTDIR} +[[ $d == /* && $d != / ]] || { echo "Use an absolute staging directory" >&2; exit 1; } +install -Dm755 bin/omamobile-tegu-mmd-attach "$d/usr/bin/omamobile-tegu-mmd-attach" +install -Dm644 systemd/10-tegu-attach.conf "$d/usr/lib/systemd/system/omamobile-mmd.service.d/10-tegu-attach.conf" +install -Dm644 README.md "$d/usr/share/doc/omamobile-telephony-tegu/README.md" +install -Dm644 LICENSE "$d/usr/share/licenses/omamobile-telephony-tegu/LICENSE" +install -Dm644 version "$d/usr/share/omamobile/telephony-tegu/version" diff --git a/packages/omamobile-telephony-tegu/omamobile-telephony-tegu.install b/packages/omamobile-telephony-tegu/omamobile-telephony-tegu.install new file mode 100644 index 000000000..095527446 --- /dev/null +++ b/packages/omamobile-telephony-tegu/omamobile-telephony-tegu.install @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: MIT +post_install() { + systemctl daemon-reload 2>/dev/null || true + echo "omamobile-telephony-tegu: installed; no services enabled or started." + echo " From the graphical user's terminal, with sitd already running:" + echo " omamobile-tegu-mmd-attach --check, then --attach (attended)." + echo " Migrate any /etc copy of omamobile-sitd.service first; see the README." +} +post_upgrade() { + post_install +} diff --git a/packages/omamobile-telephony-tegu/systemd/10-tegu-attach.conf b/packages/omamobile-telephony-tegu/systemd/10-tegu-attach.conf new file mode 100644 index 000000000..d2e0ad6e3 --- /dev/null +++ b/packages/omamobile-telephony-tegu/systemd/10-tegu-attach.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: MIT +# Check the existing RIL, never pull it or the CP into a start transaction. +[Unit] +Requisite=omamobile-sitd.service +After=omamobile-sitd.service + +[Service] +ExecStartPre=/usr/bin/omamobile-tegu-mmd-attach --service-check diff --git a/packages/omamobile-telephony-tegu/test/all b/packages/omamobile-telephony-tegu/test/all new file mode 100755 index 000000000..9f3a4f1cc --- /dev/null +++ b/packages/omamobile-telephony-tegu/test/all @@ -0,0 +1,30 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Package and attended attachment tests: fixtures only, no phone or system bus. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +for f in PKGBUILD install omamobile-telephony-tegu.install test/all; do bash -n "$f"; done +python3 -B -m unittest discover -s test -p 'test_*.py' +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +./install "$t/root" +for f in usr/bin/omamobile-tegu-mmd-attach usr/lib/systemd/system/omamobile-mmd.service.d/10-tegu-attach.conf \ + usr/share/doc/omamobile-telephony-tegu/README.md usr/share/omamobile/telephony-tegu/version; do + [[ -f $t/root/$f ]] || { echo "not ok - missing $f"; exit 1; } +done +[[ -z $(find "$t/root" -type l -print) ]] || { echo 'not ok - package enables a unit'; exit 1; } +[[ ! -d $t/root/etc ]] || { echo 'not ok - package copies or overrides /etc'; exit 1; } +[[ -x $t/root/usr/bin/omamobile-tegu-mmd-attach ]] +"$t/root/usr/bin/omamobile-tegu-mmd-attach" --help >/dev/null +python3 -I -c 'import sys; compile(open(sys.argv[1]).read(), sys.argv[1], "exec")' bin/omamobile-tegu-mmd-attach +# Read the dependency declarations, not a grep that can match an optdepend. +deps=$(startdir=$PWD bash -c 'source PKGBUILD; printf "%s\n" "${depends[@]}"') +for dep in 'omamobile-device-tegu>=0.2.9' 'omamobile-modem-sit>=0.3.12' 'omamobile-mmd>=0.1.1' 'omatel-agent>=0.2.4'; do + grep -qxF "$dep" <<<"$deps" +done +! grep -qx omamobile-device-cheetah <<<"$deps" +# Requisite is an active-state check, not a start request. No Wants/Requires +# or multi-user target links may be added by this package. +grep -qx 'Requisite=omamobile-sitd.service' systemd/10-tegu-attach.conf +! grep -E '^(Requires|Wants|BindsTo)=' systemd/10-tegu-attach.conf +! grep -E 'systemctl .*\b(start|restart|enable)\b' omamobile-telephony-tegu.install +echo 'ok - opt-in package stages the attended helper and non-pulling bridge policy' diff --git a/packages/omamobile-telephony-tegu/test/test_attach.py b/packages/omamobile-telephony-tegu/test/test_attach.py new file mode 100644 index 000000000..665abb13c --- /dev/null +++ b/packages/omamobile-telephony-tegu/test/test_attach.py @@ -0,0 +1,292 @@ +# SPDX-License-Identifier: MIT +"""The attended script with fake service/bus calls and private socket data.""" +import contextlib +import copy +import importlib.machinery +import importlib.util +import io +import json +from pathlib import Path +import subprocess +import tempfile +import unittest +from unittest.mock import Mock, patch + +SCRIPT = Path(__file__).resolve().parents[1] / 'bin/omamobile-tegu-mmd-attach' +loader = importlib.machinery.SourceFileLoader('attach', str(SCRIPT)) +spec = importlib.util.spec_from_loader(loader.name, loader) +a = importlib.util.module_from_spec(spec) +loader.exec_module(a) + + +class SystemCheck(unittest.TestCase): + def setUp(self): + self.scratch = tempfile.TemporaryDirectory() + self.addCleanup(self.scratch.cleanup) + self.root = Path(self.scratch.name) + desc = self.root / 'usr/share/omamobile/device.conf' + desc.parent.mkdir(parents=True) + desc.write_text('CODENAME=tegu\n') + ver = self.root / 'usr/share/omamobile/device-tegu/version' + ver.parent.mkdir() + ver.write_text('0.2.9\n') + self.status = dict(modem=dict(present=True, sim=dict(state='ready'), radio='on', + registration='home', ims='unregistered', data=False, + operator='PRIVATE NETWORK'), calls=[], sms={'received': []}) + self.units = { + a.SITD: dict(ActiveState='active', MainPID='123', FragmentPath='/usr/lib/systemd/system/' + a.SITD, + Requisite=a.MODEM, Requires='sysinit.target', Wants='', BindsTo='', NeedDaemonReload='no'), + a.MODEM: dict(ActiveState='active', MainPID='122'), + a.BRIDGE: dict(ActiveState='inactive', MainPID='0', FragmentPath='/usr/lib/systemd/system/' + a.BRIDGE, + Requisite=a.SITD, Requires='dbus.socket sysinit.target', Wants='', BindsTo='', NeedDaemonReload='no'), + 'ModemManager.service': dict(ActiveState='inactive', MainPID='0'), + } + self.owner = 'b false' + self.commands = [] + for target, value in [('os.geteuid', lambda: 0), ('properties', lambda name: self.units[name]), + ('run', self.command), ('socket_status', lambda path: self.status)]: + helper = patch.object(a.os, 'geteuid', value) if target == 'os.geteuid' else patch.object(a, target, value) + helper.start() + self.addCleanup(helper.stop) + helper = patch.dict(a.os.environ, OMAMOBILE_TEGU_ROOT=str(self.root)) + helper.start() + self.addCleanup(helper.stop) + + def command(self, args): + self.commands.append(args) + self.assertEqual(args[:3], ['busctl', '--system', 'call']) + self.assertIn('NameHasOwner', args) + return self.owner + + def refused(self): + with self.assertRaises(a.Refused): + a.system_check() + + def test_live_no_ims_no_bearer_passes_without_radio_actions(self): + self.assertEqual(a.system_check(), {'sitd_pid': '123', 'modem_pid': '122'}) + self.assertEqual(len(self.commands), 1) + self.assertNotIn('PRIVATE', json.dumps(a.system_check())) + + def test_wrong_board_and_non_root_refused(self): + with patch.object(a.os, 'geteuid', return_value=1000): + self.refused() + (self.root / 'usr/share/omamobile/device.conf').write_text('CODENAME=cheetah\n') + self.refused() + + def test_missing_or_inactive_ril_or_modem_refused(self): + for unit in (a.SITD, a.MODEM): + for field, value in [('ActiveState', 'inactive'), ('MainPID', '0')]: + with self.subTest(unit=unit, field=field): + old = self.units[unit][field] + self.units[unit][field] = value + self.refused() + self.units[unit][field] = old + + def test_shadow_units_and_reload_pending_refused(self): + for unit in (a.SITD, a.BRIDGE): + for field, value in [('FragmentPath', '/etc/systemd/system/' + unit), ('NeedDaemonReload', 'yes')]: + with self.subTest(unit=unit, field=field): + old = self.units[unit][field] + self.units[unit][field] = value + self.refused() + self.units[unit][field] = old + + def test_missing_policy_or_pulling_dependency_refused(self): + for unit in (a.SITD, a.BRIDGE): + for field, value in [('Requisite', ''), ('Requires', a.MODEM), ('Wants', a.SITD), ('BindsTo', a.MODEM)]: + with self.subTest(unit=unit, field=field): + old = self.units[unit][field] + self.units[unit][field] = value + self.refused() + self.units[unit][field] = old + + def test_competing_bus_owner_or_real_manager_refused(self): + self.owner = 'b true' + self.refused() + self.units[a.BRIDGE]['ActiveState'] = 'active' + self.assertEqual(a.system_check()['sitd_pid'], '123') + self.units['ModemManager.service']['ActiveState'] = 'activating' + self.refused() + + def test_unready_registration_or_live_call_refused(self): + good = copy.deepcopy(self.status) + for key, value in [('sim', {'state': 'absent'}), ('radio', 'off'), ('registration', 'searching')]: + self.status = copy.deepcopy(good) + self.status['modem'][key] = value + self.refused() + self.status = copy.deepcopy(good) + self.status['calls'] = [dict(state='active', number='PRIVATE NUMBER')] + self.refused() + + def test_service_recovery_allows_live_calls_and_registration_loss(self): + self.status['calls'] = [dict(state='active')] + self.status['modem']['radio'] = 'off' + self.status['modem']['registration'] = 'searching' + self.status['modem']['sim'] = dict(state='absent') + self.refused() + self.assertEqual(a.system_check(require_ready=False)['sitd_pid'], '123') + + def test_stop_dependency_is_refused(self): + self.units[a.BRIDGE]['Conflicts'] = 'ModemManager.service shutdown.target' + self.refused() + + def test_malformed_rpc_is_refused_without_private_output(self): + self.status = {'modem': None, 'calls': ['PRIVATE']} + self.refused() + self.status = dict(modem=dict(present=True, sim=None)) + self.refused() + + +class SocketRead(unittest.TestCase): + def test_only_status_sent_and_refused_payload_hidden(self): + fake = Mock() + fake.__enter__ = Mock(return_value=fake) + fake.__exit__ = Mock(return_value=False) + fake.makefile.return_value = io.BytesIO(b'{"ok":true,"result":{"calls":[]}}\n') + with patch.object(a.socket, 'socket', return_value=fake): + self.assertEqual(a.socket_status('/private/socket'), {'calls': []}) + fake.sendall.assert_called_once_with(b'{"action":"status"}\n') + for response in [b'{"ok":false,"error":"PRIVATE NUMBER"}\n', b'bad PRIVATE JSON\n', b'{}']: + fake.makefile.return_value = io.BytesIO(response) + with patch.object(a.socket, 'socket', return_value=fake), self.assertRaises(a.Refused) as error: + a.socket_status('/private/socket') + self.assertNotIn('PRIVATE', str(error.exception)) + + +class Attended(unittest.TestCase): + def setUp(self): + self.commands = [] + self.identity = {'sitd_pid': '123', 'modem_pid': '122'} + self.output = io.StringIO() + self.output.isatty = lambda: True + self.input = Mock() + self.input.isatty.return_value = True + helpers = [patch.object(a.os, 'geteuid', return_value=1000), + patch.object(a, 'root_check', return_value=self.identity), + patch.object(a, 'run', side_effect=self.command), + patch.object(a.sys, 'stdin', self.input), patch.object(a.sys, 'stdout', self.output), + patch.object(a.sys, 'stderr', new=io.StringIO()), patch('builtins.input', return_value='ATTACH')] + for helper in helpers: + helper.start() + self.addCleanup(helper.stop) + + def command(self, args, **kwargs): + self.commands.append(args) + return 'loaded' if '--property=LoadState' in args else '' + + def mutations(self): + return [cmd for cmd in self.commands if 'start' in cmd] + + def test_check_changes_nothing(self): + self.assertEqual(a.main(['--check']), 0) + self.assertFalse(self.mutations()) + + def test_attach_starts_exactly_bridge_and_user_agent(self): + for _ in range(2): + self.assertEqual(a.main(['--attach']), 0) + self.assertEqual(self.mutations(), [ + ['sudo', '--', 'systemctl', 'start', a.BRIDGE], ['systemctl', '--user', 'start', a.AGENT]] * 2) + self.assertNotIn('restart', str(self.commands)) + self.assertNotIn('enable', str(self.commands)) + self.assertNotIn(a.MODEM, str(self.commands)) + self.assertNotIn(a.SITD, str(self.commands)) + + def test_requires_terminal_and_explicit_confirmation(self): + self.input.isatty.return_value = False + self.assertEqual(a.main(['--attach']), 1) + self.assertFalse(self.commands) + self.input.isatty.return_value = True + with patch('builtins.input', return_value='yes'): + self.assertEqual(a.main(['--attach']), 1) + self.assertFalse(self.mutations()) + + def test_ril_change_or_preflight_failure_never_starts_services(self): + with patch.object(a, 'root_check', side_effect=[self.identity, {'sitd_pid': '124', 'modem_pid': '122'}]): + self.assertEqual(a.main(['--attach']), 1) + self.assertFalse(self.mutations()) + with patch.object(a, 'root_check', side_effect=a.Refused('inactive')): + self.assertEqual(a.main(['--attach']), 1) + self.assertFalse(self.mutations()) + + def test_agent_failure_never_recovers_modem_or_ril(self): + def command(args, **kwargs): + value = self.command(args, **kwargs) + if args == ['systemctl', '--user', 'start', a.AGENT]: + raise a.Refused('agent failed') + return value + with patch.object(a, 'run', side_effect=command): + self.assertEqual(a.main(['--attach']), 1) + self.assertEqual(self.mutations(), [['sudo', '--', 'systemctl', 'start', a.BRIDGE], + ['systemctl', '--user', 'start', a.AGENT]]) + + def test_refuses_root_and_missing_user_unit(self): + with patch.object(a.os, 'geteuid', return_value=0): + self.assertEqual(a.main(['--check']), 1) + with patch.object(a, 'run', return_value='not-found'): + self.assertEqual(a.main(['--check']), 1) + self.assertFalse(self.mutations()) + + +class UnitPolicy(unittest.TestCase): + repo = Path(__file__).resolve().parents[3] + + def unit(self, path): + fields = {} + for line in path.read_text().splitlines(): + if '=' in line and not line.startswith('#'): + key, value = line.split('=', 1) + fields.setdefault(key, []).extend(value.split()) + return fields + + def test_effective_device_dependencies_and_readiness(self): + base_path = self.repo / 'packages/omamobile-modem-sit/systemd/omamobile-sitd.service' + if not base_path.exists(): + self.skipTest('device unit integration needs the repository') + base = self.unit(base_path) + self.assertNotIn('Requires', base) + self.assertIn('omamobile-audio.service', base['After']) + for dev in ('tegu', 'cheetah', 'raven'): + policy = self.unit(self.repo / f'packages/omamobile-device-{dev}/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf') + if dev == 'tegu': + self.assertEqual(policy['Requisite'], [a.MODEM]) + for field in ('Requires', 'Wants', 'BindsTo'): + self.assertNotIn(field, policy) + self.assertEqual(policy['ExecStartPre'], ['/usr/lib/omamobile-vendor/omamobile-modem-cp', 'state']) + self.assertIn(a.MODEM, policy['After']) + else: + self.assertEqual(policy['Requires'], ['omamobile-modem.service']) + self.assertEqual(policy['After'], ['omamobile-modem.service']) + + def test_bridge_dependency_cannot_start_ril_or_cp(self): + base_path = self.repo / 'packages/omamobile-mmd/systemd/omamobile-mmd.service' + if not base_path.exists(): + self.skipTest('bridge unit integration needs the repository') + policy = self.unit(Path(__file__).resolve().parents[1] / 'systemd/10-tegu-attach.conf') + base = self.unit(base_path) + for fields in (base, policy): + for key in ('Requires', 'Wants', 'BindsTo'): + self.assertNotIn(key, fields) + self.assertNotIn('Conflicts', base) + self.assertEqual(policy['Requisite'], [a.SITD]) + self.assertEqual(policy['ExecStartPre'], ['/usr/bin/omamobile-tegu-mmd-attach', '--service-check']) + + def test_ril_requires_device_policy_and_dependency_fix(self): + pkg = self.repo / 'packages/omamobile-modem-sit/PKGBUILD' + if not pkg.exists(): + self.skipTest('package closure needs the repository') + def array(path, name): + return subprocess.run(['bash', '-c', + 'startdir=$(dirname "$1"); source "$1"; declare -p "$2"', '_', str(path), name], + check=True, capture_output=True, text=True).stdout + self.assertIn('omamobile-sitd-policy', array(pkg, 'depends')) + modem = self.repo / 'packages/omamobile-modem/PKGBUILD' + self.assertIn('omamobile-modem-policy', array(modem, 'depends')) + self.assertNotIn('omamobile-device-cheetah', array(modem, 'depends')) + for device in ('cheetah', 'raven', 'tegu'): + provides = array(self.repo / f'packages/omamobile-device-{device}/PKGBUILD', 'provides') + self.assertIn('omamobile-sitd-policy', provides) + self.assertIn('omamobile-modem-policy', provides) + + +if __name__ == '__main__': + unittest.main() diff --git a/packages/omamobile-telephony-tegu/test/test_units.py b/packages/omamobile-telephony-tegu/test/test_units.py new file mode 100644 index 000000000..74d4e8640 --- /dev/null +++ b/packages/omamobile-telephony-tegu/test/test_units.py @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: MIT +"""Have systemd itself validate the three composed unit policies offline.""" +from pathlib import Path +import shutil +import subprocess +import tempfile +import unittest + + +@unittest.skipUnless(shutil.which('systemd-analyze'), 'systemd-analyze not installed') +class Units(unittest.TestCase): + def test_composed_units_verify_for_each_device(self): + repo = Path(__file__).resolve().parents[3] + packages = repo / 'packages' + if not (packages / 'omamobile-mmd').exists(): + self.skipTest('composed unit test needs the repository') + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + units = root / 'usr/lib/systemd/system' + units.mkdir(parents=True) + for pkg, name in [('omamobile-modem-sit', 'omamobile-sitd'), ('omamobile-mmd', 'omamobile-mmd')]: + shutil.copy2(packages / pkg / f'systemd/{name}.service', units / f'{name}.service') + # Stubs satisfy references only; verify never starts them. + for name in ['basic', 'sysinit', 'shutdown', 'sockets', 'multi-user', 'slices']: + (units / f'{name}.target').write_text('[Unit]\nDescription=Fixture\n') + (units / 'system.slice').write_text('[Unit]\nDescription=Fixture slice\n') + for name in ['omamobile-modem', 'omamobile-tegu-modem', 'omamobile-audio', + 'omamobile-aoc', 'omamobile-tegu-aoc', 'dbus']: + (units / f'{name}.service').write_text('[Service]\nExecStart=/bin/true\n') + (units / 'dbus.socket').write_text('[Socket]\nListenStream=/run/fixture-bus\n') + for name in ['bin/true', 'usr/bin/omamobile-sitd', 'usr/bin/omamobile-mmd', + 'usr/bin/omamobile-tegu-mmd-attach', 'usr/lib/omamobile-vendor/omamobile-modem-cp']: + path = root / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_text('fixture') + path.chmod(0o755) + drop = units / 'omamobile-sitd.service.d' + drop.mkdir() + bridge = units / 'omamobile-mmd.service.d' + bridge.mkdir() + for device in ['cheetah', 'raven', 'tegu']: + shutil.copy2(packages / f'omamobile-device-{device}/vendor/systemd/system/omamobile-sitd.service.d/10-device-modem.conf', + drop / '10-device-modem.conf') + if device == 'tegu': + shutil.copy2(packages / 'omamobile-telephony-tegu/systemd/10-tegu-attach.conf', bridge / '10-tegu-attach.conf') + result = subprocess.run(['systemd-analyze', '--root', directory, '--man=no', 'verify', + 'omamobile-sitd.service', 'omamobile-mmd.service'], + capture_output=True, text=True) + if result.returncode and 'Operation not permitted' in result.stderr: + self.skipTest('local sandbox blocks systemd verification sockets') + self.assertEqual(result.returncode, 0, f'{device}: {result.stdout}{result.stderr}') diff --git a/packages/omamobile-telephony-tegu/version b/packages/omamobile-telephony-tegu/version new file mode 100644 index 000000000..6e8bf73aa --- /dev/null +++ b/packages/omamobile-telephony-tegu/version @@ -0,0 +1 @@ +0.1.0 diff --git a/tests/all b/tests/all index e688fc605..1feeac2ef 100755 --- a/tests/all +++ b/tests/all @@ -32,7 +32,7 @@ sh -n device/flame/initramfs/init sh -n device/flame/initramfs/build bash -n tools/build-flame-probe echo "ok - scripts parse" -for t in tests/pr-check tests/kernel-pr-check tests/phone-smoke tests/alarm-wake-test tests/install-phone tests/build-rootfs tests/phone-provision tests/nv-backup tests/initramfs-grow tests/images-layout tests/boot-update-parity tests/stage-boot-files tests/initramfs-reproducible tests/device-overlays tests/simplefb-trigger tests/initramfs-steps tests/storage-guard tests/usb-product tests/boot-method tests/make-bundle-keys tests/make-bundle tests/release-signing tests/flame-probe packages/omamobile-firstboot/test/all packages/omamobile-device-felix/test/all packages/omamobile-device-lynx/test/all packages/omamobile-device-panther/test/all tests/local-builds tests/phone-install-package tests/publish-kernel tests/fetch-toolchain tests/release-upload tests/extract-camera-data tests/release; do +for t in tests/pr-check tests/kernel-pr-check tests/phone-smoke tests/alarm-wake-test tests/install-phone tests/build-rootfs tests/phone-provision tests/nv-backup tests/initramfs-grow tests/images-layout tests/boot-update-parity tests/stage-boot-files tests/initramfs-reproducible tests/device-overlays tests/simplefb-trigger tests/initramfs-steps tests/storage-guard tests/usb-product tests/boot-method tests/make-bundle-keys tests/make-bundle tests/release-signing tests/flame-probe packages/omamobile-firstboot/test/all packages/omamobile-device-felix/test/all packages/omamobile-device-lynx/test/all packages/omamobile-device-panther/test/all tests/local-builds tests/phone-install-package tests/publish-kernel tests/fetch-toolchain tests/release-upload tests/extract-camera-data tests/extract-tegu-call-tuning tests/release; do echo "# $t" "$t" done diff --git a/tests/extract-tegu-call-tuning b/tests/extract-tegu-call-tuning new file mode 100755 index 000000000..0a144b35a --- /dev/null +++ b/tests/extract-tegu-call-tuning @@ -0,0 +1,51 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# Synthetic ext4 vendor image only: no owner files, mounts or phone access. +set -euo pipefail +cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." +for tool in mkfs.ext4 debugfs python3; do + command -v "$tool" >/dev/null || { echo "ok - tegu call tuning extraction # SKIP missing $tool"; exit 0; } +done +t=$(mktemp -d); trap 'rm -rf "$t"' EXIT +python3 - "$t/vendor" <<'PY' +from pathlib import Path +import sys +r = Path(sys.argv[1]) +files = { + 'build.prop': b'ro.product.vendor.device=tegu\nro.vendor.build.fingerprint=synthetic-test\n', + 'firmware/fw_bcmdhd.bin': b'4383a3-roml Version=1.2.3 (synthetic)', + 'firmware/bcmdhd.cal_4383_a3': b'NVRAMRev=synthetic\n', + 'firmware/bcmdhd_clm.blob_4383_a3': b'synthetic', + 'firmware/bcmdhd_txcap.blob_4383_a3': b'synthetic', + 'firmware/brcm/BCM.hcd': b'BCM4383A3 synthetic[test]', + 'firmware/aoc.bin': b'synthetic', + 'etc/sensors/registry/fictional.json': b'{}\n', +} +for name in ('cs40l26.wmfw', 'cs40l26-calib.wmfw'): + files['firmware/' + name] = b'WMFW' + bytes(6) + b'\x04FIRMWARE_CS40L26 BUZZ_EFFECTS2_BUZZ_LEVEL' +for name in ('cs40l26.bin', 'cs40l26-svc.bin', 'cs40l26-dvl.bin'): + files['firmware/' + name] = b'WMDR-synthetic' +for route in ('speaker', 'handset'): + for name in (f'uplink_{route}_aec_on_config.pb', f'uplink_{route}_aec_off_config.pb', + f'downlink_{route}_config.pb'): + files['etc/aoc/' + name] = b'synthetic-' + name.encode() +for name, data in files.items(): + path = r / name + path.parent.mkdir(parents=True, exist_ok=True) + path.write_bytes(data) +PY +truncate -s 16M "$t/vendor.img" +mkfs.ext4 -q -F -d "$t/vendor" "$t/vendor.img" +tools/extract-vendor-firmware -d tegu -o "$t/out" "$t/vendor.img" > "$t/log" 2>&1 || { cat "$t/log"; exit 1; } +for f in "$t/vendor/etc/aoc/"*.pb; do + cmp "$f" "$t/out/usr/lib/firmware/updates/omamobile/tegu/aoc/$(basename "$f")" +done +(cd "$t/out/usr/lib/firmware/updates" && sha256sum -c "$t/out/vendor-firmware.sha256" >/dev/null) +echo 'ok - all six tegu call tuning files copied unchanged and checksummed' +rm "$t/vendor/etc/aoc/uplink_handset_aec_off_config.pb" +mkfs.ext4 -q -F -d "$t/vendor" "$t/vendor.img" +if tools/extract-vendor-firmware -d tegu -o "$t/missing" "$t/vendor.img" > "$t/log" 2>&1; then + echo 'not ok - missing AEC-off cleanup file accepted' >&2; exit 1 +fi +grep -qF '/vendor/etc/aoc/uplink_handset_aec_off_config.pb is missing' "$t/log" +echo 'ok - missing cleanup tuning fails extraction' diff --git a/tools/extract-vendor-firmware b/tools/extract-vendor-firmware index 534c5d5d0..0465e9d0f 100755 --- a/tools/extract-vendor-firmware +++ b/tools/extract-vendor-firmware @@ -45,6 +45,8 @@ # vendor/firmware/bcmdhd_clm.blob_4383_a3 -> brcm/brcmfmac4383-pcie..clm_blob (regulatory) # vendor/firmware/bcmdhd_txcap.blob_4383_a3 -> brcm/brcmfmac4383-pcie..txcap_blob (TX capabilities) # vendor/firmware/brcm/BCM.hcd -> brcm/BCM..hcd (btbcm) +# vendor/etc/aoc/{uplink_{speaker,handset}_aec_{on,off},downlink_{speaker,handset}}_config.pb +# -> omamobile/tegu/aoc/ (call tuning, unchanged owner files) # vendor/firmware/aoc.bin -> aoc-tegu.bin (the AoC DSP, under the 9a's own name) # vendor/etc/sensors/registry/ -> /usr/share/omamobile/sensors/registry/ # vendor/firmware/cs40l26*.{wmfw,bin} -> the same five files as cheetah's @@ -210,6 +212,12 @@ case $DEVICE_OPT in "firmware/bcmdhd_txcap.blob_4383_a3|brcm/$FW_BASE.$BOARD.txcap_blob" "firmware/brcm/BCM.hcd|brcm/BCM.$BOARD.hcd" "firmware/aoc.bin|aoc-tegu.bin" + "etc/aoc/uplink_speaker_aec_on_config.pb|omamobile/tegu/aoc/uplink_speaker_aec_on_config.pb" + "etc/aoc/uplink_speaker_aec_off_config.pb|omamobile/tegu/aoc/uplink_speaker_aec_off_config.pb" + "etc/aoc/downlink_speaker_config.pb|omamobile/tegu/aoc/downlink_speaker_config.pb" + "etc/aoc/uplink_handset_aec_on_config.pb|omamobile/tegu/aoc/uplink_handset_aec_on_config.pb" + "etc/aoc/uplink_handset_aec_off_config.pb|omamobile/tegu/aoc/uplink_handset_aec_off_config.pb" + "etc/aoc/downlink_handset_config.pb|omamobile/tegu/aoc/downlink_handset_config.pb" "firmware/cs40l26.wmfw|cs40l26.wmfw" "firmware/cs40l26.bin|cs40l26.bin" "firmware/cs40l26-svc.bin|cs40l26-svc.bin" diff --git a/tools/sit-sim b/tools/sit-sim index d49cce8e5..b1ac8d6c6 100755 --- a/tools/sit-sim +++ b/tools/sit-sim @@ -24,10 +24,12 @@ fictional 555-01xx ones, addresses are from the documentation ranges. tools/sit-sim --ipc PATH --router PATH [--transcript FILE] [--search-polls N] [--incoming-sms] [--no-sim] [--reject-setup CAUSE] - [--no-ims-registration] [--control PATH] + [--no-ims-registration] [--unconfirmed-hangup] [--control PATH] --no-ims-registration accepts ADD_PDN_INFO but never registers IMS (a -carrier whose IMS values differ). --control PATH is a datagram socket for tests: "ring" (an incoming IMS call), +carrier whose IMS values differ). --unconfirmed-hangup acknowledges hangup +requests but leaves the call active and never sends a release indication. +--control PATH is a datagram socket for tests: "ring" (an incoming IMS call), "remote-hangup" (the far end ends the current call), "sms" (one text message), "wap-push" (one MMS notification: an 8-bit SMS to port 2948). @@ -212,7 +214,8 @@ class Sim: cid, apn = p[0], p[4:0xd9 - 12].split(b'\0')[0].decode() # psi: the PDU session ID at 0xf6, 0 when the modem is to pick it. self.log(event='setup_data_call', cid=cid, apn=apn, ip=p[0xda - 12], - psi=struct.unpack_from('