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

Commit 64c41f70 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

Revert "Start SubscriberService as background service"

This reverts commit 2864e9eb.
parent 7e57557c
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ 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
@@ -88,6 +89,21 @@ 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
                    context.startService(it)
                    ContextCompat.startForegroundService(context, it)
                }
            }
            return Result.success()