From 3562eb69d04fa0c63769d098bcea03544f12bc29 Mon Sep 17 00:00:00 2001 From: "Martin.JM" Date: Sun, 24 Nov 2024 16:40:54 +0100 Subject: [PATCH] Huawei: Add P2P to SyncState --- .../devices/huawei/HuaweiSupportProvider.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java index a89aea5b7..9e79c0a87 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huawei/HuaweiSupportProvider.java @@ -198,6 +198,7 @@ public class HuaweiSupportProvider { private class SyncState { private boolean activitySync = false; + private boolean p2pSync = false; private boolean workoutSync = false; private int workoutGpsDownload = 0; @@ -206,6 +207,11 @@ public class HuaweiSupportProvider { updateState(); } + public void setP2pSync(boolean state) { + this.p2pSync = state; + updateState(); + } + public void setWorkoutSync(boolean state) { this.workoutSync = state; updateState(); @@ -225,7 +231,7 @@ public class HuaweiSupportProvider { } public void updateState(boolean needSync) { - if (!activitySync && !workoutSync && workoutGpsDownload == 0) { + if (!activitySync && !p2pSync && !workoutSync && workoutGpsDownload == 0) { if (getDevice().isBusy()) { getDevice().unsetBusyTask(); getDevice().sendDeviceUpdateIntent(context); @@ -1290,14 +1296,14 @@ public class HuaweiSupportProvider { } private void fetchActivityDataP2P() { - // TODO: Add sync state support for this - + syncState.setP2pSync(true); HuaweiP2PDataDictionarySyncService P2PSyncService = HuaweiP2PDataDictionarySyncService.getRegisteredInstance(huaweiP2PManager); if (P2PSyncService != null && getHuaweiCoordinator().supportsTemperature()) { P2PSyncService.sendSyncRequest(400012, new HuaweiP2PDataDictionarySyncService.DictionarySyncCallback() { @Override public void onComplete(boolean complete) { LOG.info("Sync P2P Temperature complete"); + syncState.setP2pSync(false); } }); }