Log Worker results

This commit is contained in:
Milos Kozak 2022-12-04 17:49:03 +01:00
parent 8dc346e4c8
commit bd35007f44
41 changed files with 145 additions and 326 deletions

View file

@ -26,5 +26,6 @@ enum class LTag(val tag: String, val defaultValue : Boolean = true, val requires
TIDEPOOL("TIDEPOOL"),
UI("UI", defaultValue = false),
WEAR("WEAR"),
WIDGET("WIDGET")
WIDGET("WIDGET"),
WORKER("WORKER")
}

View file

@ -7,16 +7,15 @@ import androidx.work.OneTimeWorkRequest
import androidx.work.WorkInfo
import androidx.work.WorkManager
import androidx.work.WorkQuery
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.google.common.util.concurrent.ListenableFuture
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.BuildConfig
import info.nightscout.androidaps.R
import info.nightscout.configuration.maintenance.MaintenancePlugin
import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.LocalAlertUtils
@ -31,7 +30,6 @@ import info.nightscout.interfaces.queue.CommandQueue
import info.nightscout.interfaces.receivers.ReceiverStatusStore
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventProfileSwitchChanged
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
@ -45,9 +43,8 @@ import kotlin.math.abs
class KeepAliveWorker(
private val context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var localAlertUtils: LocalAlertUtils
@Inject lateinit var repository: AppRepository
@Inject lateinit var config: Config
@ -65,10 +62,6 @@ class KeepAliveWorker(
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var sp: SP
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
companion object {
private val STATUS_UPDATE_FREQUENCY = T.mins(15).msecs()
@ -83,7 +76,7 @@ class KeepAliveWorker(
private const val KA_10 = "KeepAlive_10"
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
aapsLogger.debug(LTag.CORE, "KeepAlive received from: " + inputData.getString("schedule"))
// 15 min interval is WorkManager minimum so schedule another instances to have 5 min interval

View file

@ -0,0 +1,25 @@
package info.nightscout.core.utils.worker
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import javax.inject.Inject
abstract class LoggingWorker(context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
@Inject lateinit var aapsLogger: AAPSLogger
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result =
doWorkAndLog().also {
aapsLogger.debug(LTag.WORKER, "Worker result ${it::class.java.simpleName.uppercase()} for ${this::class.java}")
}
abstract fun doWorkAndLog(): Result
}

View file

@ -16,7 +16,6 @@ import androidx.fragment.app.FragmentActivity
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -28,6 +27,7 @@ import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.dialogs.TwoMessagesAlertDialog
import info.nightscout.core.ui.dialogs.WarningDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.UserEntry
import info.nightscout.database.entities.UserEntry.Action
import info.nightscout.database.entities.UserEntry.Sources
@ -381,10 +381,9 @@ class ImportExportPrefsImpl @Inject constructor(
class CsvExportWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var prefFileList: PrefFileListProvider
@Inject lateinit var context: Context
@ -392,11 +391,7 @@ class ImportExportPrefsImpl @Inject constructor(
@Inject lateinit var storage: Storage
@Inject lateinit var persistenceLayer: PersistenceLayer
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val entries = persistenceLayer.getUserEntryFilteredDataFromTime(MidnightTime.calc() - T.days(90).msecs()).blockingGet()
prefFileList.ensureExportDirExists()
val newFile = prefFileList.newExportCsvFile()

View file

@ -1,12 +1,12 @@
package info.nightscout.plugins.general.food
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.foodFromJson
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.Food
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.SyncNsFoodTransaction
@ -43,19 +43,14 @@ class FoodPlugin @Inject constructor(
class FoodWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var sp: SP
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val foods = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
?: return Result.failure(workDataOf("Error" to "missing input data"))
aapsLogger.debug(LTag.DATABASE, "Received Food Data: $foods")

View file

@ -7,7 +7,6 @@ import android.text.TextUtils
import androidx.preference.EditTextPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -19,6 +18,7 @@ import info.nightscout.core.iob.iobCobCalculator.GlucoseStatusProvider
import info.nightscout.core.iob.round
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.validators.ValidatingEditTextPreference
import info.nightscout.database.entities.OfflineEvent
import info.nightscout.database.entities.TemporaryTarget
@ -196,16 +196,12 @@ class SmsCommunicatorPlugin @Inject constructor(
class SmsCommunicatorWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var smsCommunicatorPlugin: SmsCommunicatorPlugin
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val bundle = dataWorkerStorage.pickupBundle(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
?: return Result.failure(workDataOf("Error" to "missing input data"))
val format = bundle.getString("format")

View file

@ -2,7 +2,6 @@ package info.nightscout.plugins.profile
import android.content.Context
import androidx.fragment.app.FragmentActivity
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -13,6 +12,7 @@ import info.nightscout.core.profile.ProfileSealed
import info.nightscout.core.ui.dialogs.OKDialog
import info.nightscout.core.ui.toast.ToastUtils
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
import info.nightscout.interfaces.GlucoseUnit
@ -434,10 +434,9 @@ class ProfilePlugin @Inject constructor(
class NSProfileWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var rxBus: RxBus
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@ -447,11 +446,7 @@ class ProfilePlugin @Inject constructor(
@Inject lateinit var xDripBroadcast: XDripBroadcast
@Inject lateinit var profileInstantiator: ProfileInstantiator
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val profileJson = dataWorkerStorage.pickupJSONObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
?: return Result.failure(workDataOf("Error" to "missing input data"))
xDripBroadcast.sendProfile(profileJson)
@ -471,5 +466,4 @@ class ProfilePlugin @Inject constructor(
return Result.success(workDataOf("Result" to "Sync not enabled"))
}
}
}

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -61,18 +61,13 @@ class AidexPlugin @Inject constructor(
class AidexWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var aidexPlugin: AidexPlugin
@Inject lateinit var repository: AppRepository
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!aidexPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -4,12 +4,12 @@ import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import androidx.core.content.ContextCompat
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.fromConstant
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.entities.UserEntry.Action
@ -85,9 +85,8 @@ class DexcomPlugin @Inject constructor(
class DexcomWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var dexcomPlugin: DexcomPlugin
@Inject lateinit var sp: SP
@ -97,11 +96,7 @@ class DexcomPlugin @Inject constructor(
@Inject lateinit var repository: AppRepository
@Inject lateinit var uel: UserEntryLogger
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!dexcomPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
@ -54,21 +54,16 @@ class EversensePlugin @Inject constructor(
class EversenseWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var eversensePlugin: EversensePlugin
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var repository: AppRepository
@Inject lateinit var xDripBroadcast: XDripBroadcast
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!eversensePlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.androidaps.annotations.OpenForTesting
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -45,19 +45,14 @@ class GlimpPlugin @Inject constructor(
class GlimpWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var glimpPlugin: GlimpPlugin
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var xDripBroadcast: XDripBroadcast
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!glimpPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -46,21 +46,16 @@ class MM640gPlugin @Inject constructor(
class MM640gWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var mM640gPlugin: MM640gPlugin
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var repository: AppRepository
@Inject lateinit var xDripBroadcast: XDripBroadcast
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!mM640gPlugin.isEnabled()) return Result.success()

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.transactions.TransactionGlucoseValue
@ -87,11 +87,11 @@ class NSClientSourcePlugin @Inject constructor(
class NSClientSourceWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) :
LoggingWorker(context, params) {
@Inject lateinit var nsClientSourcePlugin: NSClientSourcePlugin
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP
@Inject lateinit var rxBus: RxBus
@Inject lateinit var dateUtil: DateUtil
@ -101,10 +101,6 @@ class NSClientSourcePlugin @Inject constructor(
@Inject lateinit var activePlugin: ActivePlugin
@Inject lateinit var storeDataForDb: StoreDataForDb
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
private fun toGv(jsonObject: JSONObject): TransactionGlucoseValue? {
val sgv = NSSgv(jsonObject)
return TransactionGlucoseValue(
@ -132,7 +128,7 @@ class NSClientSourcePlugin @Inject constructor(
}
@Suppress("SpellCheckingInspection")
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
val sgvs = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -47,19 +47,14 @@ class PoctechPlugin @Inject constructor(
class PoctechWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var poctechPlugin: PoctechPlugin
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var xDripBroadcast: XDripBroadcast
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!poctechPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -1,10 +1,10 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -44,21 +44,16 @@ class TomatoPlugin @Inject constructor(
class TomatoWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var tomatoPlugin: TomatoPlugin
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP
@Inject lateinit var repository: AppRepository
@Inject lateinit var xDripBroadcast: XDripBroadcast
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
@Suppress("SpellCheckingInspection")
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!tomatoPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -1,11 +1,11 @@
package info.nightscout.plugins.source
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.GlucoseValue
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.CgmSourceTransaction
@ -62,18 +62,13 @@ class XdripPlugin @Inject constructor(
class XdripWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var xdripPlugin: XdripPlugin
@Inject lateinit var repository: AppRepository
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
if (!xdripPlugin.isEnabled()) return Result.success(workDataOf("Result" to "Plugin not enabled"))

View file

@ -2,9 +2,8 @@ package info.nightscout.plugins.sync.nsShared
import android.content.Context
import android.os.SystemClock
import androidx.work.Worker
import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.BolusCalculatorResult
import info.nightscout.database.entities.Carbs
@ -102,18 +101,14 @@ class StoreDataForDbImpl @Inject constructor(
class StoreBgWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
storeDataForDb.storeGlucoseValuesToDb()
return Result.success()
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}
fun <T> HashMap<T, Long>.inc(key: T) =

View file

@ -2,11 +2,10 @@ package info.nightscout.plugins.sync.nsclient.workers
import android.content.Context
import android.os.SystemClock
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.DeviceStatus
import info.nightscout.database.impl.AppRepository
import info.nightscout.database.impl.transactions.UpdateNsIdBolusCalculatorResultTransaction
@ -41,7 +40,6 @@ import info.nightscout.plugins.sync.nsclient.acks.NSAddAck
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import javax.inject.Inject
@ -49,17 +47,16 @@ import javax.inject.Inject
class NSClientAddAckWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus
@Inject lateinit var dataSyncSelector: DataSyncSelector
@Inject lateinit var aapsSchedulers: AapsSchedulers
@Inject lateinit var sp: SP
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
val ack = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as NSAddAck?
@ -323,8 +320,4 @@ class NSClientAddAckWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,12 +1,11 @@
package info.nightscout.plugins.sync.nsclient.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.extensions.bolusCalculatorResultFromJson
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.entities.TherapyEvent
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
@ -28,7 +27,6 @@ import info.nightscout.plugins.sync.nsclient.extensions.temporaryBasalFromJson
import info.nightscout.plugins.sync.nsclient.extensions.temporaryTargetFromJson
import info.nightscout.plugins.sync.nsclient.extensions.therapyEventFromJson
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
@ -37,10 +35,9 @@ import javax.inject.Inject
class NSClientAddUpdateWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var config: Config
@Inject lateinit var sp: SP
@Inject lateinit var dateUtil: DateUtil
@ -51,7 +48,7 @@ class NSClientAddUpdateWorker(
@Inject lateinit var xDripBroadcast: XDripBroadcast
@Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val treatments = dataWorkerStorage.pickupJSONArray(inputData.getLong(DataWorkerStorage.STORE_KEY, -1))
?: return Result.failure(workDataOf("Error" to "missing input data"))
@ -171,8 +168,4 @@ class NSClientAddUpdateWorker(
xDripBroadcast.sendTreatments(treatments)
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,11 +1,10 @@
package info.nightscout.plugins.sync.nsclient.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.Config
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.sync.nsclient.data.NSMbg
@ -16,14 +15,14 @@ import javax.inject.Inject
class NSClientMbgWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var sp: SP
@Inject lateinit var config: Config
@Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val ret = Result.success()
val acceptNSData = sp.getBoolean(info.nightscout.core.utils.R.string.key_ns_receive_therapy_events, false) || config.NSCLIENT
@ -39,8 +38,4 @@ class NSClientMbgWorker(
// storeDataForDb.storeTreatmentsToDb() don't do this. It will be stored along with other treatments
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,11 +1,10 @@
package info.nightscout.plugins.sync.nsclient.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.sync.DataSyncSelector
import info.nightscout.interfaces.sync.DataSyncSelector.PairBolus
@ -24,22 +23,20 @@ import info.nightscout.plugins.sync.nsclient.acks.NSUpdateAck
import info.nightscout.rx.AapsSchedulers
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger
import javax.inject.Inject
class NSClientUpdateRemoveAckWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus
@Inject lateinit var dataSyncSelector: DataSyncSelector
@Inject lateinit var aapsSchedulers: AapsSchedulers
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
val ack = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as NSUpdateAck?
@ -157,8 +154,4 @@ class NSClientUpdateRemoveAckWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -4,17 +4,15 @@ import android.content.Context
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.workflow.WorkerClasses
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.sharedPreferences.SP
import info.nightscout.shared.utils.DateUtil
import kotlinx.coroutines.runBlocking
@ -22,9 +20,8 @@ import javax.inject.Inject
class LoadBgWorker(
context: Context, params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var rxBus: RxBus
@Inject lateinit var sp: SP
@ -38,7 +35,7 @@ class LoadBgWorker(
val JOB_NAME: String = this::class.java.simpleName
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
runBlocking {
@ -91,8 +88,4 @@ class LoadBgWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,16 +1,14 @@
package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.plugins.sync.nsclient.data.NSDeviceStatusHandler
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.utils.DateUtil
import info.nightscout.shared.utils.T
import kotlinx.coroutines.runBlocking
@ -19,9 +17,8 @@ import javax.inject.Inject
class LoadDeviceStatusWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var rxBus: RxBus
@Inject lateinit var context: Context
@ -29,7 +26,7 @@ class LoadDeviceStatusWorker(
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var nsDeviceStatusHandler: NSDeviceStatusHandler
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
runBlocking {
@ -50,8 +47,4 @@ class LoadDeviceStatusWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,23 +1,20 @@
package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.logging.AAPSLogger
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
class LoadLastModificationWorker(
context: Context, params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var nsClientV3Plugin: NSClientV3Plugin
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
runBlocking {
@ -32,8 +29,4 @@ class LoadLastModificationWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,23 +1,20 @@
package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.logging.AAPSLogger
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
class LoadStatusWorker(
context: Context, params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var nsClientV3Plugin: NSClientV3Plugin
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
runBlocking {
@ -31,8 +28,4 @@ class LoadStatusWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -4,17 +4,14 @@ import android.content.Context
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequest
import androidx.work.WorkManager
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.interfaces.nsclient.StoreDataForDb
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.plugins.sync.nsShared.StoreDataForDbImpl
import info.nightscout.plugins.sync.nsclientV3.NSClientV3Plugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventNSClientNewLog
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.utils.DateUtil
import kotlinx.coroutines.runBlocking
import javax.inject.Inject
@ -22,9 +19,8 @@ import javax.inject.Inject
class LoadTreatmentsWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var rxBus: RxBus
@Inject lateinit var context: Context
@ -32,7 +28,7 @@ class LoadTreatmentsWorker(
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
var ret = Result.success()
runBlocking {
@ -88,8 +84,4 @@ class LoadTreatmentsWorker(
}
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,11 +1,10 @@
package info.nightscout.plugins.sync.nsclientV3.workers
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.Constants
@ -25,7 +24,6 @@ import info.nightscout.plugins.sync.nsclientV3.extensions.toTemporaryBasal
import info.nightscout.plugins.sync.nsclientV3.extensions.toTemporaryTarget
import info.nightscout.plugins.sync.nsclientV3.extensions.toTherapyEvent
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.sdk.localmodel.treatment.NSBolus
import info.nightscout.sdk.localmodel.treatment.NSBolusWizard
@ -45,10 +43,9 @@ import javax.inject.Inject
class ProcessTreatmentsWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var config: Config
@Inject lateinit var sp: SP
@Inject lateinit var dateUtil: DateUtil
@ -59,7 +56,7 @@ class ProcessTreatmentsWorker(
@Inject lateinit var xDripBroadcast: XDripBroadcast
@Inject lateinit var storeDataForDb: StoreDataForDbImpl
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
@Suppress("UNCHECKED_CAST")
val treatments = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as List<NSTreatment>?
?: return Result.failure(workDataOf("Error" to "missing input data"))
@ -147,8 +144,4 @@ class ProcessTreatmentsWorker(
// xDripBroadcast.sendTreatments(treatments)
return ret
}
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
}

View file

@ -1,13 +1,13 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import info.nightscout.core.utils.worker.LoggingWorker
class DummyWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
override fun doWork(): Result = Result.success()
override fun doWorkAndLog(): Result = Result.success()
}

View file

@ -1,11 +1,10 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.aps.Loop
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.rx.events.Event
@ -15,16 +14,12 @@ import javax.inject.Inject
class InvokeLoopWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var iobCobCalculator: IobCobCalculator
@Inject lateinit var loop: Loop
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class InvokeLoopData(
val cause: Event?
)
@ -36,7 +31,7 @@ class InvokeLoopWorker(
the event causing the calculation is not EventNewBg.
<p>
*/
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as InvokeLoopData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,11 +1,10 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.aps.AutosensDataStore
import info.nightscout.interfaces.iob.IobCobCalculator
@ -20,18 +19,13 @@ import javax.inject.Inject
class LoadBgDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var rxBus: RxBus
@Inject lateinit var repository: AppRepository
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class LoadBgData(
val iobCobCalculator: IobCobCalculator,
val end: Long
@ -53,7 +47,7 @@ class LoadBgDataWorker(
}
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as LoadBgData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -3,15 +3,14 @@ package info.nightscout.workflow
import android.content.Context
import android.graphics.DashPathEffect
import android.graphics.Paint
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.ScaledDataPoint
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction
@ -22,7 +21,7 @@ import javax.inject.Inject
class PrepareBasalDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var profileFunction: ProfileFunction
@ -30,7 +29,6 @@ class PrepareBasalDataWorker(
@Inject lateinit var rxBus: RxBus
private var ctx: Context
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context)
}
@ -39,7 +37,7 @@ class PrepareBasalDataWorker(
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBasalData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,15 +1,14 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.GlucoseUnit
import info.nightscout.interfaces.iob.IobCobCalculator
@ -23,7 +22,7 @@ import javax.inject.Inject
class PrepareBgDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var profileFunction: ProfileFunction
@ -31,16 +30,12 @@ class PrepareBgDataWorker(
@Inject lateinit var defaultValueHelper: DefaultValueHelper
@Inject lateinit var repository: AppRepository
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class PrepareBgData(
val iobCobCalculator: IobCobCalculator, // cannot be injected : HistoryBrowser uses different instance
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBgData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,41 +1,34 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.InMemoryGlucoseValueDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.iob.IobCobCalculator
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.shared.interfaces.ResourceHelper
import javax.inject.Inject
class PrepareBucketedDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var aapsLogger: AAPSLogger
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class PrepareBucketedData(
val iobCobCalculator: IobCobCalculator, // cannot be injected : HistoryBrowser uses different instance
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareBucketedData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -3,12 +3,10 @@ package info.nightscout.workflow
import android.content.Context
import android.graphics.DashPathEffect
import android.graphics.Paint
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.jjoe64.graphview.series.BarGraphSeries
import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.DataPointWithLabelInterface
@ -21,6 +19,7 @@ import info.nightscout.core.iob.combine
import info.nightscout.core.iob.copy
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.ValueWrapper
import info.nightscout.database.impl.AppRepository
@ -32,7 +31,6 @@ import info.nightscout.interfaces.overview.OverviewMenus
import info.nightscout.interfaces.profile.ProfileFunction
import info.nightscout.interfaces.utils.DecimalFormatter
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.utils.DateUtil
@ -44,20 +42,18 @@ import kotlin.math.min
class PrepareIobAutosensGraphDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var dateUtil: DateUtil
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var rh: ResourceHelper
@Inject lateinit var overviewMenus: OverviewMenus
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var repository: AppRepository
@Inject lateinit var rxBus: RxBus
private var ctx: Context
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context)
}
@ -116,7 +112,7 @@ class PrepareIobAutosensGraphDataWorker(
}
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareIobAutosensData?
?: return Result.failure(workDataOf("Error" to "missing input data"))
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_IOB_AUTOSENS_DATA, 0, null))

View file

@ -1,7 +1,6 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -10,6 +9,7 @@ import info.nightscout.core.graph.data.DataPointWithLabelInterface
import info.nightscout.core.graph.data.GlucoseValueDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
import info.nightscout.interfaces.aps.Loop
@ -29,7 +29,7 @@ import kotlin.math.min
class PreparePredictionsWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var injector: HasAndroidInjector
@Inject lateinit var overviewData: OverviewData
@ -44,15 +44,11 @@ class PreparePredictionsWorker(
@Inject lateinit var profileFunction: ProfileFunction
@Inject lateinit var rh: ResourceHelper
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class PreparePredictionsData(
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PreparePredictionsData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,16 +1,15 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import com.jjoe64.graphview.series.DataPoint
import com.jjoe64.graphview.series.LineGraphSeries
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.extensions.target
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.ValueWrapper
import info.nightscout.database.impl.AppRepository
@ -25,7 +24,7 @@ import kotlin.math.max
class PrepareTemporaryTargetDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var profileFunction: ProfileFunction
@ -35,7 +34,6 @@ class PrepareTemporaryTargetDataWorker(
@Inject lateinit var rxBus: RxBus
private var ctx: Context
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
ctx = rh.getThemedCtx(context)
}
@ -43,7 +41,7 @@ class PrepareTemporaryTargetDataWorker(
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareTemporaryTargetData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,10 +1,8 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.graph.OverviewData
import info.nightscout.core.graph.data.BolusDataPoint
@ -15,6 +13,7 @@ import info.nightscout.core.graph.data.ExtendedBolusDataPoint
import info.nightscout.core.graph.data.PointsWithLabelGraphSeries
import info.nightscout.core.graph.data.TherapyEventDataPoint
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.entities.Bolus
import info.nightscout.database.entities.TherapyEvent
@ -34,7 +33,7 @@ import javax.inject.Inject
class PrepareTreatmentsDataWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
@Inject lateinit var profileFunction: ProfileFunction
@ -45,15 +44,11 @@ class PrepareTreatmentsDataWorker(
@Inject lateinit var repository: AppRepository
@Inject lateinit var defaultValueHelper: DefaultValueHelper
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class PrepareTreatmentsData(
val overviewData: OverviewData
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as PrepareTreatmentsData?
?: return Result.failure(workDataOf("Error" to "missing input data"))

View file

@ -1,10 +1,9 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.rx.bus.RxBus
@ -14,16 +13,12 @@ import javax.inject.Inject
class UpdateGraphWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var rxBus: RxBus
@Inject lateinit var activePlugin: ActivePlugin
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
if (inputData.getString(CalculationWorkflow.JOB) == CalculationWorkflow.MAIN_CALCULATION)
activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewGraph("UpdateGraphWorker"))
else

View file

@ -1,9 +1,8 @@
package info.nightscout.workflow
import android.content.Context
import androidx.work.Worker
import androidx.work.WorkerParameters
import dagger.android.HasAndroidInjector
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.interfaces.plugin.ActivePlugin
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.EventUpdateOverviewIobCob
@ -13,16 +12,12 @@ import javax.inject.Inject
class UpdateIobCobSensWorker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var rxBus: RxBus
@Inject lateinit var activePlugin: ActivePlugin
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewIobCob("UpdateIobCobSensWorker"))
activePlugin.activeOverview.overviewBus.send(EventUpdateOverviewSensitivity("UpdateIobCobSensWorker"))
return Result.success()

View file

@ -2,7 +2,6 @@ package info.nightscout.workflow.iob
import android.content.Context
import android.os.SystemClock
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -11,6 +10,7 @@ import info.nightscout.core.extensions.target
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.ValueWrapper
import info.nightscout.database.impl.AppRepository
@ -27,7 +27,6 @@ import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
@ -44,9 +43,8 @@ import kotlin.math.roundToLong
class IobCobOref1Worker(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP
@Inject lateinit var rxBus: RxBus
@Inject lateinit var rh: ResourceHelper
@ -60,10 +58,6 @@ class IobCobOref1Worker(
@Inject lateinit var repository: AppRepository
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class IobCobOref1WorkerData(
val injector: HasAndroidInjector,
val iobCobCalculator: IobCobCalculator, // cannot be injected : HistoryBrowser uses different instance
@ -73,7 +67,7 @@ class IobCobOref1Worker(
val cause: Event?
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as IobCobOref1WorkerData?
?: return Result.success(workDataOf("Error" to "missing input data"))

View file

@ -2,7 +2,6 @@ package info.nightscout.workflow.iob
import android.content.Context
import android.os.SystemClock
import androidx.work.Worker
import androidx.work.WorkerParameters
import androidx.work.workDataOf
import dagger.android.HasAndroidInjector
@ -10,6 +9,7 @@ import info.nightscout.core.events.EventIobCalculationProgress
import info.nightscout.core.iob.iobCobCalculator.data.AutosensDataObject
import info.nightscout.core.utils.fabric.FabricPrivacy
import info.nightscout.core.utils.receivers.DataWorkerStorage
import info.nightscout.core.utils.worker.LoggingWorker
import info.nightscout.core.workflow.CalculationWorkflow
import info.nightscout.database.impl.AppRepository
import info.nightscout.interfaces.Config
@ -25,7 +25,6 @@ import info.nightscout.plugins.iob.iobCobCalculator.fromCarbs
import info.nightscout.rx.bus.RxBus
import info.nightscout.rx.events.Event
import info.nightscout.rx.events.EventAutosensCalculationFinished
import info.nightscout.rx.logging.AAPSLogger
import info.nightscout.rx.logging.LTag
import info.nightscout.shared.interfaces.ResourceHelper
import info.nightscout.shared.sharedPreferences.SP
@ -40,9 +39,8 @@ import kotlin.math.roundToLong
class IobCobOrefWorker @Inject internal constructor(
context: Context,
params: WorkerParameters
) : Worker(context, params) {
) : LoggingWorker(context, params) {
@Inject lateinit var aapsLogger: AAPSLogger
@Inject lateinit var sp: SP
@Inject lateinit var rxBus: RxBus
@Inject lateinit var rh: ResourceHelper
@ -56,10 +54,6 @@ class IobCobOrefWorker @Inject internal constructor(
@Inject lateinit var repository: AppRepository
@Inject lateinit var dataWorkerStorage: DataWorkerStorage
init {
(context.applicationContext as HasAndroidInjector).androidInjector().inject(this)
}
class IobCobOrefWorkerData(
val injector: HasAndroidInjector,
val iobCobCalculatorPlugin: IobCobCalculator, // cannot be injected : HistoryBrowser uses different instance
@ -69,7 +63,7 @@ class IobCobOrefWorker @Inject internal constructor(
val cause: Event?
)
override fun doWork(): Result {
override fun doWorkAndLog(): Result {
val data = dataWorkerStorage.pickupObject(inputData.getLong(DataWorkerStorage.STORE_KEY, -1)) as IobCobOrefWorkerData?
?: return Result.success(workDataOf("Error" to "missing input data"))