prevent stack overflow

This commit is contained in:
Milos Kozak 2020-07-26 11:11:14 +02:00
parent bad7a584c6
commit 1edef7fb4e

View file

@ -7,6 +7,7 @@ import dagger.android.DaggerBroadcastReceiver
import info.nightscout.androidaps.interfaces.ActivePluginProvider import info.nightscout.androidaps.interfaces.ActivePluginProvider
import info.nightscout.androidaps.interfaces.PumpInterface import info.nightscout.androidaps.interfaces.PumpInterface
import info.nightscout.androidaps.logging.AAPSLogger import info.nightscout.androidaps.logging.AAPSLogger
import info.nightscout.androidaps.logging.BundleLogger
import info.nightscout.androidaps.logging.LTag import info.nightscout.androidaps.logging.LTag
import info.nightscout.androidaps.utils.TimeChangeType import info.nightscout.androidaps.utils.TimeChangeType
import java.util.* import java.util.*
@ -38,37 +39,38 @@ class TimeDateOrTZChangeReceiver : DaggerBroadcastReceiver() {
val action = intent.action val action = intent.action
val activePump: PumpInterface = activePlugin.activePump val activePump: PumpInterface = activePlugin.activePump
aapsLogger.debug(LTag.PUMP,"TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action) aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Date, Time and/or TimeZone changed. [action={}]", action)
try { aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Intent::{}", BundleLogger.log(intent.extras))
aapsLogger.debug(LTag.PUMP, "TimeDateOrTZChangeReceiver::Intent::{}", gson.toJson(intent))
} catch (ignored : Exception) {}
when { when {
action == null -> { action == null -> {
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Action is null. Exiting.") aapsLogger.error(LTag.PUMP, "TimeDateOrTZChangeReceiver::Action is null. Exiting.")
} }
Intent.ACTION_TIMEZONE_CHANGED == action -> { Intent.ACTION_TIMEZONE_CHANGED == action -> {
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.") aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Timezone changed. Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange) activePump.timezoneOrDSTChanged(TimeChangeType.TimezoneChange)
} }
Intent.ACTION_TIME_CHANGED == action -> { Intent.ACTION_TIME_CHANGED == action -> {
val currentDst = calculateDST() val currentDst = calculateDST()
if (currentDst == isDST) { if (currentDst == isDST) {
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.") aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::Time changed (manual). Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange) activePump.timezoneOrDSTChanged(TimeChangeType.ManualTimeChange)
} else { } else {
if (currentDst) { if (currentDst) {
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.") aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::DST started. Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started) activePump.timezoneOrDSTChanged(TimeChangeType.DST_Started)
} else { } else {
aapsLogger.info(LTag.PUMP,"TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.") aapsLogger.info(LTag.PUMP, "TimeDateOrTZChangeReceiver::DST ended. Notifying pump driver.")
activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended) activePump.timezoneOrDSTChanged(TimeChangeType.DST_Ended)
} }
} }
isDST = currentDst isDST = currentDst
} }
else -> { else -> {
aapsLogger.error(LTag.PUMP,"TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action) aapsLogger.error(LTag.PUMP, "TimeDateOrTZChangeReceiver::Unknown action received [name={}]. Exiting.", action)
} }
} }
} }