mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-24 19:06:53 +01:00
Fossil HR: cleaned up firmware version handling
This commit is contained in:
parent
e0e1a91dc8
commit
1a472493c7
@ -173,9 +173,7 @@ public class HRConfigActivity extends AbstractGBActivity {
|
||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||
for (GBDevice device : devices) {
|
||||
if (device.getType() == DeviceType.FOSSILQHYBRID) {
|
||||
String fwVersion_str = device.getFirmwareVersion();
|
||||
fwVersion_str = fwVersion_str.replaceFirst("^DN1\\.0\\.", "").replaceFirst
|
||||
("^IV0\\.0\\.", "").replaceFirst("r\\.v.*", "");
|
||||
String fwVersion_str = device.getFirmwareVersion2();
|
||||
Version fwVersion = new Version(fwVersion_str);
|
||||
if (fwVersion.compareTo(new Version("2.20")) >= 0) {
|
||||
findViewById(R.id.qhybrid_widget_add).setEnabled(false);
|
||||
|
@ -235,15 +235,6 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
@Override
|
||||
public boolean supportsFindDevice() {
|
||||
return true;
|
||||
/*GBDevice connectedDevice = GBApplication.app().getDeviceManager().getSelectedDevice();
|
||||
if(connectedDevice == null || connectedDevice.getType() != DeviceType.FOSSILQHYBRID){
|
||||
return true;
|
||||
}
|
||||
ItemWithDetails vibration = connectedDevice.getDeviceInfo(QHybridSupport.ITEM_EXTENDED_VIBRATION_SUPPORT);
|
||||
if(vibration == null){
|
||||
return true;
|
||||
}
|
||||
return vibration.getDetails().equals("true");*/
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -253,7 +244,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||
if (isHybridHR() && getFirmwareVersion() != null && getFirmwareVersion().compareTo(new Version("2.20")) < 0) {
|
||||
if (isHybridHR() && getFirmwareVersion() != null && getFirmwareVersion().smallerThan(new Version("2.20"))) {
|
||||
return new int[]{
|
||||
R.xml.devicesettings_fossilhybridhr_pre_fw20,
|
||||
R.xml.devicesettings_fossilhybridhr,
|
||||
@ -306,15 +297,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||
for (GBDevice device : devices) {
|
||||
if (isFossilHybrid(device)) {
|
||||
String firmware = device.getFirmwareVersion();
|
||||
if (firmware != null) {
|
||||
firmware = firmware.replaceFirst("DN1\\.0\\.", "").replaceFirst("IV0\\.0\\.", "");
|
||||
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
|
||||
if (matcher.find()) {
|
||||
firmware = matcher.group(0);
|
||||
return new Version(firmware);
|
||||
}
|
||||
}
|
||||
return new Version(device.getFirmwareVersion2());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
@ -78,6 +80,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests.mis
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.Version;
|
||||
|
||||
public class QHybridSupport extends QHybridBaseSupport {
|
||||
public static final String QHYBRID_COMMAND_CONTROL = "qhybrid_command_control";
|
||||
@ -756,8 +759,15 @@ public class QHybridSupport extends QHybridBaseSupport {
|
||||
switch (characteristic.getUuid().toString()) {
|
||||
case "00002a26-0000-1000-8000-00805f9b34fb": {
|
||||
String firmwareVersion = characteristic.getStringValue(0);
|
||||
|
||||
gbDevice.setFirmwareVersion(firmwareVersion);
|
||||
|
||||
Matcher matcher = Pattern
|
||||
.compile("(?<=[A-Z]{2}[0-9]\\.[0-9]\\.)[0-9]+\\.[0-9]+")
|
||||
.matcher(firmwareVersion);
|
||||
if(matcher.find()){
|
||||
gbDevice.setFirmwareVersion2(matcher.group());
|
||||
}
|
||||
|
||||
this.watchAdapter = new WatchAdapterFactory().createWatchAdapter(firmwareVersion, this);
|
||||
this.watchAdapter.initialize();
|
||||
showNotificationsByAllActive(false);
|
||||
|
@ -1749,8 +1749,6 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
|
||||
boolean versionSupportsConfirmation = getCleanFWVersion().greaterOrEqualThan(new Version("2.22"));
|
||||
|
||||
versionSupportsConfirmation |= getDeviceSupport().getDevice().getModel().startsWith("VA");
|
||||
|
||||
if(!versionSupportsConfirmation){
|
||||
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
|
||||
return;
|
||||
@ -1852,18 +1850,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
||||
}
|
||||
|
||||
private Version getCleanFWVersion() {
|
||||
if(cleanFirmwareVersion != null){
|
||||
return cleanFirmwareVersion;
|
||||
}
|
||||
String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
|
||||
Matcher matcher = Pattern
|
||||
.compile("(?<=[A-Z]{2}[0-9]\\.[0-9]\\.)[0-9]+\\.[0-9]+")
|
||||
.matcher(firmware);
|
||||
if(!matcher.find()){
|
||||
return null;
|
||||
}
|
||||
cleanFirmwareVersion = new Version(matcher.group());
|
||||
return cleanFirmwareVersion;
|
||||
return new Version(getDeviceSupport().getDevice().getFirmwareVersion2());
|
||||
}
|
||||
|
||||
public String getInstalledAppNameFromUUID(UUID uuid) {
|
||||
|
Loading…
Reference in New Issue
Block a user