mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e68bb791f7 | |||
| 2297a72e29 | |||
| 5aabb40c48 | |||
| 53aa3c3ccb | |||
| 47cbdc6a44 |
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user