Skip to content

Commit e32cbf7

Browse files
authored
Merge pull request #700 from react-native-webrtc/add_call_payload
Allow extra payload in displayIncomingCall and startCall
2 parents d9d7250 + afedc2c commit e32cbf7

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

android/src/main/java/io/wazo/callkeep/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public class Constants {
2323
public static final String EXTRA_CALL_UUID = "EXTRA_CALL_UUID";
2424
public static final String EXTRA_CALLER_NAME = "EXTRA_CALLER_NAME";
2525
public static final String EXTRA_HAS_VIDEO = "EXTRA_HAS_VIDEO";
26+
public static final String EXTRA_PAYLOAD = "EXTRA_PAYLOAD";
2627
// Can't use telecom.EXTRA_DISABLE_ADD_CALL ...
2728
public static final String EXTRA_DISABLE_ADD_CALL = "android.telecom.extra.DISABLE_ADD_CALL";
2829

android/src/main/java/io/wazo/callkeep/RNCallKeepModule.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
import static io.wazo.callkeep.Constants.EXTRA_CALL_UUID;
8484
import static io.wazo.callkeep.Constants.EXTRA_CALL_NUMBER;
8585
import static io.wazo.callkeep.Constants.EXTRA_HAS_VIDEO;
86+
import static io.wazo.callkeep.Constants.EXTRA_PAYLOAD;
8687
import static io.wazo.callkeep.Constants.ACTION_END_CALL;
8788
import static io.wazo.callkeep.Constants.ACTION_ANSWER_CALL;
8889
import static io.wazo.callkeep.Constants.ACTION_MUTE_CALL;
@@ -308,17 +309,22 @@ public void unregisterEvents() {
308309

309310
@ReactMethod
310311
public void displayIncomingCall(String uuid, String number, String callerName) {
311-
this.displayIncomingCall(uuid, number, callerName, false);
312+
this.displayIncomingCall(uuid, number, callerName, false, null);
312313
}
313314

314315
@ReactMethod
315316
public void displayIncomingCall(String uuid, String number, String callerName, boolean hasVideo) {
317+
this.displayIncomingCall(uuid, number, callerName, hasVideo, null);
318+
}
319+
320+
@ReactMethod
321+
public void displayIncomingCall(String uuid, String number, String callerName, boolean hasVideo, @Nullable Bundle payload) {
316322
if (!isConnectionServiceAvailable() || !hasPhoneAccount()) {
317323
Log.w(TAG, "[RNCallKeepModule] displayIncomingCall ignored due to no ConnectionService or no phone account");
318324
return;
319325
}
320326

321-
Log.d(TAG, "[RNCallKeepModule] displayIncomingCall, uuid: " + uuid + ", number: " + number + ", callerName: " + callerName + ", hasVideo: " + hasVideo);
327+
Log.d(TAG, "[RNCallKeepModule] displayIncomingCall, uuid: " + uuid + ", number: " + number + ", callerName: " + callerName + ", hasVideo: " + hasVideo + ", payload: " + payload);
322328

323329
Bundle extras = new Bundle();
324330
Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, number, null);
@@ -327,6 +333,9 @@ public void displayIncomingCall(String uuid, String number, String callerName, b
327333
extras.putString(EXTRA_CALLER_NAME, callerName);
328334
extras.putString(EXTRA_CALL_UUID, uuid);
329335
extras.putString(EXTRA_HAS_VIDEO, String.valueOf(hasVideo));
336+
if (payload != null) {
337+
extras.putBundle(EXTRA_PAYLOAD, payload);
338+
}
330339

331340
telecomManager.addNewIncomingCall(handle, extras);
332341
}
@@ -350,12 +359,17 @@ public void answerIncomingCall(String uuid) {
350359

351360
@ReactMethod
352361
public void startCall(String uuid, String number, String callerName) {
353-
this.startCall(uuid, number, callerName, false);
362+
this.startCall(uuid, number, callerName, false, null);
354363
}
355364

356365
@ReactMethod
357366
public void startCall(String uuid, String number, String callerName, boolean hasVideo) {
358-
Log.d(TAG, "[RNCallKeepModule] startCall called, uuid: " + uuid + ", number: " + number + ", callerName: " + callerName);
367+
this.startCall(uuid, number, callerName, hasVideo, null);
368+
}
369+
370+
@ReactMethod
371+
public void startCall(String uuid, String number, String callerName, boolean hasVideo, @Nullable Bundle payload) {
372+
Log.d(TAG, "[RNCallKeepModule] startCall called, uuid: " + uuid + ", number: " + number + ", callerName: " + callerName + ", payload: " + payload);
359373

360374
if (!isConnectionServiceAvailable() || !hasPhoneAccount() || !hasPermissions() || number == null) {
361375
Log.w(TAG, "[RNCallKeepModule] startCall ignored: " + isConnectionServiceAvailable() + ", " + hasPhoneAccount() + ", " + hasPermissions() + ", " + number);
@@ -370,6 +384,9 @@ public void startCall(String uuid, String number, String callerName, boolean has
370384
callExtras.putString(EXTRA_CALL_UUID, uuid);
371385
callExtras.putString(EXTRA_CALL_NUMBER, number);
372386
callExtras.putString(EXTRA_HAS_VIDEO, String.valueOf(hasVideo));
387+
if (payload != null) {
388+
callExtras.putBundle(EXTRA_PAYLOAD, payload);
389+
}
373390

374391
extras.putParcelable(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, handle);
375392
extras.putParcelable(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, callExtras);

0 commit comments

Comments
 (0)