Skip to content

Commit

Permalink
as we called startForeground(), longer timeouts should be fine
Browse files Browse the repository at this point in the history
  • Loading branch information
r10s committed Sep 23, 2024
1 parent 9fc4bfb commit 9ffa76c
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,11 @@ public void onCreate() {

startForeground(NotificationCenter.ID_FETCH, notification);

// Start explicit fetch only after we marked ourselves as requiring foreground;
// this may help we on getting network and time adequately
// Fetch is started in background to not block the UI.
// We then run not longer than the max. of 20 seconds,
// see https://firebase.google.com/docs/cloud-messaging/android/receive .
Util.runOnAnyBackgroundThread(() -> {
Log.i(TAG, "Starting fetch");
if (!ApplicationContext.dcAccounts.backgroundFetch(19)) {
if (!ApplicationContext.dcAccounts.backgroundFetch(300)) { // as startForeground() was called, there is time
FetchForegroundService.stop(this);
}
} // else we stop FetchForegroundService on DC_EVENT_ACCOUNTS_BACKGROUND_FETCH_DONE
});
}

Expand Down

0 comments on commit 9ffa76c

Please sign in to comment.