Skip to content

Commit 2b69925

Browse files
author
Kyle Kurz
authored
Merge pull request #34 from sangoma/endAllCallsAndroid
End all calls android
2 parents e2cffa8 + 9d73892 commit 2b69925

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ RNCallKeep.endCall(uuid);
207207
- `uuid`: string
208208
- The `uuid` used for `startCall` or `displayIncomingCall`
209209

210+
### endAllCalls
211+
212+
End all ongoing connections.
213+
214+
```js
215+
RNCallKeep.endAllCalls();
216+
```
217+
210218
### rejectCall
211219

212220
When you reject an incoming call.

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
import java.util.Arrays;
6262
import java.util.HashMap;
6363
import java.util.List;
64+
import java.util.Map;
6465
import java.util.ResourceBundle;
6566

6667
import static android.support.v4.app.ActivityCompat.requestPermissions;
@@ -192,6 +193,22 @@ public void endCall(String uuid) {
192193
Log.d(TAG, "endCall executed");
193194
}
194195

196+
@ReactMethod
197+
public void endAllCalls() {
198+
Log.d(TAG, "endAllCalls called");
199+
if (!isConnectionServiceAvailable() || !hasPhoneAccount()) {
200+
return;
201+
}
202+
203+
Map<String, VoiceConnection> currentConnections = VoiceConnectionService.currentConnections;
204+
for (Map.Entry<String, VoiceConnection> connectionEntry : currentConnections.entrySet()) {
205+
Connection connectionToEnd = connectionEntry.getValue();
206+
connectionToEnd.onDisconnect();
207+
}
208+
209+
Log.d(TAG, "endAllCalls executed");
210+
}
211+
195212
@ReactMethod
196213
public void checkPhoneAccountPermission(ReadableArray optionalPermissions, Promise promise) {
197214
Activity currentActivity = this.getCurrentActivity();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
public class VoiceConnectionService extends ConnectionService {
6464
private static Boolean isAvailable = false;
6565
private static String TAG = "RNCK:VoiceConnectionService";
66-
private static Map<String, VoiceConnection> currentConnections = new HashMap<>();
66+
public static Map<String, VoiceConnection> currentConnections = new HashMap<>();
6767

6868
public static Connection getConnection(String connectionId) {
6969
if (currentConnections.containsKey(connectionId)) {

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class RNCallKeep {
104104
};
105105

106106
endAllCalls = () => {
107-
isIOS ? RNCallKeepModule.endAllCalls() : RNCallKeepModule.endCall();
107+
RNCallKeepModule.endAllCalls();
108108
};
109109

110110
supportConnectionService = () => supportConnectionService;

0 commit comments

Comments
 (0)