mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-11 09:30:16 +02:00
Fixed bg task issue + notification icon
This commit is contained in:
BIN
android/app/src/main/res/drawable/ic_notification.png
Normal file → Executable file
BIN
android/app/src/main/res/drawable/ic_notification.png
Normal file → Executable file
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 4.1 KiB |
@@ -8,9 +8,19 @@ import 'package:provider/provider.dart';
|
||||
import 'package:workmanager/workmanager.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void backgroundUpdateCheck() {
|
||||
Workmanager().executeTask((task, inputData) async {
|
||||
var appsProvider = AppsProvider(bg: true);
|
||||
await appsProvider.notify(
|
||||
4,
|
||||
'Checking for Updates',
|
||||
'',
|
||||
'BG_UPDATE_CHECK',
|
||||
'Checking for Updates',
|
||||
'Transient notification that appears when checking for updates',
|
||||
important: false);
|
||||
try {
|
||||
await appsProvider.loadApps();
|
||||
List<App> updates = await appsProvider.getUpdates();
|
||||
if (updates.isNotEmpty) {
|
||||
@@ -27,6 +37,20 @@ void backgroundUpdateCheck() {
|
||||
'Notifies the user that updates are available for one or more Apps tracked by Obtainium');
|
||||
}
|
||||
return Future.value(true);
|
||||
} catch (e) {
|
||||
await appsProvider.downloaderNotifications.cancel(5);
|
||||
await appsProvider.notify(
|
||||
5,
|
||||
'Error Checking for Updates',
|
||||
e.toString(),
|
||||
'BG_UPDATE_CHECK_ERROR',
|
||||
'Error Checking for Updates',
|
||||
'A notification that shows when background update checking fails',
|
||||
important: false);
|
||||
return Future.value(false);
|
||||
} finally {
|
||||
await appsProvider.downloaderNotifications.cancel(4);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user