From 269a71d336a7094d1930f76b2aab08c8aecafe2e Mon Sep 17 00:00:00 2001 From: Alberto Ponces Date: Mon, 19 Sep 2022 01:46:12 +0100 Subject: [PATCH] fix: Improve foreground service init and disable --- lib/ui/views/installer/installer_viewmodel.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/ui/views/installer/installer_viewmodel.dart b/lib/ui/views/installer/installer_viewmodel.dart index 165a250a..cfe3394f 100644 --- a/lib/ui/views/installer/installer_viewmodel.dart +++ b/lib/ui/views/installer/installer_viewmodel.dart @@ -33,7 +33,7 @@ class InstallerViewModel extends BaseViewModel { Future initialize(BuildContext context) async { if (await Permission.ignoreBatteryOptimizations.isGranted) { try { - await FlutterBackground.initialize( + FlutterBackground.initialize( androidConfig: FlutterBackgroundAndroidConfig( notificationTitle: FlutterI18n.translate( context, @@ -49,8 +49,7 @@ class InstallerViewModel extends BaseViewModel { defType: 'drawable', ), ), - ); - await FlutterBackground.enableBackgroundExecution(); + ).then((value) => FlutterBackground.enableBackgroundExecution()); } on Exception { // ignore } @@ -123,9 +122,9 @@ class InstallerViewModel extends BaseViewModel { hasErrors = true; update(-1.0, 'Aborting...', 'No app or patches selected! Aborting'); } - if (await Permission.ignoreBatteryOptimizations.isGranted) { + if (FlutterBackground.isBackgroundExecutionEnabled) { try { - await FlutterBackground.disableBackgroundExecution(); + FlutterBackground.disableBackgroundExecution(); } on Exception { // ignore }