From e68bb791f75f95a285bdd9b3bb01469304416ac9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 7 Jan 2026 15:58:54 +0000 Subject: [PATCH] Add fallback to synchronous fetch when onCreate() fails Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com> --- .../securesms/service/FetchForegroundService.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java b/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java index 4777e85fc..e6fc34b5f 100644 --- a/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java +++ b/src/main/java/org/thoughtcrime/securesms/service/FetchForegroundService.java @@ -91,11 +91,22 @@ public final class FetchForegroundService extends Service { try { startForeground(NotificationCenter.ID_FETCH, notification); } catch (Exception e) { - Log.w(TAG, "Failed to start foreground service", e); + Log.w(TAG, "Failed to start foreground service, falling back to synchronous fetch", e); synchronized (SERVICE_LOCK) { service = null; } stopSelf(); + // Fallback to synchronous fetching when foreground service fails + fetchingSynchronously = true; + if (ApplicationContext.getDcAccounts().backgroundFetch(10)) { + synchronized (STOP_NOTIFIER) { + while (fetchingSynchronously) { + try { + STOP_NOTIFIER.wait(); + } catch (InterruptedException ex) {} + } + } + } return; }