Skip to content

Commit b760af9

Browse files
committed
Stop foreground service when connection is closed
1 parent 1d64946 commit b760af9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ public static void deinitConnection(String connectionId) {
133133
Log.d(TAG, "deinitConnection:" + connectionId);
134134
VoiceConnectionService.hasOutgoingCall = false;
135135

136+
currentConnectionService.stopForegroundService();
137+
136138
if (currentConnections.containsKey(connectionId)) {
137139
currentConnections.remove(connectionId);
138140
}
@@ -260,6 +262,15 @@ private void startForegroundService() {
260262
startForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE, notification);
261263
}
262264

265+
private void stopForegroundService() {
266+
Log.d(TAG, "stopForegroundService");
267+
if (_settings == null || !_settings.hasKey("foregroundService")) {
268+
Log.d(TAG, "Discarding stop foreground service, no service configured");
269+
return;
270+
}
271+
stopForeground(FOREGROUND_SERVICE_TYPE_MICROPHONE);
272+
}
273+
263274
private void wakeUpApplication(String uuid, String number, String displayName) {
264275
Log.d(TAG, "wakeUpApplication, uuid:" + uuid + ", number :" + number + ", displayName:" + displayName);
265276

0 commit comments

Comments
 (0)