Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c34737c authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Fix that foreground service notification was always shown (fix for bitfireAT/davx5#32)

parent 989cb1fd
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -52,7 +52,8 @@ class ForegroundService : Service() {
         * Starts the foreground service when enabled in the app settings and applicable.
         */
        fun startIfActive(context: Context) {
            if (foregroundServiceActivated(context) && batteryOptimizationWhitelisted(context)) {
            if (foregroundServiceActivated(context)) {
                if (batteryOptimizationWhitelisted(context)) {
                    val serviceIntent = Intent(ACTION_FOREGROUND, null, context, ForegroundService::class.java)
                    if (Build.VERSION.SDK_INT >= 26)
                        context.startForegroundService(serviceIntent)
@@ -61,6 +62,7 @@ class ForegroundService : Service() {
                } else
                    notifyBatteryOptimization(context)
            }
        }

        private fun notifyBatteryOptimization(context: Context) {
            val settingsIntent = Intent(context, AppSettingsActivity::class.java).apply {