1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-13 11:17:33 +01:00

Fossil Hybrid HR: do nothing in renderWidget() on firmware 1.0.2.20 or later

It seems that newer firmwares have watchfaces which are a special kind of apps
This means that a simply specifying the layout of widget does not longer work

(At least we do not know how)

This commit fixes bluetooth communication being completely stuck when
Gadgetbridge tries to render widgets (for example when switching force
white mode or when having the notification widget enabled in settings)
This commit is contained in:
Andreas Shimokawa 2021-03-12 22:22:28 +01:00
parent ae40afb827
commit 2e67321adb

View File

@ -414,6 +414,10 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
}
private void renderWidgets() {
Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("1.0.2.20")) >= 0) {
return; // this does not work on newer firmware versions
}
Prefs prefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDeviceSupport().getDevice().getAddress()));
boolean forceWhiteBackground = prefs.getBoolean("force_white_color_scheme", false);
boolean drawCircles = prefs.getBoolean("widget_draw_circles", false);
@ -1159,12 +1163,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
String singlePressEvent = "short_press_release";
String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
if (matcher.find()) {
firmware = matcher.group(0);
Version version = new Version(firmware);
if (version.compareTo(new Version("1.0.2.19")) == -1)
Version firmwareVersion = getCleanFWVersion();
if (firmwareVersion != null && firmwareVersion.compareTo(new Version("1.0.2.19")) < 0) {
singlePressEvent = "single_click";
}
ArrayList<ButtonConfiguration> configs = new ArrayList<>(5);
@ -1180,7 +1180,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
// filter out all apps not installed on watch
ArrayList<ButtonConfiguration> availableConfigs = new ArrayList<>();
outerLoop: for (ButtonConfiguration config : configs){
outerLoop:
for (ButtonConfiguration config : configs) {
for (ApplicationInformation installedApp : installedApplications) {
if (installedApp.getAppName().equals(config.getAction())) {
availableConfigs.add(config);
@ -1200,7 +1201,8 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
GBApplication.getPrefs().getString(HRConfigActivity.CONFIG_KEY_Q_ACTIONS, "[]")
);
String[] menuItems = new String[jsonArray.length()];
for (int i = 0; i < jsonArray.length(); i++) menuItems[i] = jsonArray.getString(i);
for (int i = 0; i < jsonArray.length(); i++)
menuItems[i] = jsonArray.getString(i);
queueWrite(new CommuteConfigPutRequest(menuItems, this));
break;
}
@ -1418,4 +1420,14 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
public byte getJsonIndex() {
return jsonIndex++;
}
private Version getCleanFWVersion() {
String firmware = getDeviceSupport().getDevice().getFirmwareVersion();
Matcher matcher = Pattern.compile("[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+").matcher(firmware); // DN1.0.2.19r.v5
if (matcher.find()) {
firmware = matcher.group(0);
return new Version(firmware);
}
return null;
}
}