Skip to content

Commit aba39c4

Browse files
committed
add missing FLAG_IMMUTABLE flags / check for null activities
1 parent 1fe50e2 commit aba39c4

File tree

4 files changed

+38
-29
lines changed

4 files changed

+38
-29
lines changed

android/src/main/java/com/ngs/react/RNTwilioVideo/IncomingVideoCallFullscreenActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import android.os.Build;
99
import android.os.Bundle;
1010
import android.os.Handler;
11-
import android.support.v4.content.LocalBroadcastManager;
11+
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
1212
import android.util.Log;
1313
import android.view.View;
1414
import android.view.WindowManager;
@@ -65,15 +65,15 @@ protected void onCreate(Bundle savedInstanceState) {
6565

6666
TextView caller = findViewById(R.id.caller);
6767
TextView appName = findViewById(R.id.app_name);
68-
TextView incomingVoiceCall = (TextView) findViewById(R.id.incomingVoiceCall);
68+
TextView incomingVideoCall = (TextView) findViewById(R.id.incomingVideoCall);
6969
TextView decline = (TextView) findViewById(R.id.decline_text);
7070
TextView answer = (TextView) findViewById(R.id.answer_text);
7171
TextView goOffline = (TextView) findViewById(R.id.go_offline_text);
7272

7373
Context context = getApplicationContext();
7474
SharedPreferences sharedPref = context.getSharedPreferences("db", Context.MODE_PRIVATE);
7575

76-
incomingVoiceCall.setText(sharedPref.getString(LocalizedKeys.INCOMING_VIDEO_CALL, "Incoming video call"));
76+
incomingVideoCall.setText(sharedPref.getString(LocalizedKeys.INCOMING_VIDEO_CALL, "Incoming video call"));
7777
decline.setText(sharedPref.getString(LocalizedKeys.DECLINE, "Decline"));
7878
answer.setText(sharedPref.getString(LocalizedKeys.ACCEPT, "Accept"));
7979
goOffline.setText(sharedPref.getString(LocalizedKeys.GO_OFFLINE, "Go offline"));
@@ -116,7 +116,7 @@ private View.OnClickListener answer() {
116116
this,
117117
0,
118118
answerIntent,
119-
PendingIntent.FLAG_UPDATE_CURRENT
119+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
120120
);
121121

122122
try {
@@ -144,7 +144,7 @@ private View.OnClickListener decline() {
144144
this,
145145
1,
146146
rejectIntent,
147-
PendingIntent.FLAG_UPDATE_CURRENT
147+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
148148
);
149149

150150
try {
@@ -172,7 +172,7 @@ private View.OnClickListener goOffline() {
172172
this,
173173
1,
174174
rejectIntent,
175-
PendingIntent.FLAG_UPDATE_CURRENT
175+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
176176
);
177177

178178
try {

android/src/main/java/com/ngs/react/RNTwilioVideo/TwilioVideoModule.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,23 @@ public void getActiveCall(Promise promise) {
195195

196196
@ReactMethod
197197
public void getCallInvite(Promise promise) {
198+
Log.d(TAG, "getCallInvite");
198199
Activity activity = getCurrentActivity();
199-
Intent intent = activity.getIntent();
200-
VideoCallInvite activeCallInvite = intent.getParcelableExtra(INCOMING_CALL_INVITE);
201-
202-
if (activeCallInvite != null) {
203-
Log.d(TAG, "Call invite found " + activeCallInvite);
204-
WritableMap params = Arguments.createMap();
205-
for (Map.Entry<String, String> entry : activeCallInvite.getData().entrySet()) {
206-
params.putString(entry.getKey(), entry.getValue());
200+
if (activity != null) {
201+
Intent intent = activity.getIntent();
202+
VideoCallInvite activeCallInvite = intent.getParcelableExtra(INCOMING_CALL_INVITE);
203+
204+
if (activeCallInvite != null) {
205+
Log.d(TAG, "Call invite found " + activeCallInvite);
206+
WritableMap params = Arguments.createMap();
207+
for (Map.Entry<String, String> entry : activeCallInvite.getData().entrySet()) {
208+
params.putString(entry.getKey(), entry.getValue());
209+
}
210+
promise.resolve(params);
211+
return;
207212
}
208-
promise.resolve(params);
209-
return;
213+
} else {
214+
Log.d(TAG, "Warning! getCurrentActivity() is null");
210215
}
211216
promise.resolve(null);
212217
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import android.os.Build;
99
import android.os.Bundle;
1010
import android.os.Handler;
11-
import android.support.v4.content.LocalBroadcastManager;
11+
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
1212
import android.util.Log;
1313
import android.view.View;
1414
import android.view.WindowManager;
@@ -122,7 +122,7 @@ private View.OnClickListener answer() {
122122
this,
123123
0,
124124
answerIntent,
125-
PendingIntent.FLAG_UPDATE_CURRENT
125+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
126126
);
127127

128128
try {
@@ -150,7 +150,7 @@ private View.OnClickListener decline() {
150150
this,
151151
1,
152152
rejectIntent,
153-
PendingIntent.FLAG_UPDATE_CURRENT
153+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
154154
);
155155

156156
try {
@@ -178,7 +178,7 @@ private View.OnClickListener goOffline() {
178178
this,
179179
1,
180180
rejectIntent,
181-
PendingIntent.FLAG_UPDATE_CURRENT
181+
PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT
182182
);
183183

184184
try {

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

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -687,17 +687,21 @@ public void getCallInvite(Promise promise) {
687687
Log.d(TAG, "getCallInvite");
688688

689689
Activity activity = getCurrentActivity();
690-
Intent intent = activity.getIntent();
691-
activeCallInvite = intent.getParcelableExtra(VoiceConstants.INCOMING_CALL_INVITE);
690+
if (activity != null) {
691+
Intent intent = activity.getIntent();
692+
activeCallInvite = intent.getParcelableExtra(VoiceConstants.INCOMING_CALL_INVITE);
692693

693-
if (activeCallInvite != null) {
694-
if (BuildConfig.DEBUG) {
695-
Log.d(TAG, "Call invite found "+ activeCallInvite);
694+
if (activeCallInvite != null) {
695+
if (BuildConfig.DEBUG) {
696+
Log.d(TAG, "Call invite found "+ activeCallInvite);
697+
}
698+
intent.removeExtra(VoiceConstants.INCOMING_CALL_INVITE);
699+
WritableMap params = buildRNNotification(activeCallInvite);
700+
promise.resolve(params);
701+
return;
696702
}
697-
intent.removeExtra(VoiceConstants.INCOMING_CALL_INVITE);
698-
WritableMap params = buildRNNotification(activeCallInvite);
699-
promise.resolve(params);
700-
return;
703+
} else {
704+
Log.d(TAG, "Warning! getCurrentActivity() is null");
701705
}
702706
promise.resolve(null);
703707
}

0 commit comments

Comments
 (0)