shouldConfigureForegroundNotification function

  1. @visibleForTesting
bool shouldConfigureForegroundNotification(
  1. bool? foreground
)

Whether _ensureConfigured should register a running TaskNotification for the given foreground setting (#356). Extracted as a pure function so the decision is unit-testable without a FileDownloader seam: on Android, background_downloader only calls WorkManager.setForeground() — the thing that actually activates the foreground service — when a running notification is configured. Setting Config.runInForeground alone is a no-op without it.

Scoped to the EXPLICIT foreground: true flag only (#357 review). The notification, once configured, is global: background_downloader's Notifications.kt shows it for every task in the running state, including ones that are NOT running in foreground (displayNotification's else branch calls notify() unconditionally when runInForeground is false for that task). Returning true for the auto-detect branch (foreground == null) would therefore show a "Downloading model" notification on EVERY download — including small ones well under the 500MB foreground threshold, where none showed before. Trade-off: an auto-detected LARGE file (>500MB, which DOES run in foreground) won't get a notification unless the caller passes foreground: true explicitly. That's accepted in order to avoid the spurious notification on the much more common small-download path.

Implementation

@visibleForTesting
bool shouldConfigureForegroundNotification(bool? foreground) =>
    foreground == true;