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