From 5704c01cab1f41665c9922c3acff473957e36146 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:20:38 +0100 Subject: [PATCH 1/2] omamobile-modem-sit 0.3.43: a call the modem no longer lists ends here, sitd keeps running A call to a number that forwards straight back to this phone rings here while the outgoing call is still dialing. The outgoing call then ends with cause 17, and the modem never mentions the incoming one again: it refuses AIMS_ANSWER and AIMS_HANGUP with error 2 and GET_CURRENT_CALLS lists no call. sitd kept the call as ringing-in, and 12 s after the first refused request the hangup deadline expired and it stopped itself ("Call release was not confirmed"): no calls or SMS until a reboot (#729, a Pixel 9a, twice on 2026-11-13). Before giving a call up as unconfirmed, sitd now asks the modem (Service.reconcile): when a hang-up or an answer is refused, when the hangup deadline expires, and at the service stop before unconfirmed_release(). If GET_CURRENT_CALLS is empty, the calls it still shows end here (terminated, reason error), the audio route is released and sitd goes on. The dial action already relies on the same answer before it dials. A dial whose setup is still pending is left out: while self.pending is set, or a live call has no modem ID yet, the modem is not asked and the old path runs. The same deadline is armed when a dial times out, the modem may not list a late dial yet, and ending it here would drop the status of a call that then connects. A modem that still lists a call, or doesn't answer the question, also stays with unconfirmed_release(). tools/sit-sim: --forwarded-back (a ring for a second call ID, the dialled call ended with cause 17, an empty call list, answer and hang-up refused with error 2) and --silent-dial (AIMS_DIAL never answered, no call listed). Tests: test_sim.py runs the forwarded call with a refused hang-up, a refused answer and a service stop (sitd keeps running past the 12 s deadline, the call ends, no radio-off; the stop exits 0), and the pending dial, which still ends in the unconfirmed release without a second GET_CURRENT_CALLS. test_service.py has the same cases as unit tests, plus a modem that still lists a call and a call check that fails. test/all (run on the Pixel 9a itself, aarch64): passes. On a Pixel 9a (2026-11-14, 7.3.0-rc6-omamobile-push1-gcbb1a7eb0a78): this head's lib/service.py over the installed 0.3.35 (the file is the same in 0.3.35 and on main), then a reboot. An ordinary outgoing call, hung up while it rang: AIMS_HANGUP error 0, as before. The forwarded call, twice, the returning call hung up and then answered through omamobile-mmd: error 2 each time, "the modem lists no call; 1 stale call(s) ended here", the call terminated, the audio routes restored, sitd still running 16 s later and the next dial accepted. Not run on a phone: the service stop with a stale call and the pending dial (both in the simulator only). Co-Authored-By: Claude Fable 5.2 --- packages/omamobile-modem-sit/lib/service.py | 54 +++++++++++++- .../omamobile-modem-sit/test/test_service.py | 71 ++++++++++++++++++ packages/omamobile-modem-sit/test/test_sim.py | 73 +++++++++++++++++++ packages/omamobile-modem-sit/version | 2 +- tools/sit-sim | 23 +++++- 5 files changed, 218 insertions(+), 5 deletions(-) diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index ab7d9be68..6e929c2da 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -514,9 +514,49 @@ def pump(self): break self.event(packet) if self.hangup_deadline and time.monotonic() > self.hangup_deadline: + if self.reconcile('the hangup deadline expired'): + return self.release_unconfirmed = True unconfirmed_release(self.client, 'hangup deadline expired') + def reconcile(self, why): + """Ask the modem before giving a call up as unconfirmed. + + A call forwarded straight back to this phone rings here, the + outgoing call ends with cause 17, and the modem never mentions the + incoming one again: it refuses the answer and the hang-up (error 2) + and lists no call. If GET_CURRENT_CALLS is empty, the calls still + shown here are stale and end here; True then. The dial action relies + on the same answer before it dials. + + Not while a dial's setup is pending (no status yet, so no modem ID): + the modem may not list a late dial yet, and ending it here would + drop the status of a call that then connects. That case, a modem + that lists a call and one that doesn't answer stay with + unconfirmed_release(). + """ + if self.pending or any(call['modem_id'] is None for call in self.live()): + return False + try: + listed = self.client.request(0x0000, timeout=5) + except (ModemError, TimeoutError, OSError) as error: + print('Call check after', why, 'failed:', type(error).__name__, flush=True) + return False + if listed != bytes(4): + print('Call check after', why + ': the modem still lists a call', flush=True) + return False + stale = self.live() + for call in stale: + call['state'] = 'terminated' + call['reason'] = 'error' + call['since'] = time.time() + self.hangup_deadline = None + self.audio_stop() + self.save_calls() + print('Call check after', why + ': the modem lists no call;', len(stale), 'stale call(s) ended here', + flush=True) + return True + def send_sms(self, request): key = request.get('request_id', '') if not isinstance(key, str) or len(key) != 32 or any(c not in '0123456789abcdef' for c in key): @@ -794,12 +834,22 @@ def dispatch(self, request): try: # Ordinary voice, audio send/receive, no video. self.client.request(0x0d02, struct.pack(' Date: Sun, 15 Nov 2026 08:20:32 +0100 Subject: [PATCH 2/2] omamobile-modem-sit: a call check that breaks still ends in the radio-off reconcile() caught ModemError, TimeoutError and OSError from GET_CURRENT_CALLS, but the transport also raises a plain RuntimeError (invalid SIT framing, a short SIT write, the unprocessed indication limit) and EOFError when the channel closes. Those left reconcile() before unconfirmed_release() ran: with a ringing call and an expired deadline, main raises UnconfirmedRelease after one radio-off, and the branch raised the RuntimeError with none. Any failure of the check now returns False, so the old path runs. A test with both errors; MODEM-CLIENT.md says that sitd asks the modem first. Co-Authored-By: Claude Fable 5.2 --- device/cheetah/MODEM-CLIENT.md | 11 +++++++--- packages/omamobile-modem-sit/lib/service.py | 7 +++++-- .../omamobile-modem-sit/test/test_service.py | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/device/cheetah/MODEM-CLIENT.md b/device/cheetah/MODEM-CLIENT.md index 8561bb114..2b1915296 100644 --- a/device/cheetah/MODEM-CLIENT.md +++ b/device/cheetah/MODEM-CLIENT.md @@ -122,9 +122,14 @@ registration indication), unless `ims_required = yes`. message appears in the daemon's log. - **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, turns the radio off (best effort, AT+CFUN=0) - and stops sitd with the call still recorded as its own, for an attended +- **Calls**: when a hangup's release isn't confirmed within 12 s, or the + modem refuses an answer or a hang-up, sitd first asks the modem for its + calls (`GET_CURRENT_CALLS`): if it lists none, and no dial is still being + set up, the calls shown here are stale and end here, and sitd keeps + running ("the modem lists no call; N stale call(s) ended here"). Otherwise + (the modem lists a call, the check fails, a dial is pending), and for a call + left over from a previous run, the radio goes off (best effort, AT+CFUN=0) + and sitd stops 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, diff --git a/packages/omamobile-modem-sit/lib/service.py b/packages/omamobile-modem-sit/lib/service.py index 6e929c2da..525faad82 100644 --- a/packages/omamobile-modem-sit/lib/service.py +++ b/packages/omamobile-modem-sit/lib/service.py @@ -532,14 +532,17 @@ def reconcile(self, why): Not while a dial's setup is pending (no status yet, so no modem ID): the modem may not list a late dial yet, and ending it here would drop the status of a call that then connects. That case, a modem - that lists a call and one that doesn't answer stay with + that lists a call and a check that fails in any way stay with unconfirmed_release(). """ if self.pending or any(call['modem_id'] is None for call in self.live()): return False try: listed = self.client.request(0x0000, timeout=5) - except (ModemError, TimeoutError, OSError) as error: + except Exception as error: + # Anything, not only a refusal or a timeout: the transport also + # raises RuntimeError (framing, a short write, the indication + # limit) and EOFError, and none of them may skip the radio-off. print('Call check after', why, 'failed:', type(error).__name__, flush=True) return False if listed != bytes(4): diff --git a/packages/omamobile-modem-sit/test/test_service.py b/packages/omamobile-modem-sit/test/test_service.py index e7f27b32a..9cf8f4e86 100644 --- a/packages/omamobile-modem-sit/test/test_service.py +++ b/packages/omamobile-modem-sit/test/test_service.py @@ -343,6 +343,26 @@ def test_call_check_that_fails_keeps_the_deadline(self): self.assertEqual(call['state'], 'ringing-in') self.assertIsNotNone(self.service.hangup_deadline) + def test_call_check_that_breaks_still_ends_in_the_radio_off(self): + # The transport's own errors are not ModemError: the check must not + # let them out past the unconfirmed release. + for error in (RuntimeError('unprocessed indication limit exceeded'), EOFError('SIT channel closed')): + with self.subTest(error=type(error).__name__): + self.service.calls.clear() + self.service.release_unconfirmed = False + call = self.stale_ring() + def request(message, *args, error=error, **kwargs): + if message == 0x0000: raise error + return bytes(4) # the radio state, asked after the radio-off + self.client.request.side_effect = request + self.service.hangup_deadline = 0.001 + with patch.object(app_service, 'radio') as radio, \ + patch.object(app_service.cp, 'state', return_value=app_service.cp.ONLINE): + with self.assertRaises(app_service.UnconfirmedRelease): self.service.pump() + radio.assert_called_once_with(False) + self.assertTrue(self.service.release_unconfirmed) + self.assertEqual((call['state'], self.service.live()), ('ringing-in', [call])) + def test_pending_dial_is_never_ended_by_the_call_check(self): # A dial that timed out: still pending, no modem ID, and the modem # doesn't list it yet. The deadline must not end it here.