Skip to content

Commit 93593d4

Browse files
authored
Merge pull request #160 from cybex-dev/fix_android_outgoing_connected_event
Fix: no Connected event on outbound Android calls
2 parents d91d276 + a88eeee commit 93593d4

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnection.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,26 +170,26 @@ open class TVCallConnection(
170170
setInitialized()
171171
}
172172
}
173+
onCallStateListener?.withValue(call.state)
173174
onEvent?.onChange(TVNativeCallEvents.EVENT_RINGING, Bundle().apply {
174175
putString(TVBroadcastReceiver.EXTRA_CALL_HANDLE, callParams?.callSid)
175176
putString(TVBroadcastReceiver.EXTRA_CALL_FROM, callParams?.fromRaw)
176177
putString(TVBroadcastReceiver.EXTRA_CALL_TO, callParams?.toRaw)
177178
putInt(TVBroadcastReceiver.EXTRA_CALL_DIRECTION, callDirection.id)
178179
})
179-
onCallStateListener?.withValue(call.state)
180180
}
181181

182182
override fun onConnected(call: Call) {
183183
Log.d(TAG, "onConnected: onConnected")
184184
twilioCall = call
185185
setActive()
186+
onCallStateListener?.withValue(call.state)
186187
onEvent?.onChange(TVNativeCallEvents.EVENT_CONNECTED, Bundle().apply {
187188
putString(TVBroadcastReceiver.EXTRA_CALL_HANDLE, callParams?.callSid)
188189
putString(TVBroadcastReceiver.EXTRA_CALL_FROM, callParams?.fromRaw)
189190
putString(TVBroadcastReceiver.EXTRA_CALL_TO, callParams?.toRaw)
190191
putInt(TVBroadcastReceiver.EXTRA_CALL_DIRECTION, callDirection.id)
191192
})
192-
onCallStateListener?.withValue(call.state)
193193
}
194194

195195
/**
@@ -205,14 +205,14 @@ open class TVCallConnection(
205205
*/
206206
override fun onReconnecting(call: Call, callException: CallException) {
207207
twilioCall = call
208+
onCallStateListener?.withValue(call.state)
208209
onEvent?.onChange(TVNativeCallEvents.EVENT_RECONNECTING, Bundle().apply {
209210
putString(TVBroadcastReceiver.EXTRA_CALL_HANDLE, callParams?.callSid)
210211
putString(TVBroadcastReceiver.EXTRA_CALL_FROM, callParams?.fromRaw)
211212
putString(TVBroadcastReceiver.EXTRA_CALL_TO, callParams?.toRaw)
212213
putInt(TVBroadcastReceiver.EXTRA_CALL_DIRECTION, callDirection.id)
213214
putExtras(callException.toBundle())
214215
})
215-
onCallStateListener?.withValue(call.state)
216216
}
217217

218218
/**
@@ -223,25 +223,25 @@ open class TVCallConnection(
223223
override fun onReconnected(call: Call) {
224224
twilioCall = call
225225
setActive()
226+
onCallStateListener?.withValue(call.state)
226227
onEvent?.onChange(TVNativeCallEvents.EVENT_RECONNECTED, Bundle().apply {
227228
putString(TVBroadcastReceiver.EXTRA_CALL_HANDLE, callParams?.callSid)
228229
putString(TVBroadcastReceiver.EXTRA_CALL_FROM, callParams?.fromRaw)
229230
putString(TVBroadcastReceiver.EXTRA_CALL_TO, callParams?.toRaw)
230231
putInt(TVBroadcastReceiver.EXTRA_CALL_DIRECTION, callDirection.id)
231232
});
232-
onCallStateListener?.withValue(call.state)
233233
}
234234

235235
override fun onDisconnected(call: Call, reason: CallException?) {
236236
// TODO run below only if we did NOT ended call i.e. remove disconnect from other client
237237
Log.d(TAG, "onDisconnected: onDisconnected, reason: ${reason?.message}.\nException: ${reason.toString()}")
238238
twilioCall = null
239+
onCallStateListener?.withValue(call.state)
239240
onEvent?.onChange(TVNativeCallEvents.EVENT_DISCONNECTED_REMOTE, Bundle().apply {
240241
reason?.toBundle()?.let { putExtras(it) }
241242
})
242243
setDisconnected(DisconnectCause(DisconnectCause.REMOTE))
243244
onDisconnected?.withValue(DisconnectCause(DisconnectCause.REMOTE))
244-
onCallStateListener?.withValue(call.state)
245245
destroy()
246246
}
247247
//endregion

android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ class TVConnectionService : ConnectionService() {
571571
val callSid = call.sid!!
572572

573573
// Resolve call parameters
574-
val callParams = TVCallParametersImpl(mStorage, connection.twilioCall!!, to, from, params)
574+
val callParams = TVCallParametersImpl(mStorage, call, to, from, params)
575575
connection.setCallParameters(callParams)
576576

577577
// If call is not attached, attach it

0 commit comments

Comments
 (0)