Skip to content

Commit afc758c

Browse files
committed
avoid npe on twilioMos if call is disconnected prematurely
1 parent aba39c4 commit afc758c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

android/src/main/java/com/ngs/react/RNTwilioVoice/TwilioVoiceModule.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,13 @@ public void onDisconnected(Call call, CallException error) {
307307
proximityManager.stopProximitySensor();
308308
headsetManager.stopWiredHeadsetEvent(getReactApplicationContext());
309309
callAccepted = false;
310-
twilioMos.stop(); // Stop MOS listener
310+
if (twilioMos != null) {
311+
twilioMos.stop(); // Stop MOS listener
312+
}
311313

312314
WritableMap params = Arguments.createMap();
313315
String callSid = "";
314-
if (call != null) {
316+
if (twilioMos != null && call != null) {
315317
callSid = call.getSid();
316318
params.putString("call_sid", callSid);
317319
params.putString("call_state", call.getState().name());

0 commit comments

Comments
 (0)