From 08aebb1e5196837beaf0014db02f18e19f55bc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 18 Jun 2026 19:01:06 +0100 Subject: [PATCH] Garmin: Only trigger ExploreSync after normal sync --- .../devices/garmin/ExploreSyncHandler.java | 2 +- .../service/devices/garmin/GarminSupport.java | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/ExploreSyncHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/ExploreSyncHandler.java index fdf2a140d7..b33c107092 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/ExploreSyncHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/ExploreSyncHandler.java @@ -648,7 +648,7 @@ class ExploreSyncHandler { * timestamp, plus per-point HR samples for indoor activities. */ private void flush() throws Exception { - if (points.isEmpty()) { + if (points.isEmpty() || alreadyImported(points.get(0).getTime().getTime() / 1000L)) { // Upfront skip-check matched in absorb(). LOG.info("Historical line {}: skipped (already imported)", uuidHex); return; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java index 59537aa4a6..9b302244d7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/GarminSupport.java @@ -544,14 +544,6 @@ public class GarminSupport extends AbstractBTLESingleDeviceSupport implements IC // otherwise we might get incomplete monitor files sendOutgoingMessage("fetch recorded data", fileTransferHandler.initiateDownload()); - if (getCoordinator().supports(getDevice(), GarminCapability.EXPLORE_SYNC)) { - // Re-arm the ExploreSync historical catalog walk so any activities - // recorded since the initial connect get picked up. Watches that - // don't support the service reject our StartSyncRequest and the - // handler tears the session down on its own. - protocolBufferHandler.getExploreSyncHandler().startSession(); - } - //TODO: ask the watch to initiate the sync? Something like: // sendOutgoingMessage("set sync ready", new SystemEventMessage(SystemEventMessage.GarminSystemEventType.SYNC_READY, 0)); // sendOutgoingMessage("set foreground", new SystemEventMessage(SystemEventMessage.GarminSystemEventType.HOST_DID_ENTER_FOREGROUND, 0)); @@ -956,8 +948,17 @@ public class GarminSupport extends AbstractBTLESingleDeviceSupport implements IC } isBusyFetching = false; + // FIXME: This should probably only happen after exploresync also finishes sendOutgoingMessage("set sync complete", new SystemEventMessage(SystemEventMessage.GarminSystemEventType.SYNC_COMPLETE, 0)); + if (getCoordinator().supports(getDevice(), GarminCapability.EXPLORE_SYNC)) { + // Re-arm the ExploreSync historical catalog walk so any activities + // recorded since the initial connect get picked up. Watches that + // don't support the service reject our StartSyncRequest and the + // handler tears the session down on its own. + protocolBufferHandler.getExploreSyncHandler().startSession(); + } + return; }