Skip to content

Commit a229a9d

Browse files
authored
fix: fix cancellation of maybeStartForegroundService (#1524)
1 parent b4e4b52 commit a229a9d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/ClientState.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ import io.getstream.video.android.core.socket.coordinator.state.VideoSocketState
3030
import io.getstream.video.android.core.utils.safeCallWithDefault
3131
import io.getstream.video.android.model.StreamCallId
3232
import io.getstream.video.android.model.User
33+
import kotlinx.coroutines.delay
3334
import kotlinx.coroutines.flow.MutableStateFlow
3435
import kotlinx.coroutines.flow.StateFlow
36+
import kotlinx.coroutines.launch
3537

3638
// These are UI states, need to move out.
3739
@Stable
@@ -150,7 +152,13 @@ class ClientState(private val client: StreamVideo) {
150152
fun setActiveCall(call: Call) {
151153
this._activeCall.value = call
152154
removeRingingCall(call)
153-
maybeStartForegroundService(call, CallService.TRIGGER_ONGOING_CALL)
155+
call.scope.launch {
156+
/**
157+
* Temporary fix: `maybeStartForegroundService` is called just before this code, which can stop the service
158+
*/
159+
delay(500L)
160+
maybeStartForegroundService(call, CallService.TRIGGER_ONGOING_CALL)
161+
}
154162
}
155163

156164
/**

stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/notifications/internal/service/CallService.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ internal open class CallService : Service() {
343343
// STOP SERVICE LOGIC STARTS
344344
if (shouldStopServiceFromIntent(intent)) {
345345
stopService()
346+
return START_NOT_STICKY
346347
}
347348
// STOP SERVICE LOGIC ENDS
348349

0 commit comments

Comments
 (0)