Make sure TelecomManager's connection's state matches our Call's one when the service takes time to be created...
This commit is contained in:
parent
93ecb9c72b
commit
18f36b85bb
1 changed files with 28 additions and 2 deletions
|
@ -109,7 +109,20 @@ class TelecomConnectionService : ConnectionService() {
|
|||
}
|
||||
|
||||
val connection = NativeCallWrapper(callId)
|
||||
connection.setDialing()
|
||||
val call = coreContext.core.calls.find { it.callLog.callId == callId }
|
||||
if (call != null) {
|
||||
val callState = call.state
|
||||
Log.i("[Telecom Connection Service] Found outgoing call from ID [$callId] with state [$callState]")
|
||||
when (callState) {
|
||||
Call.State.OutgoingEarlyMedia, Call.State.OutgoingInit, Call.State.OutgoingProgress, Call.State.OutgoingRinging -> connection.setDialing()
|
||||
Call.State.Paused, Call.State.PausedByRemote, Call.State.Pausing -> connection.setOnHold()
|
||||
Call.State.End, Call.State.Error, Call.State.Released -> connection.setDisconnected(DisconnectCause(DisconnectCause.ERROR))
|
||||
else -> connection.setActive()
|
||||
}
|
||||
} else {
|
||||
Log.w("[Telecom Connection Service] Outgoing call not found for cal ID [$callId], assuming it's state is dialing")
|
||||
connection.setDialing()
|
||||
}
|
||||
|
||||
val providedHandle = request.address
|
||||
connection.setAddress(providedHandle, TelecomManager.PRESENTATION_ALLOWED)
|
||||
|
@ -153,7 +166,20 @@ class TelecomConnectionService : ConnectionService() {
|
|||
Log.i("[Telecom Connection Service] Incoming connection is for call [$callId] with display name [$displayName]")
|
||||
|
||||
val connection = NativeCallWrapper(callId)
|
||||
connection.setRinging()
|
||||
val call = coreContext.core.calls.find { it.callLog.callId == callId }
|
||||
if (call != null) {
|
||||
val callState = call.state
|
||||
Log.i("[Telecom Connection Service] Found incoming call from ID [$callId] with state [$callState]")
|
||||
when (callState) {
|
||||
Call.State.IncomingEarlyMedia, Call.State.IncomingReceived -> connection.setRinging()
|
||||
Call.State.Paused, Call.State.PausedByRemote, Call.State.Pausing -> connection.setOnHold()
|
||||
Call.State.End, Call.State.Error, Call.State.Released -> connection.setDisconnected(DisconnectCause(DisconnectCause.ERROR))
|
||||
else -> connection.setActive()
|
||||
}
|
||||
} else {
|
||||
Log.w("[Telecom Connection Service] Incoming call not found for cal ID [$callId], assuming it's state is ringing")
|
||||
connection.setRinging()
|
||||
}
|
||||
|
||||
val providedHandle =
|
||||
incomingExtras?.getParcelable<Uri>(TelecomManager.EXTRA_INCOMING_CALL_ADDRESS)
|
||||
|
|
Loading…
Reference in a new issue