Skip to content

sip: retry IMS registration instead of silently going dark - #33

Open
SavedByLight wants to merge 1 commit into
phhusson:mainfrom
SavedByLight:main
Open

sip: retry IMS registration instead of silently going dark#33
SavedByLight wants to merge 1 commit into
phhusson:mainfrom
SavedByLight:main

Conversation

@SavedByLight

Copy link
Copy Markdown

Previously any REGISTER failure (bad challenge, non-200 response, or a thrown exception in registerCallback via require(statusCode == 200)) left the client permanently deregistered with no automatic recovery path other than the periodic keep-alive alarm, which only fired every 50 minutes. Combined with onAvailable()'s one-shot network.isInitialized guard (which could never retrigger a connect() once set, even after the network was lost and regained), a single transient failure could mean missed VoLTE calls/SMS for up to 50 minutes, or indefinitely until a manual VoLTE/airplane-mode toggle.

SipHandler.kt:

  • Add sessionActive flag, scheduleReconnect() with exponential backoff (5s -> 120s cap), and ensureRegistered().
  • connect()'s two hard-failure paths (bad initial challenge, failed authenticated REGISTER) now call scheduleReconnect() instead of just returning.
  • registerCallback() no longer throws/kills the thread on a non-200 response; it schedules a reconnect instead.
  • A successful registration resets the backoff counter and marks the session active.
  • getVolteNetwork()'s NetworkCallback now keys reconnection off sessionActive instead of the permanently-latched network.isInitialized check, so losing and regaining the network actually triggers a reconnect.

PhhImsService.kt:

  • Shorten the periodic keep-alive alarm from 3,000,000ms (50 min) to 180,000ms (3 min); cheap now that ensureRegistered() only does real work when needed.

PhhImsBroadcastReceiver.kt:

  • Periodic alarm handler now calls ensureRegistered() instead of a raw register() against a socket that may already be dead.

Previously any REGISTER failure (bad challenge, non-200 response, or a
thrown exception in registerCallback via require(statusCode == 200))
left the client permanently deregistered with no automatic recovery
path other than the periodic keep-alive alarm, which only fired every
50 minutes. Combined with onAvailable()'s one-shot
`network.isInitialized` guard (which could never retrigger a connect()
once set, even after the network was lost and regained), a single
transient failure could mean missed VoLTE calls/SMS for up to 50
minutes, or indefinitely until a manual VoLTE/airplane-mode toggle.

SipHandler.kt:
- Add `sessionActive` flag, `scheduleReconnect()` with exponential
  backoff (5s -> 120s cap), and `ensureRegistered()`.
- connect()'s two hard-failure paths (bad initial challenge, failed
  authenticated REGISTER) now call scheduleReconnect() instead of
  just returning.
- registerCallback() no longer throws/kills the thread on a non-200
  response; it schedules a reconnect instead.
- A successful registration resets the backoff counter and marks the
  session active.
- getVolteNetwork()'s NetworkCallback now keys reconnection off
  sessionActive instead of the permanently-latched
  network.isInitialized check, so losing and regaining the network
  actually triggers a reconnect.

PhhImsService.kt:
- Shorten the periodic keep-alive alarm from 3,000,000ms (50 min) to
  180,000ms (3 min); cheap now that ensureRegistered() only does real
  work when needed.

PhhImsBroadcastReceiver.kt:
- Periodic alarm handler now calls ensureRegistered() instead of a
  raw register() against a socket that may already be dead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant