mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
WIP: Huawei: Diving sync fixes
This commit is contained in:
+4
@@ -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) {
|
||||
|
||||
+2
@@ -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
|
||||
|
||||
+13
-11
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user