Compare commits

...

5 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] e68bb791f7 Add fallback to synchronous fetch when onCreate() fails
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
2026-01-07 15:58:54 +00:00
copilot-swe-agent[bot] 2297a72e29 Clear service variable when onCreate() fails to start foreground service
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
2026-01-07 15:53:23 +00:00
copilot-swe-agent[bot] 5aabb40c48 Improve logging for foreground service exception
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
2026-01-07 14:50:08 +00:00
copilot-swe-agent[bot] 53aa3c3ccb Fix ForegroundServiceStartNotAllowedException in FetchForegroundService.onCreate
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
2026-01-07 14:48:30 +00:00
copilot-swe-agent[bot] 47cbdc6a44 Initial plan 2026-01-07 14:44:26 +00:00
@@ -88,7 +88,27 @@ public final class FetchForegroundService extends Service {
.setSmallIcon(R.drawable.notification_permanent)
.build();
startForeground(NotificationCenter.ID_FETCH, notification);
try {
startForeground(NotificationCenter.ID_FETCH, notification);
} catch (Exception 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;
}
Util.runOnAnyBackgroundThread(() -> {
Log.i(TAG, "Starting fetch");