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

Commit 2864e9eb authored by Jonathan Klee's avatar Jonathan Klee Committed by Guillaume Jacquart
Browse files

Start SubscriberService as background service

(cherry picked from commit 5aceba64)
parent ad05aa27
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ import android.app.*
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.pm.ServiceInfo
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
@@ -89,21 +88,6 @@ class SubscriberService : Service() {

        Log.init(this) // Init logs in all entry points
        Log.d(TAG, "Subscriber service has been created")

        val title = getString(R.string.channel_subscriber_notification_title)
        val text = if (BuildConfig.FIREBASE_AVAILABLE) {
            getString(R.string.channel_subscriber_notification_instant_text)
        } else {
            getString(R.string.channel_subscriber_notification_noinstant_text)
        }
        notificationManager = createNotificationChannel()
        serviceNotification = createNotification(title, text)

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
            startForeground(NOTIFICATION_SERVICE_ID, serviceNotification!!, ServiceInfo.FOREGROUND_SERVICE_TYPE_SPECIAL_USE)
        } else {
            startForeground(NOTIFICATION_SERVICE_ID, serviceNotification)
        }
    }

    override fun onDestroy() {
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ class SubscriberServiceManager(private val context: Context) {
                Log.d(TAG, "ServiceStartWorker: Starting foreground service with action $action (work ID: ${id})")
                Intent(context, SubscriberService::class.java).also {
                    it.action = action.name
                    ContextCompat.startForegroundService(context, it)
                    context.startService(it)
                }
            }
            return Result.success()