69
69
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CONNECTION_DID_CONNECT ;
70
70
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CONNECTION_DID_DISCONNECT ;
71
71
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_DEVICE_DID_RECEIVE_INCOMING ;
72
- import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CALL_INVITE_CANCELLED ;
73
72
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_DEVICE_NOT_READY ;
74
73
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_DEVICE_READY ;
75
74
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CALL_STATE_RINGING ;
75
+ import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CALL_INVITE_CANCELLED ;
76
76
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CONNECTION_IS_RECONNECTING ;
77
77
import static com .hoxfon .react .RNTwilioVoice .EventManager .EVENT_CONNECTION_DID_RECONNECT ;
78
78
@@ -111,7 +111,7 @@ public class TwilioVoiceModule extends ReactContextBaseJavaModule implements Act
111
111
private AudioFocusRequest focusRequest ;
112
112
private HeadsetManager headsetManager ;
113
113
private EventManager eventManager ;
114
- private int callInviteIntent ;
114
+ private int existingCallInviteIntent ;
115
115
116
116
public TwilioVoiceModule (ReactApplicationContext reactContext ,
117
117
boolean shouldAskForMicPermission ) {
@@ -170,8 +170,8 @@ public void onHostResume() {
170
170
if (BuildConfig .DEBUG ) {
171
171
Log .d (TAG , "Module creation " +action +". Intent " + intent .getExtras ());
172
172
}
173
- if (action .equals (ACTION_ACCEPT ) && callInviteIntent != currentCallInviteIntent ) {
174
- callInviteIntent = currentCallInviteIntent ;
173
+ if (action .equals (ACTION_ACCEPT ) && currentCallInviteIntent != existingCallInviteIntent ) {
174
+ existingCallInviteIntent = currentCallInviteIntent ;
175
175
handleIncomingCallIntent (intent );
176
176
}
177
177
}
@@ -189,6 +189,11 @@ public void onHostDestroy() {
189
189
unsetAudioFocus ();
190
190
}
191
191
192
+ @ Override
193
+ public String getName () {
194
+ return TAG ;
195
+ }
196
+
192
197
@ Override
193
198
public void onNewIntent (Intent intent ) {
194
199
// This is called only when the App is in the foreground
@@ -198,11 +203,6 @@ public void onNewIntent(Intent intent) {
198
203
handleIncomingCallIntent (intent );
199
204
}
200
205
201
- @ Override
202
- public String getName () {
203
- return TAG ;
204
- }
205
-
206
206
private RegistrationListener registrationListener () {
207
207
return new RegistrationListener () {
208
208
@ Override
@@ -698,26 +698,11 @@ public void connect(ReadableMap params) {
698
698
twiMLParams .put (key , params .getString (key ));
699
699
break ;
700
700
default :
701
- Log .d (TAG , "Could not convert with key: " + key + "." );
701
+ Log .d (TAG , "Could not convert key: " + key + ". ReadableType: " + readableType . toString () );
702
702
break ;
703
703
}
704
704
}
705
705
706
- // Set<IceServer> iceServers = new HashSet<>();
707
- // iceServers.add(new IceServer("stun:global.stun.twilio.com:3478?transport=udp"));
708
- // iceServers.add(new IceServer("turn:global.turn.twilio.com:3478?transport=udp","8e6467be547b969ad913f7bdcfb73e411b35f648bd19f2c1cb4161b4d4a067be","n8zwmkgjIOphHN93L/aQxnkUp1xJwrZVLKc/RXL0ZpM="));
709
- // iceServers.add(new IceServer("turn:global.turn.twilio.com:3478?transport=tcp","8e6467be547b969ad913f7bdcfb73e411b35f648bd19f2c1cb4161b4d4a067be","n8zwmkgjIOphHN93L/aQxnkUp1xJwrZVLKc/RXL0ZpM="));
710
- // iceServers.add(new IceServer("turn:global.turn.twilio.com:443?transport=tcp","8e6467be547b969ad913f7bdcfb73e411b35f648bd19f2c1cb4161b4d4a067be","n8zwmkgjIOphHN93L/aQxnkUp1xJwrZVLKc/RXL0ZpM="));
711
- //
712
- // IceOptions iceOptions = new IceOptions.Builder()
713
- // .iceServers(iceServers)
714
- // .build();
715
- //
716
- // ConnectOptions connectOptions = new ConnectOptions.Builder(accessToken)
717
- // .iceOptions(iceOptions)
718
- // .enableDscp(true)
719
- // .params(twiMLParams)
720
- // .build();
721
706
ConnectOptions connectOptions = new ConnectOptions .Builder (accessToken )
722
707
.enableDscp (true )
723
708
.params (twiMLParams )
@@ -807,7 +792,7 @@ private void setAudioFocus() {
807
792
}
808
793
savedAudioMode = audioManager .getMode ();
809
794
// Request audio focus before making any device switch
810
- if (Build .VERSION .SDK_INT >= 26 ) {
795
+ if (Build .VERSION .SDK_INT >= Build . VERSION_CODES . O ) {
811
796
AudioAttributes playbackAttributes = new AudioAttributes .Builder ()
812
797
.setUsage (AudioAttributes .USAGE_VOICE_COMMUNICATION )
813
798
.setContentType (AudioAttributes .CONTENT_TYPE_SPEECH )
@@ -845,7 +830,7 @@ private void unsetAudioFocus() {
845
830
return ;
846
831
}
847
832
audioManager .setMode (savedAudioMode );
848
- if (Build .VERSION .SDK_INT >= 26 ) {
833
+ if (Build .VERSION .SDK_INT >= Build . VERSION_CODES . O ) {
849
834
if (focusRequest != null ) {
850
835
audioManager .abandonAudioFocusRequest (focusRequest );
851
836
}
@@ -864,9 +849,7 @@ private void requestPermissionForMicrophone() {
864
849
return ;
865
850
}
866
851
if (ActivityCompat .shouldShowRequestPermissionRationale (getCurrentActivity (), Manifest .permission .RECORD_AUDIO )) {
867
- // Snackbar.make(coordinatorLayout,
868
- // "Microphone permissions needed. Please allow in your application settings.",
869
- // SNACKBAR_DURATION).show();
852
+ // TODO
870
853
} else {
871
854
ActivityCompat .requestPermissions (getCurrentActivity (), new String []{Manifest .permission .RECORD_AUDIO }, MIC_PERMISSION_REQUEST_CODE );
872
855
}
0 commit comments