From 379a6706970fa93ea0ee194f5ac288d404ba909c Mon Sep 17 00:00:00 2001 From: Jamorham Date: Sat, 26 Aug 2023 10:41:12 +0000 Subject: [PATCH] UIBased: improve non changing value handling --- .../dexdrip/services/UiBasedCollector.java | 17 +++++++++++------ .../dexdrip/services/UiBasedCollectorTest.java | 6 ++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/services/UiBasedCollector.java b/app/src/main/java/com/eveningoutpost/dexdrip/services/UiBasedCollector.java index b4daea6cf..49d448f77 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/services/UiBasedCollector.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/services/UiBasedCollector.java @@ -1,7 +1,7 @@ package com.eveningoutpost.dexdrip.services; -import static com.eveningoutpost.dexdrip.models.JoH.msSince; import static com.eveningoutpost.dexdrip.cgm.dex.ClassifierAction.lastReadingTimestamp; +import static com.eveningoutpost.dexdrip.models.JoH.msSince; import static com.eveningoutpost.dexdrip.utils.DexCollectionType.UiBased; import static com.eveningoutpost.dexdrip.utils.DexCollectionType.getDexCollectionType; import static com.eveningoutpost.dexdrip.xdrip.gs; @@ -26,22 +26,20 @@ import androidx.annotation.VisibleForTesting; import com.eveningoutpost.dexdrip.BestGlucose; +import com.eveningoutpost.dexdrip.R; import com.eveningoutpost.dexdrip.alert.Persist; +import com.eveningoutpost.dexdrip.cgm.dex.BlueTails; import com.eveningoutpost.dexdrip.models.BgReading; import com.eveningoutpost.dexdrip.models.JoH; import com.eveningoutpost.dexdrip.models.Sensor; import com.eveningoutpost.dexdrip.models.UserError; -import com.eveningoutpost.dexdrip.R; import com.eveningoutpost.dexdrip.utilitymodels.Constants; import com.eveningoutpost.dexdrip.utilitymodels.PersistentStore; import com.eveningoutpost.dexdrip.utilitymodels.Unitized; -import com.eveningoutpost.dexdrip.cgm.dex.BlueTails; import com.eveningoutpost.dexdrip.utils.DexCollectionType; import com.eveningoutpost.dexdrip.xdrip; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.regex.Matcher; @@ -334,7 +332,14 @@ private boolean isJammed(final int mgdl) { } val lastRepeat = PersistentStore.getLong(UI_BASED_STORE_LAST_REPEAT); UserError.Log.d(TAG, "Last repeat: " + lastRepeat); - return lastRepeat > 3; + return lastRepeat > jamThreshold(); + } + + private int jamThreshold() { + if (lastPackage != null) { + if (lastPackage.startsWith("com.medtronic")) return 9; + } + return 4; } private void getTextViews(final List output, final ViewGroup parent) { diff --git a/app/src/test/java/com/eveningoutpost/dexdrip/services/UiBasedCollectorTest.java b/app/src/test/java/com/eveningoutpost/dexdrip/services/UiBasedCollectorTest.java index 50461c96d..d70a03cdf 100644 --- a/app/src/test/java/com/eveningoutpost/dexdrip/services/UiBasedCollectorTest.java +++ b/app/src/test/java/com/eveningoutpost/dexdrip/services/UiBasedCollectorTest.java @@ -36,6 +36,10 @@ public void filterStringTest() { val spec2p = "5.123"; val spec3 = "≥100.123"; val spec3p = "100.123"; + val spec4 = "\u0038\u002c\u0039\u00a0\u006d\u006d\u006f\u006c\u2060\u002f\u2060\u006c\u0020"; + val spec4p = "8,9"; + val spec5 = "\u0038\u002c\u0039\u00a0\u006d\u006d\u006f\u006c\u2060\u002f\u2060\u2191\u2b06\u006c\u0020"; + val spec5p = "8,9"; assertWithMessage("null test pass through 1").that(i.filterString(spec1)).isEqualTo(spec1); assertWithMessage("null test pass through 2").that(i.filterString(spec2)).isEqualTo(spec2); assertWithMessage("null test pass through 3").that(i.filterString(spec3)).isEqualTo(spec3); @@ -43,6 +47,8 @@ public void filterStringTest() { assertWithMessage("non 1").that(i.filterString(spec1)).isEqualTo(spec1); assertWithMessage("gte 1").that(i.filterString(spec2)).isEqualTo(spec2p); assertWithMessage("lte 1").that(i.filterString(spec3)).isEqualTo(spec3p); + assertWithMessage("gc1 1").that(i.filterString(spec4)).isEqualTo(spec4p); + assertWithMessage("gc1 2").that(i.filterString(spec5)).isEqualTo(spec5p); } @Test