Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## 0.3.1

* Fix: [Android] placing outgoing call then ending immediately results in no Flutter plugin not registering call ended. Thanks to [@RageshAntonyHM](https://github.com/RageshAntonyHM) & [@Erchil66](https://github.com/Erchil66) [Issue #275](https://github.com/cybex-dev/twilio_voice/issues/275)
* Fix: [Android] Migrate to declarative plugins block from Flutter's `app_plugin_loader` Gradle plugin. (see: [Deprecated imperative apply of Flutter's Gradle plugins](https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply))
* Docs: update CHANGELOG, TODO

## 0.3.0+1

Expand Down
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Project TODO

## Android Plugin
* [TwilioVoicePlugin] Update documentation (and Permission annotations) where necessary
* [TwilioVoicePlugin] Update documentation (and Permission annotations) where necessary

## Platform communication
* Improve message handling between Flutter and native platforms for event channels
Original file line number Diff line number Diff line change
Expand Up @@ -1682,8 +1682,8 @@ class TwilioVoicePlugin : FlutterPlugin, MethodCallHandler, EventChannel.StreamH
return
}
// callSid = null
Log.d(TAG, "handleBroadcastIntent: Call ended $callHandle")
logEvent("", "Call ended")
Log.d(TAG, "handleBroadcastIntent: Call Ended $callHandle")
logEvent("", "Call Ended")
}

TVBroadcastReceiver.ACTION_CALL_STATE -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ open class TVCallConnection(
rejectInvite()
} else {
Log.d(TAG, "onDisconnected: onDisconnected")
twilioCall.let {
it?.disconnect()
}
twilioCall?.disconnect()
onEvent?.onChange(TVNativeCallEvents.EVENT_DISCONNECTED_LOCAL, null)
setDisconnected(DisconnectCause(DisconnectCause.LOCAL))
onDisconnected?.withValue(DisconnectCause(DisconnectCause.LOCAL))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,36 @@ class TVConnectionService : ConnectionService() {
}
}
}


// Set call disconnected listener, removes connection from active connections when call is disconnected
val onCallInitializingDisconnectedListener: CompletionHandler<DisconnectCause> = CompletionHandler {
connection.twilioCall?.let {
if (activeConnections.containsKey(it.sid)) {
activeConnections.remove(it.sid)
}
sendBroadcastEvent(applicationContext, TVBroadcastReceiver.ACTION_CALL_ENDED, it.sid ?: "", connection.extras)
stopForegroundService()
stopSelfSafe()
}
}

// NOTE(cybex-dev): This could be used as an alternative to the [onCallInitializingDisconnectedListener],
// however in the case of a call being initialized followed by a local disconnect - the call only has a temporary SID.
// The call SID is set in the [attachCallEventListeners] method when the call is in a RINGING or CONNECTED state.
// Thus, using [onEvent] will pass through a null call handle which may not be a good design.
// val onEvent: ValueBundleChanged<String> = ValueBundleChanged { event: String?, extra: Bundle? ->
// if(event == TVBroadcastReceiver.ACTION_CALL_ENDED) {
// val callSid = connection.twilioCall?.sid;
// sendBroadcastEvent(applicationContext, event ?: "", callSid, extra)
// // This is a temporary solution since `isOnCall` returns true when there is an active ConnectionService, regardless of the source app. This also applies to SIM/Telecom calls.
// sendBroadcastCallHandle(applicationContext, extra?.getString(TVBroadcastReceiver.EXTRA_CALL_HANDLE))
// }
// }

connection.setOnCallStateListener(onCallStateListener)
connection.setOnCallDisconnected(onCallInitializingDisconnectedListener)
// connection.setOnCallEventListener(onEvent)

// Setup connection UI parameters
connection.setInitializing()
Expand Down