From 951772626c084a2185e45f3c3f34be4f8284eb3c Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Mon, 4 Jul 2022 17:12:41 +0200 Subject: [PATCH] Fossil Hybrid HR: Show app versions --- .../appmanager/AbstractAppManagerFragment.java | 3 ++- .../gadgetbridge/devices/qhybrid/FossilAppWriter.java | 4 +++- .../gadgetbridge/devices/qhybrid/FossilFileReader.java | 4 +++- .../devices/qhybrid/HybridHRWatchfaceFactory.java | 2 +- .../gadgetbridge/service/AbstractDeviceSupport.java | 1 + .../fossil_hr/application/ApplicationsListRequest.java | 9 +++++---- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java index 43f76324e..de829d3df 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/appmanager/AbstractAppManagerFragment.java @@ -122,11 +122,12 @@ public abstract class AbstractAppManagerFragment extends Fragment { for (int i = 0; i < appCount; i++) { String appName = intent.getStringExtra("app_name" + i); String appCreator = intent.getStringExtra("app_creator" + i); + String appVersion = intent.getStringExtra("app_version" + i); UUID uuid = UUID.fromString(intent.getStringExtra("app_uuid" + i)); GBDeviceApp.Type appType = GBDeviceApp.Type.values()[intent.getIntExtra("app_type" + i, 0)]; Bitmap previewImage = getAppPreviewImage(uuid.toString()); - GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, "", appType, previewImage); + GBDeviceApp app = new GBDeviceApp(uuid, appName, appCreator, appVersion, appType, previewImage); app.setOnDevice(true); if (filterApp(app)) { appList.add(app); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java index 4917e879a..086b9c211 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilAppWriter.java @@ -47,7 +47,7 @@ public class FossilAppWriter { this.mContext = context; if (this.mContext == null) throw new AssertionError("context cannot be null"); this.version = version; - if (!this.version.matches("^[0-9]\\.[0-9]\\.[0-9]\\.[0-9]$")) throw new AssertionError("Version must be in x.x.x.x format"); + if (!this.version.matches("^[0-9]\\.[0-9]$")) throw new AssertionError("Version must be in x.x format"); this.code = code; if (this.code.size() == 0) throw new AssertionError("At least one code file InputStream must be supplied"); this.icons = icons; @@ -75,10 +75,12 @@ public class FossilAppWriter { int offsetFileEnd = offsetConfig + configData.length; ByteArrayOutputStream filePart = new ByteArrayOutputStream(); + filePart.write(0x1); // 1 = watchface, 2 = app String[] versionParts = this.version.split("\\."); for (String versionPart : versionParts) { filePart.write(Integer.valueOf(versionPart).byteValue()); } + filePart.write(0x0); filePart.write(intToLEBytes(0)); filePart.write(intToLEBytes(0)); filePart.write(intToLEBytes(offsetCode)); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilFileReader.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilFileReader.java index c8ad1bb7b..903fe5160 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilFileReader.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/FossilFileReader.java @@ -135,7 +135,9 @@ public class FossilFileReader { buf.order(ByteOrder.LITTLE_ENDIAN); buf.position(8); // skip file handle and version int fileSize = buf.getInt(); - foundVersion = (int)buf.get() + "." + (int)buf.get() + "." + (int)buf.get() + "." + (int)buf.get(); + buf.get(); // 1 = watchface, 2 = app + foundVersion = (int)buf.get() + "." + (int)buf.get(); + buf.get(); // unknown mAppKeys.put("version", foundVersion); buf.position(buf.position() + 8); // skip null bytes jerryStart = buf.getInt(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java index 6e54ae74e..463fb562e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/qhybrid/HybridHRWatchfaceFactory.java @@ -211,7 +211,7 @@ public class HybridHRWatchfaceFactory { } catch (JSONException e) { LOG.warn("Could not generate configuration", e); } - FossilAppWriter appWriter = new FossilAppWriter(context, "1.2.0.0", code, icons, layout, displayName, config); + FossilAppWriter appWriter = new FossilAppWriter(context, "1.0", code, icons, layout, displayName, config); return appWriter.getWapp(); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java index 0848c1117..6066584fa 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/AbstractDeviceSupport.java @@ -334,6 +334,7 @@ public abstract class AbstractDeviceSupport implements DeviceSupport { for (int i = 0; i < appCount; i++) { appInfoIntent.putExtra("app_name" + i, appInfoEvent.apps[i].getName()); appInfoIntent.putExtra("app_creator" + i, appInfoEvent.apps[i].getCreator()); + appInfoIntent.putExtra("app_version" + i, appInfoEvent.apps[i].getVersion()); appInfoIntent.putExtra("app_uuid" + i, appInfoEvent.apps[i].getUUID().toString()); appInfoIntent.putExtra("app_type" + i, appInfoEvent.apps[i].getType().ordinal()); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/application/ApplicationsListRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/application/ApplicationsListRequest.java index 4ee71cd21..f115b96a3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/application/ApplicationsListRequest.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/fossil_hr/application/ApplicationsListRequest.java @@ -38,10 +38,11 @@ public class ApplicationsListRequest extends FileLookupAndGetRequest{ buffer.get(); // null byte byte handle = buffer.get(); int hash = buffer.getInt(); - String version = String.format( - "%d.%d.%d.%d", - buffer.get(), buffer.get(), buffer.get(), buffer.get() - ); + buffer.get(); // unknown + int version_minor = buffer.get(); + int version_major = buffer.get(); + buffer.get(); // unknown + String version = String.format("%d.%d", version_major, version_minor); applicationInfos.add(new ApplicationInformation( name, version,