From 96f87cf913ad32db5eaa737496779ff285bbe392 Mon Sep 17 00:00:00 2001 From: MPeter <> Date: Thu, 1 Sep 2022 22:15:35 +0200 Subject: [PATCH] persist metadata in class, move validity check to isValid() function --- .../pinetime/PineTimeInstallHandler.java | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java index 42a46e06e..5cf3f2666 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java @@ -43,7 +43,8 @@ public class PineTimeInstallHandler implements InstallHandler { private static final Logger LOG = LoggerFactory.getLogger(PineTimeInstallHandler.class); private final Context context; - private boolean valid = false; + + private InfiniTimeDFUPackage dfuPackageManifest; private String version = "(Unknown version)"; public PineTimeInstallHandler(Uri uri, Context context) { @@ -71,17 +72,6 @@ public class PineTimeInstallHandler implements InstallHandler { } catch (Exception e) { LOG.error("Unknown error occurred.", e); } - - if (metadata != null && - metadata.manifest != null && - metadata.manifest.application != null && - metadata.manifest.application.bin_file != null) { - valid = true; - version = metadata.manifest.application.bin_file; - } else { - valid = false; - LOG.error("Somehow metadata was found, but some data was missing"); - } } @Override @@ -103,7 +93,7 @@ public class PineTimeInstallHandler implements InstallHandler { return; } - if (!valid) { + if (!isValid()) { LOG.error("Firmware cannot be installed (not valid)"); installActivity.setInfoText("Firmware cannot be installed (not valid)"); installActivity.setInstallEnabled(false); @@ -126,6 +116,9 @@ public class PineTimeInstallHandler implements InstallHandler { @Override public boolean isValid() { - return valid; + return dfuPackageManifest != null && + dfuPackageManifest.manifest != null && + dfuPackageManifest.manifest.application != null && + dfuPackageManifest.manifest.application.bin_file != null; } }