From ee4695b2dfe781f70a113cf79ad6ed75cb00c30c Mon Sep 17 00:00:00 2001 From: KGCybeX Date: Thu, 19 Oct 2023 08:18:26 +0200 Subject: [PATCH 1/2] assert request & connection manager not null --- .../com/twilio/twilio_voice/service/TVConnectionService.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt b/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt index 43a55b22..98fe22f3 100644 --- a/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt +++ b/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt @@ -472,6 +472,9 @@ class TVConnectionService : ConnectionService() { //endregion override fun onCreateIncomingConnection(connectionManagerPhoneAccount: PhoneAccountHandle?, request: ConnectionRequest?): Connection { + assert(request != null) { "ConnectionRequest cannot be null" } + assert(connectionManagerPhoneAccount != null) { "ConnectionManagerPhoneAccount cannot be null" } + super.onCreateIncomingConnection(connectionManagerPhoneAccount, request) Log.d(TAG, "onCreateIncomingConnection") @@ -512,6 +515,9 @@ class TVConnectionService : ConnectionService() { } override fun onCreateOutgoingConnection(connectionManagerPhoneAccount: PhoneAccountHandle?, request: ConnectionRequest?): Connection { + assert(request != null) { "ConnectionRequest cannot be null" } + assert(connectionManagerPhoneAccount != null) { "ConnectionManagerPhoneAccount cannot be null" } + super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request) Log.d(TAG, "onCreateOutgoingConnection") From c3ea73343e47dbb2c3289068e7bf8c559f38fd68 Mon Sep 17 00:00:00 2001 From: KGCybeX Date: Thu, 19 Oct 2023 08:18:45 +0200 Subject: [PATCH 2/2] throw exception on missing parameters --- .../twilio_voice/service/TVConnectionService.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt b/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt index 98fe22f3..431ec626 100644 --- a/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt +++ b/android/src/main/kotlin/com/twilio/twilio_voice/service/TVConnectionService.kt @@ -481,13 +481,13 @@ class TVConnectionService : ConnectionService() { val extras = request?.extras val myBundle: Bundle = extras?.getBundle(TelecomManager.EXTRA_INCOMING_CALL_EXTRAS) ?: run { Log.e(TAG, "onCreateIncomingConnection: request is missing Bundle EXTRA_INCOMING_CALL_EXTRAS") - return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateIncomingConnection: request is missing Bundle EXTRA_INCOMING_CALL_EXTRAS"); } myBundle.classLoader = CallInvite::class.java.classLoader val ci: CallInvite = myBundle.getParcelableSafe(EXTRA_INCOMING_CALL_INVITE) ?: run { Log.e(TAG, "onCreateIncomingConnection: request is missing CallInvite EXTRA_INCOMING_CALL_INVITE") - return super.onCreateIncomingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateIncomingConnection: request is missing CallInvite EXTRA_INCOMING_CALL_INVITE"); } // Create storage instance for call parameters @@ -524,21 +524,21 @@ class TVConnectionService : ConnectionService() { val extras = request?.extras val myBundle: Bundle = extras?.getBundle(EXTRA_OUTGOING_PARAMS) ?: run { Log.e(TAG, "onCreateOutgoingConnection: request is missing Bundle EXTRA_OUTGOING_PARAMS") - return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateOutgoingConnection: request is missing Bundle EXTRA_OUTGOING_PARAMS"); } // check required EXTRA_TOKEN, EXTRA_TO, EXTRA_FROM val token: String = myBundle.getString(EXTRA_TOKEN) ?: run { Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TOKEN") - return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TOKEN"); } val to = myBundle.getString(EXTRA_TO) ?: run { Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TO") - return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_TO"); } val from = myBundle.getString(EXTRA_FROM) ?: run { Log.e(TAG, "onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_FROM") - return super.onCreateOutgoingConnection(connectionManagerPhoneAccount, request) + throw Exception("onCreateOutgoingConnection: ACTION_PLACE_OUTGOING_CALL is missing String EXTRA_FROM"); } // Get all params from bundle