From 34fd18885ae60221dc1c561e2ef95f71546f4b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 1 Feb 2024 13:36:48 +0000 Subject: [PATCH] Zepp OS: Refactor firmware uploads Zepp OS 3 firmware upgrades are big (200MB+). Gadgetbridge was crashing, since the entire firmware file would be pulled into memory. This commit unifies all the logic for Zepp OS firmware handling. However, since the needed refactor was big, this commit duplicates some of the code from Huami classes, namely: - ZeppOsFirmwareUpdateOperation clones UpdateFirmwareOperation2020 - ZeppOsFwInstallHandler clones AbstractMiBandFWInstallHandler This avoids changes to older device logic and introducing regressions. Lost functionality: - Repackaging firmwares as UIHH (does not seem to be needed, and was not used anyway). Code can be recovered from this commit if needed in the future - Whitelisted firmwares by checksum (we do not have a lot of them at this point anyway) Other misc changes: - Rename ZipFile to GBZipFile not to clash with the java class Tested by updating the Amazfit GTR 4 to Zepp OS 3. --- .../devices/huami/HuamiFWHelper.java | 38 +- .../AmazfitActiveCoordinator.java | 27 +- .../amazfitactive/AmazfitActiveFWHelper.java | 44 -- .../AmazfitActiveFWInstallHandler.java | 50 -- .../AmazfitActiveEdgeCoordinator.java | 28 +- .../AmazfitActiveEdgeFWHelper.java | 44 -- .../AmazfitActiveEdgeFWInstallHandler.java | 50 -- .../AmazfitBalanceCoordinator.java | 27 +- .../AmazfitBalanceFWHelper.java | 44 -- .../AmazfitBalanceFWInstallHandler.java | 50 -- .../amazfitband7/AmazfitBand7Coordinator.java | 37 +- .../amazfitband7/AmazfitBand7FWHelper.java | 44 -- .../AmazfitBand7FWInstallHandler.java | 49 -- .../amazfitbip5/AmazfitBip5Coordinator.java | 35 +- .../amazfitbip5/AmazfitBip5FWHelper.java | 44 -- .../AmazfitBip5FWInstallHandler.java | 50 -- .../AmazfitCheetahProCoordinator.java | 37 +- .../AmazfitCheetahProFWHelper.java | 45 -- .../AmazfitCheetahProFWInstallHandler.java | 49 -- .../AmazfitCheetahRoundCoordinator.java | 33 +- .../AmazfitCheetahRoundFWHelper.java | 44 -- .../AmazfitCheetahRoundFWInstallHandler.java | 50 -- .../AmazfitCheetahSquareCoordinator.java | 35 +- .../AmazfitCheetahSquareFWHelper.java | 44 -- .../AmazfitCheetahSquareFWInstallHandler.java | 50 -- .../AmazfitFalconCoordinator.java | 33 +- .../amazfitfalcon/AmazfitFalconFWHelper.java | 44 -- .../AmazfitFalconFWInstallHandler.java | 50 -- .../amazfitgtr3/AmazfitGTR3Coordinator.java | 42 +- .../amazfitgtr3/AmazfitGTR3FWHelper.java | 44 -- .../AmazfitGTR3FWInstallHandler.java | 49 -- .../AmazfitGTR3ProCoordinator.java | 37 +- .../AmazfitGTR3ProFWHelper.java | 44 -- .../AmazfitGTR3ProFWInstallHandler.java | 49 -- .../amazfitgtr4/AmazfitGTR4Coordinator.java | 40 +- .../amazfitgtr4/AmazfitGTR4FWHelper.java | 44 -- .../AmazfitGTR4FWInstallHandler.java | 49 -- .../AmazfitGTRMiniCoordinator.java | 33 +- .../AmazfitGTRMiniFWHelper.java | 44 -- .../AmazfitGTRMiniFWInstallHandler.java | 50 -- .../amazfitgts3/AmazfitGTS3Coordinator.java | 39 +- .../amazfitgts3/AmazfitGTS3FWHelper.java | 44 -- .../AmazfitGTS3FWInstallHandler.java | 49 -- .../amazfitgts4/AmazfitGTS4Coordinator.java | 50 +- .../amazfitgts4/AmazfitGTS4FWHelper.java | 44 -- .../AmazfitGTS4FWInstallHandler.java | 49 -- .../AmazfitGTS4MiniCoordinator.java | 38 +- .../AmazfitGTS4MiniFWHelper.java | 44 -- .../AmazfitGTS4MiniFWInstallHandler.java | 49 -- .../amazfittrex2/AmazfitTRex2Coordinator.java | 37 +- .../amazfittrex2/AmazfitTRex2FWHelper.java | 44 -- .../AmazfitTRex2FWInstallHandler.java | 49 -- .../AmazfitTRexUltraCoordinator.java | 33 +- .../AmazfitTRexUltraFWHelper.java | 44 -- .../AmazfitTRexUltraFWInstallHandler.java | 50 -- .../huami/miband7/MiBand7Coordinator.java | 48 +- .../huami/miband7/MiBand7FWHelper.java | 44 -- .../miband7/MiBand7FWInstallHandler.java | 49 -- .../huami/zeppos/ZeppOsCoordinator.java | 29 +- .../devices/huami/zeppos/ZeppOsFwHelper.java | 453 +++++++++++++++++ .../pinetime/PineTimeInstallHandler.java | 6 +- .../devices/huami/AbstractHuamiOperation.java | 6 - .../devices/huami/HuamiFirmwareType.java | 46 +- .../AmazfitActiveFirmwareInfo.java | 58 --- .../amazfitactive/AmazfitActiveSupport.java | 33 -- .../AmazfitActiveEdgeFirmwareInfo.java | 58 --- .../AmazfitActiveEdgeSupport.java | 33 -- .../AmazfitBalanceFirmwareInfo.java | 58 --- .../amazfitbalance/AmazfitBalanceSupport.java | 33 -- .../AmazfitBand7FirmwareInfo.java | 57 --- .../amazfitband7/AmazfitBand7Support.java | 33 -- .../amazfitbip5/AmazfitBip5FirmwareInfo.java | 58 --- .../huami/amazfitbip5/AmazfitBip5Support.java | 33 -- .../AmazfitCheetahProFirmwareInfo.java | 58 --- .../AmazfitCheetahProSupport.java | 33 -- .../AmazfitCheetahRoundFirmwareInfo.java | 58 --- .../AmazfitCheetahRoundSupport.java | 33 -- .../AmazfitCheetahSquareFirmwareInfo.java | 58 --- .../AmazfitCheetahSquareSupport.java | 33 -- .../AmazfitFalconFirmwareInfo.java | 58 --- .../amazfitfalcon/AmazfitFalconSupport.java | 33 -- .../amazfitgtr3/AmazfitGTR3FirmwareInfo.java | 63 --- .../huami/amazfitgtr3/AmazfitGTR3Support.java | 38 -- .../AmazfitGTR3ProFirmwareInfo.java | 63 --- .../amazfitgtr3pro/AmazfitGTR3ProSupport.java | 38 -- .../amazfitgtr4/AmazfitGTR4FirmwareInfo.java | 61 --- .../huami/amazfitgtr4/AmazfitGTR4Support.java | 33 -- .../AmazfitGTRMiniFirmwareInfo.java | 58 --- .../amazfitgtrmini/AmazfitGTRMiniSupport.java | 33 -- .../amazfitgts3/AmazfitGTS3FirmwareInfo.java | 63 --- .../huami/amazfitgts3/AmazfitGTS3Support.java | 38 -- .../amazfitgts4/AmazfitGTS4FirmwareInfo.java | 58 --- .../huami/amazfitgts4/AmazfitGTS4Support.java | 33 -- .../AmazfitGTS4MiniFirmwareInfo.java | 58 --- .../AmazfitGTS4MiniSupport.java | 33 -- .../AmazfitTRex2FirmwareInfo.java | 58 --- .../amazfittrex2/AmazfitTRex2Support.java | 33 -- .../AmazfitTRexUltraFirmwareInfo.java | 58 --- .../AmazfitTRexUltraSupport.java | 33 -- .../huami/miband7/MiBand7FirmwareInfo.java | 62 --- .../devices/huami/miband7/MiBand7Support.java | 33 -- .../operations/UpdateFirmwareOperation.java | 4 +- .../UpdateFirmwareOperation2021.java | 124 ----- .../AbstractZeppOsFwInstallHandler.java | 115 ----- .../huami/zeppos/ZeppOsFirmwareInfo.java | 471 ------------------ .../huami/zeppos/ZeppOsFwInstallHandler.java | 177 +++++++ .../devices/huami/zeppos/ZeppOsSupport.java | 32 +- .../zeppos/operations/ZeppOsAgpsFile.java | 8 +- .../ZeppOsFirmwareUpdateOperation.java | 376 ++++++++++++++ .../util/{ZipFile.java => GBZipFile.java} | 12 +- .../{ZipFileTest.java => GBZipFileTest.java} | 18 +- 111 files changed, 1359 insertions(+), 4787 deletions(-) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsFwHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/{ZipFile.java => GBZipFile.java} (93%) rename app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/{ZipFileTest.java => GBZipFileTest.java} (93%) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java index b016d35dc..56db6d512 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiFWHelper.java @@ -25,7 +25,6 @@ import java.io.IOException; import androidx.annotation.NonNull; import nodomain.freeyourgadget.gadgetbridge.GBApplication; -import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo; @@ -46,42 +45,7 @@ public abstract class HuamiFWHelper extends AbstractMiBandFWHelper { @NonNull @Override public String getFirmwareKind() { - int resId = R.string.kind_invalid; - switch (getFirmwareInfo().getFirmwareType()) { - case FONT: - case FONT_LATIN: - resId = R.string.kind_font; - break; - case GPS: - resId = R.string.kind_gps; - break; - case GPS_ALMANAC: - resId = R.string.kind_gps_almanac; - break; - case GPS_CEP: - resId = R.string.kind_gps_cep; - break; - case AGPS_UIHH: - resId = R.string.kind_agps_bundle; - break; - case RES: - case RES_COMPRESSED: - resId = R.string.kind_resources; - break; - case FIRMWARE: - case FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG: - resId = R.string.kind_firmware; - break; - case WATCHFACE: - resId = R.string.kind_watchface; - break; - case APP: - resId = R.string.kind_app; - break; - case INVALID: - // fall through - } - return GBApplication.getContext().getString(resId); + return GBApplication.getContext().getString(getFirmwareInfo().getFirmwareType().getNameResId()); } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java index 0343cc397..ec2c4a32e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java @@ -16,25 +16,25 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive.AmazfitActiveSupport; public class AmazfitActiveCoordinator extends ZeppOsCoordinator { - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitActiveSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_ACTIVE_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8323328)); } @Override @@ -48,11 +48,6 @@ public class AmazfitActiveCoordinator extends ZeppOsCoordinator { return name.startsWith(HuamiConst.AMAZFIT_ACTIVE_NAME) && !name.contains("Edge"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitActiveFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java deleted file mode 100644 index 3ea7e80cf..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive.AmazfitActiveFirmwareInfo; - -public class AmazfitActiveFWHelper extends HuamiFWHelper { - public AmazfitActiveFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitActiveFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Active firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java deleted file mode 100644 index d2b06955f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitActiveFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitActiveFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_active); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitActiveFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITACTIVE; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java index 75fdab83e..b362b0aa2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java @@ -16,20 +16,15 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge.AmazfitActiveEdgeSupport; public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator { @Override @@ -37,10 +32,14 @@ public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator { return true; } - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitActiveEdgeSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_ACTIVE_EDGE_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8388864, 8388865)); } @Override @@ -53,11 +52,6 @@ public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_ACTIVE_EDGE_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitActiveEdgeFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java deleted file mode 100644 index ebadfcc7f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge.AmazfitActiveEdgeFirmwareInfo; - -public class AmazfitActiveEdgeFWHelper extends HuamiFWHelper { - public AmazfitActiveEdgeFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitActiveEdgeFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Active Edge firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java deleted file mode 100644 index dd8b61f4f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitActiveEdgeFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitActiveEdgeFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_active_edge); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitActiveEdgeFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITACTIVEEDGE; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java index 9c6796605..1a593c12b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java @@ -16,26 +16,25 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance.AmazfitBalanceSupport; public class AmazfitBalanceCoordinator extends ZeppOsCoordinator { - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitBalanceSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_BALANCE_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8519936, 8519937, 8519939)); } @Override @@ -48,10 +47,6 @@ public class AmazfitBalanceCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_BALANCE_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitBalanceFWInstallHandler(uri, context); - } @Override public boolean supportsContinuousFindDevice() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWHelper.java deleted file mode 100644 index 7c0366d0f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 Maxime Reyrolle - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance.AmazfitBalanceFirmwareInfo; - -public class AmazfitBalanceFWHelper extends HuamiFWHelper { - public AmazfitBalanceFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitBalanceFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Balance firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWInstallHandler.java deleted file mode 100644 index e7d90a0fa..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 Maxime Reyrolle - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitBalanceFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitBalanceFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_balance); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBalanceFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITBALANCE; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java index b4a86ff86..069c70ae5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7Coordinator.java @@ -16,41 +16,31 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7Support; public class AmazfitBand7Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand7Coordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_BAND7_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(252, 253, 254)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_BAND7_NAME + ".*", Pattern.CASE_INSENSITIVE); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitBand7Support.class; - } - - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitBand7FWInstallHandler(uri, context); - } @Override public boolean supportsAgpsUpdates() { @@ -68,7 +58,6 @@ public class AmazfitBand7Coordinator extends ZeppOsCoordinator { return R.string.devicetype_amazfit_band7; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_default; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java deleted file mode 100644 index 854c65130..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7FirmwareInfo; - -public class AmazfitBand7FWHelper extends HuamiFWHelper { - public AmazfitBand7FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 32; // 32.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitBand7FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not an Amazfit Band 7 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java deleted file mode 100644 index c13b5eb56..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitBand7FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitBand7FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_band7, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBand7FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITBAND7; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java index ae5353c4c..e0dbbcc7d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java @@ -16,31 +16,25 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5.AmazfitBip5Support; public class AmazfitBip5Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip5Coordinator.class); - - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitBip5Support.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_BIP5_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8454400, 8454401)); } @Override @@ -48,11 +42,6 @@ public class AmazfitBip5Coordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_BIP5_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitBip5FWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; @@ -88,13 +77,11 @@ public class AmazfitBip5Coordinator extends ZeppOsCoordinator { return true; } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_bip5; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_amazfit_bip; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java deleted file mode 100644 index e28fa4959..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5.AmazfitBip5FirmwareInfo; - -public class AmazfitBip5FWHelper extends HuamiFWHelper { - public AmazfitBip5FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitBip5FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Bip 5 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java deleted file mode 100644 index f84a647c8..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitBip5FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitBip5FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_bip5); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBip5FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITBIP5; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java index 5cabda521..1baa0da64 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java @@ -16,48 +16,37 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro.AmazfitCheetahProSupport; public class AmazfitCheetahProCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahProCoordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_CHEETAH_PRO_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8126720, 8126721)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_PRO_NAME + ".*"); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitCheetahProSupport.class; - } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_cheetah_pro; } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitCheetahProFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWHelper.java deleted file mode 100644 index 49f003ad3..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWHelper.java +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2023-2024 Raghd Hamzeh - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro.AmazfitCheetahProFirmwareInfo; - -public class AmazfitCheetahProFWHelper extends HuamiFWHelper { - public AmazfitCheetahProFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitCheetahProFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a " + DeviceType.AMAZFITCHEETAHPRO + " firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWInstallHandler.java deleted file mode 100644 index 4c48362e0..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProFWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2023-2024 Raghd Hamzeh - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitCheetahProFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitCheetahProFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_cheetah_pro, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahProFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITCHEETAHPRO; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java index 586e2c8d5..0b3ecb7b7 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java @@ -16,36 +16,30 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround.AmazfitCheetahRoundSupport; public class AmazfitCheetahRoundCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahRoundCoordinator.class); - @Override public boolean isExperimental() { return true; } - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitCheetahRoundSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(8192256, 8192257)); } @Override @@ -58,11 +52,6 @@ public class AmazfitCheetahRoundCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitCheetahRoundFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java deleted file mode 100644 index 60fc1fef7..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround.AmazfitCheetahRoundFirmwareInfo; - -public class AmazfitCheetahRoundFWHelper extends HuamiFWHelper { - public AmazfitCheetahRoundFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitCheetahRoundFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Cheetah (Round) firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java deleted file mode 100644 index dfdd0fde7..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitCheetahRoundFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitCheetahRoundFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_round); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahRoundFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITCHEETAHROUND; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java index a5ac83940..92e4faeff 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java @@ -16,36 +16,30 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareSupport; public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahSquareCoordinator.class); - @Override public boolean isExperimental() { return true; } - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitCheetahSquareSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Collections.singletonList(8257793)); } @Override @@ -53,11 +47,6 @@ public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitCheetahSquareFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; @@ -98,13 +87,11 @@ public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator { return true; } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_cheetah_square; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_amazfit_bip; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java deleted file mode 100644 index bfbc766ac..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareFirmwareInfo; - -public class AmazfitCheetahSquareFWHelper extends HuamiFWHelper { - public AmazfitCheetahSquareFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitCheetahSquareFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Cheetah (Square) firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java deleted file mode 100644 index 42b1ae4b7..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitCheetahSquareFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitCheetahSquareFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_square); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahSquareFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITCHEETAHSQUARE; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java index 2f7ea3d83..806e63eb0 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java @@ -16,36 +16,30 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon.AmazfitFalconSupport; public class AmazfitFalconCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitFalconCoordinator.class); - @Override public boolean isExperimental() { return true; } - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitFalconSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_FALCON_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(414, 415)); } @Override @@ -58,11 +52,6 @@ public class AmazfitFalconCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_FALCON_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitFalconFWInstallHandler(uri, context); - } - @Override public boolean sendAgpsAsFileTransfer() { return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java deleted file mode 100644 index 63af00b33..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon.AmazfitFalconFirmwareInfo; - -public class AmazfitFalconFWHelper extends HuamiFWHelper { - public AmazfitFalconFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitFalconFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit Falcon firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java deleted file mode 100644 index 24c15a53c..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitFalconFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitFalconFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_falcon); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitFalconFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITFALCON; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3Coordinator.java index 8d4f7a05c..ebb44282b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3Coordinator.java @@ -16,45 +16,34 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3; -import android.content.Context; -import android.net.Uri; - import androidx.annotation.NonNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3Support; public class AmazfitGTR3Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3Coordinator.class); - - @NonNull @Override - public boolean supports(final GBDeviceCandidate candidate) { - try { - final String name = candidate.getName(); - if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR3_NAME) && !name.contains("Pro")) { - return true; - } - } catch (final Exception e) { - LOG.error("unable to check device support", e); - } + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTR3_NAME; + } - return false; + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(226, 227)); } @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitGTR3Support.class; + public boolean supports(final GBDeviceCandidate candidate) { + final String name = candidate.getName(); + return name.startsWith(HuamiConst.AMAZFIT_GTR3_NAME) && !name.contains("Pro"); } @Override @@ -62,11 +51,6 @@ public class AmazfitGTR3Coordinator extends ZeppOsCoordinator { return R.string.devicetype_amazfit_gtr3; } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR3FWInstallHandler(uri, context); - } - @Override public boolean sendAgpsAsFileTransfer() { return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java deleted file mode 100644 index 507c81549..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, thermatk - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3FirmwareInfo; - -public class AmazfitGTR3FWHelper extends HuamiFWHelper { - public AmazfitGTR3FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTR3FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTR 3 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java deleted file mode 100644 index fc9afaa48..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, thermatk - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTR3FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTR3FWInstallHandler(Uri uri, Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr3, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTR3FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTR3; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProCoordinator.java index f187d071a..002ca0a11 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProCoordinator.java @@ -16,48 +16,37 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro.AmazfitGTR3ProSupport; public class AmazfitGTR3ProCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTR3_PRO_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(229, 230, 6095106)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_GTR3_PRO_NAME + ".*"); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitGTR3ProSupport.class; - } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_gtr3_pro; } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR3ProFWInstallHandler(uri, context); - } - @Override public boolean sendAgpsAsFileTransfer() { return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java deleted file mode 100644 index e767e36eb..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro.AmazfitGTR3ProFirmwareInfo; - -public class AmazfitGTR3ProFWHelper extends HuamiFWHelper { - public AmazfitGTR3ProFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTR3ProFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTR 3 Pro firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java deleted file mode 100644 index 9bae5d5a4..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTR3ProFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTR3ProFWInstallHandler(Uri uri, Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr3_pro, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTR3ProFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTR3PRO; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4Coordinator.java index f800bd5e4..3409dc741 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4Coordinator.java @@ -16,36 +16,45 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4Support; public class AmazfitGTR4Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTR4_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(7930112, 7930113, 7864577)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_GTR4_NAME + ".*"); } - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitGTR4Support.class; + protected Map getCrcMap() { + return new HashMap() {{ + // firmware + put(1699, "3.17.0.2"); + put(20712, "3.18.1.1 (diff from 3.17.0.2)"); + put(49685, "3.23.3.1 (diff from 3.21.0.1)"); + }}; } @Override @@ -53,11 +62,6 @@ public class AmazfitGTR4Coordinator extends ZeppOsCoordinator { return R.string.devicetype_amazfit_gtr4; } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR4FWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java deleted file mode 100644 index 0c1952524..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4FirmwareInfo; - -public class AmazfitGTR4FWHelper extends HuamiFWHelper { - public AmazfitGTR4FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTR4FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTR 4 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java deleted file mode 100644 index 1d5fff622..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTR4FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTR4FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr4, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTR4FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTR4; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java index 0c32cbfba..dd5e7a0d2 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java @@ -16,31 +16,25 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini.AmazfitGTRMiniSupport; public class AmazfitGTRMiniCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTRMiniCoordinator.class); - - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitGTRMiniSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTR_MINI_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(250, 251)); } @Override @@ -53,11 +47,6 @@ public class AmazfitGTRMiniCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_GTR_MINI_NAME + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTRMiniFWInstallHandler(uri, context); - } - @Override public boolean sendAgpsAsFileTransfer() { // Even though it's a Zepp OS 2.0 device, it doesn't seem to support the AGPS service diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java deleted file mode 100644 index d21a0d645..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini.AmazfitGTRMiniFirmwareInfo; - -public class AmazfitGTRMiniFWHelper extends HuamiFWHelper { - public AmazfitGTRMiniFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTRMiniFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTR Mini firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java deleted file mode 100644 index 87b6d4c56..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTRMiniFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTRMiniFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_gtr_mini); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTRMiniFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTRMINI; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3Coordinator.java index b5a7d3563..e10eee737 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3Coordinator.java @@ -16,43 +16,32 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3Support; public class AmazfitGTS3Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTS3_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(224, 225)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_GTS3_NAME + ".*"); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitGTS3Support.class; - } - - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS3FWInstallHandler(uri, context); - } - @Override public boolean sendAgpsAsFileTransfer() { return false; @@ -63,13 +52,11 @@ public class AmazfitGTS3Coordinator extends ZeppOsCoordinator { return false; } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_gts3; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_amazfit_bip; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java deleted file mode 100644 index 1e3cdcc45..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, sedy89 - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3FirmwareInfo; - -public class AmazfitGTS3FWHelper extends HuamiFWHelper { - public AmazfitGTS3FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTS3FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTS 3 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java deleted file mode 100644 index 32ec2d7be..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, sedy89 - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTS3FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTS3FWInstallHandler(Uri uri, Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts3, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTS3FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTS3; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java index ea68f513d..a6e34e0db 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java @@ -16,49 +16,31 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4Support; public class AmazfitGTS4Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4Coordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTS4_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(7995648, 7995649)); + } @Override public boolean supports(final GBDeviceCandidate candidate) { - try { - final String name = candidate.getName(); - if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTS4_NAME) && !name.contains("Mini")) { - return true; - } - } catch (final Exception e) { - LOG.error("unable to check device support", e); - } - - return false; - } - - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitGTS4Support.class; - } - - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS4FWInstallHandler(uri, context); + final String name = candidate.getName(); + return name.startsWith(HuamiConst.AMAZFIT_GTS4_NAME) && !name.contains("Mini"); } @Override @@ -96,13 +78,11 @@ public class AmazfitGTS4Coordinator extends ZeppOsCoordinator { return true; } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_gts4; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_amazfit_bip; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java deleted file mode 100644 index 46e2357ac..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4FirmwareInfo; - -public class AmazfitGTS4FWHelper extends HuamiFWHelper { - public AmazfitGTS4FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTS4FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTS 4 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java deleted file mode 100644 index 2495cc7c0..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTS4FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTS4FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts4, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTS4FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTS4; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniCoordinator.java index f0f533560..f8be8dcc6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniCoordinator.java @@ -16,42 +16,32 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniSupport; public class AmazfitGTS4MiniCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_GTS4_MINI_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(246, 247)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_GTS4_MINI_NAME + ".*"); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitGTS4MiniSupport.class; - } - - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS4MiniFWInstallHandler(uri, context); - } @Override public boolean sendAgpsAsFileTransfer() { @@ -63,13 +53,11 @@ public class AmazfitGTS4MiniCoordinator extends ZeppOsCoordinator { return false; } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_gts4_mini; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_amazfit_bip; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java deleted file mode 100644 index 321f03998..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniFirmwareInfo; - -public class AmazfitGTS4MiniFWHelper extends HuamiFWHelper { - public AmazfitGTS4MiniFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitGTS4MiniFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit GTS 4 Mini firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java deleted file mode 100644 index 13ab4d237..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitGTS4MiniFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitGTS4MiniFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts4_mini, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTS4MiniFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITGTS4MINI; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2Coordinator.java index 568feae10..b414d9321 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2Coordinator.java @@ -16,48 +16,37 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.AmazfitTRex2Support; public class AmazfitTRex2Coordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class); + @Override + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_TREX_2_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(418, 419)); + } @Override protected Pattern getSupportedDeviceName() { return Pattern.compile(HuamiConst.AMAZFIT_TREX_2_NAME + ".*"); } - @NonNull - @Override - public Class getDeviceSupportClass() { - return AmazfitTRex2Support.class; - } - @Override public int getDeviceNameResource() { return R.string.devicetype_amazfit_trex_2; } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitTRex2FWInstallHandler(uri, context); - } - @Override public boolean supportsControlCenter() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java deleted file mode 100644 index cc9a29a02..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.AmazfitTRex2FirmwareInfo; - -public class AmazfitTRex2FWHelper extends HuamiFWHelper { - public AmazfitTRex2FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitTRex2FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit T-Rex 2 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java deleted file mode 100644 index d721d99d2..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitTRex2FWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitTRex2FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_amazfit_trex2, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitTRex2FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITTREX2; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java index c8c09a379..8a3e6758d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java @@ -16,31 +16,25 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra.AmazfitTRexUltraSupport; public class AmazfitTRexUltraCoordinator extends ZeppOsCoordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexUltraCoordinator.class); - - @NonNull @Override - public Class getDeviceSupportClass() { - return AmazfitTRexUltraSupport.class; + public String getDeviceBluetoothName() { + return HuamiConst.AMAZFIT_TREX_ULTRA; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(6553856, 6553857)); } @Override @@ -53,11 +47,6 @@ public class AmazfitTRexUltraCoordinator extends ZeppOsCoordinator { return Pattern.compile(HuamiConst.AMAZFIT_TREX_ULTRA + ".*"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitTRexUltraFWInstallHandler(uri, context); - } - @Override public boolean supportsContinuousFindDevice() { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java deleted file mode 100644 index ca02e43a0..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra.AmazfitTRexUltraFirmwareInfo; - -public class AmazfitTRexUltraFWHelper extends HuamiFWHelper { - public AmazfitTRexUltraFWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 128; // 128.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new AmazfitTRexUltraFirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Amazfit T-Rex Ultra firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java deleted file mode 100644 index 52754ba2d..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class AmazfitTRexUltraFWInstallHandler extends AbstractZeppOsFwInstallHandler { - AmazfitTRexUltraFWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - final String deviceName = mContext.getString(R.string.devicetype_amazfit_trex_ultra); - return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); - } - - @Override - protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitTRexUltraFWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(final GBDevice device) { - return device.getType() == DeviceType.AMAZFITTREXULTRA; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java index cf6f43463..c6a907dc4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java @@ -16,32 +16,46 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7; -import android.content.Context; -import android.net.Uri; - -import androidx.annotation.NonNull; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; -import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7Support; public class MiBand7Coordinator extends ZeppOsCoordinator { + @Override + public String getDeviceBluetoothName() { + return HuamiConst.XIAOMI_SMART_BAND7_NAME; + } + + @Override + public Set getDeviceSources() { + return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265)); + } + + @Override + protected Map getCrcMap() { + return new HashMap() {{ + // firmware + put(26036, "1.20.3.1"); + put(55449, "1.27.0.4"); + put(14502, "2.0.0.2"); + put(25658, "2.1.0.1"); + }}; + } + @Override public boolean supports(final GBDeviceCandidate candidate) { final String name = candidate.getName(); return name.startsWith(HuamiConst.XIAOMI_SMART_BAND7_NAME) && !name.contains("Pro"); } - @Override - public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new MiBand7FWInstallHandler(uri, context); - } - @Override public boolean supportsAgpsUpdates() { return false; @@ -52,24 +66,16 @@ public class MiBand7Coordinator extends ZeppOsCoordinator { return false; } - @NonNull - @Override - public Class getDeviceSupportClass() { - return MiBand7Support.class; - } - @Override public boolean supportsBluetoothPhoneCalls(final GBDevice device) { return false; } - @Override public int getDeviceNameResource() { return R.string.devicetype_miband7; } - @Override public int getDefaultIconResource() { return R.drawable.ic_device_miband6; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java deleted file mode 100644 index 28cbe32d5..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7FirmwareInfo; - -public class MiBand7FWHelper extends HuamiFWHelper { - public MiBand7FWHelper(final Uri uri, final Context context) throws IOException { - super(uri, context); - } - - @Override - public long getMaxExpectedFileSize() { - return 1024 * 1024 * 32; // 32.0MB - } - - @Override - protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { - firmwareInfo = new MiBand7FirmwareInfo(wholeFirmwareBytes); - if (!firmwareInfo.isHeaderValid()) { - throw new IllegalArgumentException("Not a Xiaomi Smart Band 7 firmware"); - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java deleted file mode 100644 index bdf67e957..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; - -class MiBand7FWInstallHandler extends AbstractZeppOsFwInstallHandler { - MiBand7FWInstallHandler(Uri uri, Context context) { - super(uri, context); - } - - @Override - protected String getFwUpgradeNotice() { - return mContext.getString(R.string.fw_upgrade_notice_miband7, helper.getHumanFirmwareVersion()); - } - - @Override - protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException { - return new MiBand7FWHelper(uri, context); - } - - @Override - protected boolean isSupportedDeviceType(GBDevice device) { - return device.getType() == DeviceType.MIBAND7; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsCoordinator.java index 0077cb81c..fadacce2a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsCoordinator.java @@ -28,7 +28,10 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.Set; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity; @@ -54,7 +57,9 @@ import nodomain.freeyourgadget.gadgetbridge.entities.HuamiSpo2SampleDao; import nodomain.freeyourgadget.gadgetbridge.entities.HuamiStressSampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryParser; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler; +import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFwInstallHandler; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAlexaService; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsContactsService; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsLogsService; @@ -69,7 +74,20 @@ import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; public abstract class ZeppOsCoordinator extends HuamiCoordinator { - public abstract AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context); + public abstract String getDeviceBluetoothName(); + + public abstract Set getDeviceSources(); + + protected Map getCrcMap() { + // A map from CRC16 to human-readable version for flashable files + return Collections.emptyMap(); + } + + @NonNull + @Override + public final Class getDeviceSupportClass() { + return ZeppOsSupport.class; + } @Override public InstallHandler findInstallHandler(final Uri uri, final Context context) { @@ -87,7 +105,12 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator { } } - final AbstractZeppOsFwInstallHandler handler = createFwInstallHandler(uri, context); + final ZeppOsFwInstallHandler handler = new ZeppOsFwInstallHandler( + uri, + context, + getDeviceBluetoothName(), + getDeviceSources() + ); return handler.isValid() ? handler : null; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsFwHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsFwHelper.java new file mode 100644 index 000000000..ff98ee073 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/zeppos/ZeppOsFwHelper.java @@ -0,0 +1,453 @@ +/* Copyright (C) 2024 José Rebelo + + This file is part of Gadgetbridge. + + Gadgetbridge is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Gadgetbridge is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ +package nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.net.Uri; + +import androidx.annotation.Nullable; + +import org.json.JSONArray; +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Set; +import java.util.UUID; +import java.util.zip.CRC32; +import java.util.zip.ZipEntry; +import java.util.zip.ZipException; +import java.util.zip.ZipFile; + +import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; +import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil; +import nodomain.freeyourgadget.gadgetbridge.util.CheckSums; +import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile; +import nodomain.freeyourgadget.gadgetbridge.util.UriHelper; + +public class ZeppOsFwHelper { + private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFwHelper.class); + + private final Uri uri; + private final Context context; + private final String deviceName; + private final Set deviceSources; + + private HuamiFirmwareType firmwareType = HuamiFirmwareType.INVALID; + private File file = null; + private int crc32; + private String version = "Unknown"; + private GBDeviceApp gbDeviceApp = null; + + public ZeppOsFwHelper(final Uri uri, final Context context, final String deviceName, final Set deviceSources) { + this.uri = uri; + this.context = context; + this.deviceName = deviceName; + this.deviceSources = deviceSources; + + processUri(); + } + + public HuamiFirmwareType getFirmwareType() { + return firmwareType; + } + + public String getFirmwareVersion() { + return version; + } + + public File getFile() { + if (file == null) { + throw new IllegalStateException("file is null"); + } + + return file; + } + + public int getSize() { + if (file == null) { + throw new IllegalStateException("file is null"); + } + + return (int) file.length(); + } + + public int getCrc32() { + return crc32; + } + + private void processUri() { + // Copy file to cache first + final File cacheDir = context.getCacheDir(); + final File zpkCacheDir = new File(cacheDir, "zeppos"); + zpkCacheDir.mkdir(); + + try { + file = File.createTempFile("fwhelper","bin", context.getCacheDir()); + file.deleteOnExit(); + } catch (final IOException e) { + LOG.error("Failed to create temp file for zpk", e); + return; + } + + final UriHelper uriHelper; + try { + uriHelper = UriHelper.get(uri, context); + } catch (final IOException e) { + LOG.error("Failed to get uri helper", e); + return; + } + + final CRC32 crc = new CRC32(); + try (FileOutputStream outputStream = new FileOutputStream(file); + InputStream inputStream = uriHelper.openInputStream()) { + final byte[] buffer = new byte[64 * 1024]; + int len; + while ((len = inputStream.read(buffer)) != -1) { + outputStream.write(buffer, 0, len); + crc.update(buffer, 0, len); + } + crc32 = (int) crc.getValue(); + } catch (final IOException e) { + LOG.error("Failed to write bytes to temporary file", e); + return; + } + + try (ZipFile zipFile = new ZipFile(file, java.util.zip.ZipFile.OPEN_READ)) { + processZipFile(zipFile); + } catch (final ZipException e) { + LOG.warn("{} is not a valid zip file", uri, e); + } catch (final IOException e) { + LOG.warn("Error while processing {}", uri, e); + } + + // TODO process as UIHH + } + + private void processZipFile(final ZipFile zipFile) { + // Attempt to handle as a firmware + final byte[] firmwareBin = getFileFromZip(zipFile, "META/firmware.bin"); + if (firmwareBin != null) { + if (isCompatibleFirmwareBin(firmwareBin)) { + firmwareType = HuamiFirmwareType.FIRMWARE; + final JSONObject fwInfoRoot = getJson(zipFile, "META/fw_info"); + if (fwInfoRoot != null) { + final JSONArray fwInfoArr = fwInfoRoot.optJSONArray("fw_info"); + if (fwInfoArr != null) { + for (int i = 0; i < fwInfoArr.length(); i++) { + final JSONObject fwInfo = fwInfoArr.optJSONObject(i); + if (fwInfo == null) { + continue; + } + + if ("firmware".equals(fwInfo.optString("name"))) { + version = fwInfo.optString("version"); + break; + } + } + } + } else { + version = getFirmwareVersion(firmwareBin); + } + } else { + firmwareType = HuamiFirmwareType.INVALID; + } + + return; + } + + // Attempt to handle as an app / watchface + final JSONObject appJson = getJson(zipFile, "app.json"); + if (appJson != null) { + final int appId; + final String appName; + final String appVersion; + final String appType; + final String appCreator; + final String appIconPath; + final JSONObject appJsonApp; + try { + appJsonApp = appJson.getJSONObject("app"); + appId = appJsonApp.getInt("appId"); + appName = appJsonApp.getString("appName"); + appVersion = appJsonApp.getJSONObject("version").getString("name"); + appType = appJsonApp.getString("appType"); + appCreator = appJsonApp.getString("vender"); + appIconPath = appJsonApp.getString("icon"); + } catch (final Exception e) { + LOG.error("Failed to get appType from app.json", e); + firmwareType = HuamiFirmwareType.INVALID; + return; + } + + final GBDeviceApp.Type gbDeviceAppType; + switch (appType) { + case "watchface": + firmwareType = HuamiFirmwareType.WATCHFACE; + gbDeviceAppType = GBDeviceApp.Type.WATCHFACE; + version = String.format("%s (watchface)", appName); + break; + case "app": + firmwareType = HuamiFirmwareType.APP; + gbDeviceAppType = GBDeviceApp.Type.APP_GENERIC; + version = String.format("%s (app)", appName); + break; + default: + LOG.warn("Unknown app type {}", appType); + firmwareType = HuamiFirmwareType.INVALID; + return; + } + + Bitmap icon = null; + final byte[] iconBytes = getFileFromZip(zipFile, "assets/" + appIconPath); + if (iconBytes != null) { + if (BitmapUtil.isPng(iconBytes)) { + icon = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length); + } else { + icon = BitmapUtil.decodeTga(iconBytes); + } + } + + gbDeviceApp = new GBDeviceApp( + UUID.fromString(String.format("%08x-0000-0000-0000-000000000000", appId)), + appName, + appCreator, + appVersion, + gbDeviceAppType, + icon + ); + + return; + } + + // Attempt to handle as a zab file + final byte[] zpkBytes = handleZabPackage(zipFile); + if (zpkBytes != null) { + final File cacheDir = context.getCacheDir(); + final File zpkCacheDir = new File(cacheDir, "zpk"); + zpkCacheDir.mkdir(); + + final File zpkFile; + try { + zpkFile = File.createTempFile("zpk","zip", context.getCacheDir()); + zpkFile.deleteOnExit(); + } catch (final IOException e) { + LOG.error("Failed to create temp file for zpk", e); + return; + } + + try (FileOutputStream outputStream = new FileOutputStream(zpkFile)) { + outputStream.write(zpkBytes); + } catch (final IOException e) { + LOG.error("Failed to write zpk bytes to temporary file", e); + return; + } + + try (ZipFile zpkZpkFile = new ZipFile(zpkFile, java.util.zip.ZipFile.OPEN_READ)) { + processZipFile(zpkZpkFile); + } catch (final ZipException e) { + LOG.warn("{} is not a valid zip file", uri, e); + } catch (final IOException e) { + LOG.warn("Error while processing {}", uri, e); + } + + if (firmwareType != HuamiFirmwareType.INVALID) { + file = zpkFile; + crc32 = CheckSums.getCRC32(zpkBytes); + } + } + } + + /** + * A zab package is a zip file with: + * - manifest.json + * - .sc (source code) + * - One or more zpk files + *

+ * Right now, we only handle the first compatible zpk file that is supported by the connected device. + */ + private byte[] handleZabPackage(final ZipFile zipFile) { + final JSONObject manifest = getJson(zipFile, "manifest.json"); + if (manifest == null) { + return null; + } + + final JSONArray zpks; + try { + zpks = manifest.getJSONArray("zpks"); + } catch (final Exception e) { + LOG.error("Failed to get zpks from manifest.json", e); + return null; + } + + // Iterate all zpks until a compatible one is found + for (int i = 0; i < zpks.length(); i++) { + try { + final JSONObject zpkEntry = zpks.getJSONObject(i); + final JSONArray platforms = zpkEntry.getJSONArray("platforms"); + + // Check if this zpk is compatible with the current device + for (int j = 0; j < platforms.length(); j++) { + final JSONObject platform = platforms.getJSONObject(j); + + if (deviceSources.contains(platform.getInt("deviceSource"))) { + // It's compatible with the device, fetch device.zip + final String name = zpkEntry.getString("name"); + final byte[] zpkBytes = getFileFromZip(zipFile, name); + if (!GBZipFile.isZipFile(zpkBytes)) { + LOG.warn("bytes for {} not a zip file", name); + continue; + } + final GBZipFile zpkFile = new GBZipFile(zpkBytes); + final byte[] deviceZip = zpkFile.getFileFromZip("device.zip"); + if (!GBZipFile.isZipFile(zpkBytes)) { + LOG.warn("bytes for device.zip of zpk {} not a zip file", name); + continue; + } + + return deviceZip; + } + } + } catch (final Exception e) { + LOG.warn("Failed to parse zpk", e); + } + } + + LOG.warn("No compatible zpk found in zab file"); + + return null; + } + + @Nullable + public GBDeviceApp getAppInfo() { + return gbDeviceApp; + } + + public boolean isValid() { + return firmwareType != HuamiFirmwareType.INVALID; + } + + @Nullable + public Bitmap getPreview() { + if (gbDeviceApp != null) { + return gbDeviceApp.getPreviewImage(); + } + + return null; + } + + private boolean isCompatibleFirmwareBin(final byte[] firmwareBin) { + if (firmwareBin == null) { + LOG.error("firmware bin is null"); + return false; + } + + if (!searchString(firmwareBin, deviceName)) { + LOG.warn("Failed to find {} in fwBytes", deviceName); + return false; + } + + return true; + } + + public static String getFirmwareVersion(final byte[] firmwareBin) { + int startIdx = 10; + int endIdx = -1; + + for (int i = startIdx; i < startIdx + 20; i++) { + byte c = firmwareBin[i]; + + if (c == 0) { + endIdx = i; + break; + } + + if (c != '.' && (c < '0' || c > '9')) { + // not a valid version character + break; + } + } + + if (endIdx == -1) { + LOG.warn("Failed to find firmware version in expected offset"); + return null; + } + + return new String(Arrays.copyOfRange(firmwareBin, startIdx, endIdx)); + } + + @Nullable + private static JSONObject getJson(final ZipFile zipFile, final String path) { + final byte[] appJsonBin = getFileFromZip(zipFile, path); + if (appJsonBin == null) { + return null; + } + + try { + final String appJsonString = new String(appJsonBin, StandardCharsets.UTF_8) + // Remove UTF-8 BOM if present + .replace("\uFEFF", ""); + return new JSONObject(appJsonString); + } catch (final Exception e) { + LOG.error("Failed to parse " + path, e); + } + + return null; + } + + @Nullable + private static byte[] getFileFromZip(final ZipFile zipFile, final String path) { + try { + final ZipEntry entry = zipFile.getEntry(path); + if (entry == null) { + return null; + } + return GBZipFile.readAllBytes(zipFile.getInputStream(entry)); + } catch (final IOException e) { + LOG.error("Failed to read " + path, e); + return null; + } + } + + public static boolean searchString(final byte[] fwBytes, final String str) { + final byte[] strBytes = (str + "\0").getBytes(StandardCharsets.UTF_8); + + for (int i = 0; i < fwBytes.length - strBytes.length + 1; i++) { + boolean found = true; + for (int j = 0; j < strBytes.length; j++) { + if (fwBytes[i + j] != strBytes[j]) { + found = false; + break; + } + } + if (found) { + return true; + } + } + + return false; + } +} 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 27059ecce..5bbfcdc20 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 @@ -16,8 +16,6 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.devices.pinetime; -import static java.nio.charset.StandardCharsets.UTF_8; - import android.content.Context; import android.net.Uri; @@ -38,7 +36,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; import nodomain.freeyourgadget.gadgetbridge.util.UriHelper; -import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; +import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; public class PineTimeInstallHandler implements InstallHandler { @@ -57,7 +55,7 @@ public class PineTimeInstallHandler implements InstallHandler { try { uriHelper = UriHelper.get(uri, this.context); - ZipFile dfuPackage = new ZipFile(uriHelper.openInputStream()); + GBZipFile dfuPackage = new GBZipFile(uriHelper.openInputStream()); String manifest = new String(dfuPackage.getFileFromZip("manifest.json")); if (!manifest.trim().isEmpty()) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java index 2332225b9..33e224fcd 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java @@ -16,9 +16,7 @@ along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.AbstractMiBandOperation; public abstract class AbstractHuamiOperation extends AbstractMiBandOperation { @@ -31,9 +29,5 @@ public abstract class AbstractHuamiOperation extends AbstractMiBandOperation. */ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami; +import androidx.annotation.StringRes; + +import nodomain.freeyourgadget.gadgetbridge.R; + public enum HuamiFirmwareType { - FIRMWARE((byte) 0), - CHANGELOG_TXT((byte) 16), + FIRMWARE((byte) 0, R.string.kind_firmware), + CHANGELOG_TXT((byte) 16, R.string.action_changelog), // MB7 firmwares are sent as UIHH packing FIRMWARE (zip) + CHANGELOG_TXT, type 0xfd - FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG((byte) -3), - FONT((byte) 1), - RES((byte) 2), - RES_COMPRESSED((byte) 130), - GPS((byte) 3), - GPS_CEP((byte) 4), - AGPS_UIHH((byte) -4), - GPS_ALMANAC((byte) 5), - WATCHFACE((byte) 8), - APP((byte) 8), - FONT_LATIN((byte) 11), - ZEPPOS_UNKNOWN_0X13((byte) 0x13), - ZEPPOS_APP((byte) 0xa0), - INVALID(Byte.MIN_VALUE); + FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG((byte) -3, R.string.kind_firmware), + FONT((byte) 1, R.string.kind_font), + RES((byte) 2, R.string.kind_resources), + RES_COMPRESSED((byte) 130, R.string.kind_resources), + GPS((byte) 3, R.string.kind_gps), + GPS_CEP((byte) 4, R.string.kind_gps_cep), + AGPS_UIHH((byte) -4, R.string.kind_agps_bundle), + GPS_ALMANAC((byte) 5, R.string.kind_gps_almanac), + WATCHFACE((byte) 8, R.string.kind_watchface), + APP((byte) 8, R.string.kind_app), + FONT_LATIN((byte) 11, R.string.kind_font), + ZEPPOS_UNKNOWN_0X13((byte) 0x13, R.string.unknown), + ZEPPOS_APP((byte) 0xa0, R.string.kind_app), + INVALID(Byte.MIN_VALUE, R.string.kind_invalid), + ; private final byte value; + private final int nameResId; - HuamiFirmwareType(byte value) { + HuamiFirmwareType(byte value, int nameResId) { this.value = value; + this.nameResId = nameResId; } public byte getValue() { return value; } + @StringRes + public int getNameResId() { + return nameResId; + } + public boolean isApp() { return this == APP || this == ZEPPOS_APP; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java deleted file mode 100644 index 9a5d24492..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitActiveFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitActiveFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_ACTIVE_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8323328)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVE; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java deleted file mode 100644 index 05cf14908..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive.AmazfitActiveFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitActiveSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitActiveFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java deleted file mode 100644 index 273602e11..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitActiveEdgeFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitActiveEdgeFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_ACTIVE_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8388864, 8388865)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVEEDGE; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java deleted file mode 100644 index 2141be205..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge.AmazfitActiveEdgeFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitActiveEdgeSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitActiveEdgeFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java deleted file mode 100644 index 1618f7799..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 Maxime Reyrolle - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitBalanceFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitBalanceFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_BALANCE_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8519936, 8519937, 8519939)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITBALANCE; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java deleted file mode 100644 index 1827f6e32..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 Maxime Reyrolle - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance.AmazfitBalanceFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitBalanceSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBalanceFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java deleted file mode 100644 index 7e0e09ea8..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitBand7FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - }}; - - public AmazfitBand7FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_BAND7_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(252, 253, 254)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITBAND7; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java deleted file mode 100644 index 0b894f292..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7.AmazfitBand7FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitBand7Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBand7FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java deleted file mode 100644 index bcbfc1f97..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitBip5FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitBip5FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_BIP5_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8454400, 8454401)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITBIP5; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java deleted file mode 100644 index 945a5f258..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5.AmazfitBip5FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitBip5Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitBip5FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java deleted file mode 100644 index a586fad82..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 Raghd Hamzeh - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitCheetahProFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitCheetahProFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_CHEETAH_PRO_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8126720, 8126721)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHPRO; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java deleted file mode 100644 index fdb32bdc0..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 Raghd Hamzeh - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro.AmazfitCheetahProFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitCheetahProSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahProFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java deleted file mode 100644 index 76e2f6253..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitCheetahRoundFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitCheetahRoundFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(8192256, 8192257)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHROUND; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java deleted file mode 100644 index 59d8019c0..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround.AmazfitCheetahRoundFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitCheetahRoundSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahRoundFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java deleted file mode 100644 index 1a232f2a5..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitCheetahSquareFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitCheetahSquareFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Collections.singletonList(8257793)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHSQUARE; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java deleted file mode 100644 index 3061f5e5c..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitCheetahSquareSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitCheetahSquareFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java deleted file mode 100644 index 2252f4732..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitFalconFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitFalconFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_FALCON_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(414, 415)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITFALCON; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java deleted file mode 100644 index 8dcab31dc..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon.AmazfitFalconFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitFalconSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitFalconFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java deleted file mode 100644 index 0056b84ab..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, thermatk - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTR3FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3FirmwareInfo.class); - - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTR3FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR3_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(226, 227)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java deleted file mode 100644 index 5d9417862..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, thermatk - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3; - -import android.content.Context; -import android.net.Uri; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3.AmazfitGTR3FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTR3Support extends ZeppOsSupport { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3Support.class); - - @Override - public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTR3FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java deleted file mode 100644 index cc028f625..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTR3ProFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProFirmwareInfo.class); - - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTR3ProFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR3_PRO_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(229, 230, 6095106)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3PRO; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java deleted file mode 100644 index d88140bcf..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro; - -import android.content.Context; -import android.net.Uri; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro.AmazfitGTR3ProFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTR3ProSupport extends ZeppOsSupport { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProSupport.class); - - @Override - public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTR3ProFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java deleted file mode 100644 index 3ac35ae35..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTR4FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - put(1699, "3.17.0.2"); - put(20712, "3.18.1.1 (diff from 3.17.0.2)"); - put(49685, "3.23.3.1 (diff from 3.21.0.1)"); - }}; - - public AmazfitGTR4FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR4_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(7930112, 7930113)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR4; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java deleted file mode 100644 index 1c8686de2..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4.AmazfitGTR4FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTR4Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTR4FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java deleted file mode 100644 index 764d5f849..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTRMiniFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTRMiniFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR_MINI_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(250, 251)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTRMINI; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java deleted file mode 100644 index b4244827d..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini.AmazfitGTRMiniFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTRMiniSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTRMiniFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java deleted file mode 100644 index 157f3c807..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, sedy89 - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTS3FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3FirmwareInfo.class); - - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTS3FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS3_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(224, 225)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS3; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java deleted file mode 100644 index e20dc7f5c..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, sedy89 - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3; - -import android.content.Context; -import android.net.Uri; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3.AmazfitGTS3FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTS3Support extends ZeppOsSupport { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Support.class); - - @Override - public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException { - return new AmazfitGTS3FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java deleted file mode 100644 index 91e1d8553..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTS4FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTS4FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS4_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(7995648, 7995649)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java deleted file mode 100644 index bd91e9799..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4.AmazfitGTS4FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTS4Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTS4FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java deleted file mode 100644 index 7866b8be1..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitGTS4MiniFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitGTS4MiniFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS4_MINI_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(246, 247)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4MINI; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java deleted file mode 100644 index e85ea3d53..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini.AmazfitGTS4MiniFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitGTS4MiniSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitGTS4MiniFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java deleted file mode 100644 index d0b94a115..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitTRex2FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitTRex2FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_TREX_2_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(418, 419)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREX2; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java deleted file mode 100644 index 249d8bb2e..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2.AmazfitTRex2FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitTRex2Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitTRex2FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java deleted file mode 100644 index 6041aa299..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class AmazfitTRexUltraFirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - }}; - - public AmazfitTRexUltraFirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.AMAZFIT_TREX_ULTRA; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(6553856, 6553857)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREXULTRA; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java deleted file mode 100644 index d3a7d40fd..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2023-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra.AmazfitTRexUltraFWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class AmazfitTRexUltraSupport extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new AmazfitTRexUltraFWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java deleted file mode 100644 index dbf225624..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo; - -public class MiBand7FirmwareInfo extends ZeppOsFirmwareInfo { - private static final Map crcToVersion = new HashMap() {{ - // firmware - put(26036, "1.20.3.1"); - put(55449, "1.27.0.4"); - put(14502, "2.0.0.2"); - put(25658, "2.1.0.1"); - }}; - - public MiBand7FirmwareInfo(final byte[] bytes) { - super(bytes); - } - - @Override - public String deviceName() { - return HuamiConst.XIAOMI_SMART_BAND7_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265)); - } - - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return isHeaderValid() && device.getType() == DeviceType.MIBAND7; - } - - @Override - protected Map getCrcMap() { - return crcToVersion; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java deleted file mode 100644 index 9dd0bde50..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7.MiBand7FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; - -public class MiBand7Support extends ZeppOsSupport { - @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { - return new MiBand7FWHelper(uri, context); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java index 2d7846746..173e51f79 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java @@ -80,7 +80,7 @@ public class UpdateFirmwareOperation extends AbstractHuamiOperation { //the firmware will be sent by the notification listener if the band confirms that the metadata are ok. } - AbstractHuamiFirmwareInfo createFwInfo(Uri uri, Context context) throws IOException { + protected AbstractHuamiFirmwareInfo createFwInfo(Uri uri, Context context) throws IOException { HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context); return fwHelper.getFirmwareInfo(); } @@ -283,7 +283,7 @@ public class UpdateFirmwareOperation extends AbstractHuamiOperation { builder.queue(getQueue()); } - AbstractHuamiFirmwareInfo getFirmwareInfo() { + protected AbstractHuamiFirmwareInfo getFirmwareInfo() { return firmwareInfo; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java deleted file mode 100644 index 891e53226..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations; - -import android.content.Context; -import android.net.Uri; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService; -import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; -import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; -import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; - -public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { - private static final Logger LOG = LoggerFactory.getLogger(UpdateFirmwareOperation2021.class); - - public UpdateFirmwareOperation2021(final Uri uri, final ZeppOsSupport support) { - super(uri, support); - } - - @Override - AbstractHuamiFirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException { - return super.createFwInfo(uri, context); - - /* This does not actually seem to be needed, but it's what the official app does - final HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context); - final AbstractHuamiFirmwareInfo firmwareInfo = fwHelper.getFirmwareInfo(); - - if (!(firmwareInfo instanceof Huami2021FirmwareInfo)) { - throw new IllegalArgumentException("Firmware not Huami2021FirmwareInfo"); - } - - final Huami2021FirmwareInfo firmwareInfo2021 = (Huami2021FirmwareInfo) firmwareInfo; - if (firmwareInfo2021.getFirmwareType() == HuamiFirmwareType.FIRMWARE) { - // This does not actually seem to be needed, but it's what the official app does - return firmwareInfo2021.repackFirmwareInUIHH(); - } - - return firmwareInfo; - */ - } - - @Override - public ZeppOsSupport getSupport() { - return (ZeppOsSupport) super.getSupport(); - } - - @Override - protected void handleNotificationNotif(byte[] value) { - super.handleNotificationNotif(value); - - if (ArrayUtils.startsWith(value, new byte[]{HuamiService.RESPONSE, COMMAND_FINALIZE_UPDATE, HuamiService.SUCCESS})) { - if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.APP) { - // After an app is installed, request the display items from the band (new app will be at the end) - try { - TransactionBuilder builder = performInitialized("request display items and apps"); - getSupport().requestDisplayItems(builder); - getSupport().requestApps(builder); - builder.queue(getQueue()); - } catch (final IOException e) { - LOG.error("Failed to request display items after app install", e); - } - } else if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.WATCHFACE) { - // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end) - try { - TransactionBuilder builder = performInitialized("request watchfaces and apps"); - getSupport().requestWatchfaces(builder); - getSupport().requestApps(builder); - builder.queue(getQueue()); - } catch (final IOException e) { - LOG.error("Failed to request watchfaces after watchface install", e); - } - } - } - } - - @Override - protected byte[] buildFirmwareInfoCommand() { - final int fwSize = firmwareInfo.getSize(); - final int crc32 = firmwareInfo.getCrc32(); - - final byte[] sizeBytes = BLETypeConversions.fromUint32(fwSize); - final byte[] chunkSizeBytes = BLETypeConversions.fromUint16(mChunkLength); - final byte[] crcBytes = BLETypeConversions.fromUint32(crc32); - - return new byte[]{ - COMMAND_SEND_FIRMWARE_INFO, - getFirmwareInfo().getFirmwareType().getValue(), - sizeBytes[0], - sizeBytes[1], - sizeBytes[2], - sizeBytes[3], - crcBytes[0], - crcBytes[1], - crcBytes[2], - crcBytes[3], - chunkSizeBytes[0], - chunkSizeBytes[1], - 0, // 0 to update in foreground, 1 for background - (byte) 0xff, // ?? - }; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java deleted file mode 100644 index ecca27e0e..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2022-2024 Daniel Dakhno, José Rebelo - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos; - -import android.content.Context; -import android.graphics.Bitmap; -import android.net.Uri; - -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.Writer; - -import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo; -import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; - -public abstract class AbstractZeppOsFwInstallHandler extends AbstractMiBandFWInstallHandler { - private static final Logger LOG = LoggerFactory.getLogger(AbstractZeppOsFwInstallHandler.class); - - public AbstractZeppOsFwInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - public void onStartInstall(final GBDevice device) { - final AbstractHuamiFirmwareInfo firmwareInfo = getHelper().getFirmwareInfo(); - final boolean shouldCache = firmwareInfo.getFirmwareType().isApp() || firmwareInfo.getFirmwareType().isWatchface(); - if (shouldCache) { - if (firmwareInfo instanceof ZeppOsFirmwareInfo) { - saveToCache((ZeppOsFirmwareInfo) firmwareInfo, device); - } else { - LOG.warn("firmwareInfo is {} - this should never happen", firmwareInfo.getClass()); - } - } - - // Unset the firmware bytes - // Huami2021 firmwares are large (> 130MB). With the current architecture, the update operation - // will re-read them to memory, and we run out-of-memory. - helper.unsetFwBytes(); - } - - protected abstract HuamiFWHelper createHelper(Uri uri, Context context) throws IOException; - - public HuamiFWHelper getHelper() { - return (HuamiFWHelper) helper; - } - - private void saveToCache(final ZeppOsFirmwareInfo firmwareInfo, final GBDevice device) { - final DeviceCoordinator coordinator = device.getDeviceCoordinator(); - - final File appCacheDir; - try { - appCacheDir = coordinator.getAppCacheDir(); - } catch (final IOException e) { - LOG.error("Failed to get app cache dir", e); - return ; - } - - final GBDeviceApp app = firmwareInfo.getAppInfo(); - - // write app zip - final File appOutputFile = new File(appCacheDir, app.getUUID().toString() + coordinator.getAppFileExtension()); - try { - appCacheDir.mkdirs(); - FileUtils.copyURItoFile(getContext(), getUri(), appOutputFile); - } catch (final IOException e) { - LOG.error("Failed to save app to cache", e); - return; - } - - // write app metadata - final File metadataOutputFile = new File(appCacheDir, app.getUUID().toString() + ".json"); - try (Writer writer = new BufferedWriter(new FileWriter(metadataOutputFile))) { - final JSONObject appJSON = app.getJSON(); - writer.write(appJSON.toString()); - } catch (final IOException e) { - LOG.error("Failed to write app metadata", e); - return; - } - - if (app.getPreviewImage() != null) { - final File previewOutputFile = new File(appCacheDir, app.getUUID().toString() + "_preview.png"); - try (FileOutputStream fos = new FileOutputStream(previewOutputFile)) { - app.getPreviewImage().compress(Bitmap.CompressFormat.PNG, 9, fos); - } catch (final IOException e) { - LOG.error("Failed to write app preview", e); - } - } - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java deleted file mode 100644 index 6225b70ec..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java +++ /dev/null @@ -1,471 +0,0 @@ -/* Copyright (C) 2022-2024 José Rebelo, MPeter - - This file is part of Gadgetbridge. - - Gadgetbridge is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Gadgetbridge is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . */ - -package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -import androidx.annotation.Nullable; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - -import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; -import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.UIHHContainer; -import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; -import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil; -import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; -import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; - - -public abstract class ZeppOsFirmwareInfo extends AbstractHuamiFirmwareInfo { - private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFirmwareInfo.class); - - private final String preComputedVersion; - private GBDeviceApp gbDeviceApp; - - public ZeppOsFirmwareInfo(final byte[] bytes) { - super(bytes); - this.preComputedVersion = preComputeVersion(); - } - - /** - * The device name, to search on firmware.bin in order to determine compatibility. - */ - public abstract String deviceName(); - - /** - * The device sources, to match compatible packages. - * As per: https://docs.zepp.com/docs/reference/related-resources/device-list/ - */ - public abstract Set deviceSources(); - - @Override - protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) { - if (ArrayUtils.equals(bytes, UIHHContainer.UIHH_HEADER, 0)) { - return handleUihhPackage(bytes); - } else if (ZipFile.isZipFile(bytes)) { - return handleZipPackage(bytes); - } else { - return HuamiFirmwareType.INVALID; - } - } - - private HuamiFirmwareType handleUihhPackage(byte[] bytes) { - final UIHHContainer uihh = UIHHContainer.fromRawBytes(bytes); - if (uihh == null) { - LOG.warn("Invalid UIHH file"); - return HuamiFirmwareType.INVALID; - } - - final Set agpsEpoTypes = new HashSet<>(); - UIHHContainer.FileEntry uihhFirmwareZipFile = null; - boolean hasChangelog = false; - for (final UIHHContainer.FileEntry file : uihh.getFiles()) { - switch (file.getType()) { - case FIRMWARE_ZIP: - uihhFirmwareZipFile = file; - continue; - case FIRMWARE_CHANGELOG: - hasChangelog = true; - continue; - case AGPS_EPO_GR_3: - case AGPS_EPO_GAL_7: - case AGPS_EPO_BDS_3: - agpsEpoTypes.add(file.getType()); - continue; - default: - LOG.warn("Unexpected file for {}", file.getType()); - } - } - - if (uihhFirmwareZipFile != null && hasChangelog) { - // UIHH firmware update - final ZipFile zipFile = new ZipFile(uihhFirmwareZipFile.getContent()); - final byte[] firmwareBin; - try { - firmwareBin = zipFile.getFileFromZip("META/firmware.bin"); - } catch (final ZipFileException e) { - LOG.error("Failed to read zip from UIHH", e); - return HuamiFirmwareType.INVALID; - } - - if (isCompatibleFirmwareBin(firmwareBin)) { - return HuamiFirmwareType.FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG; - } - } - - if (agpsEpoTypes.size() == 3) { - // AGPS EPO update - return HuamiFirmwareType.AGPS_UIHH; - } - - return HuamiFirmwareType.INVALID; - } - - private HuamiFirmwareType handleZipPackage(byte[] bytes) { - final ZipFile zipFile = new ZipFile(bytes); - - // Attempt to handle as a firmware - try { - final byte[] firmwareBin = zipFile.getFileFromZip("META/firmware.bin"); - if (isCompatibleFirmwareBin(firmwareBin)) { - return HuamiFirmwareType.FIRMWARE; - } else { - return HuamiFirmwareType.INVALID; - } - } catch (final ZipFileException e) { - LOG.warn("Failed to get firmware.bin from zip file", e); - } - - // Attempt to handle as an app / watchface - final JSONObject appJson = getJson(zipFile, "app.json"); - if (appJson != null) { - final int appId; - final String appName; - final String appVersion; - final String appType; - final String appCreator; - final String appIconPath; - final JSONObject appJsonApp; - try { - appJsonApp = appJson.getJSONObject("app"); - appId = appJsonApp.getInt("appId"); - appName = appJsonApp.getString("appName"); - appVersion = appJsonApp.getJSONObject("version").getString("name"); - appType = appJsonApp.getString("appType"); - appCreator = appJsonApp.getString("vender"); - appIconPath = appJsonApp.getString("icon"); - } catch (final Exception e) { - LOG.error("Failed to get appType from app.json", e); - return HuamiFirmwareType.INVALID; - } - - final HuamiFirmwareType huamiFirmwareType; - final GBDeviceApp.Type gbDeviceAppType; - switch (appType) { - case "watchface": - huamiFirmwareType = HuamiFirmwareType.WATCHFACE; - gbDeviceAppType = GBDeviceApp.Type.WATCHFACE; - break; - case "app": - huamiFirmwareType = HuamiFirmwareType.APP; - gbDeviceAppType = GBDeviceApp.Type.APP_GENERIC; - break; - default: - LOG.warn("Unknown app type {}", appType); - return HuamiFirmwareType.INVALID; - } - - Bitmap icon = null; - try { - final byte[] iconBytes = zipFile.getFileFromZip("assets/" + appIconPath); - if (BitmapUtil.isPng(iconBytes)) { - icon = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length); - } else { - icon = BitmapUtil.decodeTga(iconBytes); - } - } catch (final ZipFileException e) { - LOG.error("Failed to get app icon from zip", e); - } - - gbDeviceApp = new GBDeviceApp( - UUID.fromString(String.format("%08x-0000-0000-0000-000000000000", appId)), - appName, - appCreator, - appVersion, - gbDeviceAppType, - icon - ); - - return huamiFirmwareType; - } - - // Attempt to handle as a zab file - final byte[] zpk = handleZabPackage(zipFile); - if (zpk != null) { - setBytes(zpk); - return handleZipPackage(zpk); - } - - return HuamiFirmwareType.INVALID; - } - - /** - * A zab package is a zip file with: - * - manifest.json - * - .sc (source code) - * - One or more zpk files - *

- * Right now, we only handle the first compatible zpk file that is supported by the connected device. - */ - private byte[] handleZabPackage(final ZipFile zipFile) { - final JSONObject manifest = getJson(zipFile, "manifest.json"); - if (manifest == null) { - return null; - } - - final JSONArray zpks; - try { - zpks = manifest.getJSONArray("zpks"); - } catch (final Exception e) { - LOG.error("Failed to get zpks from manifest.json", e); - return null; - } - - // Iterate all zpks until a compatible one is found - for (int i = 0; i < zpks.length(); i++) { - try { - final JSONObject zpkEntry = zpks.getJSONObject(i); - final JSONArray platforms = zpkEntry.getJSONArray("platforms"); - - // Check if this zpk is compatible with the current device - for (int j = 0; j < platforms.length(); j++) { - final JSONObject platform = platforms.getJSONObject(j); - - if (deviceSources().contains(platform.getInt("deviceSource"))) { - // It's compatible with the device, fetch device.zip - final String name = zpkEntry.getString("name"); - final byte[] zpkBytes = zipFile.getFileFromZip(name); - if (!ZipFile.isZipFile(zpkBytes)) { - LOG.warn("bytes for {} not a zip file", name); - continue; - } - final ZipFile zpkFile = new ZipFile(zpkBytes); - final byte[] deviceZip = zpkFile.getFileFromZip("device.zip"); - if (!ZipFile.isZipFile(zpkBytes)) { - LOG.warn("bytes for device.zip of zpk {} not a zip file", name); - continue; - } - - return deviceZip; - } - } - } catch (final Exception e) { - LOG.warn("Failed to parse zpk", e); - } - } - - LOG.warn("No compatible zpk found in zab file"); - - return null; - } - - @Override - public String toVersion(int crc16) { - final String crcMapVersion = getCrcMap().get(crc16); - if (crcMapVersion != null) { - return crcMapVersion; - } - - return preComputedVersion; - } - - public String preComputeVersion() { - try { - switch (firmwareType) { - case FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG: - final UIHHContainer uihh = UIHHContainer.fromRawBytes(getBytes()); - if (uihh == null) { - return null; - } - return getFirmwareVersion(uihh.getFile(UIHHContainer.FileType.FIRMWARE_ZIP)); - case FIRMWARE: - return getFirmwareVersion(getBytes()); - case WATCHFACE: - final String watchfaceName = getAppName(new ZipFile(getBytes())); - if (watchfaceName == null) { - return "(unknown watchface)"; - } - return String.format("%s (watchface)", watchfaceName); - case APP: - final String appName = getAppName(new ZipFile(getBytes())); - if (appName == null) { - return "(unknown app)"; - } - return String.format("%s (app)", appName); - } - } catch (final Exception e) { - LOG.error("Failed to pre compute version", e); - } - - return null; - } - - public GBDeviceApp getAppInfo() { - return gbDeviceApp; - } - - @Nullable - @Override - public Bitmap getPreview() { - if (gbDeviceApp != null) { - return gbDeviceApp.getPreviewImage(); - } - - return null; - } - - public ZeppOsFirmwareInfo repackFirmwareInUIHH() throws IOException { - if (!firmwareType.equals(HuamiFirmwareType.FIRMWARE)) { - throw new IllegalStateException("Can only repack FIRMWARE"); - } - - final UIHHContainer uihh = packFirmwareInUIHH(getBytes()); - - try { - final Constructor constructor = this.getClass().getConstructor(byte[].class); - return constructor.newInstance((Object) uihh.toRawBytes()); - } catch (final Exception e) { - throw new IOException("Failed to construct new " + getClass().getName(), e); - } - } - - private static UIHHContainer packFirmwareInUIHH(final byte[] zipBytes) { - final UIHHContainer uihh = new UIHHContainer(); - final byte[] timestampBytes = BLETypeConversions.fromUint32((int) (System.currentTimeMillis() / 1000L)); - final String changelogText = "Unknown changelog"; - final byte[] changelogBytes = BLETypeConversions.join( - timestampBytes, - changelogText.getBytes(StandardCharsets.UTF_8) - ); - uihh.addFile(UIHHContainer.FileType.FIRMWARE_ZIP, zipBytes); - uihh.addFile(UIHHContainer.FileType.FIRMWARE_CHANGELOG, changelogBytes); - return uihh; - } - - private boolean isCompatibleFirmwareBin(final byte[] firmwareBin) { - if (firmwareBin == null) { - LOG.error("firmware bin is null"); - return false; - } - - if (!searchString(firmwareBin, deviceName())) { - LOG.warn("Failed to find {} in fwBytes", deviceName()); - return false; - } - - return true; - } - - public static String getFirmwareVersion(final byte[] fwBytes) { - final ZipFile zipFile = new ZipFile(fwBytes); - final byte[] firmwareBin; - try { - firmwareBin = zipFile.getFileFromZip("META/firmware.bin"); - } catch (final ZipFileException e) { - LOG.error("Failed to get firmware.bin from zip", e); - return null; - } - - int startIdx = 10; - int endIdx = -1; - - for (int i = startIdx; i < startIdx + 20; i++) { - byte c = firmwareBin[i]; - - if (c == 0) { - endIdx = i; - break; - } - - if (c != '.' && (c < '0' || c > '9')) { - // not a valid version character - break; - } - } - - if (endIdx == -1) { - LOG.warn("Failed to find firmware version in expected offset"); - return null; - } - - return new String(Arrays.copyOfRange(firmwareBin, startIdx, endIdx)); - } - - public String getAppName(final ZipFile zipFile) { - // TODO check i18n section? - // TODO Show preview icon? - - final JSONObject appJson = getJson(zipFile, "app.json"); - if (appJson == null) { - return null; - } - - try { - return appJson.getJSONObject("app").getString("appName"); - } catch (final Exception e) { - LOG.error("Failed to get appName from app.json", e); - } - - return null; - } - - private static JSONObject getJson(final ZipFile zipFile, final String path) { - final byte[] appJsonBin; - try { - appJsonBin = zipFile.getFileFromZip(path); - } catch (final ZipFileException e) { - LOG.error("Failed to read " + path, e); - return null; - } - - try { - final String appJsonString = new String(appJsonBin, StandardCharsets.UTF_8) - // Remove UTF-8 BOM if present - .replace("\uFEFF", ""); - return new JSONObject(appJsonString); - } catch (final Exception e) { - LOG.error("Failed to parse " + path, e); - } - - return null; - } - - public static boolean searchString(final byte[] fwBytes, final String str) { - final byte[] strBytes = (str + "\0").getBytes(StandardCharsets.UTF_8); - - for (int i = 0; i < fwBytes.length - strBytes.length + 1; i++) { - boolean found = true; - for (int j = 0; j < strBytes.length; j++) { - if (fwBytes[i + j] != strBytes[j]) { - found = false; - break; - } - } - if (found) { - return true; - } - } - - return false; - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java new file mode 100644 index 000000000..3a7fa6521 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java @@ -0,0 +1,177 @@ +/* Copyright (C) 2022-2024 Daniel Dakhno, José Rebelo + + This file is part of Gadgetbridge. + + Gadgetbridge is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Gadgetbridge is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ +package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos; + +import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType.AGPS_UIHH; + +import android.content.Context; +import android.graphics.Bitmap; +import android.net.Uri; + +import org.json.JSONObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity; +import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsFwHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; +import nodomain.freeyourgadget.gadgetbridge.model.GenericItem; +import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; + +public class ZeppOsFwInstallHandler implements InstallHandler { + private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFwInstallHandler.class); + + private final Uri mUri; + private final Context mContext; + + private final ZeppOsFwHelper mHelper; + + public ZeppOsFwInstallHandler(final Uri uri, final Context context, final String deviceName, final Set deviceSources) { + mUri = uri; + mContext = context; + mHelper = new ZeppOsFwHelper(uri, context, deviceName, deviceSources); + } + + @Override + public boolean isValid() { + return mHelper.isValid(); + } + + @Override + public void validateInstallation(InstallActivity installActivity, GBDevice device) { + if (device.isBusy()) { + installActivity.setInfoText(device.getBusyTask()); + installActivity.setInstallEnabled(false); + return; + } + + if (!device.isInitialized()) { + installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_ready)); + installActivity.setInstallEnabled(false); + return; + } + + if (!mHelper.isValid()) { + installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_supported)); + installActivity.setInstallEnabled(false); + return; + } + + final DeviceCoordinator coordinator = device.getDeviceCoordinator(); + + final GenericItem fwItem = new GenericItem(mContext.getString( + R.string.installhandler_firmware_name, + device.getAliasOrName(), + mHelper.getFirmwareType(), // TODO human name + mHelper.getFirmwareVersion() + )); + fwItem.setIcon(coordinator.getDefaultIconResource()); + + final StringBuilder sb = new StringBuilder(); + if (!mHelper.getFirmwareType().isWatchface() && !mHelper.getFirmwareType().isApp() && mHelper.getFirmwareType() != AGPS_UIHH) { + sb.append(mContext.getString( + R.string.fw_upgrade_notice, + mContext.getString(R.string.fw_upgrade_notice_zepp_os, mHelper.getFirmwareVersion(), device.getAliasOrName()) + )); + + // TODO whitelisted firmware + //if (mHelper.isFirmwareWhitelisted()) { + // sb.append(" ").append(mContext.getString(R.string.miband_firmware_known)); + // fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_compatible_version)); + // // TODO: set a CHECK (OKAY) button + //} else { + sb.append(" ").append(mContext.getString(R.string.miband_firmware_unknown_warning)).append(" \n\n") + .append(mContext.getString(R.string.miband_firmware_suggest_whitelist, String.valueOf(mHelper.getFirmwareVersion()))); + fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_untested_version)); + // TODO: set a UNKNOWN (question mark) button + //} + } + + installActivity.setPreview(mHelper.getPreview()); + + installActivity.setInfoText(sb.toString()); + installActivity.setInstallItem(fwItem); + installActivity.setInstallEnabled(true); + } + + @Override + public void onStartInstall(final GBDevice device) { + final boolean shouldCache = mHelper.getFirmwareType().isApp() || mHelper.getFirmwareType().isWatchface(); + if (shouldCache) { + saveToCache(device); + } + } + + private void saveToCache(final GBDevice device) { + final DeviceCoordinator coordinator = device.getDeviceCoordinator(); + + final File appCacheDir; + try { + appCacheDir = coordinator.getAppCacheDir(); + } catch (final IOException e) { + LOG.error("Failed to get app cache dir", e); + return; + } + + final GBDeviceApp app = mHelper.getAppInfo(); + if (app == null) { + LOG.warn("Unable to cache app, appInfo is null"); + return; + } + + // write app zip + final File appOutputFile = new File(appCacheDir, app.getUUID().toString() + coordinator.getAppFileExtension()); + try { + appCacheDir.mkdirs(); + FileUtils.copyURItoFile(mContext, mUri, appOutputFile); + } catch (final IOException e) { + LOG.error("Failed to save app to cache", e); + return; + } + + // write app metadata + final File metadataOutputFile = new File(appCacheDir, app.getUUID().toString() + ".json"); + try (Writer writer = new BufferedWriter(new FileWriter(metadataOutputFile))) { + final JSONObject appJSON = app.getJSON(); + writer.write(appJSON.toString()); + } catch (final IOException e) { + LOG.error("Failed to write app metadata", e); + return; + } + + if (app.getPreviewImage() != null) { + final File previewOutputFile = new File(appCacheDir, app.getUUID().toString() + "_preview.png"); + try (FileOutputStream fos = new FileOutputStream(previewOutputFile)) { + app.getPreviewImage().compress(Bitmap.CompressFormat.PNG, 9, fos); + } catch (final IOException e) { + LOG.error("Failed to write app preview", e); + } + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java index c42643902..6a7aeffa1 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java @@ -38,6 +38,7 @@ import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos. import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService.ConfigArg.TEMPERATURE_UNIT; import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService.ConfigArg.TIME_FORMAT; +import android.content.Context; import android.location.Location; import android.net.Uri; import android.os.Handler; @@ -78,6 +79,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSilentMode; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Service; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; @@ -111,7 +113,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiPhoneGpsS import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiVibrationPatternNotificationType; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2021; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsFirmwareUpdateOperation; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsAgpsUpdateOperation; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsGpxRouteUploadOperation; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAgpsService; @@ -143,7 +145,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.SilentMode; -public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback { +public final class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback { private static final Logger LOG = LoggerFactory.getLogger(ZeppOsSupport.class); // Tracks whether realtime HR monitoring is already started, so we can just @@ -592,6 +594,11 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr writeToChunked2021("toggle realtime steps", CHUNKED2021_ENDPOINT_STEPS, cmd, false); } + @Override + public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) { + throw new UnsupportedOperationException("this method should not be used"); + } + @Override public void onInstallApp(final Uri uri) { final ZeppOsAgpsInstallHandler agpsHandler = new ZeppOsAgpsInstallHandler(uri, getContext()); @@ -635,7 +642,7 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr return; } - new UpdateFirmwareOperation2021(Uri.parse(uihhFile.toURI().toString()), this).perform(); + new ZeppOsFirmwareUpdateOperation(Uri.parse(uihhFile.toURI().toString()), this).perform(); } } catch (final Exception e) { @@ -656,11 +663,13 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr } catch (final Exception e) { GB.toast(getContext(), "Gpx route file cannot be installed: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e); } - - return; } - super.onInstallApp(uri); + try { + new ZeppOsFirmwareUpdateOperation(uri, this).perform(); + } catch (final IOException ex) { + GB.toast(getContext(), "Firmware cannot be installed: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex); + } } @Override @@ -999,6 +1008,12 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr servicesService.requestServices(builder); } + @Override + @Deprecated + public final HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + throw new UnsupportedOperationException("This function should not be used for Zepp OS devices"); + } + public void addSupportedService(final short endpoint, final boolean encrypted) { mSupportedServices.add(endpoint); if (encrypted) { @@ -1054,11 +1069,6 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr return mServiceMap.get(endpoint); } - @Override - public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) { - return new UpdateFirmwareOperation2021(uri, this); - } - @Override public int getActivitySampleSize() { return 8; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java index f13ac8953..9b2727af5 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java @@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory; import java.nio.charset.StandardCharsets; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.UIHHContainer; -import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; +import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; public class ZeppOsAgpsFile { @@ -36,11 +36,11 @@ public class ZeppOsAgpsFile { } public boolean isValid() { - if (!ZipFile.isZipFile(zipBytes)) { + if (!GBZipFile.isZipFile(zipBytes)) { return false; } - final ZipFile zipFile = new ZipFile(zipBytes); + final GBZipFile zipFile = new GBZipFile(zipBytes); try { final byte[] manifestBin = zipFile.getFileFromZip("META-INF/MANIFEST.MF"); @@ -67,7 +67,7 @@ public class ZeppOsAgpsFile { public byte[] getUihhBytes() { final UIHHContainer uihh = new UIHHContainer(); - final ZipFile zipFile = new ZipFile(zipBytes); + final GBZipFile zipFile = new GBZipFile(zipBytes); try { uihh.addFile(UIHHContainer.FileType.AGPS_EPO_GR_3, zipFile.getFileFromZip("EPO_GR_3.DAT")); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java new file mode 100644 index 000000000..2fc48b5e6 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java @@ -0,0 +1,376 @@ +/* Copyright (C) 2022-2024 José Rebelo + + This file is part of Gadgetbridge. + + Gadgetbridge is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Gadgetbridge is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . */ +package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations; + +import android.bluetooth.BluetoothGatt; +import android.bluetooth.BluetoothGattCharacteristic; +import android.net.Uri; +import android.widget.Toast; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.RandomAccessFile; +import java.util.UUID; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage; +import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsFwHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; +import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; +import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction; +import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.AbstractMiBandOperation; +import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; +import nodomain.freeyourgadget.gadgetbridge.util.GB; + +/** + * This class is basically UpdateFirmwareOperation2020. However, Zepp OS firmwares are growing huge (200+MB), + * which crash Gadgetbridge. In order to refactor the upgrade process for Zepp OS devices without having to + * refactor all 52 devices, the code was moved to this class so it can be refactored with a smaller impact. + *

+ * The protocol for Zepp OS devices differs from UpdateFirmwareOperation2020 in the following points: + * - no crc16 support (not needed for zepp os) + * - buildFirmwareInfoCommand is slightly different + * - at the end of the update, we request display items / watchfaces depending on what was installed, to refresh the + * preferences in the UI + */ +public class ZeppOsFirmwareUpdateOperation extends AbstractMiBandOperation { + private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFirmwareUpdateOperation.class); + + private final Uri uri; + private final BluetoothGattCharacteristic fwCControlChar; + private final BluetoothGattCharacteristic fwCDataChar; + private ZeppOsFwHelper fwHelper; + private RandomAccessFile raf; + + protected int mChunkLength = -1; + + public ZeppOsFirmwareUpdateOperation(final Uri uri, final ZeppOsSupport support) { + super(support); + this.uri = uri; + this.fwCControlChar = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_FIRMWARE); + this.fwCDataChar = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_FIRMWARE_DATA); + } + + @Override + protected void enableNeededNotifications(TransactionBuilder builder, boolean enable) { + builder.notify(fwCControlChar, enable); + } + + @Override + protected void enableOtherNotifications(final TransactionBuilder builder, final boolean enable) { + // Disable 2021 chunked reads, otherwise firmware upgrades and activity sync get interrupted + // FIXME is this still needed? + builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ), enable); + } + + @Override + protected void doPerform() throws IOException { + final GBDevice device = getDevice(); + final DeviceCoordinator coordinator = device.getDeviceCoordinator(); + if (!(coordinator instanceof ZeppOsCoordinator)) { + throw new IOException("Not a Zepp OS coordinator for " + getDevice().getAddress()); + } + + fwHelper = new ZeppOsFwHelper( + uri, + getContext(), + ((ZeppOsCoordinator) coordinator).getDeviceBluetoothName(), + ((ZeppOsCoordinator) coordinator).getDeviceSources() + ); + + if (!fwHelper.isValid()) { + throw new IOException("Firmware is not valid for: " + getDevice().getAddress()); + } + + raf = new RandomAccessFile(fwHelper.getFile(), "r"); + + if (!requestParameters()) { + displayErrorMessage("Error requesting parameters, aborting."); + done(); + } + } + + protected void done() { + LOG.info("Operation done."); + operationFinished(); + unsetBusy(); + } + + @Override + public boolean onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { + if (status != BluetoothGatt.GATT_SUCCESS) { + operationFailed(); + } + return super.onCharacteristicWrite(gatt, characteristic, status); + } + + void operationFailed() { + GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_write_failed), false, 0, getContext()); + } + + @Override + public boolean onCharacteristicChanged(BluetoothGatt gatt, + BluetoothGattCharacteristic characteristic) { + UUID characteristicUUID = characteristic.getUuid(); + if (fwCControlChar.getUuid().equals(characteristicUUID)) { + handleNotificationNotif(characteristic.getValue()); + return true; // don't let anyone else handle it + } else { + super.onCharacteristicChanged(gatt, characteristic); + } + return false; + } + + protected void handleNotificationNotif(byte[] value) { + boolean success = (value[2] == HuamiService.SUCCESS) || ((value[1] == UpdateFirmwareOperation2020.REPLY_UPDATE_PROGRESS) && value.length >= 6); // ugly + + if (value[0] == HuamiService.RESPONSE && success) { + try { + switch (value[1]) { + case UpdateFirmwareOperation2020.COMMAND_REQUEST_PARAMETERS: { + mChunkLength = (value[4] & 0xff) | ((value[5] & 0xff) << 8); + LOG.info("got chunk length of " + mChunkLength); + sendFwInfo(); + break; + } + case UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO: + sendTransferStart(); + break; + case UpdateFirmwareOperation2020.COMMAND_START_TRANSFER: + sendFirmwareDataChunk(0); + break; + // not used in zepp os + //case HuamiService.COMMAND_FIRMWARE_START_DATA: + // sendChecksum(); + // break; + case UpdateFirmwareOperation2020.REPLY_UPDATE_PROGRESS: + int offset = (value[2] & 0xff) | ((value[3] & 0xff) << 8) | ((value[4] & 0xff) << 16) | ((value[5] & 0xff) << 24); + LOG.info("update progress " + offset + " bytes"); + sendFirmwareDataChunk(offset); + break; + case UpdateFirmwareOperation2020.COMMAND_COMPLETE_TRANSFER: + sendFinalize(); + break; + case UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE: { + if (fwHelper.getFirmwareType() == HuamiFirmwareType.FIRMWARE) { + TransactionBuilder builder = performInitialized("reboot"); + getSupport().sendReboot(builder); + builder.queue(getQueue()); + } else { + GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext()); + done(); + } + break; + } + case HuamiService.COMMAND_FIRMWARE_REBOOT: { + LOG.info("Reboot command successfully sent."); + GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext()); + done(); + break; + } + default: { + LOG.error("Unexpected response during firmware update: "); + getSupport().logMessageContent(value); + operationFailed(); + displayErrorMessage(getContext().getString(R.string.updatefirmwareoperation_updateproblem_do_not_reboot)); + done(); + } + } + } catch (Exception ex) { + displayErrorMessage(getContext().getString(R.string.updatefirmwareoperation_updateproblem_do_not_reboot)); + done(); + } + } else { + LOG.error("Unexpected notification during firmware update: "); + operationFailed(); + getSupport().logMessageContent(value); + int errorMessage = R.string.updatefirmwareoperation_metadata_updateproblem; + // Display a more specific error message for known errors + + if (value[0] == HuamiService.RESPONSE && value[1] == UpdateFirmwareOperation2020.COMMAND_START_TRANSFER && value[2] == UpdateFirmwareOperation2020.REPLY_ERROR_FREE_SPACE) { + // Not enough free space on the device + errorMessage = R.string.updatefirmwareoperation_updateproblem_free_space; + } else if (value[0] == HuamiService.RESPONSE && value[1] == UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO && value[2] == UpdateFirmwareOperation2020.REPLY_ERROR_LOW_BATTERY) { + // Battery is too low + errorMessage = R.string.updatefirmwareoperation_updateproblem_low_battery; + } + displayErrorMessage(getContext().getString(errorMessage)); + done(); + } + + if (ArrayUtils.startsWith(value, new byte[]{HuamiService.RESPONSE, UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE, HuamiService.SUCCESS})) { + if (fwHelper.getFirmwareType() == HuamiFirmwareType.APP) { + // After an app is installed, request the display items from the band (new app will be at the end) + try { + TransactionBuilder builder = performInitialized("request display items and apps"); + getSupport().requestDisplayItems(builder); + getSupport().requestApps(builder); + builder.queue(getQueue()); + } catch (final IOException e) { + LOG.error("Failed to request display items after app install", e); + } + } else if (fwHelper.getFirmwareType() == HuamiFirmwareType.WATCHFACE) { + // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end) + try { + TransactionBuilder builder = performInitialized("request watchfaces and apps"); + getSupport().requestWatchfaces(builder); + getSupport().requestApps(builder); + builder.queue(getQueue()); + } catch (final IOException e) { + LOG.error("Failed to request watchfaces after watchface install", e); + } + } + } + } + + private void displayErrorMessage(String message) { + getSupport().handleGBDeviceEvent(new GBDeviceEventDisplayMessage(message, Toast.LENGTH_LONG, GB.ERROR)); + } + + public void sendFwInfo() { + try { + TransactionBuilder builder = performInitialized("send firmware info"); + builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext())); + builder.write(fwCControlChar, buildFirmwareInfoCommand()); + builder.queue(getQueue()); + } catch (IOException e) { + LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e); + } + } + + protected byte[] buildFirmwareInfoCommand() { + final int fwSize = fwHelper.getSize(); + final int crc32 = fwHelper.getCrc32(); + + final byte[] sizeBytes = BLETypeConversions.fromUint32(fwSize); + final byte[] chunkSizeBytes = BLETypeConversions.fromUint16(mChunkLength); + final byte[] crcBytes = BLETypeConversions.fromUint32(crc32); + + return new byte[]{ + UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO, + fwHelper.getFirmwareType().getValue(), + sizeBytes[0], + sizeBytes[1], + sizeBytes[2], + sizeBytes[3], + crcBytes[0], + crcBytes[1], + crcBytes[2], + crcBytes[3], + chunkSizeBytes[0], + chunkSizeBytes[1], + 0, // 0 to update in foreground, 1 for background + (byte) 0xff, // ?? + }; + } + + public boolean requestParameters() { + try { + TransactionBuilder builder = performInitialized("get update capabilities"); + byte[] bytes = new byte[]{UpdateFirmwareOperation2020.COMMAND_REQUEST_PARAMETERS}; + builder.write(fwCControlChar, bytes); + builder.queue(getQueue()); + return true; + } catch (IOException e) { + LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e); + return false; + } + } + + private void sendFirmwareDataChunk(int offset) { + int len = fwHelper.getSize(); + int remaining = len - offset; + final int packetLength = getSupport().getMTU() - 3; + + int chunkLength = mChunkLength; + if (remaining < mChunkLength) { + chunkLength = remaining; + } + + int packets = chunkLength / packetLength; + int chunkProgress = 0; + + try { + if (remaining <= 0) { + sendTransferComplete(); + return; + } + + TransactionBuilder builder = performInitialized("send firmware packets"); + + for (int i = 0; i < packets; i++) { + raf.seek(offset + (long) i * packetLength); + byte[] fwChunk = new byte[packetLength]; + raf.read(fwChunk); + + builder.write(fwCDataChar, fwChunk); + chunkProgress += packetLength; + } + + if (chunkProgress < chunkLength) { + raf.seek(offset + (long) packets * packetLength); + byte[] lastChunk = new byte[chunkLength - chunkProgress]; + raf.read(lastChunk); + builder.write(fwCDataChar, lastChunk); + } + + int progressPercent = (int) ((((float) (offset + chunkLength)) / len) * 100); + + builder.add(new SetProgressAction(getContext().getString(R.string.updatefirmwareoperation_update_in_progress), true, progressPercent, getContext())); + + builder.queue(getQueue()); + + } catch (final IOException e) { + LOG.error("Unable to send fw to device", e); + GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_firmware_not_sent), false, 0, getContext()); + } + } + + protected void sendTransferStart() throws IOException { + final TransactionBuilder builder = performInitialized("transfer complete"); + builder.write(fwCControlChar, new byte[]{ + UpdateFirmwareOperation2020.COMMAND_START_TRANSFER, 1, + }); + builder.queue(getQueue()); + } + + protected void sendTransferComplete() throws IOException { + final TransactionBuilder builder = performInitialized("transfer complete"); + builder.write(fwCControlChar, new byte[]{ + UpdateFirmwareOperation2020.COMMAND_COMPLETE_TRANSFER, + }); + builder.queue(getQueue()); + } + + protected void sendFinalize() throws IOException { + final TransactionBuilder builder = performInitialized("finalize firmware"); + builder.write(fwCControlChar, new byte[]{ + UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE, + }); + builder.queue(getQueue()); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java similarity index 93% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java index 4d194569b..08c33e192 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java @@ -27,13 +27,11 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipException; import java.util.zip.ZipInputStream; -import androidx.annotation.Nullable; - /** * Utility class for recognition and reading of ZIP archives. */ -public class ZipFile { - private static final Logger LOG = LoggerFactory.getLogger(ZipFile.class); +public class GBZipFile { + private static final Logger LOG = LoggerFactory.getLogger(GBZipFile.class); public static final byte[] ZIP_HEADER = new byte[]{ 0x50, 0x4B, 0x03, 0x04 }; @@ -44,7 +42,7 @@ public class ZipFile { * Open ZIP file from byte array already in memory. * @param zipBytes data to handle as a ZIP file. */ - public ZipFile(byte[] zipBytes) { + public GBZipFile(byte[] zipBytes) { this.zipBytes = zipBytes; } @@ -53,7 +51,7 @@ public class ZipFile { * This will read the entire file into memory at once. * @param inputStream data to handle as a ZIP file. */ - public ZipFile(InputStream inputStream) throws IOException { + public GBZipFile(InputStream inputStream) throws IOException { this.zipBytes = readAllBytes(inputStream); } @@ -118,7 +116,7 @@ public class ZipFile { } } - private static byte[] readAllBytes(final InputStream is) throws IOException { + public static byte[] readAllBytes(final InputStream is) throws IOException { final ByteArrayOutputStream buffer = new ByteArrayOutputStream(); int n; diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java similarity index 93% rename from app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java rename to app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java index e9934b135..d634643d6 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java @@ -12,10 +12,10 @@ import java.nio.charset.StandardCharsets; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; +import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; -public class ZipFileTest extends TestBase { +public class GBZipFileTest extends TestBase { private static final String TEST_FILE_NAME = "manifest.json"; private static final String TEST_NESTED_FILE_NAME = "directory/manifest.json"; private static final String TEST_FILE_CONTENTS_1 = "{ \"mykey\": \"myvalue\", \"myarr\": [0, 1, 2, 3] }"; @@ -44,7 +44,7 @@ public class ZipFileTest extends TestBase { byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents); - ZipFile zipFile = new ZipFile(zipArchive); + GBZipFile zipFile = new GBZipFile(zipArchive); String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME)); Assert.assertEquals(contents, readContents); @@ -56,7 +56,7 @@ public class ZipFileTest extends TestBase { byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents); - ZipFile zipFile = new ZipFile(zipArchive); + GBZipFile zipFile = new GBZipFile(zipArchive); String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME)); Assert.assertEquals(contents, readContents); @@ -68,7 +68,7 @@ public class ZipFileTest extends TestBase { byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents); - ZipFile zipFile = new ZipFile(zipArchive); + GBZipFile zipFile = new GBZipFile(zipArchive); String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME)); Assert.assertEquals(contents, readContents); @@ -80,7 +80,7 @@ public class ZipFileTest extends TestBase { byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents); - ZipFile zipFile = new ZipFile(zipArchive); + GBZipFile zipFile = new GBZipFile(zipArchive); String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME)); Assert.assertEquals(contents, readContents); @@ -92,7 +92,7 @@ public class ZipFileTest extends TestBase { byte[] zipArchive = createZipArchive(TEST_NESTED_FILE_NAME, contents); - ZipFile zipFile = new ZipFile(zipArchive); + GBZipFile zipFile = new GBZipFile(zipArchive); String readContents = new String(zipFile.getFileFromZip(TEST_NESTED_FILE_NAME)); Assert.assertEquals(contents, readContents); @@ -112,7 +112,7 @@ public class ZipFileTest extends TestBase { writeFileToZip(contents3, "file3", zipWriteStream); zipWriteStream.close(); - ZipFile zipFile = new ZipFile(baos.toByteArray()); + GBZipFile zipFile = new GBZipFile(baos.toByteArray()); String readContents2 = new String(zipFile.getFileFromZip("file2")); String readContents1 = new String(zipFile.getFileFromZip("file1")); String readContents3 = new String(zipFile.getFileFromZip("file3")); @@ -132,7 +132,7 @@ public class ZipFileTest extends TestBase { writeFileToZip("Hello, World!", "folder1/file3", zipWriteStream); zipWriteStream.close(); - final ZipFile zipFile = new ZipFile(baos.toByteArray()); + final GBZipFile zipFile = new GBZipFile(baos.toByteArray()); Assert.assertTrue(zipFile.fileExists("file2")); Assert.assertTrue(zipFile.fileExists("file1")); Assert.assertTrue(zipFile.fileExists("folder1/file3"));