mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Xiaomi: Improve activity fetch logging
This commit is contained in:
parent
e6cb15d9eb
commit
376956bbe9
@ -25,17 +25,12 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
@ -137,7 +132,7 @@ public class XiaomiActivityFileFetcher {
|
||||
isFetching = true;
|
||||
final XiaomiSupport support = mHealthService.getSupport();
|
||||
final Context context = support.getContext();
|
||||
GB.updateTransferNotification(context.getString(R.string.busy_task_fetch_activity_data),"", true, 0, context);
|
||||
GB.updateTransferNotification(context.getString(R.string.busy_task_fetch_activity_data), "", true, 0, context);
|
||||
support.getDevice().setBusyTask(context.getString(R.string.busy_task_fetch_activity_data));
|
||||
support.getDevice().sendDeviceUpdateIntent(support.getContext());
|
||||
triggerNextFetch();
|
||||
@ -162,12 +157,21 @@ public class XiaomiActivityFileFetcher {
|
||||
}
|
||||
|
||||
protected void dumpBytesToExternalStorage(final XiaomiActivityFileId fileId, final byte[] bytes) {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.US);
|
||||
|
||||
try {
|
||||
final File externalFilesDir = FileUtils.getExternalFilesDir();
|
||||
final File targetDir = new File(externalFilesDir, "rawFetchOperations");
|
||||
targetDir.mkdirs();
|
||||
|
||||
final String filename = "xiaomi_" + GB.hexdump(fileId.toBytes()) + ".bin";
|
||||
final String filename = String.format(
|
||||
Locale.ROOT, "xiaomi_%s_%02X_%02X_%02X_v%d.bin",
|
||||
sdf.format(fileId.getTimestamp()),
|
||||
fileId.getTypeCode(),
|
||||
fileId.getSubtypeCode(),
|
||||
fileId.getDetailTypeCode(),
|
||||
fileId.getVersion()
|
||||
);
|
||||
|
||||
final File outputFile = new File(targetDir, filename);
|
||||
|
||||
|
@ -58,14 +58,26 @@ public class XiaomiActivityFileId {
|
||||
return Type.fromCode(type);
|
||||
}
|
||||
|
||||
public int getTypeCode() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Subtype getSubtype() {
|
||||
return Subtype.fromCode(getType(), subtype);
|
||||
}
|
||||
|
||||
public int getSubtypeCode() {
|
||||
return subtype;
|
||||
}
|
||||
|
||||
public DetailType getDetailType() {
|
||||
return DetailType.fromCode(detailType);
|
||||
}
|
||||
|
||||
public int getDetailTypeCode() {
|
||||
return detailType;
|
||||
}
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
@ -114,9 +126,9 @@ public class XiaomiActivityFileId {
|
||||
return getClass().getSimpleName() + "{" +
|
||||
"timestamp=" + DateTimeUtils.formatIso8601(timestamp) +
|
||||
", timezone=" + timezone +
|
||||
", type=" + (typeName + "(" + type + ")") +
|
||||
", subtype=" + (subtypeName + "(" + subtype + ")") +
|
||||
", detailType=" + (detailTypeName + "(" + detailType + ")") +
|
||||
", type=" + (typeName + String.format("(0x%02X)", type)) +
|
||||
", subtype=" + (subtypeName + String.format("(0x%02X)", subtype)) +
|
||||
", detailType=" + (detailTypeName + String.format("(0x%02X)", detailType)) +
|
||||
", version=" + version +
|
||||
"}";
|
||||
}
|
||||
@ -149,12 +161,12 @@ public class XiaomiActivityFileId {
|
||||
|
||||
public enum Subtype {
|
||||
UNKNOWN(Type.UNKNOWN, -1),
|
||||
ACTIVITY_DAILY(Type.ACTIVITY, 0),
|
||||
ACTIVITY_SLEEP(Type.ACTIVITY,8),
|
||||
SPORTS_OUTDOOR_RUNNING(Type.SPORTS, 1),
|
||||
SPORTS_FREESTYLE(Type.SPORTS, 8),
|
||||
SPORTS_ELLIPTICAL(Type.SPORTS, 11),
|
||||
SPORTS_OUTDOOR_CYCLING(Type.SPORTS, 23),
|
||||
ACTIVITY_DAILY(Type.ACTIVITY, 0x00),
|
||||
ACTIVITY_SLEEP(Type.ACTIVITY, 0x08),
|
||||
SPORTS_OUTDOOR_RUNNING(Type.SPORTS, 0x01),
|
||||
SPORTS_FREESTYLE(Type.SPORTS, 0x08),
|
||||
SPORTS_ELLIPTICAL(Type.SPORTS, 0x0B),
|
||||
SPORTS_OUTDOOR_CYCLING(Type.SPORTS, 0x17),
|
||||
;
|
||||
|
||||
private final Type type;
|
||||
@ -182,8 +194,8 @@ public class XiaomiActivityFileId {
|
||||
public enum DetailType {
|
||||
UNKNOWN(-1),
|
||||
DETAILS(0),
|
||||
SUMMARY(1),
|
||||
GPS_TRACK(2),
|
||||
SUMMARY(0x01),
|
||||
GPS_TRACK(0x02),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
Loading…
Reference in New Issue
Block a user