mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Add fallback to synchronous fetch when onCreate() fails
Co-authored-by: adbenitez <24558636+adbenitez@users.noreply.github.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user