mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 10:05:49 +01:00
Fossil Hybrid: refactored requests to use fileHandle enum
This commit is contained in:
parent
c85e30cb07
commit
2535342ac4
@ -36,6 +36,7 @@ import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import no.nordicsemi.android.dfu.FileType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
@ -95,6 +96,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fos
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.widget.CustomWidgetElement;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.widget.Widget;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.widget.WidgetsPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.AnimationRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
@ -626,7 +628,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
syncSettings();
|
||||
|
||||
queueWrite(new VerifyPrivateKeyRequest(this.getSecretKey(), this));
|
||||
queueWrite(new FileLookupRequest((byte) 0x01, this) {
|
||||
queueWrite(new FileLookupRequest(FileHandle.ACTIVITY_FILE, this) {
|
||||
@Override
|
||||
public void handleFileLookup(final short fileHandle) {
|
||||
queueWrite(new FileEncryptedGetRequest(fileHandle, FossilHRWatchAdapter.this) {
|
||||
|
@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file;
|
||||
|
||||
public enum FileHandle {
|
||||
OTA_FILE(0x00, 0x00),
|
||||
ACTIVITY_FILE(0x01, 0x00),
|
||||
HARDWARE_LOG_FILE(0x02, 0x00),
|
||||
FONT_FILE(0x03, 0x00),
|
||||
MUSIC_INFO(0x04, 0x00),
|
||||
UI_CONTROL(0x05, 0x00),
|
||||
@ -32,4 +34,8 @@ public enum FileHandle {
|
||||
public short getHandle(){
|
||||
return (short)((handle << 8) | (subHandle));
|
||||
}
|
||||
|
||||
public byte getMajorHandle() {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,11 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
|
||||
public abstract class FileLookupAndGetRequest extends FileLookupRequest {
|
||||
public FileLookupAndGetRequest(byte fileType, FossilWatchAdapter adapter) {
|
||||
super(fileType, adapter);
|
||||
public FileLookupAndGetRequest(FileHandle fileHandle, FossilWatchAdapter adapter) {
|
||||
super(fileHandle, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -24,6 +24,7 @@ import java.util.UUID;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FossilRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.ResultCode;
|
||||
|
||||
@ -39,8 +40,8 @@ public abstract class FileLookupRequest extends FossilRequest {
|
||||
|
||||
protected boolean finished = false;
|
||||
|
||||
public FileLookupRequest(byte fileType, FossilWatchAdapter adapter) {
|
||||
this.fileType = fileType;
|
||||
public FileLookupRequest(FileHandle fileHandle, FossilWatchAdapter adapter) {
|
||||
this.fileType = fileHandle.getMajorHandle();
|
||||
this.adapter = adapter;
|
||||
|
||||
this.data =
|
||||
|
@ -8,13 +8,14 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.configuration.ConfigurationPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.FileEncryptedLookupAndGetRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class ConfigurationGetRequest extends FileEncryptedLookupAndGetRequest {
|
||||
public ConfigurationGetRequest(FossilHRWatchAdapter adapter) {
|
||||
super((byte) 0x08, adapter);
|
||||
super(FileHandle.CONFIGURATION, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -17,11 +17,12 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil_hr.FossilHRWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileLookupRequest;
|
||||
|
||||
public abstract class FileEncryptedLookupAndGetRequest extends FileLookupRequest {
|
||||
public FileEncryptedLookupAndGetRequest(byte fileType, FossilHRWatchAdapter adapter) {
|
||||
super(fileType, adapter);
|
||||
public FileEncryptedLookupAndGetRequest(FileHandle fileHandle, FossilHRWatchAdapter adapter) {
|
||||
super(fileHandle, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user