2 * Copyright © 2021 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Cell <https://www.stoutner.com/privacy-cell>.
6 * Privacy Cell is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Cell is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Cell. If not, see <http://www.gnu.org/licenses/>.
20 package com.stoutner.privacycell.workers
22 import android.content.Context
23 import android.content.Intent
25 import androidx.work.Worker
26 import androidx.work.WorkerParameters
27 import com.stoutner.privacycell.services.RealtimeMonitoringService
29 class RestartServiceWorker(appContext: Context, workerParameters: WorkerParameters) : Worker(appContext, workerParameters) {
30 override fun doWork(): Result {
31 // Start the realtime monitoring service as a foreground service, which is required because the worker is running in the background.
32 applicationContext.startForegroundService(Intent(applicationContext, RealtimeMonitoringService::class.java))
35 return Result.success()