Merge branch 'staledata' into dev
This commit is contained in:
commit
34fe8d8b60
2 changed files with 24 additions and 13 deletions
|
@ -632,6 +632,13 @@ public class NSClientService extends Service {
|
||||||
if (sgv.getMills() > latestDateInReceivedData)
|
if (sgv.getMills() > latestDateInReceivedData)
|
||||||
latestDateInReceivedData = sgv.getMills();
|
latestDateInReceivedData = sgv.getMills();
|
||||||
}
|
}
|
||||||
|
// Was that sgv more less 15 mins ago ?
|
||||||
|
boolean lessThan15MinAgo = false;
|
||||||
|
if((System.currentTimeMillis()-latestDateInReceivedData)/(60 * 1000L) < 15L )
|
||||||
|
lessThan15MinAgo = true;
|
||||||
|
if(Notification.isAlarmForStaleData() && lessThan15MinAgo){
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.NSALARM));
|
||||||
|
}
|
||||||
BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
BroadcastSgvs.handleNewSgv(sgvs, MainApp.instance().getApplicationContext(), isDelta);
|
||||||
}
|
}
|
||||||
MainApp.bus().post(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData)));
|
MainApp.bus().post(new EventNSClientNewLog("LAST", DateUtil.dateAndTimeString(latestDateInReceivedData)));
|
||||||
|
|
|
@ -64,6 +64,8 @@ public class Notification {
|
||||||
|
|
||||||
public NSAlarm nsAlarm = null;
|
public NSAlarm nsAlarm = null;
|
||||||
public Integer soundId = null;
|
public Integer soundId = null;
|
||||||
|
public Notification() {
|
||||||
|
}
|
||||||
|
|
||||||
public Notification(int id, Date date, String text, int level, Date validTo) {
|
public Notification(int id, Date date, String text, int level, Date validTo) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -175,8 +177,9 @@ public class Notification {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isAlarmForStaleData() {
|
public static boolean isAlarmForStaleData(){
|
||||||
if (SP.getLong("snoozedTo", 0L) != 0L) {
|
long snoozedTo = SP.getLong("snoozedTo", 0L);
|
||||||
|
if(snoozedTo != 0L){
|
||||||
if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) {
|
if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) {
|
||||||
//log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
|
//log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
|
||||||
return false;
|
return false;
|
||||||
|
@ -189,10 +192,11 @@ public class Notification {
|
||||||
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
|
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
|
||||||
// Added for testing
|
// Added for testing
|
||||||
// bgReadingAgoMin = 20;
|
// bgReadingAgoMin = 20;
|
||||||
log.debug("bgReadingAgoMin value is:" + bgReadingAgoMin);
|
|
||||||
Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
|
|
||||||
boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts();
|
boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts();
|
||||||
log.debug("OpenAPS Alerts enabled: " + openAPSEnabledAlerts);
|
//log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin);
|
||||||
|
//log.debug("Stale alarm snoozed to: "+(System.currentTimeMillis() - snoozedTo)/60000L);
|
||||||
|
Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
|
||||||
|
//log.debug("OpenAPS Alerts enabled: "+openAPSEnabledAlerts);
|
||||||
// if no thresshold from Ns get it loccally
|
// if no thresshold from Ns get it loccally
|
||||||
if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D);
|
if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D);
|
||||||
// No threshold of OpenAPS Alarm so using the one for BG
|
// No threshold of OpenAPS Alarm so using the one for BG
|
||||||
|
|
Loading…
Reference in a new issue