mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-02-17 21:06:48 +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();
|
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||||
for (GBDevice device : devices) {
|
for (GBDevice device : devices) {
|
||||||
if (device.getType() == DeviceType.FOSSILQHYBRID) {
|
if (device.getType() == DeviceType.FOSSILQHYBRID) {
|
||||||
String fwVersion_str = device.getFirmwareVersion();
|
String fwVersion_str = device.getFirmwareVersion2();
|
||||||
fwVersion_str = fwVersion_str.replaceFirst("^DN1\\.0\\.", "").replaceFirst
|
|
||||||
("^IV0\\.0\\.", "").replaceFirst("r\\.v.*", "");
|
|
||||||
Version fwVersion = new Version(fwVersion_str);
|
Version fwVersion = new Version(fwVersion_str);
|
||||||
if (fwVersion.compareTo(new Version("2.20")) >= 0) {
|
if (fwVersion.compareTo(new Version("2.20")) >= 0) {
|
||||||
findViewById(R.id.qhybrid_widget_add).setEnabled(false);
|
findViewById(R.id.qhybrid_widget_add).setEnabled(false);
|
||||||
|
@ -235,15 +235,6 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsFindDevice() {
|
public boolean supportsFindDevice() {
|
||||||
return true;
|
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
|
@Override
|
||||||
@ -253,7 +244,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
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[]{
|
return new int[]{
|
||||||
R.xml.devicesettings_fossilhybridhr_pre_fw20,
|
R.xml.devicesettings_fossilhybridhr_pre_fw20,
|
||||||
R.xml.devicesettings_fossilhybridhr,
|
R.xml.devicesettings_fossilhybridhr,
|
||||||
@ -306,15 +297,7 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
|
|||||||
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
List<GBDevice> devices = GBApplication.app().getDeviceManager().getSelectedDevices();
|
||||||
for (GBDevice device : devices) {
|
for (GBDevice device : devices) {
|
||||||
if (isFossilHybrid(device)) {
|
if (isFossilHybrid(device)) {
|
||||||
String firmware = device.getFirmwareVersion();
|
return new Version(device.getFirmwareVersion2());
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
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.service.serial.GBDeviceProtocol;
|
||||||
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.Version;
|
||||||
|
|
||||||
public class QHybridSupport extends QHybridBaseSupport {
|
public class QHybridSupport extends QHybridBaseSupport {
|
||||||
public static final String QHYBRID_COMMAND_CONTROL = "qhybrid_command_control";
|
public static final String QHYBRID_COMMAND_CONTROL = "qhybrid_command_control";
|
||||||
@ -756,8 +759,15 @@ public class QHybridSupport extends QHybridBaseSupport {
|
|||||||
switch (characteristic.getUuid().toString()) {
|
switch (characteristic.getUuid().toString()) {
|
||||||
case "00002a26-0000-1000-8000-00805f9b34fb": {
|
case "00002a26-0000-1000-8000-00805f9b34fb": {
|
||||||
String firmwareVersion = characteristic.getStringValue(0);
|
String firmwareVersion = characteristic.getStringValue(0);
|
||||||
|
|
||||||
gbDevice.setFirmwareVersion(firmwareVersion);
|
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 = new WatchAdapterFactory().createWatchAdapter(firmwareVersion, this);
|
||||||
this.watchAdapter.initialize();
|
this.watchAdapter.initialize();
|
||||||
showNotificationsByAllActive(false);
|
showNotificationsByAllActive(false);
|
||||||
|
@ -1749,8 +1749,6 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
|
|
||||||
boolean versionSupportsConfirmation = getCleanFWVersion().greaterOrEqualThan(new Version("2.22"));
|
boolean versionSupportsConfirmation = getCleanFWVersion().greaterOrEqualThan(new Version("2.22"));
|
||||||
|
|
||||||
versionSupportsConfirmation |= getDeviceSupport().getDevice().getModel().startsWith("VA");
|
|
||||||
|
|
||||||
if(!versionSupportsConfirmation){
|
if(!versionSupportsConfirmation){
|
||||||
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
|
GB.toast("not supported in this version", Toast.LENGTH_SHORT, GB.ERROR);
|
||||||
return;
|
return;
|
||||||
@ -1852,18 +1850,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Version getCleanFWVersion() {
|
private Version getCleanFWVersion() {
|
||||||
if(cleanFirmwareVersion != null){
|
return new Version(getDeviceSupport().getDevice().getFirmwareVersion2());
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstalledAppNameFromUUID(UUID uuid) {
|
public String getInstalledAppNameFromUUID(UUID uuid) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user