Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't start a new alert also if there is no reception. #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,17 @@ public void FileBasedNotifications(Context context) {
AlertPlayer.getPlayer().stopAlert(context, true, false);
return;
}
//disable alert on stale data
if(prefs.getBoolean("disable_alerts_stale_data", false)) {
int minutes = Integer.parseInt(prefs.getString("disable_alerts_stale_data_minutes", "15")) + 2;
if ((new Date().getTime()) - (60000 * minutes) - bgReading.timestamp > 0) {
Log.d(TAG, "FileBasedNotifications last recieved packet is " + ((new Date().getTime()) - bgReading.timestamp ) / 60000 + " minutes old, alerts are disabled" );
return;
}
}

Log.d(TAG, "FileBasedNotifications called bgReading.calculated_value = " + bgReading.calculated_value);

// TODO: tzachi what is the time of this last bgReading
// If the last reading does not have a sensor, or that sensor was stopped.
// or the sensor was started, but the 2 hours did not still pass? or there is no calibrations.
// In all this cases, bgReading.calculated_value should be 0.
Expand All @@ -165,15 +172,6 @@ public void FileBasedNotifications(Context context) {
if (activeBgAlert.uuid.equals(newAlert.uuid)) {
// This is the same alert. Might need to play again...

//disable alert on stale data
if(prefs.getBoolean("disable_alerts_stale_data", false)) {
int minutes = Integer.parseInt(prefs.getString("disable_alerts_stale_data_minutes", "15")) + 2;
if ((new Date().getTime()) - (60000 * minutes) - BgReading.lastNoSenssor().timestamp > 0) {
Log.d(TAG, "FileBasedNotifications : active alert found but not replaying it because more than three readings missed : " + newAlert.name);
return;
}
}

Log.d(TAG, "FileBasedNotifications we have found an active alert, checking if we need to play it " + newAlert.name);
boolean trendingToAlertEnd = trendingToAlertEnd(context, false, newAlert);
AlertPlayer.getPlayer().ClockTick(context, trendingToAlertEnd, EditAlertActivity.unitsConvert2Disp(doMgdl, bgReading.calculated_value));
Expand Down