1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-29 16:26:18 +02:00

Amazfit Bip: work around problems when syncing tracks in CEST

(#952)
This commit is contained in:
Andreas Shimokawa 2018-04-02 00:22:55 +02:00
parent 08feaf30e1
commit e19c3f7ea0
3 changed files with 20 additions and 4 deletions

View File

@ -171,6 +171,10 @@ public abstract class AbstractFetchOperation extends AbstractMiBand2Operation {
this.startTimestamp = startTimestamp;
}
protected Calendar getLastStartTimestamp() {
return startTimestamp;
}
protected void saveLastSyncTimestamp(@NonNull GregorianCalendar timestamp) {
SharedPreferences.Editor editor = GBApplication.getPrefs().getPreferences().edit();
editor.putLong(getLastSyncTimeKey(), timestamp.getTimeInMillis());

View File

@ -68,6 +68,7 @@ public class FetchSportsDetailsOperation extends AbstractFetchOperation {
LOG.info("start " + getName());
buffer = new ByteArrayOutputStream(1024);
GregorianCalendar sinceWhen = getLastSuccessfulSyncTime();
builder.write(characteristicFetch, BLETypeConversions.join(new byte[] {
MiBand2Service.COMMAND_ACTIVITY_DATA_START_DATE,
AmazfitBipService.COMMAND_ACTIVITY_DATA_TYPE_SPORTS_DETAILS},

View File

@ -27,7 +27,6 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.concurrent.TimeUnit;
@ -184,9 +183,21 @@ public class FetchSportsSummaryOperation extends AbstractFetchOperation {
LOG.error("Error mapping acivity kind: " + ex.getMessage(), ex);
}
summary.setActivityKind(activityKind);
// FIXME: should save timezone etc.
summary.setStartTime(new Date(BLETypeConversions.toUnsigned(buffer.getInt()) * 1000));
summary.setEndTime(new Date(BLETypeConversions.toUnsigned(buffer.getInt()) * 1000));
// FIXME: should honor timezone we were in at that time etc
long timestamp_start = BLETypeConversions.toUnsigned(buffer.getInt()) * 1000;
long timestamp_end = BLETypeConversions.toUnsigned(buffer.getInt()) * 1000;
// FIXME: should be done like this but seems to return crap when in DST
//summary.setStartTime(new Date(timestamp_start));
//summary.setEndTime(new Date(timestamp_end));
// FIXME ... so do it like this
long duration = timestamp_end - timestamp_start;
summary.setStartTime(new Date(getLastStartTimestamp().getTimeInMillis()));
summary.setEndTime(new Date(getLastStartTimestamp().getTimeInMillis() + duration));
int baseLongitude = buffer.getInt();
int baseLatitude = buffer.getInt();
int baseAltitude = buffer.getInt();