From a7e9aa18484c283cbf6ce6ebbdc39148aa4d9d0c Mon Sep 17 00:00:00 2001 From: Jamorham Date: Sat, 8 Jul 2023 17:36:57 +0000 Subject: [PATCH] MockDataSource: add support for pre-calibration --- .../dexdrip/services/Ob1G5CollectionService.java | 8 +++++++- .../com/eveningoutpost/dexdrip/services/WixelReader.java | 3 +++ .../dexdrip/utilitymodels/VoiceCommands.java | 7 +++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java index e9f3b4f613..b23f9fe0a7 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/services/Ob1G5CollectionService.java @@ -1970,7 +1970,13 @@ public static boolean usingNativeMode() { } public static boolean onlyUsingNativeMode() { - return usingNativeMode() && !fallbackToXdripAlgorithm(); + return (usingNativeMode() && !fallbackToXdripAlgorithm()) + || usingMockPreCalibrated(); + } + + public static boolean usingMockPreCalibrated() { + return Pref.getBooleanDefaultFalse("fake_data_pre_calibrated") + && DexCollectionType.getDexCollectionType() == DexCollectionType.Mock; } public static boolean isProvidingNativeGlucoseData() { diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/services/WixelReader.java b/app/src/main/java/com/eveningoutpost/dexdrip/services/WixelReader.java index dd2c8625e0..9af3896892 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/services/WixelReader.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/services/WixelReader.java @@ -137,6 +137,9 @@ private static List readFake() { trd.CaptureDateTime = System.currentTimeMillis() - trd.RelativeTime; final List l = new ArrayList<>(); l.add(trd); + if (Ob1G5CollectionService.usingMockPreCalibrated()) { + BgReading.bgReadingInsertFromG5(trd.RawValue / 1000.0, trd.getCaptureDateTime(), "Mock"); + } return l; } diff --git a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/VoiceCommands.java b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/VoiceCommands.java index 1abefc67fc..a6bf4caba3 100644 --- a/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/VoiceCommands.java +++ b/app/src/main/java/com/eveningoutpost/dexdrip/utilitymodels/VoiceCommands.java @@ -46,6 +46,13 @@ public static void processVoiceCommand(final String allWords, final Activity mAc Pref.setString(DexCollectionType.DEX_COLLECTION_METHOD, DexCollectionType.Mock.toString()); JoH.static_toast_long("YOU ARE NOW USING FAKE DATA!!!"); MockDataSource.defaults(); + CollectionServiceStarter.restartCollectionServiceBackground(); + } else if (get_engineering_mode() && allWords.equals("fake data source automatic calibration")) { + Pref.setBoolean("fake_data_pre_calibrated", true); + JoH.static_toast_long("Fake data pre-calibration ON"); + } else if (get_engineering_mode() && allWords.equals("fake data source manual calibration")) { + Pref.setBoolean("fake_data_pre_calibrated", false); + JoH.static_toast_long("Fake data pre-calibration OFF"); } else if (get_engineering_mode() && allWords.equals("break fake data source")) { JoH.static_toast_long("Breaking fake data source"); MockDataSource.breakRaw();