[mob][photos] Fix BG task not getting killed (#1608)

## Description

`BackgroundFetch.finish(taskId)` doesn't seems to be killing the BG
task.
Explicitly killing the Isolate does the work.
This commit is contained in:
Vishnu Mohandas 2024-05-03 19:56:35 +05:30 committed by GitHub
commit 7f6e8228af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:io';
import "dart:isolate";
import "package:adaptive_theme/adaptive_theme.dart";
import 'package:background_fetch/background_fetch.dart';
@ -330,10 +331,15 @@ Future<void> _killBGTask([String? taskId]) async {
DateTime.now().microsecondsSinceEpoch,
);
final prefs = await SharedPreferences.getInstance();
await prefs.remove(kLastBGTaskHeartBeatTime);
if (taskId != null) {
BackgroundFetch.finish(taskId);
}
///Band aid for background process not getting killed. Should migrate to using
///workmanager instead of background_fetch.
Isolate.current.kill();
}
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {