Fossil Q: Support for find device

This commit is contained in:
Arjan Schrijver
2026-04-05 14:18:10 +02:00
committed by Arjan Schrijver
parent 66f2c26c53
commit 5ceef900de
4 changed files with 30 additions and 77 deletions
@@ -73,7 +73,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.WatchAdapter;
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.adapter.WatchAdapterFactory;
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.misfit.DownloadFileRequest;
@@ -134,8 +133,6 @@ public class QHybridSupport extends QHybridBaseSupport {
private final PackageConfigHelper helper;
public volatile boolean searchDevice = false;
private long timeOffset;
private boolean useActivityHand;
@@ -62,7 +62,6 @@ public abstract class WatchAdapter {
public abstract void setHands(MoveHandsRequest.MovementConfiguration movement);
public abstract void saveCalibration();
public abstract void vibrate(PlayNotificationRequest.VibrationType vibration);
public abstract void vibrateFindMyDevicePattern();
public abstract void requestHandsControl();
public abstract void releaseHandsControl();
public abstract void setStepGoal(int stepGoal);
@@ -72,7 +71,6 @@ public abstract class WatchAdapter {
public abstract void setTimezoneOffsetMinutes(short offset);
public abstract void onInstallApp(Uri uri);
public abstract boolean supportsFindDevice();
public abstract boolean supportsExtendedVibration();
public abstract boolean supportsActivityHand();
@@ -308,30 +308,38 @@ public class FossilWatchAdapter extends WatchAdapter {
queueWrite(new PlayTextNotificationRequest(config.getPackageName(), this), false);
}
private void vibrateStartCall() {
try {
getDeviceSupport().createTransactionBuilder("vibrate call")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
(byte) 0x01, (byte) 0x04, (byte) 0x30, (byte) 0x75, (byte) 0x00, (byte) 0x00)
.queue();
} catch (Exception e) {
LOG.error("Error triggering call vibration", e);
}
}
private void vibrateEndCall() {
try {
getDeviceSupport().createTransactionBuilder("stop call vibration")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
(byte) 0x02, (byte) 0x05, (byte) 0x04)
.queue();
} catch (Exception e) {
LOG.error("Error stopping call vibration", e);
}
}
@Override
public void onSetCallState(CallSpec callSpec) {
if (callSpec.command == CallSpec.CALL_INCOMING) {
LOG.info("Incoming call, triggering vibration on watch");
try {
getDeviceSupport().createTransactionBuilder("vibrate call")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
(byte) 0x01, (byte) 0x04, (byte) 0x30, (byte) 0x75, (byte) 0x00, (byte) 0x00)
.queue();
} catch (Exception e) {
LOG.error("Error triggering call vibration", e);
}
vibrateStartCall();
} else {
LOG.info("Call ended, stopping vibration on watch");
try {
getDeviceSupport().createTransactionBuilder("stop call vibration")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
(byte) 0x02, (byte) 0x05, (byte) 0x04)
.queue();
} catch (Exception e) {
LOG.error("Error stopping call vibration", e);
}
vibrateEndCall();
}
}
@@ -434,12 +442,6 @@ public class FossilWatchAdapter extends WatchAdapter {
// queueWrite(new nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.misfit.PlayNotificationRequest(vibration, -1, -1));
}
@Override
public void vibrateFindMyDevicePattern() {
}
@Override
public void requestHandsControl() {
queueWrite(new RequestHandControlRequest(), false);
@@ -563,11 +565,6 @@ public class FossilWatchAdapter extends WatchAdapter {
}
}
@Override
public boolean supportsFindDevice() {
return false;
}
@Override
public boolean supportsExtendedVibration() {
String modelNumber = getDeviceSupport().getDevice().getModel();
@@ -793,47 +790,14 @@ public class FossilWatchAdapter extends WatchAdapter {
@Override
public void onFindDevice(boolean start) {
try {
if (!this.supportsExtendedVibration()) {
if (start) {
getDeviceSupport().createTransactionBuilder("vibrate find")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
new byte[]{(byte) 0x01, (byte) 0x04, (byte) 0x30, (byte) 0x75, (byte) 0x00, (byte) 0x00}
)
.queue();
} else {
getDeviceSupport().createTransactionBuilder("vibrate find")
.write(
UUID.fromString("3dda0005-957f-7d4a-34a6-74696673696d"),
new byte[]{(byte) 0x02, (byte) 0x05, (byte) 0x04}
)
.queue();
}
if (start) {
vibrateStartCall();
} else {
vibrateEndCall();
}
} catch (UnsupportedOperationException e) {
LOG.error("error", e);
}
if (start && getDeviceSupport().searchDevice) return;
getDeviceSupport().searchDevice = start;
if (start) {
new Thread(new Runnable() {
@Override
public void run() {
int i = 0;
while (getDeviceSupport().searchDevice) {
vibrateFindMyDevicePattern();
try {
Thread.sleep(2500);
} catch (InterruptedException e) {
LOG.error("error", e);
}
}
}
}).start();
}
}
protected void handleBackgroundCharacteristic(BluetoothGattCharacteristic characteristic, byte[] value) {
@@ -368,7 +368,6 @@ public class MisfitWatchAdapter extends WatchAdapter {
queueWrite(new PlayNotificationRequest(vibration, -1, -1));
}
@Override
public void vibrateFindMyDevicePattern() {
queueWrite(new VibrateRequest(false, (short) 4, (short) 1));
}
@@ -423,11 +422,6 @@ public class MisfitWatchAdapter extends WatchAdapter {
}
@Override
public boolean supportsFindDevice() {
return supportsExtendedVibration();
}
@Override
public boolean supportsExtendedVibration() {
String modelNumber = getDeviceSupport().getDevice().getModel();