|
@@ -106,9 +106,11 @@ Future<void> _runBackgroundTask(String taskId, {String mode = 'normal'}) async {
|
|
await _sync('bgTaskActiveProcess');
|
|
await _sync('bgTaskActiveProcess');
|
|
BackgroundFetch.finish(taskId);
|
|
BackgroundFetch.finish(taskId);
|
|
} else {
|
|
} else {
|
|
|
|
+ // ignore: unawaited_futures
|
|
_runWithLogs(
|
|
_runWithLogs(
|
|
() async {
|
|
() async {
|
|
_logger.info("Starting background task in $mode mode");
|
|
_logger.info("Starting background task in $mode mode");
|
|
|
|
+ // ignore: unawaited_futures
|
|
_runInBackground(taskId);
|
|
_runInBackground(taskId);
|
|
},
|
|
},
|
|
prefix: "[bg]",
|
|
prefix: "[bg]",
|
|
@@ -152,7 +154,7 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|
_logger.info("Initializing... inBG =$isBackground via: $via");
|
|
_logger.info("Initializing... inBG =$isBackground via: $via");
|
|
final SharedPreferences preferences = await SharedPreferences.getInstance();
|
|
final SharedPreferences preferences = await SharedPreferences.getInstance();
|
|
await _logFGHeartBeatInfo();
|
|
await _logFGHeartBeatInfo();
|
|
- _scheduleHeartBeat(preferences, isBackground);
|
|
|
|
|
|
+ unawaited(_scheduleHeartBeat(preferences, isBackground));
|
|
AppLifecycleService.instance.init(preferences);
|
|
AppLifecycleService.instance.init(preferences);
|
|
if (isBackground) {
|
|
if (isBackground) {
|
|
AppLifecycleService.instance.onAppInBackground('init via: $via');
|
|
AppLifecycleService.instance.onAppInBackground('init via: $via');
|
|
@@ -185,15 +187,15 @@ Future<void> _init(bool isBackground, {String via = ''}) async {
|
|
SearchService.instance.init();
|
|
SearchService.instance.init();
|
|
StorageBonusService.instance.init(preferences);
|
|
StorageBonusService.instance.init(preferences);
|
|
if (Platform.isIOS) {
|
|
if (Platform.isIOS) {
|
|
|
|
+ // ignore: unawaited_futures
|
|
PushService.instance.init().then((_) {
|
|
PushService.instance.init().then((_) {
|
|
FirebaseMessaging.onBackgroundMessage(
|
|
FirebaseMessaging.onBackgroundMessage(
|
|
_firebaseMessagingBackgroundHandler,
|
|
_firebaseMessagingBackgroundHandler,
|
|
);
|
|
);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- FeatureFlagService.instance.init();
|
|
|
|
- SemanticSearchService.instance.init(preferences);
|
|
|
|
-
|
|
|
|
|
|
+ unawaited(FeatureFlagService.instance.init());
|
|
|
|
+ unawaited(SemanticSearchService.instance.init(preferences));
|
|
// Can not including existing tf/ml binaries as they are not being built
|
|
// Can not including existing tf/ml binaries as they are not being built
|
|
// from source.
|
|
// from source.
|
|
// See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819
|
|
// See https://gitlab.com/fdroid/fdroiddata/-/merge_requests/12671#note_1294346819
|
|
@@ -242,6 +244,7 @@ Future<void> _scheduleHeartBeat(
|
|
DateTime.now().microsecondsSinceEpoch,
|
|
DateTime.now().microsecondsSinceEpoch,
|
|
);
|
|
);
|
|
Future.delayed(kHeartBeatFrequency, () async {
|
|
Future.delayed(kHeartBeatFrequency, () async {
|
|
|
|
+ // ignore: unawaited_futures
|
|
_scheduleHeartBeat(prefs, isBackground);
|
|
_scheduleHeartBeat(prefs, isBackground);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -281,7 +284,7 @@ Future<void> _killBGTask([String? taskId]) async {
|
|
DateTime.now().microsecondsSinceEpoch,
|
|
DateTime.now().microsecondsSinceEpoch,
|
|
);
|
|
);
|
|
final prefs = await SharedPreferences.getInstance();
|
|
final prefs = await SharedPreferences.getInstance();
|
|
- prefs.remove(kLastBGTaskHeartBeatTime);
|
|
|
|
|
|
+ await prefs.remove(kLastBGTaskHeartBeatTime);
|
|
if (taskId != null) {
|
|
if (taskId != null) {
|
|
BackgroundFetch.finish(taskId);
|
|
BackgroundFetch.finish(taskId);
|
|
}
|
|
}
|
|
@@ -299,6 +302,7 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// App is dead
|
|
// App is dead
|
|
|
|
+ // ignore: unawaited_futures
|
|
_runWithLogs(
|
|
_runWithLogs(
|
|
() async {
|
|
() async {
|
|
_logger.info("Background push received");
|
|
_logger.info("Background push received");
|