Notofocation -> kt
This commit is contained in:
parent
20cabd00bb
commit
658f565cf2
|
@ -13,6 +13,7 @@ jacoco {
|
|||
|
||||
tasks.withType(Test) {
|
||||
jacoco.includeNoLocationClasses = true
|
||||
jacoco.excludes = ['jdk.internal.*']
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
|
|
@ -40,10 +40,10 @@ open class StorageConstraintPlugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.CONSTRAINTS, "Internal storage free (Mb):$diskFree")
|
||||
if (diskFree < Constants.MINIMUM_FREE_SPACE) {
|
||||
value[aapsLogger, false, resourceHelper.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE)] = this
|
||||
val notification = Notification(Notification.DISKFULL, resourceHelper.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL)
|
||||
val notification = Notification(Notification.DISK_FULL, resourceHelper.gs(R.string.diskfull, Constants.MINIMUM_FREE_SPACE), Notification.NORMAL)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.DISKFULL))
|
||||
rxBus.send(EventDismissNotification(Notification.DISK_FULL))
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ class VersionCheckerPlugin @Inject constructor(
|
|||
gracePeriod.old,
|
||||
gracePeriod.veryOld
|
||||
)
|
||||
val notification = Notification(Notification.OLDVERSION, message, Notification.NORMAL)
|
||||
val notification = Notification(Notification.OLD_VERSION, message, Notification.NORMAL)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ public class NSClientPlugin extends PluginBase {
|
|||
&& !enteredBy.equals(sp.getString("careportal_enteredby", "AndroidAPS"))) {
|
||||
boolean defaultVal = config.getNSCLIENT();
|
||||
if (sp.getBoolean(R.string.key_ns_announcements, defaultVal)) {
|
||||
Notification announcement = new Notification(Notification.NSANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60);
|
||||
Notification announcement = new Notification(Notification.NS_ANNOUNCEMENT, notes, Notification.ANNOUNCEMENT, 60);
|
||||
rxBus.send(new EventNewNotification(announcement));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -347,7 +347,7 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
rxBus.send(new EventNSClientNewLog("WATCHDOG", "connections in last " + WATCHDOG_INTERVAL_MINUTES + " mins: " + reconnections.size() + "/" + WATCHDOG_MAXCONNECTIONS));
|
||||
if (reconnections.size() >= WATCHDOG_MAXCONNECTIONS) {
|
||||
Notification n = new Notification(Notification.NSMALFUNCTION, resourceHelper.gs(R.string.nsmalfunction), Notification.URGENT);
|
||||
Notification n = new Notification(Notification.NS_MALFUNCTION, resourceHelper.gs(R.string.nsmalfunction), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(n));
|
||||
rxBus.send(new EventNSClientNewLog("WATCHDOG", "pausing for " + WATCHDOG_RECONNECT_IN + " mins"));
|
||||
nsClientPlugin.pause(true);
|
||||
|
@ -508,8 +508,8 @@ public class NSClientService extends DaggerService {
|
|||
try {
|
||||
data = (JSONObject) args[0];
|
||||
rxBus.send(new EventNSClientNewLog("CLEARALARM", "received"));
|
||||
rxBus.send(new EventDismissNotification(Notification.NSALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NSURGENTALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NS_ALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NS_URGENT_ALARM));
|
||||
aapsLogger.debug(LTag.NSCLIENT, data.toString());
|
||||
} catch (Exception e) {
|
||||
aapsLogger.error("Unhandled exception", e);
|
||||
|
@ -710,8 +710,8 @@ public class NSClientService extends DaggerService {
|
|||
}
|
||||
// Was that sgv more less 5 mins ago ?
|
||||
if ((System.currentTimeMillis() - latestDateInReceivedData) / (60 * 1000L) < 5L) {
|
||||
rxBus.send(new EventDismissNotification(Notification.NSALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NSURGENTALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NS_ALARM));
|
||||
rxBus.send(new EventDismissNotification(Notification.NS_URGENT_ALARM));
|
||||
}
|
||||
handleNewSgv(sgvs, isDelta);
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class NotificationStore @Inject constructor(
|
|||
store.add(n)
|
||||
if (sp.getBoolean(R.string.key_raise_notifications_as_android_notifications, true) && n !is NotificationWithAction)
|
||||
raiseSystemNotification(n)
|
||||
if (n.soundId != null && n.soundId != 0) alarmSoundServiceHelper.startAlarm(context, n.soundId)
|
||||
if (n.soundId != null && n.soundId != 0) alarmSoundServiceHelper.startAlarm(context, n.soundId!!)
|
||||
Collections.sort(store, NotificationComparator())
|
||||
return true
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ class NotificationStore @Inject constructor(
|
|||
@Suppress("SetTextI18n")
|
||||
holder.binding.text.text = dateUtil.timeString(notification.date) + " " + notification.text
|
||||
when (notification.level) {
|
||||
Notification.URGENT -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationUrgent))
|
||||
Notification.NORMAL -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationNormal))
|
||||
Notification.LOW -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationLow))
|
||||
Notification.INFO -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationInfo))
|
||||
Notification.URGENT -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationUrgent))
|
||||
Notification.NORMAL -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationNormal))
|
||||
Notification.LOW -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationLow))
|
||||
Notification.INFO -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationInfo))
|
||||
Notification.ANNOUNCEMENT -> holder.binding.cv.setBackgroundColor(resourceHelper.gc(R.color.notificationAnnouncement))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,21 +38,21 @@ class NotificationWithAction constructor(
|
|||
date = System.currentTimeMillis()
|
||||
when (nsAlarm.level()) {
|
||||
0 -> {
|
||||
id = NSANNOUNCEMENT
|
||||
id = NS_ANNOUNCEMENT
|
||||
level = ANNOUNCEMENT
|
||||
text = nsAlarm.message()
|
||||
validTo = System.currentTimeMillis() + T.mins(60).msecs()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
id = NSALARM
|
||||
id = NS_ALARM
|
||||
level = NORMAL
|
||||
text = nsAlarm.title()
|
||||
soundId = R.raw.alarm
|
||||
}
|
||||
|
||||
2 -> {
|
||||
id = NSURGENTALARM
|
||||
id = NS_URGENT_ALARM
|
||||
level = URGENT
|
||||
text = nsAlarm.title()
|
||||
soundId = R.raw.urgentalarm
|
||||
|
|
|
@ -159,7 +159,7 @@ class IobCobOref1Thread internal constructor(
|
|||
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, bucketedData.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, iobCobCalculatorPlugin.bgReadings.toString())
|
||||
val notification = Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
val notification = Notification(Notification.SEND_LOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
sp.putBoolean("log_AUTOSENS", true)
|
||||
break
|
||||
|
@ -182,7 +182,7 @@ class IobCobOref1Thread internal constructor(
|
|||
aapsLogger.debug(autosensDataTable.toString())
|
||||
aapsLogger.debug(bucketedData.toString())
|
||||
aapsLogger.debug(iobCobCalculatorPlugin.bgReadings.toString())
|
||||
val notification = Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
val notification = Notification(Notification.SEND_LOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
sp.putBoolean("log_AUTOSENS", true)
|
||||
break
|
||||
|
|
|
@ -156,7 +156,7 @@ class IobCobThread @Inject internal constructor(
|
|||
aapsLogger.debug(LTag.AUTOSENS, autosensDataTable.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, bucketedData.toString())
|
||||
aapsLogger.debug(LTag.AUTOSENS, iobCobCalculatorPlugin.bgReadings.toString())
|
||||
val notification = Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
val notification = Notification(Notification.SEND_LOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
sp.putBoolean("log_AUTOSENS", true)
|
||||
break
|
||||
|
@ -179,7 +179,7 @@ class IobCobThread @Inject internal constructor(
|
|||
aapsLogger.debug(autosensDataTable.toString())
|
||||
aapsLogger.debug(bucketedData.toString())
|
||||
aapsLogger.debug(iobCobCalculatorPlugin.bgReadings.toString())
|
||||
val notification = Notification(Notification.SENDLOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
val notification = Notification(Notification.SEND_LOGFILES, resourceHelper.gs(R.string.sendlogfiles), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
sp.putBoolean("log_AUTOSENS", true)
|
||||
break
|
||||
|
|
|
@ -91,10 +91,10 @@ class AndroidPermission @Inject constructor(
|
|||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_SMS))
|
||||
// Following is a bug in Android 8
|
||||
if (permissionNotGranted(activity, Manifest.permission.READ_PHONE_STATE)) {
|
||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_PHONESTATE, resourceHelper.gs(R.string.smscommunicator_missingphonestatepermission), Notification.URGENT)
|
||||
val notification = NotificationWithAction(injector, Notification.PERMISSION_PHONE_STATE, resourceHelper.gs(R.string.smscommunicator_missingphonestatepermission), Notification.URGENT)
|
||||
notification.action(R.string.request) { askForPermission(activity, arrayOf(Manifest.permission.READ_PHONE_STATE)) }
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_PHONESTATE))
|
||||
} else rxBus.send(EventDismissNotification(Notification.PERMISSION_PHONE_STATE))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
|||
import info.nightscout.androidaps.interfaces.SensitivityInterface
|
||||
import info.nightscout.androidaps.logging.AAPSLogger
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult
|
||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.json.JSONObject
|
||||
|
@ -25,7 +24,7 @@ class AbstractSensitivityPluginTest : TestBase() {
|
|||
@Mock lateinit var resourceHelper: ResourceHelper
|
||||
@Mock lateinit var sp: SP
|
||||
|
||||
private inner class SensitivityTestClass(pluginDescription: PluginDescription, aapsLogger: AAPSLogger, resourceHelper: ResourceHelper, sp: SP) : AbstractSensitivityPlugin(pluginDescription, HasAndroidInjector { AndroidInjector { Unit } }, aapsLogger, resourceHelper, sp) {
|
||||
private inner class SensitivityTestClass(pluginDescription: PluginDescription, aapsLogger: AAPSLogger, resourceHelper: ResourceHelper, sp: SP) : AbstractSensitivityPlugin(pluginDescription, HasAndroidInjector { AndroidInjector { } }, aapsLogger, resourceHelper, sp) {
|
||||
|
||||
override fun detectSensitivity(plugin: IobCobCalculatorInterface, fromTime: Long, toTime: Long): AutosensResult {
|
||||
return AutosensResult()
|
||||
|
|
|
@ -258,7 +258,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
if (pump.basalProfile.equals(requestedBasalProfile)) {
|
||||
//dismiss previously "FAILED" overview notifications
|
||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
|
||||
return new PumpEnactResult(getInjector()).success(true).enacted(false);
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
CommandResult setResult = runCommand(getResourceHelper().gs(R.string.combo_activity_setting_basal_profile), 2,
|
||||
() -> ruffyScripter.setBasalProfile(requestedBasalProfile));
|
||||
if (!setResult.success) {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, getResourceHelper().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, getResourceHelper().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
return new PumpEnactResult(getInjector()).success(false).enacted(false).comment(R.string.failedupdatebasalprofile);
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
|
||||
//dismiss previously "FAILED" overview notifications
|
||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
|
||||
//issue success notification
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, getResourceHelper().gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
|
@ -374,7 +374,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||
getResourceHelper().gs(R.string.combo_force_disabled_notification),
|
||||
Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
n.setSoundId(R.raw.alarm);
|
||||
rxBus.send(new EventNewNotification(n));
|
||||
return;
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||
getResourceHelper().gs(R.string.combo_force_disabled_notification),
|
||||
Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
n.setSoundId(R.raw.alarm);
|
||||
rxBus.send(new EventNewNotification(n));
|
||||
commandQueue.cancelTempBasal(true, null);
|
||||
}
|
||||
|
@ -948,11 +948,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
// so update the var with it, so the check routines below can work on it
|
||||
preCheckResult = alertConfirmationResult;
|
||||
} else if (activeAlert.errorCode != null) {
|
||||
Notification notification = new Notification();
|
||||
notification.date = DateUtil.now();
|
||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||
notification.level = Notification.URGENT;
|
||||
notification.text = getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message);
|
||||
Notification notification = new Notification(Notification.COMBO_PUMP_ALARM, DateUtil.now(), getResourceHelper().gs(R.string.combo_is_in_error_state, activeAlert.errorCode, activeAlert.message), Notification.URGENT, 0);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
return preCheckResult.success(false);
|
||||
}
|
||||
|
@ -1046,15 +1042,15 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
throw new IllegalArgumentException(activeAlert.toString());
|
||||
}
|
||||
Notification notification = new Notification();
|
||||
notification.date = DateUtil.now();
|
||||
notification.id = Notification.COMBO_PUMP_ALARM;
|
||||
notification.level = Notification.NORMAL;
|
||||
notification.setDate(DateUtil.now());
|
||||
notification.setId(Notification.COMBO_PUMP_ALARM);
|
||||
notification.setLevel(Notification.NORMAL);
|
||||
if (activeAlert.warningCode == PumpWarningCodes.CARTRIDGE_LOW) {
|
||||
notification.text = getResourceHelper().gs(R.string.combo_pump_cartridge_low_warrning);
|
||||
notification.setText(getResourceHelper().gs(R.string.combo_pump_cartridge_low_warrning));
|
||||
} else if (activeAlert.warningCode == PumpWarningCodes.BATTERY_LOW) {
|
||||
notification.text = getResourceHelper().gs(R.string.combo_pump_battery_low_warrning);
|
||||
notification.setText(getResourceHelper().gs(R.string.combo_pump_battery_low_warrning));
|
||||
} else if (activeAlert.warningCode == PumpWarningCodes.TBR_CANCELLED) {
|
||||
notification.text = getResourceHelper().gs(R.string.combo_pump_tbr_cancelled_warrning);
|
||||
notification.setText(getResourceHelper().gs(R.string.combo_pump_tbr_cancelled_warrning));
|
||||
}
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
}
|
||||
|
@ -1078,7 +1074,7 @@ public class ComboPlugin extends PumpPluginBase implements PumpInterface, Constr
|
|||
Notification n = new Notification(Notification.COMBO_PUMP_ALARM,
|
||||
getResourceHelper().gs(R.string.combo_low_suspend_forced_notification),
|
||||
Notification.URGENT);
|
||||
n.soundId = R.raw.alarm;
|
||||
n.setSoundId(R.raw.alarm);
|
||||
rxBus.send(new EventNewNotification(n));
|
||||
violationWarningRaisedForBolusAt = lowSuspendOnlyLoopEnforcedUntil;
|
||||
commandQueue.cancelTempBasal(true, null);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package info.nightscout.androidaps.interfaces
|
||||
|
||||
class PluginDescription {
|
||||
open class PluginDescription {
|
||||
|
||||
var mainType = PluginType.GENERAL
|
||||
var fragmentClass: String? = null
|
||||
|
|
|
@ -107,7 +107,7 @@ class VersionCheckerUtils @Inject constructor(
|
|||
val now = System.currentTimeMillis()
|
||||
if (now > sp.getLong(R.string.key_last_versionchecker_warning, 0) + WARN_EVERY) {
|
||||
aapsLogger.debug(LTag.CORE, "Version $currentVersion outdated. Found $newVersion")
|
||||
val notification = Notification(Notification.NEWVERSIONDETECTED, resourceHelper.gs(R.string.versionavailable, newVersion.toString()), Notification.LOW)
|
||||
val notification = Notification(Notification.NEW_VERSION_DETECTED, resourceHelper.gs(R.string.versionavailable, newVersion.toString()), Notification.LOW)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
sp.putLong(R.string.key_last_versionchecker_warning, now)
|
||||
}
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.notifications;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import info.nightscout.androidaps.utils.T;
|
||||
|
||||
public class Notification {
|
||||
// TODO join with NotificationWithAction after change to enums
|
||||
public static final int URGENT = 0;
|
||||
public static final int NORMAL = 1;
|
||||
public static final int LOW = 2;
|
||||
public static final int INFO = 3;
|
||||
public static final int ANNOUNCEMENT = 4;
|
||||
|
||||
public static final int PROFILE_SET_FAILED = 0;
|
||||
public static final int PROFILE_SET_OK = 1;
|
||||
public static final int EASYMODE_ENABLED = 2;
|
||||
public static final int EXTENDED_BOLUS_DISABLED = 3;
|
||||
public static final int UD_MODE_ENABLED = 4;
|
||||
public static final int PROFILE_NOT_SET_NOT_INITIALIZED = 5;
|
||||
public static final int FAILED_UDPATE_PROFILE = 6;
|
||||
public static final int BASAL_VALUE_BELOW_MINIMUM = 7;
|
||||
public static final int OLD_NS = 9;
|
||||
public static final int INVALID_PHONE_NUMBER = 10;
|
||||
public static final int INVALID_MESSAGE_BODY = 11;
|
||||
public static final int APPROACHING_DAILY_LIMIT = 12;
|
||||
public static final int NSCLIENT_NO_WRITE_PERMISSION = 13;
|
||||
public static final int MISSING_SMS_PERMISSION = 14;
|
||||
public static final int PUMPERROR = 15;
|
||||
public static final int WRONGSERIALNUMBER = 16;
|
||||
|
||||
public static final int NSANNOUNCEMENT = 18;
|
||||
public static final int NSALARM = 19;
|
||||
public static final int NSURGENTALARM = 20;
|
||||
public static final int SHORT_DIA = 21;
|
||||
public static final int TOAST_ALARM = 22;
|
||||
public static final int WRONGBASALSTEP = 23;
|
||||
public static final int WRONG_DRIVER = 24;
|
||||
public static final int COMBO_PUMP_ALARM = 25;
|
||||
public static final int PUMP_UNREACHABLE = 26;
|
||||
public static final int BG_READINGS_MISSED = 27;
|
||||
public static final int UNSUPPORTED_FIRMWARE = 28;
|
||||
public static final int MINIMAL_BASAL_VALUE_REPLACED = 29;
|
||||
public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30;
|
||||
public static final int ZERO_VALUE_IN_PROFILE = 31;
|
||||
public static final int PROFILE_SWITCH_MISSING = 32;
|
||||
public static final int NOT_ENG_MODE_OR_RELEASE = 33;
|
||||
public static final int WRONG_PUMP_PASSWORD = 34;
|
||||
public static final int PERMISSION_STORAGE = 35;
|
||||
public static final int PERMISSION_LOCATION = 36;
|
||||
public static final int PERMISSION_BATTERY = 37;
|
||||
public static final int PERMISSION_SMS = 38;
|
||||
public static final int MAXIMUM_BASAL_VALUE_REPLACED = 39;
|
||||
public static final int NSMALFUNCTION = 40;
|
||||
public static final int NEWVERSIONDETECTED = 41;
|
||||
public static final int SENDLOGFILES = 42;
|
||||
public static final int DEVICENOTPAIRED = 43;
|
||||
public static final int MEDTRONIC_PUMP_ALARM = 44;
|
||||
public static final int RILEYLINK_CONNECTION = 45;
|
||||
public static final int PERMISSION_PHONESTATE = 46;
|
||||
public static final int INSIGHT_DATE_TIME_UPDATED = 47;
|
||||
public static final int INSIGHT_TIMEOUT_DURING_HANDSHAKE = 48;
|
||||
public static final int DST_LOOP_DISABLED = 49;
|
||||
public static final int DST_IN_24H = 50;
|
||||
public static final int DISKFULL = 51;
|
||||
public static final int OLDVERSION = 52;
|
||||
public static final int OVER_24H_TIME_CHANGE_REQUESTED = 54;
|
||||
public static final int INVALID_VERSION = 55;
|
||||
public static final int PERMISSION_SYSTEM_WINDOW = 56;
|
||||
public static final int TIME_OR_TIMEZONE_CHANGE = 58;
|
||||
public static final int OMNIPOD_POD_NOT_ATTACHED = 59;
|
||||
public static final int CARBS_REQUIRED = 60;
|
||||
public static final int OMNIPOD_POD_SUSPENDED = 61;
|
||||
public static final int OMNIPOD_POD_ALERTS_UPDATED = 62;
|
||||
public static final int OMNIPOD_POD_ALERTS = 63;
|
||||
public static final int OMNIPOD_TBR_ALERTS = 64;
|
||||
public static final int OMNIPOD_POD_FAULT = 66;
|
||||
public static final int OMNIPOD_UNCERTAIN_SMB = 67;
|
||||
public static final int OMNIPOD_UNKNOWN_TBR = 68;
|
||||
public static final int OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69;
|
||||
public static final int OMNIPOD_TIME_OUT_OF_SYNC = 70;
|
||||
|
||||
public static final int IMPORTANCE_HIGH = 2;
|
||||
|
||||
public static final String CATEGORY_ALARM = "alarm";
|
||||
|
||||
public static final int USERMESSAGE = 1000;
|
||||
|
||||
public int id;
|
||||
public long date;
|
||||
public String text;
|
||||
public int level;
|
||||
public long validTo = 0;
|
||||
|
||||
public Integer soundId = null;
|
||||
|
||||
protected Runnable action = null;
|
||||
protected int buttonText = 0;
|
||||
|
||||
public Notification() {
|
||||
}
|
||||
|
||||
public Notification(int id, long date, String text, int level, long validTo) {
|
||||
this.id = id;
|
||||
this.date = date;
|
||||
this.text = text;
|
||||
this.level = level;
|
||||
this.validTo = validTo;
|
||||
}
|
||||
|
||||
public Notification(int id, String text, int level, int validMinutes) {
|
||||
this.id = id;
|
||||
this.date = System.currentTimeMillis();
|
||||
this.text = text;
|
||||
this.level = level;
|
||||
this.validTo = System.currentTimeMillis() + T.mins(validMinutes).msecs();
|
||||
}
|
||||
|
||||
public Notification(int id, @NonNull String text, int level) {
|
||||
this.id = id;
|
||||
this.date = System.currentTimeMillis();
|
||||
this.text = text;
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public Notification(int id) {
|
||||
this.id = id;
|
||||
this.date = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public Notification text(String text) {
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Notification level(int level) {
|
||||
this.level = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Notification sound(int soundId) {
|
||||
this.soundId = soundId;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package info.nightscout.androidaps.plugins.general.overview.notifications
|
||||
|
||||
import androidx.annotation.RawRes
|
||||
import info.nightscout.androidaps.utils.T
|
||||
|
||||
open class Notification {
|
||||
|
||||
var id = 0
|
||||
var date: Long = 0
|
||||
var text: String? = null
|
||||
var level = 0
|
||||
var validTo: Long = 0
|
||||
@RawRes var soundId: Int? = null
|
||||
var action: Runnable? = null
|
||||
var buttonText = 0
|
||||
|
||||
constructor()
|
||||
constructor(id: Int, date: Long, text: String, level: Int, validTo: Long) {
|
||||
this.id = id
|
||||
this.date = date
|
||||
this.text = text
|
||||
this.level = level
|
||||
this.validTo = validTo
|
||||
}
|
||||
|
||||
constructor(id: Int, text: String, level: Int, validMinutes: Int) {
|
||||
this.id = id
|
||||
date = System.currentTimeMillis()
|
||||
this.text = text
|
||||
this.level = level
|
||||
validTo = System.currentTimeMillis() + T.mins(validMinutes.toLong()).msecs()
|
||||
}
|
||||
|
||||
constructor(id: Int, text: String, level: Int) {
|
||||
this.id = id
|
||||
date = System.currentTimeMillis()
|
||||
this.text = text
|
||||
this.level = level
|
||||
}
|
||||
|
||||
constructor(id: Int) {
|
||||
this.id = id
|
||||
date = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
fun text(text: String): Notification = this.also { it.text = text }
|
||||
fun level(level: Int): Notification = this.also { it.level = level }
|
||||
fun sound(soundId: Int): Notification = this.also { it.soundId = soundId }
|
||||
|
||||
companion object {
|
||||
|
||||
// Hard to convert to enums because for NS notifications we create dynamic ID
|
||||
const val URGENT = 0
|
||||
const val NORMAL = 1
|
||||
const val LOW = 2
|
||||
const val INFO = 3
|
||||
const val ANNOUNCEMENT = 4
|
||||
const val PROFILE_SET_FAILED = 0
|
||||
const val PROFILE_SET_OK = 1
|
||||
const val EASY_MODE_ENABLED = 2
|
||||
const val EXTENDED_BOLUS_DISABLED = 3
|
||||
const val UD_MODE_ENABLED = 4
|
||||
const val PROFILE_NOT_SET_NOT_INITIALIZED = 5
|
||||
const val FAILED_UPDATE_PROFILE = 6
|
||||
const val BASAL_VALUE_BELOW_MINIMUM = 7
|
||||
const val OLD_NS = 9
|
||||
const val INVALID_PHONE_NUMBER = 10
|
||||
const val INVALID_MESSAGE_BODY = 11
|
||||
const val APPROACHING_DAILY_LIMIT = 12
|
||||
const val NSCLIENT_NO_WRITE_PERMISSION = 13
|
||||
const val MISSING_SMS_PERMISSION = 14
|
||||
const val PUMP_ERROR = 15
|
||||
const val WRONG_SERIAL_NUMBER = 16
|
||||
const val NS_ANNOUNCEMENT = 18
|
||||
const val NS_ALARM = 19
|
||||
const val NS_URGENT_ALARM = 20
|
||||
const val SHORT_DIA = 21
|
||||
const val TOAST_ALARM = 22
|
||||
const val WRONG_BASAL_STEP = 23
|
||||
const val WRONG_DRIVER = 24
|
||||
const val COMBO_PUMP_ALARM = 25
|
||||
const val PUMP_UNREACHABLE = 26
|
||||
const val BG_READINGS_MISSED = 27
|
||||
const val UNSUPPORTED_FIRMWARE = 28
|
||||
const val MINIMAL_BASAL_VALUE_REPLACED = 29
|
||||
const val BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30
|
||||
const val ZERO_VALUE_IN_PROFILE = 31
|
||||
const val PROFILE_SWITCH_MISSING = 32
|
||||
@Suppress("unused") const val NOT_ENG_MODE_OR_RELEASE = 33
|
||||
const val WRONG_PUMP_PASSWORD = 34
|
||||
const val PERMISSION_STORAGE = 35
|
||||
const val PERMISSION_LOCATION = 36
|
||||
const val PERMISSION_BATTERY = 37
|
||||
const val PERMISSION_SMS = 38
|
||||
const val MAXIMUM_BASAL_VALUE_REPLACED = 39
|
||||
const val NS_MALFUNCTION = 40
|
||||
const val NEW_VERSION_DETECTED = 41
|
||||
const val SEND_LOGFILES = 42
|
||||
const val DEVICE_NOT_PAIRED = 43
|
||||
const val MEDTRONIC_PUMP_ALARM = 44
|
||||
const val RILEYLINK_CONNECTION = 45
|
||||
const val PERMISSION_PHONE_STATE = 46
|
||||
const val INSIGHT_DATE_TIME_UPDATED = 47
|
||||
const val INSIGHT_TIMEOUT_DURING_HANDSHAKE = 48
|
||||
const val DST_LOOP_DISABLED = 49
|
||||
const val DST_IN_24H = 50
|
||||
const val DISK_FULL = 51
|
||||
const val OLD_VERSION = 52
|
||||
const val OVER_24H_TIME_CHANGE_REQUESTED = 54
|
||||
const val INVALID_VERSION = 55
|
||||
const val PERMISSION_SYSTEM_WINDOW = 56
|
||||
const val TIME_OR_TIMEZONE_CHANGE = 58
|
||||
const val OMNIPOD_POD_NOT_ATTACHED = 59
|
||||
const val CARBS_REQUIRED = 60
|
||||
const val OMNIPOD_POD_SUSPENDED = 61
|
||||
const val OMNIPOD_POD_ALERTS_UPDATED = 62
|
||||
const val OMNIPOD_POD_ALERTS = 63
|
||||
const val OMNIPOD_TBR_ALERTS = 64
|
||||
const val OMNIPOD_POD_FAULT = 66
|
||||
const val OMNIPOD_UNCERTAIN_SMB = 67
|
||||
const val OMNIPOD_UNKNOWN_TBR = 68
|
||||
const val OMNIPOD_STARTUP_STATUS_REFRESH_FAILED = 69
|
||||
const val OMNIPOD_TIME_OUT_OF_SYNC = 70
|
||||
|
||||
const val USER_MESSAGE = 1000
|
||||
|
||||
const val IMPORTANCE_HIGH = 2
|
||||
const val CATEGORY_ALARM = "alarm"
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ class NotificationUserMessage (text :String): Notification() {
|
|||
|
||||
init {
|
||||
var hash = text.hashCode()
|
||||
if (hash < USERMESSAGE) hash += USERMESSAGE
|
||||
if (hash < USER_MESSAGE) hash += USER_MESSAGE
|
||||
id = hash
|
||||
date = System.currentTimeMillis()
|
||||
this.text = text
|
||||
|
|
|
@ -4,7 +4,6 @@ import info.nightscout.androidaps.Constants
|
|||
import info.nightscout.androidaps.TestBaseWithProfile
|
||||
import info.nightscout.androidaps.TestPumpPlugin
|
||||
import info.nightscout.androidaps.core.R
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||
import info.nightscout.androidaps.utils.FabricPrivacy
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert
|
||||
|
@ -12,6 +11,8 @@ import org.junit.Before
|
|||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.anyInt
|
||||
import org.mockito.Mockito.anyString
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
import org.skyscreamer.jsonassert.JSONAssert
|
||||
|
@ -43,6 +44,7 @@ class ProfileTest : TestBaseWithProfile() {
|
|||
`when`(resourceHelper.gs(R.string.profile_per_unit)).thenReturn("/U")
|
||||
`when`(resourceHelper.gs(R.string.profile_carbs_per_unit)).thenReturn("g/U")
|
||||
`when`(resourceHelper.gs(R.string.profile_ins_units_per_hour)).thenReturn("U/h")
|
||||
`when`(resourceHelper.gs(anyInt(), anyString())).thenReturn("")
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -60,9 +60,9 @@ class TempTargetTest(
|
|||
override fun match(time: Long): Boolean = start() <= time && end() >= time
|
||||
override fun before(time: Long): Boolean = end() < time
|
||||
override fun after(time: Long): Boolean = start() > time
|
||||
override fun isInProgress(): Boolean = match(System.currentTimeMillis())
|
||||
override fun isEndingEvent(): Boolean = data.duration == 0L
|
||||
override fun isValid(): Boolean = true
|
||||
override val isInProgress: Boolean get() = match(System.currentTimeMillis())
|
||||
override val isEndingEvent: Boolean get() = data.duration == 0L
|
||||
override val isValid: Boolean get() = true
|
||||
|
||||
// -------- Interval interface end ---------
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ class PluginDescriptionTest {
|
|||
|
||||
@Test fun mainTypeTest() {
|
||||
val pluginDescription = PluginDescription().mainType(PluginType.PUMP)
|
||||
Assert.assertEquals(PluginType.PUMP, pluginDescription.type)
|
||||
Assert.assertEquals(PluginType.PUMP, pluginDescription.mainType)
|
||||
}
|
||||
|
||||
@Test fun fragmentClassTest() {
|
||||
val pluginDescription = PluginDescription().fragmentClass(Fragment::class.java.name)
|
||||
Assert.assertEquals(Fragment::class.java.name, pluginDescription.getFragmentClass())
|
||||
Assert.assertEquals(Fragment::class.java.name, pluginDescription.fragmentClass)
|
||||
}
|
||||
|
||||
@Test fun alwaysEnabledTest() {
|
||||
|
|
|
@ -32,10 +32,10 @@ class MsgInitConnStatusBasic_k(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "easyUIMode: $easyUIMode")
|
||||
aapsLogger.debug(LTag.PUMPCOMM, "Pump password: " + danaPump.password)
|
||||
if (danaPump.isEasyModeEnabled) {
|
||||
val notification = Notification(Notification.EASYMODE_ENABLED, resourceHelper.gs(R.string.danar_disableeasymode), Notification.URGENT)
|
||||
val notification = Notification(Notification.EASY_MODE_ENABLED, resourceHelper.gs(R.string.danar_disableeasymode), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.EASYMODE_ENABLED))
|
||||
rxBus.send(EventDismissNotification(Notification.EASY_MODE_ENABLED))
|
||||
}
|
||||
if (!danaPump.isPasswordOK) {
|
||||
val notification = Notification(Notification.WRONG_PUMP_PASSWORD, resourceHelper.gs(R.string.wrongpumppassword), Notification.URGENT)
|
||||
|
|
|
@ -152,12 +152,12 @@ public abstract class AbstractDanaRPlugin extends PumpPluginBase implements Pump
|
|||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
}
|
||||
if (!sExecutionService.updateBasalsInPump(profile)) {
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, getResourceHelper().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, getResourceHelper().gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.comment(R.string.failedupdatebasalprofile);
|
||||
} else {
|
||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, getResourceHelper().gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.success(true).enacted(true).comment("OK");
|
||||
|
|
|
@ -35,10 +35,10 @@ class MsgSettingMeal(
|
|||
danaPump.basalStep = 0.01
|
||||
}
|
||||
if (danaPump.basalStep != 0.01) {
|
||||
val notification = Notification(Notification.WRONGBASALSTEP, resourceHelper.gs(R.string.danar_setbasalstep001), Notification.URGENT)
|
||||
val notification = Notification(Notification.WRONG_BASAL_STEP, resourceHelper.gs(R.string.danar_setbasalstep001), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.WRONGBASALSTEP))
|
||||
rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP))
|
||||
}
|
||||
if (danaPump.isConfigUD) {
|
||||
val notification = Notification(Notification.UD_MODE_ENABLED, resourceHelper.gs(R.string.danar_switchtouhmode), Notification.URGENT)
|
||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.utils.DateUtil
|
|||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.Mockito.anyBoolean
|
||||
|
@ -54,6 +55,7 @@ open class DanaRTestBase : TestBase() {
|
|||
`when`(activePluginProvider.activePump).thenReturn(testPumpPlugin)
|
||||
doNothing().`when`(danaRKoreanPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||
doNothing().`when`(danaRPlugin).setPluginEnabled(anyObject(), anyBoolean())
|
||||
`when`(resourceHelper.gs(ArgumentMatchers.anyInt())).thenReturn("")
|
||||
}
|
||||
|
||||
val injector = HasAndroidInjector {
|
||||
|
|
|
@ -216,13 +216,13 @@ class DanaRSPlugin @Inject constructor(
|
|||
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
|
||||
}
|
||||
return if (danaRSService?.updateBasalsInPump(profile) != true) {
|
||||
val notification = Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT)
|
||||
val notification = Notification(Notification.FAILED_UPDATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile)
|
||||
result
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED))
|
||||
rxBus.send(EventDismissNotification(Notification.FAILED_UDPATE_PROFILE))
|
||||
rxBus.send(EventDismissNotification(Notification.FAILED_UPDATE_PROFILE))
|
||||
val notification = Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
result.success = true
|
||||
|
|
|
@ -48,10 +48,10 @@ class DanaRS_Packet_Basal_Get_Basal_Rate(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Basal " + String.format(Locale.ENGLISH, "%02d", index) + "h: " + danaPump.pumpProfiles!![danaPump.activeProfile][index])
|
||||
if (danaPump.basalStep != 0.01) {
|
||||
failed = true
|
||||
val notification = Notification(Notification.WRONGBASALSTEP, resourceHelper.gs(R.string.danar_setbasalstep001), Notification.URGENT)
|
||||
val notification = Notification(Notification.WRONG_BASAL_STEP, resourceHelper.gs(R.string.danar_setbasalstep001), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
} else {
|
||||
rxBus.send(EventDismissNotification(Notification.WRONGBASALSTEP))
|
||||
rxBus.send(EventDismissNotification(Notification.WRONG_BASAL_STEP))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class DanaRS_Packet_Notify_Alarm(
|
|||
aapsLogger.debug(LTag.PUMPCOMM, "Error detected: $errorString")
|
||||
return
|
||||
}
|
||||
val notification = Notification(Notification.USERMESSAGE, errorString, Notification.URGENT)
|
||||
val notification = Notification(Notification.USER_MESSAGE, errorString, Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(notification))
|
||||
nsUpload.uploadError(errorString)
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ class BLEComm @Inject internal constructor(
|
|||
private fun sendConnect() {
|
||||
val deviceName = connectDeviceName
|
||||
if (deviceName == null || deviceName == "") {
|
||||
val n = Notification(Notification.DEVICENOTPAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT)
|
||||
val n = Notification(Notification.DEVICE_NOT_PAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
return
|
||||
}
|
||||
|
@ -489,7 +489,7 @@ class BLEComm @Inject internal constructor(
|
|||
mSendQueue.clear()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror)))
|
||||
nsUpload.uploadError(resourceHelper.gs(R.string.pumperror))
|
||||
val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT)
|
||||
val n = Notification(Notification.PUMP_ERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
// response BUSY: error status
|
||||
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) {
|
||||
|
@ -502,7 +502,7 @@ class BLEComm @Inject internal constructor(
|
|||
mSendQueue.clear()
|
||||
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror)))
|
||||
sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + danaRSPlugin.mDeviceName)
|
||||
val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT)
|
||||
val n = Notification(Notification.WRONG_SERIAL_NUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT)
|
||||
rxBus.send(EventNewNotification(n))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,9 @@ import info.nightscout.androidaps.danars.comm.DanaRS_Packet
|
|||
import info.nightscout.androidaps.db.TemporaryBasal
|
||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||
import org.junit.Before
|
||||
import org.mockito.ArgumentMatchers
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
|
||||
open class DanaRSTestBase : TestBaseWithProfile() {
|
||||
|
||||
|
@ -27,6 +29,11 @@ open class DanaRSTestBase : TestBaseWithProfile() {
|
|||
|
||||
lateinit var danaPump: DanaPump
|
||||
|
||||
@Before
|
||||
fun prepare() {
|
||||
Mockito.`when`(resourceHelper.gs(ArgumentMatchers.anyInt())).thenReturn("AnyString")
|
||||
}
|
||||
|
||||
fun createArray(length: Int, fillWith: Byte): ByteArray {
|
||||
val ret = ByteArray(length)
|
||||
for (i in 0 until length) {
|
||||
|
|
|
@ -5,8 +5,11 @@ import dagger.android.HasAndroidInjector
|
|||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||
import info.nightscout.androidaps.danars.DanaRSTestBase
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.ArgumentMatchers.anyInt
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest
|
||||
import org.powermock.modules.junit4.PowerMockRunner
|
||||
|
||||
|
|
|
@ -505,7 +505,7 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
BRProfileBlock profileBlock = new BRProfile1Block();
|
||||
profileBlock.setProfileBlocks(profileBlocks);
|
||||
ParameterBlockUtil.writeConfigurationBlock(connectionService, profileBlock);
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UPDATE_PROFILE));
|
||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.success(true)
|
||||
|
@ -518,17 +518,17 @@ public class LocalInsightPlugin extends PumpPluginBase implements PumpInterface,
|
|||
}
|
||||
} catch (AppLayerErrorException e) {
|
||||
aapsLogger.info(LTag.PUMP, "Exception while setting profile: " + e.getClass().getCanonicalName() + " (" + e.getErrorCode() + ")");
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.comment(ExceptionTranslator.getString(context, e));
|
||||
} catch (InsightException e) {
|
||||
aapsLogger.info(LTag.PUMP, "Exception while setting profile: " + e.getClass().getCanonicalName());
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.comment(ExceptionTranslator.getString(context, e));
|
||||
} catch (Exception e) {
|
||||
aapsLogger.error("Exception while setting profile", e);
|
||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
Notification notification = new Notification(Notification.FAILED_UPDATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||
rxBus.send(new EventNewNotification(notification));
|
||||
result.comment(ExceptionTranslator.getString(context, e));
|
||||
}
|
||||
|
|
|
@ -299,7 +299,7 @@ public class AapsOmnipodErosManager {
|
|||
if (profile == null) {
|
||||
String note = getStringResource(R.string.omnipod_common_error_failed_to_set_profile_empty_profile);
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(note);
|
||||
}
|
||||
|
@ -312,14 +312,14 @@ public class AapsOmnipodErosManager {
|
|||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(historyEntryType, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
} catch (PrecedingCommandFailedUncertainlyException ex) {
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_basal_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(historyEntryType, errorMessage);
|
||||
|
@ -332,7 +332,7 @@ public class AapsOmnipodErosManager {
|
|||
} else {
|
||||
note = getStringResource(R.string.omnipod_eros_error_set_basal_might_have_failed_delivery_might_be_suspended);
|
||||
}
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, note, Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex);
|
||||
addFailureToHistory(historyEntryType, errorMessage);
|
||||
|
@ -350,7 +350,7 @@ public class AapsOmnipodErosManager {
|
|||
showNotification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, null);
|
||||
}
|
||||
|
||||
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||
dismissNotification(Notification.FAILED_UPDATE_PROFILE);
|
||||
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
||||
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||
|
||||
|
@ -590,7 +590,7 @@ public class AapsOmnipodErosManager {
|
|||
addSuccessToHistory(PodHistoryEntryType.SUSPEND_DELIVERY, null);
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
|
||||
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||
dismissNotification(Notification.FAILED_UPDATE_PROFILE);
|
||||
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||
|
||||
return new PumpEnactResult(injector).success(true).enacted(true);
|
||||
|
@ -603,21 +603,21 @@ public class AapsOmnipodErosManager {
|
|||
} catch (CommandFailedAfterChangingDeliveryStatusException ex) {
|
||||
createSuspendedFakeTbrIfNotExists();
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
} catch (PrecedingCommandFailedUncertainlyException ex) {
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex.getCause());
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
return new PumpEnactResult(injector).success(false).enacted(false).comment(errorMessage);
|
||||
} catch (Exception ex) {
|
||||
if (showNotifications) {
|
||||
showNotification(Notification.FAILED_UDPATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
showNotification(Notification.FAILED_UPDATE_PROFILE, getStringResource(R.string.omnipod_eros_error_set_time_failed_delivery_might_be_suspended), Notification.URGENT, R.raw.boluserror);
|
||||
}
|
||||
String errorMessage = translateException(ex);
|
||||
addFailureToHistory(PodHistoryEntryType.SET_TIME, errorMessage);
|
||||
|
@ -626,7 +626,7 @@ public class AapsOmnipodErosManager {
|
|||
|
||||
addSuccessToHistory(PodHistoryEntryType.SET_TIME, null);
|
||||
|
||||
dismissNotification(Notification.FAILED_UDPATE_PROFILE);
|
||||
dismissNotification(Notification.FAILED_UPDATE_PROFILE);
|
||||
dismissNotification(Notification.OMNIPOD_POD_SUSPENDED);
|
||||
dismissNotification(Notification.OMNIPOD_TIME_OUT_OF_SYNC);
|
||||
|
||||
|
@ -973,7 +973,7 @@ public class AapsOmnipodErosManager {
|
|||
message, //
|
||||
urgency);
|
||||
if (sound != null) {
|
||||
notification.soundId = sound;
|
||||
notification.setSoundId(sound);
|
||||
}
|
||||
sendEvent(new EventNewNotification(notification));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue