mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-30 22:12:55 +01:00
Fossil Hybrid: extracted file handles to enum
This commit is contained in:
parent
be2f8aaedc
commit
f36c68b065
@ -0,0 +1,35 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file;
|
||||
|
||||
public enum FileHandle {
|
||||
OTA_FILE(0x00, 0x00),
|
||||
FONT_FILE(0x03, 0x00),
|
||||
MUSIC_INFO(0x04, 0x00),
|
||||
UI_CONTROL(0x05, 0x00),
|
||||
HAND_ACTIONS(0x06, 0x00),
|
||||
SETTINGS_BUTTONS(0x06, 0x00),
|
||||
ASSET_BACKGROUND_IMAGES(0x07, 0x00),
|
||||
ASSET_NOTIFICATION_IMAGES(0x07, 0x01),
|
||||
ASSET_TRANSLATIONS(0x07, 0x02),
|
||||
ASSET_REPLY_IMAGES(0x07, 0x03),
|
||||
CONFIGURATION(0x08, 0x00),
|
||||
NOTIFICATION_PLAY(0x09, 0x00),
|
||||
ALARMS(0x0A, 0x00),
|
||||
DEVICE_INFO(0x0b, 0x00),
|
||||
NOTIFICATION_FILTER(0x0C, 0x00),
|
||||
WATCH_PARAMETERS(0x0E, 0x00),
|
||||
LOOK_UP_TABLE(0x0f, 0x00),
|
||||
RATE(0x10, 0x00),
|
||||
REPLY_MESSAGES(0x13, 0x00),
|
||||
;
|
||||
|
||||
private byte handle, subHandle;
|
||||
|
||||
FileHandle(int handle, int subHandle) {
|
||||
this.handle = (byte) handle;
|
||||
this.subHandle = (byte) subHandle;
|
||||
}
|
||||
|
||||
public short getHandle(){
|
||||
return (short)((handle << 8) | (subHandle));
|
||||
}
|
||||
}
|
@ -23,12 +23,13 @@ import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
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.file.FilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
public class AlarmsSetRequest extends FilePutRequest {
|
||||
public AlarmsSetRequest(Alarm[] alarms, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0A00, createFileFromAlarms(alarms, isNewFormat(adapter)), isNewFormat(adapter) ? (short) 3 : (short) 2, adapter); // TODO version 3
|
||||
super(FileHandle.ALARMS, createFileFromAlarms(alarms, isNewFormat(adapter)), isNewFormat(adapter) ? (short) 3 : (short) 2, adapter); // TODO version 3
|
||||
}
|
||||
|
||||
static private boolean isNewFormat(FossilWatchAdapter adapter) {
|
||||
|
@ -21,11 +21,12 @@ import java.nio.ByteOrder;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.buttonconfig.ConfigPayload;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileGetRequest;
|
||||
|
||||
public class ButtonConfigurationGetRequest extends FileGetRequest {
|
||||
public ButtonConfigurationGetRequest(FossilWatchAdapter adapter) {
|
||||
super((short) 0x0600, adapter);
|
||||
super(FileHandle.SETTINGS_BUTTONS, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,12 +20,13 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||
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.file.FileGetRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FileLookupAndGetRequest;
|
||||
|
||||
public class ConfigurationGetRequest extends FileGetRequest {
|
||||
public ConfigurationGetRequest(FossilWatchAdapter adapter) {
|
||||
super((byte) 8, adapter);
|
||||
super(FileHandle.CONFIGURATION, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -22,6 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
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.file.FilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
@ -73,11 +74,11 @@ public class ConfigurationPutRequest extends FilePutRequest {
|
||||
}
|
||||
|
||||
public ConfigurationPutRequest(ConfigItem item, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0800, createFileContent(new ConfigItem[]{item}), adapter);
|
||||
super(FileHandle.CONFIGURATION, createFileContent(new ConfigItem[]{item}), adapter);
|
||||
}
|
||||
|
||||
public ConfigurationPutRequest(ConfigItem[] items, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0800, createFileContent(items), adapter);
|
||||
super(FileHandle.CONFIGURATION, createFileContent(items), adapter);
|
||||
}
|
||||
|
||||
private static byte[] createFileContent(ConfigItem[] items) {
|
||||
|
@ -22,6 +22,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfigur
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
||||
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.notification.NotificationFilterPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
@ -29,7 +30,7 @@ public class FileCloseAndPutRequest extends FileCloseRequest {
|
||||
FossilWatchAdapter adapter;
|
||||
byte[] data;
|
||||
|
||||
public FileCloseAndPutRequest(short fileHandle, byte[] data, FossilWatchAdapter adapter) {
|
||||
public FileCloseAndPutRequest(FileHandle fileHandle, byte[] data, FossilWatchAdapter adapter) {
|
||||
super(fileHandle);
|
||||
this.adapter = adapter;
|
||||
this.data = data;
|
||||
|
@ -22,23 +22,24 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.file.FileHandle;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.Request;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FossilRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.ResultCode;
|
||||
|
||||
public class FileCloseRequest extends FossilRequest {
|
||||
private boolean isFinished = false;
|
||||
private short handle;
|
||||
private FileHandle handle;
|
||||
|
||||
public FileCloseRequest(short fileHandle) {
|
||||
public FileCloseRequest(FileHandle fileHandle) {
|
||||
this.handle = fileHandle;
|
||||
ByteBuffer buffer = this.createBuffer();
|
||||
buffer.putShort(fileHandle);
|
||||
buffer.putShort(fileHandle.getHandle());
|
||||
|
||||
this.data = buffer.array();
|
||||
}
|
||||
|
||||
public short getHandle() {
|
||||
public FileHandle getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ public class FileCloseRequest extends FossilRequest {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(value);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
if(this.handle != buffer.getShort(1)) throw new RuntimeException("wrong response handle");
|
||||
if(this.handle.getHandle() != buffer.getShort(1)) throw new RuntimeException("wrong response handle");
|
||||
|
||||
byte status = buffer.get(3);
|
||||
|
||||
|
@ -21,6 +21,7 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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;
|
||||
|
||||
@ -38,6 +39,10 @@ public class FileDeleteRequest extends FossilRequest {
|
||||
this.data = buffer.array();
|
||||
}
|
||||
|
||||
public FileDeleteRequest(FileHandle handle){
|
||||
this(handle.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleResponse(BluetoothGattCharacteristic characteristic) {
|
||||
super.handleResponse(characteristic);
|
||||
|
@ -26,6 +26,7 @@ import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
||||
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.Request;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.FossilRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.ResultCode;
|
||||
@ -52,6 +53,10 @@ public abstract class FileGetRequest extends FossilRequest {
|
||||
.array();
|
||||
}
|
||||
|
||||
public FileGetRequest(FileHandle handle, FossilWatchAdapter adapter){
|
||||
this(handle.getHandle(), adapter);
|
||||
}
|
||||
|
||||
public FossilWatchAdapter getAdapter() {
|
||||
return adapter;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
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;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CRC32C;
|
||||
@ -37,7 +38,9 @@ public class FilePutRequest extends FossilRequest {
|
||||
|
||||
private ArrayList<byte[]> packets = new ArrayList<>();
|
||||
|
||||
private short handle, fileVersion;
|
||||
private short fileVersion;
|
||||
|
||||
private FileHandle handle;
|
||||
|
||||
private FossilWatchAdapter adapter;
|
||||
|
||||
@ -45,14 +48,14 @@ public class FilePutRequest extends FossilRequest {
|
||||
|
||||
private int fullCRC;
|
||||
|
||||
public FilePutRequest(short handle, byte[] file, short fileVersion, FossilWatchAdapter adapter) {
|
||||
this.handle = handle;
|
||||
public FilePutRequest(FileHandle fileHandle, byte[] file, short fileVersion, FossilWatchAdapter adapter) {
|
||||
this.handle = fileHandle;
|
||||
this.adapter = adapter;
|
||||
this.fileVersion = fileVersion;
|
||||
|
||||
int fileLength = file.length + 16;
|
||||
ByteBuffer buffer = this.createBuffer();
|
||||
buffer.putShort(1, handle);
|
||||
buffer.putShort(1, handle.getHandle());
|
||||
buffer.putInt(3, 0);
|
||||
buffer.putInt(7, fileLength);
|
||||
buffer.putInt(11, fileLength);
|
||||
@ -64,11 +67,11 @@ public class FilePutRequest extends FossilRequest {
|
||||
state = UploadState.INITIALIZED;
|
||||
}
|
||||
|
||||
public FilePutRequest(short handle, byte[] file, FossilWatchAdapter adapter) {
|
||||
this(handle, file, (short) 2, adapter);
|
||||
public FilePutRequest(FileHandle fileHandle, byte[] file, FossilWatchAdapter adapter) {
|
||||
this(fileHandle, file, (short) 2, adapter);
|
||||
}
|
||||
|
||||
public short getHandle() {
|
||||
public FileHandle getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -110,7 +113,7 @@ public class FilePutRequest extends FossilRequest {
|
||||
throw new RuntimeException("upload status: " + code + " (" + status + ")");
|
||||
}
|
||||
|
||||
if (handle != this.handle) {
|
||||
if (handle != this.handle.getHandle()) {
|
||||
throw new RuntimeException("wrong response handle");
|
||||
}
|
||||
|
||||
@ -122,7 +125,7 @@ public class FilePutRequest extends FossilRequest {
|
||||
ByteBuffer buffer2 = ByteBuffer.allocate(3);
|
||||
buffer2.order(ByteOrder.LITTLE_ENDIAN);
|
||||
buffer2.put((byte) 4);
|
||||
buffer2.putShort(this.handle);
|
||||
buffer2.putShort(this.handle.getHandle());
|
||||
|
||||
new TransactionBuilder("file close")
|
||||
.write(
|
||||
@ -144,7 +147,7 @@ public class FilePutRequest extends FossilRequest {
|
||||
|
||||
short handle = buffer.getShort(1);
|
||||
|
||||
if (handle != this.handle) {
|
||||
if (handle != this.handle.getHandle()) {
|
||||
onFilePut(false);
|
||||
throw new RuntimeException("wrong file closing handle");
|
||||
}
|
||||
@ -199,7 +202,7 @@ public class FilePutRequest extends FossilRequest {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(file.length + 12 + 4);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
buffer.putShort(handle);
|
||||
buffer.putShort(handle.getHandle());
|
||||
buffer.putShort(fileVersion);
|
||||
buffer.putInt(0);
|
||||
buffer.putInt(file.length);
|
||||
|
@ -21,22 +21,23 @@ import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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;
|
||||
|
||||
public class FileVerifyRequest extends FossilRequest {
|
||||
private boolean isFinished = false;
|
||||
private short handle;
|
||||
private FileHandle handle;
|
||||
|
||||
public FileVerifyRequest(short fileHandle) {
|
||||
public FileVerifyRequest(FileHandle fileHandle) {
|
||||
this.handle = fileHandle;
|
||||
ByteBuffer buffer = this.createBuffer();
|
||||
buffer.putShort(fileHandle);
|
||||
buffer.putShort(fileHandle.getHandle());
|
||||
|
||||
this.data = buffer.array();
|
||||
}
|
||||
|
||||
public short getHandle() {
|
||||
public FileHandle getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -61,7 +62,7 @@ public class FileVerifyRequest extends FossilRequest {
|
||||
ByteBuffer buffer = ByteBuffer.wrap(value);
|
||||
buffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
|
||||
if(this.handle != buffer.getShort(1)) throw new RuntimeException("wrong response handle");
|
||||
if(this.handle.getHandle() != buffer.getShort(1)) throw new RuntimeException("wrong response handle");
|
||||
|
||||
byte status = buffer.get(3);
|
||||
|
||||
|
@ -23,11 +23,12 @@ import java.util.List;
|
||||
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.file.FilePutRequest;
|
||||
|
||||
public class PlayCrazyShitRequest extends FilePutRequest {
|
||||
public PlayCrazyShitRequest(byte[] appData, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0600, createPayload(appData), adapter);
|
||||
super(FileHandle.HAND_ACTIONS, createPayload(appData), adapter);
|
||||
}
|
||||
|
||||
private static byte[] createPayload(byte[] appData) {
|
||||
|
@ -20,12 +20,13 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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.file.FileGetRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CRC32C;
|
||||
|
||||
public class NotificationFilterGetRequest extends FileGetRequest {
|
||||
public NotificationFilterGetRequest(FossilWatchAdapter adapter) {
|
||||
super((short) 0x0C00, adapter);
|
||||
super(FileHandle.NOTIFICATION_FILTER, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,17 +23,18 @@ import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationConfiguration;
|
||||
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.file.FileCloseAndPutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil.file.FilePutRequest;
|
||||
|
||||
public class NotificationFilterPutRequest extends FilePutRequest {
|
||||
public NotificationFilterPutRequest(NotificationConfiguration[] configs, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0C00, createFile(configs), adapter);
|
||||
super(FileHandle.NOTIFICATION_FILTER, createFile(configs), adapter);
|
||||
}
|
||||
|
||||
|
||||
public NotificationFilterPutRequest(ArrayList<NotificationConfiguration> configs, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0C00, createFile(configs.toArray(new NotificationConfiguration[0])), adapter);
|
||||
super(FileHandle.NOTIFICATION_FILTER, createFile(configs.toArray(new NotificationConfiguration[0])), adapter);
|
||||
}
|
||||
|
||||
private static byte[] createFile(NotificationConfiguration[] configs){
|
||||
|
@ -23,20 +23,21 @@ import java.util.Arrays;
|
||||
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.file.FilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public abstract class PlayNotificationRequest extends FilePutRequest {
|
||||
public PlayNotificationRequest(int notificationType, int flags, String packageName, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0900, createFile(notificationType, flags, packageName, packageName, packageName, getCurrentMessageId()), adapter);
|
||||
super(FileHandle.NOTIFICATION_PLAY, createFile(notificationType, flags, packageName, packageName, packageName, getCurrentMessageId()), adapter);
|
||||
}
|
||||
|
||||
public PlayNotificationRequest(int notificationType, int flags, String packageName, String sender, String message, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0900, createFile(notificationType, flags, packageName, sender, message, getCurrentMessageId()), adapter);
|
||||
super(FileHandle.NOTIFICATION_PLAY, createFile(notificationType, flags, packageName, sender, message, getCurrentMessageId()), adapter);
|
||||
}
|
||||
|
||||
public PlayNotificationRequest(int notificationType, int flags, int packageCRC, String sender, String message, int messageId, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0900, createFile(notificationType, flags, "whatever", sender, message, packageCRC, messageId), adapter);
|
||||
super(FileHandle.NOTIFICATION_PLAY, createFile(notificationType, flags, "whatever", sender, message, packageCRC, messageId), adapter);
|
||||
}
|
||||
|
||||
private static int getCurrentMessageId(){
|
||||
|
@ -6,14 +6,15 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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.file.FilePutRequest;
|
||||
|
||||
public class AssetFilePutRequest extends FilePutRequest {
|
||||
public AssetFilePutRequest(AssetFile[] files, byte subHandle, FossilWatchAdapter adapter) throws IOException {
|
||||
super((short) (0x0700 | subHandle), prepareFileData(files), adapter);
|
||||
public AssetFilePutRequest(AssetFile[] files, FileHandle handle, FossilWatchAdapter adapter) throws IOException {
|
||||
super(handle, prepareFileData(files), adapter);
|
||||
}
|
||||
public AssetFilePutRequest(AssetFile file, byte subHandle, FossilWatchAdapter adapter) {
|
||||
super((short) (0x0700 | subHandle), prepareFileData(file), adapter);
|
||||
public AssetFilePutRequest(AssetFile file, FileHandle handle, FossilWatchAdapter adapter) {
|
||||
super(handle, prepareFileData(file), adapter);
|
||||
}
|
||||
|
||||
private static byte[] prepareFileData(AssetFile[] files) throws IOException {
|
||||
|
@ -35,6 +35,7 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.fossil.FossilWatchAdapter;
|
||||
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.FossilRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CRC32C;
|
||||
|
||||
@ -64,6 +65,10 @@ public abstract class FileEncryptedGetRequest extends FossilRequest {
|
||||
.array();
|
||||
}
|
||||
|
||||
public FileEncryptedGetRequest(FileHandle handle, FossilHRWatchAdapter adapter) {
|
||||
this(handle.getHandle(), adapter);
|
||||
}
|
||||
|
||||
private void initDecryption() {
|
||||
try {
|
||||
cipher = Cipher.getInstance("AES/CTR/NoPadding");
|
||||
|
@ -10,6 +10,7 @@ import java.util.zip.CRC32;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
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;
|
||||
|
||||
public class FilePutRawRequest extends FossilRequest {
|
||||
@ -45,6 +46,10 @@ public class FilePutRawRequest extends FossilRequest {
|
||||
state = UploadState.INITIALIZED;
|
||||
}
|
||||
|
||||
public FilePutRawRequest(FileHandle handle, byte[] file, FossilWatchAdapter adapter) {
|
||||
this(handle.getHandle(), file, adapter);
|
||||
}
|
||||
|
||||
public short getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public enum ResultCode {
|
||||
UNKNOWN(-1, false),
|
||||
|
||||
// no clue what there one mean
|
||||
UNKNOWN_1(-125, true);
|
||||
UNKNOWN_1(-125, false);
|
||||
|
||||
boolean success;
|
||||
int code;
|
||||
|
@ -5,11 +5,12 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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.file.FilePutRequest;
|
||||
|
||||
public class MusicInfoSetRequest extends FilePutRequest {
|
||||
public MusicInfoSetRequest(String artist, String album, String title, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0400, createFile(artist, album, title), adapter);
|
||||
super(FileHandle.MUSIC_INFO, createFile(artist, album, title), adapter);
|
||||
}
|
||||
|
||||
private static byte[] createFile(String artist, String album, String title) {
|
||||
|
@ -6,17 +6,18 @@ import java.util.ArrayList;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.qhybrid.NotificationHRConfiguration;
|
||||
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.file.FilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public class NotificationFilterPutHRRequest extends FilePutRequest {
|
||||
public NotificationFilterPutHRRequest(NotificationHRConfiguration[] configs, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0C00, createFile(configs), adapter);
|
||||
super(FileHandle.NOTIFICATION_FILTER, createFile(configs), adapter);
|
||||
}
|
||||
|
||||
|
||||
public NotificationFilterPutHRRequest(ArrayList<NotificationHRConfiguration> configs, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0C00, createFile(configs.toArray(new NotificationHRConfiguration[0])), adapter);
|
||||
super(FileHandle.NOTIFICATION_FILTER, createFile(configs.toArray(new NotificationHRConfiguration[0])), adapter);
|
||||
}
|
||||
|
||||
private static byte[] createFile(NotificationHRConfiguration[] configs) {
|
||||
|
@ -6,21 +6,22 @@ import java.nio.ByteOrder;
|
||||
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_hr.file.AssetFile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.file.AssetFilePutRequest;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
|
||||
|
||||
public class NotificationImagePutRequest extends AssetFilePutRequest {
|
||||
private NotificationImagePutRequest(String packageName, AssetFile file, FossilWatchAdapter adapter) throws IOException {
|
||||
super(file, (byte) 0x01, adapter);
|
||||
super(file, FileHandle.ASSET_NOTIFICATION_IMAGES, adapter);
|
||||
}
|
||||
|
||||
private NotificationImagePutRequest(NotificationImage image, FossilWatchAdapter adapter) throws IOException {
|
||||
super(image, (byte) 0x01, adapter);
|
||||
super(image, FileHandle.ASSET_NOTIFICATION_IMAGES, adapter);
|
||||
}
|
||||
|
||||
public NotificationImagePutRequest(NotificationImage[] images, FossilWatchAdapter adapter) throws IOException {
|
||||
super(images, (byte) 0x01, adapter);
|
||||
super(images, FileHandle.ASSET_NOTIFICATION_IMAGES, adapter);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.fossil_hr.translation;
|
||||
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.file.FileGetRequest;
|
||||
|
||||
public abstract class TranslationsGetRequest extends FileGetRequest {
|
||||
public TranslationsGetRequest(FossilWatchAdapter adapter) {
|
||||
super((short) 0x0702, adapter);
|
||||
super(FileHandle.ASSET_TRANSLATIONS, adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,11 +4,12 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
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.file.FilePutRequest;
|
||||
|
||||
public class TranslationsPutRequest extends FilePutRequest {
|
||||
public TranslationsPutRequest(TranslationData translationData, FossilWatchAdapter adapter) {
|
||||
super((short) 0x0702, createPayload(translationData), (short) 0x0d02, adapter);
|
||||
super(FileHandle.ASSET_TRANSLATIONS, createPayload(translationData), (short) 0x0d02, adapter);
|
||||
}
|
||||
|
||||
private static byte[] createPayload(TranslationData translationData){
|
||||
|
Loading…
Reference in New Issue
Block a user