fix: route calls only through ready IMS sessions

This commit is contained in:
MengMengCode
2026-08-09 21:31:24 +08:00
parent 97ca84bbfc
commit 337aa3c0ab
2 changed files with 18 additions and 1 deletions
+5 -1
View File
@@ -203,7 +203,11 @@ func (s *Server) hangupVoWiFiAfter(deviceID, callID string, duration time.Durati
func (s *Server) callTransport(deviceID string) string {
if s.vowifi != nil {
if state, err := s.vowifi.State(deviceID); err == nil && state.Enabled {
// Enabled is only the desired card policy. Calls can use IMS only after
// registration has actually completed; otherwise keep using the modem's
// circuit-switched call path instead of routing into an unavailable IMS
// session.
if state, err := s.vowifi.State(deviceID); err == nil && state.IMSReady {
return "vowifi"
}
}
+13
View File
@@ -4,6 +4,7 @@ import (
"testing"
"vocat/internal/modem"
"vocat/internal/vowifi"
)
func TestParseCLCC(t *testing.T) {
@@ -28,3 +29,15 @@ func TestValidDialNumber(t *testing.T) {
}
}
}
func TestCallTransportRequiresIMSReady(t *testing.T) {
controller := &fakeVoWiFiController{state: vowifi.State{Enabled: true}}
server := &Server{vowifi: controller}
if got := server.callTransport("ec20"); got != "cellular" {
t.Fatalf("callTransport before IMS registration = %q, want cellular", got)
}
controller.state.IMSReady = true
if got := server.callTransport("ec20"); got != "vowifi" {
t.Fatalf("callTransport with IMS ready = %q, want vowifi", got)
}
}