From bc5d27ed9018f01b123359e31c00c701618d0acb Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Wed, 17 Jan 2024 15:48:36 -0500 Subject: [PATCH] Prevent calling service crash loop when system restarts us in background. --- .../securesms/service/webrtc/WebRtcCallService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcCallService.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcCallService.java index 451bc50fc1..4a7e866d99 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcCallService.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/WebRtcCallService.java @@ -178,7 +178,7 @@ public final class WebRtcCallService extends Service implements SignalAudioManag @Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent == null || intent.getAction() == null) { - setCallNotification(true); + Log.w(TAG, "Service running with null intent/action likely from system restart, stopping"); stop(); return START_NOT_STICKY; } @@ -234,9 +234,11 @@ public final class WebRtcCallService extends Service implements SignalAudioManag if (!stopping && lastNotificationId != INVALID_NOTIFICATION_ID) { startForegroundCompat(lastNotificationId, lastNotification); } else { - Log.w(TAG, "Service running without having called start first, show temp notification and terminate service."); - startForegroundCompat(CallNotificationBuilder.getStartingStoppingNotificationId(), CallNotificationBuilder.getStoppingNotification(this)); - stop(); + if (!stopping) { + Log.i(TAG, "Service was started without calling UPDATE first, using temporary notification."); + } + startForegroundCompat(CallNotificationBuilder.getStartingStoppingNotificationId(), stopping ? CallNotificationBuilder.getStoppingNotification(this) + : CallNotificationBuilder.getStartingNotification(this)); } }