Skip to content

Commit 75b4fed

Browse files
authored
Merge pull request #186 from cybex-dev/fix_android_outgoing_connection_returns_null
[Fix] Outgoing connection returns null
2 parents 8ca91ba + c3ea733 commit 75b4fed

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,19 +472,22 @@ class TVConnectionService : ConnectionService() {
472472
//endregion
473473

474474
override fun onCreateIncomingConnection(connectionManagerPhoneAccount: PhoneAccountHandle?, request: ConnectionRequest?): Connection {
475+
assert(request != null) { "ConnectionRequest cannot be null" }
476+
assert(connectionManagerPhoneAccount != null) { "ConnectionManagerPhoneAccount cannot be null" }
477+
475478
super.onCreateIncomingConnection(connectionManagerPhoneAccount, request)
476479
Log.d(TAG, "onCreateIncomingConnection")
477480

478481
val extras = request?.extras
479482
val myBundle: Bundle = extras?.getBundle(TelecomManager.EXTRA_INCOMING_CALL_EXTRAS) ?: run {
480483
Log.e(TAG, "onCreateIncomingConnection: request is missing Bundle EXTRA_INCOMING_CALL_EXTRAS")
481-
return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request)
484+
throw Exception("onCreateIncomingConnection: request is missing Bundle EXTRA_INCOMING_CALL_EXTRAS");
482485
}
483486

484487
myBundle.classLoader = CallInvite::class.java.classLoader
485488
val ci: CallInvite = myBundle.getParcelableSafe(EXTRA_INCOMING_CALL_INVITE) ?: run {
486489
Log.e(TAG, "onCreateIncomingConnection: request is missing CallInvite EXTRA_INCOMING_CALL_INVITE")
487-
return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request)
490+
throw Exception("onCreateIncomingConnection: request is missing CallInvite EXTRA_INCOMING_CALL_INVITE");
488491
}
489492

490493
// Create storage instance for call parameters
@@ -512,27 +515,30 @@ class TVConnectionService : ConnectionService() {
512515
}
513516

514517
override fun onCreateOutgoingConnection(connectionManagerPhoneAccount: PhoneAccountHandle?, request: ConnectionRequest?): Connection {
518+
assert(request != null) { "ConnectionRequest cannot be null" }
519+
assert(connectionManagerPhoneAccount != null) { "ConnectionManagerPhoneAccount cannot be null" }
520+
515521
super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request)
516522
Log.d(TAG, "onCreateOutgoingConnection")
517523

518524
val extras = request?.extras
519525
val myBundle: Bundle = extras?.getBundle(EXTRA_OUTGOING_PARAMS) ?: run {
520526
Log.e(TAG, "onCreateOutgoingConnection: request is missing Bundle EXTRA_OUTGOING_PARAMS")
521-
return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request)
527+
throw Exception("onCreateOutgoingConnection: request is missing Bundle EXTRA_OUTGOING_PARAMS");
522528
}
523529

524530
// check required EXTRA_TOKEN, EXTRA_TO, EXTRA_FROM
525531
val token: String = myBundle.getString(EXTRA_TOKEN) ?: run {
526532
Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TOKEN")
527-
return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request)
533+
throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TOKEN");
528534
}
529535
val to = myBundle.getString(EXTRA_TO) ?: run {
530536
Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TO")
531-
return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request)
537+
throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TO");
532538
}
533539
val from = myBundle.getString(EXTRA_FROM) ?: run {
534540
Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_FROM")
535-
return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request)
541+
throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_FROM");
536542
}
537543

538544
// Get all params from bundle

0 commit comments

Comments
 (0)