1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-12 00:14:04 +02:00

Fossil HR: fixed version calculation

This commit is contained in:
Daniel Dakhno 2022-08-27 01:44:41 +02:00
parent 7b836036af
commit e0e1a91dc8
2 changed files with 21 additions and 1 deletions

View File

@ -192,6 +192,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
Messenger voiceMessenger = null; Messenger voiceMessenger = null;
private Version cleanFirmwareVersion = null;
ServiceConnection voiceServiceConnection = new ServiceConnection() { ServiceConnection voiceServiceConnection = new ServiceConnection() {
@Override @Override
public void onServiceConnected(ComponentName name, IBinder service) { public void onServiceConnected(ComponentName name, IBinder service) {
@ -1850,8 +1852,18 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
} }
private Version getCleanFWVersion() { private Version getCleanFWVersion() {
if(cleanFirmwareVersion != null){
return cleanFirmwareVersion;
}
String firmware = getDeviceSupport().getDevice().getFirmwareVersion(); String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
return new Version(firmware.substring(6, 9)); 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) {

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.util; package nodomain.freeyourgadget.gadgetbridge.util;
import androidx.annotation.NonNull;
// http://stackoverflow.com/questions/198431/how-do-you-compare-two-version-strings-in-java // http://stackoverflow.com/questions/198431/how-do-you-compare-two-version-strings-in-java
public class Version implements Comparable<Version> { public class Version implements Comparable<Version> {
@ -88,4 +90,10 @@ public class Version implements Comparable<Version> {
public int hashCode() { public int hashCode() {
return version.hashCode(); return version.hashCode();
} }
@NonNull
@Override
public String toString() {
return version;
}
} }