mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-13 03:13:43 +08:00
fix: route calls only through ready IMS sessions
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user