1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-15 14:39:26 +01:00

Garmin protocol: Simplify FILE_TYPE

This commit is contained in:
José Rebelo 2024-04-13 19:30:03 +01:00 committed by Daniele Gobbetti
parent fb06a48756
commit aaa3e086d0

View File

@ -1,7 +1,5 @@
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin; package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin;
import android.util.Pair;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
public class FileType { public class FileType {
@ -37,43 +35,45 @@ public class FileType {
} }
public enum FILETYPE { //TODO: add specialized method to parse each file type to the enum? public enum FILETYPE { //TODO: add specialized method to parse each file type to the enum?
ACTIVITY(Pair.create(128, 4)), ACTIVITY(128, 4),
MONITOR(Pair.create(128, 32)), MONITOR(128, 32),
CHANGELOG(Pair.create(128, 41)), CHANGELOG(128, 41),
METRICS(Pair.create(128, 44)), METRICS(128, 44),
SLEEP(Pair.create(128, 49)), SLEEP(128, 49),
//"virtual" and/or undocumented file types //"virtual" and/or undocumented file types
DIRECTORY(Pair.create(0, 0)), DIRECTORY(0, 0),
// SETTINGS(Pair.create(128,2)), //SETTINGS(Pair.create(128,2)),
; ;
private final Pair<Integer, Integer> type; private final int type;
private final int subtype;
FILETYPE(Pair<Integer, Integer> pair) { FILETYPE(final int type, final int subtype) {
this.type = pair; this.type = type;
this.subtype = subtype;
} }
@Nullable @Nullable
public static FILETYPE fromDataTypeSubType(int dataType, int subType) { public static FILETYPE fromDataTypeSubType(int dataType, int subType) {
for (FILETYPE ft : for (FILETYPE ft :
FILETYPE.values()) { FILETYPE.values()) {
if (ft.type.first == dataType && ft.type.second == subType) if (ft.type == dataType && ft.subtype == subType)
return ft; return ft;
} }
return null; return null;
} }
public int getType() { public int getType() {
return type.first; return type;
} }
public int getSubType() { public int getSubType() {
return type.second; return subtype;
} }
public boolean isFitFile() { public boolean isFitFile() {
return type.first == 128; return type == 128;
} }
} }
} }