1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-12 10:55:49 +01:00

Huawei: Add P2P to SyncState

This commit is contained in:
Martin.JM 2024-11-24 16:40:54 +01:00 committed by José Rebelo
parent 8bfbc07a45
commit 3562eb69d0

View File

@ -198,6 +198,7 @@ public class HuaweiSupportProvider {
private class SyncState { private class SyncState {
private boolean activitySync = false; private boolean activitySync = false;
private boolean p2pSync = false;
private boolean workoutSync = false; private boolean workoutSync = false;
private int workoutGpsDownload = 0; private int workoutGpsDownload = 0;
@ -206,6 +207,11 @@ public class HuaweiSupportProvider {
updateState(); updateState();
} }
public void setP2pSync(boolean state) {
this.p2pSync = state;
updateState();
}
public void setWorkoutSync(boolean state) { public void setWorkoutSync(boolean state) {
this.workoutSync = state; this.workoutSync = state;
updateState(); updateState();
@ -225,7 +231,7 @@ public class HuaweiSupportProvider {
} }
public void updateState(boolean needSync) { public void updateState(boolean needSync) {
if (!activitySync && !workoutSync && workoutGpsDownload == 0) { if (!activitySync && !p2pSync && !workoutSync && workoutGpsDownload == 0) {
if (getDevice().isBusy()) { if (getDevice().isBusy()) {
getDevice().unsetBusyTask(); getDevice().unsetBusyTask();
getDevice().sendDeviceUpdateIntent(context); getDevice().sendDeviceUpdateIntent(context);
@ -1290,14 +1296,14 @@ public class HuaweiSupportProvider {
} }
private void fetchActivityDataP2P() { private void fetchActivityDataP2P() {
// TODO: Add sync state support for this syncState.setP2pSync(true);
HuaweiP2PDataDictionarySyncService P2PSyncService = HuaweiP2PDataDictionarySyncService.getRegisteredInstance(huaweiP2PManager); HuaweiP2PDataDictionarySyncService P2PSyncService = HuaweiP2PDataDictionarySyncService.getRegisteredInstance(huaweiP2PManager);
if (P2PSyncService != null && getHuaweiCoordinator().supportsTemperature()) { if (P2PSyncService != null && getHuaweiCoordinator().supportsTemperature()) {
P2PSyncService.sendSyncRequest(400012, new HuaweiP2PDataDictionarySyncService.DictionarySyncCallback() { P2PSyncService.sendSyncRequest(400012, new HuaweiP2PDataDictionarySyncService.DictionarySyncCallback() {
@Override @Override
public void onComplete(boolean complete) { public void onComplete(boolean complete) {
LOG.info("Sync P2P Temperature complete"); LOG.info("Sync P2P Temperature complete");
syncState.setP2pSync(false);
} }
}); });
} }