WIP: Huawei: Diving sync fixes

This commit is contained in:
Martin.JM
2025-08-15 22:10:03 +02:00
parent 4a0a437d7f
commit 18651a08e7
3 changed files with 19 additions and 11 deletions
@@ -1383,6 +1383,10 @@ public class HuaweiSupportProvider {
if (dataType == -1)
return; // Empty queue
// TODO: Properly solve TOCTOU
// To make TOCTOU window smaller, set as busy
gbDevice.setBusyTask(R.string.busy_task_fetch_activity_data, context);
if (dataType == RecordedDataTypes.TYPE_ACTIVITY) {
fetchActivityData();
} else if (dataType == RecordedDataTypes.TYPE_GPS_TRACKS) {
@@ -25,6 +25,7 @@ class HuaweiSyncState {
}
public void addActivitySyncToQueue() {
LOG.debug("Add activity type to sync queue");
if (syncQueue.contains(RecordedDataTypes.TYPE_ACTIVITY))
LOG.info("Activity type sync already queued, ignoring");
else
@@ -32,6 +33,7 @@ class HuaweiSyncState {
}
public void addWorkoutSyncToQueue() {
LOG.debug("Add workout type to sync queue");
if (syncQueue.contains(RecordedDataTypes.TYPE_GPS_TRACKS))
LOG.info("Workout type sync already queued, ignoring");
else
@@ -67,22 +67,24 @@ public class GetWorkoutSectionsRequest extends Request {
Workout.WorkoutSections.Response packet = (Workout.WorkoutSections.Response) receivedPacket;
if (packet.error != null) {
LOG.warn("Error {} occurred during workout swim segments sync. ignoring", packet.error);
if (packet.error == null) {
LOG.info("Workout {} section {}:", this.workoutNumbers.workoutNumber, this.number);
LOG.info("workoutId : {}", packet.workoutId);
LOG.info("number : {}", packet.number);
LOG.info("Block num : {}", packet.blocks.size());
LOG.info("Blocks : {}", Arrays.toString(packet.blocks.toArray()));
supportProvider.addWorkoutSectionsData(this.databaseId, packet.blocks, this.number);
} else if (packet.error == 0x0001E079) {
// We don't know why it often returns this error, but it seems to be normal, so we ignore it
LOG.warn("Error 0001E079 occurred during workout swim segments sync. This seems to be normal, so it's ignored.");
} else {
LOG.warn("Error {} occurred during workout swim segments sync. Skipping workout", packet.error);
GB.toast("Error occurred during workout sync", Toast.LENGTH_LONG, GB.WARN);
supportProvider.nextWorkoutSync(remainder, GetWorkoutSectionsRequest.this.finalizeReq);
return;
}
LOG.info("Workout {} section {}:", this.workoutNumbers.workoutNumber, this.number);
LOG.info("workoutId : {}", packet.workoutId);
LOG.info("number : {}", packet.number);
LOG.info("Block num : {}", packet.blocks.size());
LOG.info("Blocks : {}", Arrays.toString(packet.blocks.toArray()));
supportProvider.addWorkoutSectionsData(this.databaseId, packet.blocks, this.number);
if (this.workoutNumbers.sectionsCount > this.number + 1) {
GetWorkoutSectionsRequest nextRequest = new GetWorkoutSectionsRequest(
this.supportProvider,