|
18 | 18 | import com.activeandroid.util.SQLiteUtils; |
19 | 19 | import com.eveningoutpost.dexdrip.GcmActivity; |
20 | 20 | import com.eveningoutpost.dexdrip.Home; |
| 21 | +import com.eveningoutpost.dexdrip.g5model.DexSessionKeeper; |
21 | 22 | import com.eveningoutpost.dexdrip.models.UserError.Log; |
22 | 23 | import com.eveningoutpost.dexdrip.R; |
23 | 24 | import com.eveningoutpost.dexdrip.services.SyncService; |
|
58 | 59 | import static com.eveningoutpost.dexdrip.models.JoH.msSince; |
59 | 60 | import static com.eveningoutpost.dexdrip.utilitymodels.Constants.HOUR_IN_MS; |
60 | 61 | import static com.eveningoutpost.dexdrip.utilitymodels.Constants.MINUTE_IN_MS; |
61 | | -import com.eveningoutpost.dexdrip.utilitymodels.Pref; |
62 | 62 | import static java.lang.StrictMath.abs; |
63 | 63 | import static com.eveningoutpost.dexdrip.models.JoH.emptyString; |
64 | 64 |
|
@@ -449,6 +449,15 @@ public static void sensorStartIfNeeded() { |
449 | 449 | } |
450 | 450 | } |
451 | 451 |
|
| 452 | + public static void sensorUpdateStartTimeIfNeeded() { |
| 453 | + val lastSensorStart = Treatments.lastEventTypeFromXdrip(Treatments.SENSOR_START_EVENT_TYPE); |
| 454 | + long localStartedAt = lastSensorStart.timestamp; // When the xDrip local session started |
| 455 | + long dexStartedAt = DexSessionKeeper.getStart(); // When the current session on the transmitter started |
| 456 | + if (dexStartedAt > 0 && !(dexStartedAt - localStartedAt < MINUTE_IN_MS * 5)) { // If the start time of the local session is more than 5 minutes older than the one on the transmitter |
| 457 | + Treatments.sensorStart(dexStartedAt, "Start time updated"); |
| 458 | + } |
| 459 | + } |
| 460 | + |
452 | 461 | private static void pushTreatmentSync(Treatments treatment) { |
453 | 462 | pushTreatmentSync(treatment, true, null); // new entry by default |
454 | 463 | } |
|
0 commit comments