mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Zepp OS: Auto-detect continuous find device
This commit is contained in:
-5
@@ -44,11 +44,6 @@ public class AmazfitActiveCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -50,11 +50,6 @@ public class AmazfitActive2Coordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_active_2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return false;
|
||||
|
||||
-5
@@ -49,11 +49,6 @@ public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_active_edge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -45,11 +45,6 @@ public class AmazfitBalanceCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_balance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -39,11 +39,6 @@ public class AmazfitBip5Coordinator extends ZeppOsCoordinator {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsGpxUploads() {
|
||||
return true;
|
||||
|
||||
-5
@@ -40,11 +40,6 @@ public class AmazfitBip5UnityCoordinator extends ZeppOsCoordinator {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsControlCenter() {
|
||||
return true;
|
||||
|
||||
-5
@@ -44,11 +44,6 @@ public class AmazfitCheetahProCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_cheetah_pro;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsControlCenter() {
|
||||
return true;
|
||||
|
||||
-5
@@ -44,11 +44,6 @@ public class AmazfitCheetahRoundCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_cheetah_round;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -38,11 +38,6 @@ public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -57,11 +57,6 @@ public class AmazfitGTR4Coordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_gtr4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsGpxUploads() {
|
||||
return true;
|
||||
|
||||
-5
@@ -50,11 +50,6 @@ public class AmazfitGTRMiniCoordinator extends ZeppOsCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsGpxUploads() {
|
||||
return true;
|
||||
|
||||
-5
@@ -39,11 +39,6 @@ public class AmazfitGTS4Coordinator extends ZeppOsCoordinator {
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsGpxUploads() {
|
||||
return true;
|
||||
|
||||
-5
@@ -51,11 +51,6 @@ public class AmazfitTRex3Coordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_trex_3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mainMenuHasMoreSection() {
|
||||
return true;
|
||||
|
||||
-5
@@ -44,11 +44,6 @@ public class AmazfitTRexUltraCoordinator extends ZeppOsCoordinator {
|
||||
return R.string.devicetype_amazfit_trex_ultra;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsGpxUploads() {
|
||||
return true;
|
||||
|
||||
+4
-4
@@ -62,6 +62,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsS
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAssistantService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsContactsService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsFindDeviceService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsLogsService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsLoyaltyCardService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsPhoneService;
|
||||
@@ -506,7 +507,7 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
|
||||
notificationTypes.add(HuamiVibrationPatternNotificationType.EVENT_REMINDER);
|
||||
}
|
||||
|
||||
if (!supportsContinuousFindDevice()) {
|
||||
if (!supportsContinuousFindDevice(device)) {
|
||||
notificationTypes.add(HuamiVibrationPatternNotificationType.FIND_BAND);
|
||||
}
|
||||
|
||||
@@ -528,9 +529,8 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
|
||||
return BONDING_STYLE_REQUIRE_KEY;
|
||||
}
|
||||
|
||||
public boolean supportsContinuousFindDevice() {
|
||||
// TODO: Auto-detect continuous find device?
|
||||
return false;
|
||||
public final boolean supportsContinuousFindDevice(final GBDevice device) {
|
||||
return ZeppOsFindDeviceService.supportsContinuousFindDevice(getPrefs(device));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+16
-2
@@ -26,6 +26,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
|
||||
|
||||
public class ZeppOsFindDeviceService extends AbstractZeppOsService {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFindDeviceService.class);
|
||||
@@ -44,6 +45,9 @@ public class ZeppOsFindDeviceService extends AbstractZeppOsService {
|
||||
public static final byte FIND_PHONE_STOP_FROM_PHONE = 0x14;
|
||||
public static final byte FIND_PHONE_MODE = 0x15;
|
||||
|
||||
public static final String PREF_VERSION = "zepp_os_find_device_version";
|
||||
private int mVersion = 0;
|
||||
|
||||
private final Handler findWatchHandler = new Handler();
|
||||
private boolean findingWatch = false;
|
||||
|
||||
@@ -67,12 +71,18 @@ public class ZeppOsFindDeviceService extends AbstractZeppOsService {
|
||||
case CMD_CAPABILITIES_RESPONSE:
|
||||
// mb7: 02:01:01
|
||||
// active2 / gtr4: 02:01:02
|
||||
if (payload.length == 3) {
|
||||
mVersion = payload[2] & 0xff;
|
||||
LOG.debug("Got find device service version={}", mVersion);
|
||||
} else {
|
||||
LOG.warn("Got unexpected find device capabilities length {}", payload.length);
|
||||
}
|
||||
break;
|
||||
case FIND_BAND_ACK:
|
||||
LOG.info("Band acknowledged find band command");
|
||||
|
||||
final boolean supportsContinuous = getCoordinator().supportsContinuousFindDevice();
|
||||
if (findingWatch && !supportsContinuous) {
|
||||
if (findingWatch && mVersion < 2) {
|
||||
// continuous find device not supported - schedule periodic
|
||||
findWatchHandler.postDelayed(() -> {
|
||||
LOG.debug("Triggering find device vibration");
|
||||
sendFindDeviceCommand(true);
|
||||
@@ -165,4 +175,8 @@ public class ZeppOsFindDeviceService extends AbstractZeppOsService {
|
||||
|
||||
write("found phone", FIND_PHONE_STOP_FROM_PHONE);
|
||||
}
|
||||
|
||||
public static boolean supportsContinuousFindDevice(final Prefs devicePrefs) {
|
||||
return devicePrefs.getInt(PREF_VERSION, 0) >= 2;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user