From d59e8c3f62eba11afb68de77919080e0682dd50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 15 Jun 2023 20:43:06 +0100 Subject: [PATCH] Zepp OS: Unify support class and fw handling --- .../devices/huami/Huami2021Coordinator.java | 46 +++++++--- .../devices/huami/Huami2021FWHelper.java | 69 +++++++++++++++ .../amazfitband7/AmazfitBand7Coordinator.java | 18 ++-- .../amazfitband7/AmazfitBand7FWHelper.java | 44 ---------- .../AmazfitBand7FWInstallHandler.java | 49 ----------- .../amazfitgtr3/AmazfitGTR3Coordinator.java | 16 ++-- .../amazfitgtr3/AmazfitGTR3FWHelper.java | 44 ---------- .../AmazfitGTR3FWInstallHandler.java | 49 ----------- .../AmazfitGTR3ProCoordinator.java | 16 ++-- .../AmazfitGTR3ProFWHelper.java | 44 ---------- .../AmazfitGTR3ProFWInstallHandler.java | 49 ----------- .../amazfitgtr4/AmazfitGTR4Coordinator.java | 27 ++++-- .../amazfitgtr4/AmazfitGTR4FWHelper.java | 44 ---------- .../AmazfitGTR4FWInstallHandler.java | 49 ----------- .../amazfitgts3/AmazfitGTS3Coordinator.java | 16 ++-- .../amazfitgts3/AmazfitGTS3FWHelper.java | 44 ---------- .../AmazfitGTS3FWInstallHandler.java | 49 ----------- .../amazfitgts4/AmazfitGTS4Coordinator.java | 16 ++-- .../amazfitgts4/AmazfitGTS4FWHelper.java | 44 ---------- .../AmazfitGTS4FWInstallHandler.java | 49 ----------- .../AmazfitGTS4MiniCoordinator.java | 16 ++-- .../AmazfitGTS4MiniFWHelper.java | 44 ---------- .../AmazfitGTS4MiniFWInstallHandler.java | 49 ----------- .../amazfittrex2/AmazfitTRex2Coordinator.java | 16 ++-- .../amazfittrex2/AmazfitTRex2FWHelper.java | 44 ---------- .../AmazfitTRex2FWInstallHandler.java | 49 ----------- .../huami/miband7/MiBand7Coordinator.java | 28 ++++-- .../huami/miband7/MiBand7FWHelper.java | 44 ---------- .../miband7/MiBand7FWInstallHandler.java | 49 ----------- .../service/DeviceSupportFactory.java | 29 +++--- .../AbstractHuami2021FWInstallHandler.java | 37 -------- .../huami/Huami2021FWInstallHandler.java | 88 +++++++++++++++++++ .../devices/huami/Huami2021FirmwareInfo.java | 45 ++++++---- .../devices/huami/Huami2021Support.java | 17 +++- .../AmazfitBand7FirmwareInfo.java | 57 ------------ .../amazfitband7/AmazfitBand7Support.java | 33 ------- .../amazfitgtr3/AmazfitGTR3FirmwareInfo.java | 63 ------------- .../huami/amazfitgtr3/AmazfitGTR3Support.java | 38 -------- .../AmazfitGTR3ProFirmwareInfo.java | 63 ------------- .../amazfitgtr3pro/AmazfitGTR3ProSupport.java | 38 -------- .../amazfitgtr4/AmazfitGTR4FirmwareInfo.java | 60 ------------- .../huami/amazfitgtr4/AmazfitGTR4Support.java | 33 ------- .../amazfitgts3/AmazfitGTS3FirmwareInfo.java | 63 ------------- .../huami/amazfitgts3/AmazfitGTS3Support.java | 39 -------- .../amazfitgts4/AmazfitGTS4FirmwareInfo.java | 58 ------------ .../huami/amazfitgts4/AmazfitGTS4Support.java | 33 ------- .../AmazfitGTS4MiniFirmwareInfo.java | 58 ------------ .../AmazfitGTS4MiniSupport.java | 33 ------- .../AmazfitTRex2FirmwareInfo.java | 58 ------------ .../amazfittrex2/AmazfitTRex2Support.java | 33 ------- .../huami/miband7/MiBand7FirmwareInfo.java | 64 -------------- .../devices/huami/miband7/MiBand7Support.java | 33 ------- .../UpdateFirmwareOperation2021.java | 18 ++-- .../zeppos/services/ZeppOsAlexaService.java | 1 - app/src/main/res/values/strings.xml | 10 +-- .../devices/huami/Huami2021SupportTest.java | 4 +- 56 files changed, 386 insertions(+), 1841 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.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/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/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/miband7/MiBand7FWHelper.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.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/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/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/miband7/MiBand7FirmwareInfo.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java index 49ae67868..9ab9e2a16 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021Coordinator.java @@ -28,16 +28,19 @@ 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.Locale; +import java.util.Map; +import java.util.Set; +import de.greenrobot.dao.query.QueryBuilder; +import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer; import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability; import nodomain.freeyourgadget.gadgetbridge.capabilities.password.PasswordCapabilityImpl; -import de.greenrobot.dao.query.QueryBuilder; -import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsAgpsInstallHandler; @@ -48,21 +51,19 @@ import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.entities.HuamiExtendedActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryParser; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; -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; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsShortcutCardsService; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FWInstallHandler; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiLanguageType; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiVibrationPatternNotificationType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAlexaService; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsContactsService; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsLogsService; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsPhoneService; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsShortcutCardsService; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; public abstract class Huami2021Coordinator extends HuamiCoordinator { - public abstract AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context); - @Override public InstallHandler findInstallHandler(final Uri uri, final Context context) { if (supportsAgpsUpdates()) { @@ -79,7 +80,15 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator { } } - final AbstractHuami2021FWInstallHandler handler = createFwInstallHandler(uri, context); + final Huami2021FWInstallHandler handler = new Huami2021FWInstallHandler( + uri, + context, + deviceName(), + deviceSources(), + getDeviceType(), + getFirmwareCrcMap() + ); + return handler.isValid() ? handler : null; } @@ -445,6 +454,21 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator { return BONDING_STYLE_REQUIRE_KEY; } + /** + * 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(); + + public Map getFirmwareCrcMap() { + return Collections.emptyMap(); + } + public boolean supportsContinuousFindDevice() { // TODO: Auto-detect continuous find device? return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.java new file mode 100644 index 000000000..53657cbb5 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.java @@ -0,0 +1,69 @@ +/* Copyright (C) 2016-2021 Andreas Shimokawa, Carsten Pfeiffer, Daniele + Gobbetti + + 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; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; + +public class Huami2021FWHelper extends HuamiFWHelper { + private final String deviceName; + private final Set deviceSources; + private final DeviceType deviceType; + private final Map crcMap; + + public Huami2021FWHelper(final Uri uri, + final Context context, + final String deviceName, + final Set deviceSources, + final DeviceType deviceType, + final Map crcMap) throws IOException { + super(uri, context); + this.deviceName = deviceName; + this.deviceSources = deviceSources; + this.deviceType = deviceType; + this.crcMap = crcMap; + } + + @Override + public Huami2021FirmwareInfo getFirmwareInfo() { + return (Huami2021FirmwareInfo) firmwareInfo; + } + + /** + * The maximum expected file size, in bytes. Files larger than this are assumed to be invalid. + */ + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new Huami2021FirmwareInfo(wholeFirmwareBytes, deviceName, deviceSources, deviceType, crcMap); + if (firmwareInfo.getFirmwareType() == HuamiFirmwareType.INVALID) { + throw new IllegalArgumentException("Not a " + deviceName + " firmware"); + } + } +} 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 000a906a2..f275cc54c 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 @@ -17,20 +17,23 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7; import android.bluetooth.BluetoothDevice; -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.Collections; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitBand7Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand7Coordinator.class); @@ -57,8 +60,13 @@ public class AmazfitBand7Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitBand7FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_BAND7_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(252, 253, 254)); } @Override 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 90d01983c..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 659164e72..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitBand7FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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/amazfitgtr3/AmazfitGTR3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3Coordinator.java index 7fdf02e35..d3371e6d6 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTR3Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3Coordinator.class); @@ -57,8 +58,13 @@ public class AmazfitGTR3Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR3FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTR3_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(226, 227)); } @Override 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 991396c68..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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.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 7220bddcd..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.amazfitgtr3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTR3FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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 a377b82ef..1e1573636 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class); @@ -57,8 +58,13 @@ public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR3ProFWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTR3_PRO_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(229, 230, 6095106)); } @Override 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 8e86dadec..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2023 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 00a5b1b77..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTR3ProFWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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 bcfb14020..5366c8683 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 @@ -17,20 +17,23 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4; import android.bluetooth.BluetoothDevice; -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 nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTR4Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class); @@ -57,8 +60,22 @@ public class AmazfitGTR4Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTR4FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTR4_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(7930112, 7930113)); + } + + @Override + public Map getFirmwareCrcMap() { + return new HashMap() {{ + // firmware + put(1699, "3.17.0.2"); + put(20712, "3.18.1.1 (diff from 3.17.0.2)"); + }}; } @Override 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 50a41718f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 64fcd3fbe..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTR4FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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/amazfitgts3/AmazfitGTS3Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3Coordinator.java index d2266ef2e..445c244dd 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTS3Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class); @@ -57,8 +58,13 @@ public class AmazfitGTS3Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS3FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTS3_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(224, 225)); } @Override 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 f37b4eddd..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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.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 f9203b700..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.amazfitgts3; - -import android.content.Context; -import android.net.Uri; - -import java.io.IOException; - -import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTS3FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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 8f96ffa7c..ee6debf31 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTS4Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4Coordinator.class); @@ -57,8 +58,13 @@ public class AmazfitGTS4Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS4FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTS4_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(7995648, 7995649)); } @Override 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 707d3a40c..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 ccc5d3f58..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTS4FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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 4abf0f513..e22b3de8e 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class); @@ -57,8 +58,13 @@ public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitGTS4MiniFWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_GTS4_MINI_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(246, 247)); } @Override 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 e18020ac9..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 8adcfca39..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitGTS4MiniFWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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 920ce80d3..10d3239b8 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 @@ -17,20 +17,21 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2; import android.bluetooth.BluetoothDevice; -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.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class AmazfitTRex2Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class); @@ -57,8 +58,13 @@ public class AmazfitTRex2Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new AmazfitTRex2FWInstallHandler(uri, context); + public String deviceName() { + return HuamiConst.AMAZFIT_TREX_2_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(418, 419)); } @Override 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 e22e2c6db..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 9c3a72cb3..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class AmazfitTRex2FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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/miband7/MiBand7Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7Coordinator.java index 057b4f9d6..74c045ef9 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 @@ -17,20 +17,23 @@ package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7; import android.bluetooth.BluetoothDevice; -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 nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; public class MiBand7Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(MiBand7Coordinator.class); @@ -57,8 +60,23 @@ public class MiBand7Coordinator extends Huami2021Coordinator { } @Override - public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { - return new MiBand7FWInstallHandler(uri, context); + 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 Map getFirmwareCrcMap() { + return new HashMap() {{ + // firmware + put(26036, "1.20.3.1"); + put(55449, "1.27.0.4"); + put(14502, "2.0.0.2"); + }}; } @Override 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 a3dd2ef41..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2022 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 7c0c35cae..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2022 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.miband.AbstractMiBandFWHelper; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; - -class MiBand7FWInstallHandler extends AbstractHuami2021FWInstallHandler { - 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 AbstractMiBandFWHelper 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/service/DeviceSupportFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java index d5ba1829b..3b3867b11 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -43,9 +43,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.domyos.DomyosT540Sup import nodomain.freeyourgadget.gadgetbridge.service.devices.flipper.zero.support.FlipperZeroSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.galaxy_buds.GalaxyBudsDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5.AmazfitBand5Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipLiteSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSLiteSupport; @@ -58,21 +57,14 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.Ama import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2eSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro.AmazfitGTR3ProSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2MiniSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2eSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitneo.AmazfitNeoSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpop.AmazfitPopSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpoppro.AmazfitPopProSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex.AmazfitTRexSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.AmazfitTRex2Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexpro.AmazfitTRexProSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.AmazfitVergeLSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitx.AmazfitXSupport; @@ -81,7 +73,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4.MiBand4Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand5Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband6.MiBand6Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppe.ZeppESupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.id115.ID115Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.itag.ITagSupport; @@ -193,23 +184,23 @@ public class DeviceSupportFactory { case MIBAND6: return new ServiceDeviceSupport(new MiBand6Support()); case AMAZFITGTS3: - return new ServiceDeviceSupport(new AmazfitGTS3Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITGTR3: - return new ServiceDeviceSupport(new AmazfitGTR3Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITGTR4: - return new ServiceDeviceSupport(new AmazfitGTR4Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case MIBAND7: - return new ServiceDeviceSupport(new MiBand7Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITBAND7: - return new ServiceDeviceSupport(new AmazfitBand7Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITGTS4: - return new ServiceDeviceSupport(new AmazfitGTS4Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITGTS4MINI: - return new ServiceDeviceSupport(new AmazfitGTS4MiniSupport()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITTREX2: - return new ServiceDeviceSupport(new AmazfitTRex2Support()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITGTR3PRO: - return new ServiceDeviceSupport(new AmazfitGTR3ProSupport()); + return new ServiceDeviceSupport(new Huami2021Support()); case AMAZFITBIP: return new ServiceDeviceSupport(new AmazfitBipSupport()); case AMAZFITBIP_LITE: diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java deleted file mode 100644 index f053b643a..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2022 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; - -import android.content.Context; -import android.net.Uri; - -import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; - -public abstract class AbstractHuami2021FWInstallHandler extends AbstractMiBandFWInstallHandler { - public AbstractHuami2021FWInstallHandler(final Uri uri, final Context context) { - super(uri, context); - } - - @Override - public void onStartInstall(GBDevice device) { - // 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(); - } -} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.java new file mode 100644 index 000000000..1601beed4 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.java @@ -0,0 +1,88 @@ +/* Copyright (C) 2022 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; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021FWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; + +public class Huami2021FWInstallHandler extends AbstractMiBandFWInstallHandler { + private final String deviceName; + private final Set deviceSources; + private final DeviceType deviceType; + private final Map crcMap; + + public Huami2021FWInstallHandler(final Uri uri, + final Context context, + final String deviceName, + final Set deviceSources, + final DeviceType deviceType, + final Map crcMap) { + super(uri, context); + this.deviceName = deviceName; + this.deviceSources = deviceSources; + this.deviceType = deviceType; + this.crcMap = crcMap; + } + + @Override + public Huami2021FWHelper getHelper() { + return (Huami2021FWHelper) helper; + } + + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == deviceType; + } + + @Override + protected String getFwUpgradeNotice() { + return mContext.getString( + R.string.fw_upgrade_notice_zip, + helper.getHumanFirmwareVersion(), + mContext.getString(deviceType.getName()) + ); + } + + @Override + protected Huami2021FWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new Huami2021FWHelper( + uri, + context, + deviceName, + deviceSources, + deviceType, + crcMap + ); + } + + @Override + public void onStartInstall(final GBDevice device) { + // 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(); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FirmwareInfo.java index b097a6dd8..cc7bbc677 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FirmwareInfo.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FirmwareInfo.java @@ -23,20 +23,21 @@ import android.graphics.BitmapFactory; import androidx.annotation.Nullable; import org.json.JSONArray; -import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; import java.io.IOException; import java.lang.reflect.Constructor; import java.nio.charset.StandardCharsets; import java.util.Arrays; +import java.util.Map; import java.util.Set; import java.util.UUID; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil; @@ -44,27 +45,39 @@ import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; -public abstract class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo { +public class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo { private static final Logger LOG = LoggerFactory.getLogger(Huami2021FirmwareInfo.class); + private final String deviceName; + private final Set deviceSources; + private final DeviceType deviceType; + private final Map crcMap; + private final String preComputedVersion; private GBDeviceApp gbDeviceApp; - public Huami2021FirmwareInfo(final byte[] bytes) { + public Huami2021FirmwareInfo(final byte[] bytes, + final String deviceName, + final Set deviceSources, + final DeviceType deviceType, + final Map crcMap) { super(bytes); + this.deviceName = deviceName; + this.deviceSources = deviceSources; + this.deviceType = deviceType; + this.crcMap = crcMap; this.preComputedVersion = preComputeVersion(); } - /** - * The device name, to search on firmware.bin in order to determine compatibility. - */ - public abstract String deviceName(); + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return device.getType() == deviceType; + } - /** - * 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 Map getCrcMap() { + return crcMap; + } @Override protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) { @@ -237,7 +250,7 @@ public abstract class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo { for (int j = 0; j < platforms.length(); j++) { final JSONObject platform = platforms.getJSONObject(j); - if (deviceSources().contains(platform.getInt("deviceSource"))) { + 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); @@ -354,8 +367,8 @@ public abstract class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo { return false; } - if (!searchString(firmwareBin, deviceName())) { - LOG.warn("Failed to find {} in fwBytes", deviceName()); + if (!searchString(firmwareBin, deviceName)) { + LOG.warn("Failed to find {} in fwBytes", deviceName); return false; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Support.java index f6565ad98..ba10383a8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021Support.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; @@ -80,6 +81,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021FWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Service; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; @@ -135,7 +137,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.MapUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; -public abstract class Huami2021Support extends HuamiSupport implements ZeppOsFileTransferService.Callback { +public class Huami2021Support extends HuamiSupport implements ZeppOsFileTransferService.Callback { private static final Logger LOG = LoggerFactory.getLogger(Huami2021Support.class); // Tracks whether realtime HR monitoring is already started, so we can just @@ -1204,6 +1206,19 @@ public abstract class Huami2021Support extends HuamiSupport implements ZeppOsFil } } + @Override + public Huami2021FWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + final Huami2021Coordinator coordinator = getCoordinator(); + return new Huami2021FWHelper( + uri, + context, + coordinator.deviceName(), + coordinator.deviceSources(), + coordinator.getDeviceType(), + coordinator.getFirmwareCrcMap() + ); + } + @Override public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) { return new UpdateFirmwareOperation2021(uri, this); 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 96cd494ec..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021FirmwareInfo; - -public class AmazfitBand7FirmwareInfo extends Huami2021FirmwareInfo { - 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 54ec99027..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class AmazfitBand7Support extends Huami2021Support { - @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/amazfitgtr3/AmazfitGTR3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java deleted file mode 100644 index ea10da33b..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2022 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.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.Huami2021FirmwareInfo; - -public class AmazfitGTR3FirmwareInfo extends Huami2021FirmwareInfo { - 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 74dd268e2..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2022 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.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.Huami2021Support; - -public class AmazfitGTR3Support extends Huami2021Support { - 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 649f1c665..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2023 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.Huami2021FirmwareInfo; - -public class AmazfitGTR3ProFirmwareInfo extends Huami2021FirmwareInfo { - 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 ae17ebb40..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2023 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.amazfitgtr3.AmazfitGTR3FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; - -public class AmazfitGTR3ProSupport extends Huami2021Support { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProSupport.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/amazfitgtr4/AmazfitGTR4FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java deleted file mode 100644 index f732a10d9..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021FirmwareInfo; - -public class AmazfitGTR4FirmwareInfo extends Huami2021FirmwareInfo { - 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)"); - }}; - - 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 bd88707d4..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class AmazfitGTR4Support extends Huami2021Support { - @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/amazfitgts3/AmazfitGTS3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java deleted file mode 100644 index e921611f9..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2022 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.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.Huami2021FirmwareInfo; - -public class AmazfitGTS3FirmwareInfo extends Huami2021FirmwareInfo { - 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 35e041b4f..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2022 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.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.R; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3.AmazfitGTS3FWHelper; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; - -public class AmazfitGTS3Support extends Huami2021Support { - 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 c4faaec9e..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021FirmwareInfo; - -public class AmazfitGTS4FirmwareInfo extends Huami2021FirmwareInfo { - 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 149131b9e..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class AmazfitGTS4Support extends Huami2021Support { - @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 7d77e2359..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021FirmwareInfo; - -public class AmazfitGTS4MiniFirmwareInfo extends Huami2021FirmwareInfo { - 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 f70ce608e..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class AmazfitGTS4MiniSupport extends Huami2021Support { - @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 6d66a29d5..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021FirmwareInfo; - -public class AmazfitTRex2FirmwareInfo extends Huami2021FirmwareInfo { - 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 76eab59d7..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class AmazfitTRex2Support extends Huami2021Support { - @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/miband7/MiBand7FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java deleted file mode 100644 index 9fab786ff..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2022 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 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.Huami2021FirmwareInfo; - -public class MiBand7FirmwareInfo extends Huami2021FirmwareInfo { - 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"); - }}; - - 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 863d78ef4..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2022 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.Huami2021Support; - -public class MiBand7Support extends Huami2021Support { - @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/UpdateFirmwareOperation2021.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java index 944a38aad..be99b8dbe 100644 --- 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 @@ -24,12 +24,12 @@ import org.slf4j.LoggerFactory; import java.io.IOException; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021FWHelper; 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.Huami2021FirmwareInfo; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType; import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { @@ -40,8 +40,9 @@ public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { } @Override - AbstractHuamiFirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException { - return super.createFwInfo(uri, context); + Huami2021FirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException { + final Huami2021FWHelper fwHelper = getSupport().createFWHelper(uri, context); + return fwHelper.getFirmwareInfo(); /* This does not actually seem to be needed, but it's what the official app does final HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context); @@ -71,7 +72,7 @@ public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { super.handleNotificationNotif(value); if (ArrayUtils.startsWith(value, new byte[]{HuamiService.RESPONSE, COMMAND_FINALIZE_UPDATE, HuamiService.SUCCESS})) { - if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.APP) { + if (getFirmwareInfo().getFirmwareType().isApp()) { // 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"); @@ -80,7 +81,7 @@ public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { } catch (final IOException e) { LOG.error("Failed to request display items after app install", e); } - } else if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.WATCHFACE) { + } else if (getFirmwareInfo().getFirmwareType().isWatchface()) { // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end) try { TransactionBuilder builder = performInitialized("request watchfaces"); @@ -93,6 +94,11 @@ public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { } } + @Override + Huami2021FirmwareInfo getFirmwareInfo() { + return (Huami2021FirmwareInfo) firmwareInfo; + } + @Override protected byte[] buildFirmwareInfoCommand() { final int fwSize = firmwareInfo.getSize(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsAlexaService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsAlexaService.java index a1f632f84..a238b3832 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsAlexaService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/services/ZeppOsAlexaService.java @@ -17,7 +17,6 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_VOICE_SERVICE_LANGUAGE; -import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_WATCHFACE; import android.widget.Toast; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4507d9bca..fbff6607e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -154,15 +154,7 @@ You are about to install the %s firmware on your Mi Band 4.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Mi Band 5.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Mi Band 6.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Xiaomi Smart Band 7.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTS 3.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTS 4.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTS 4 Mini.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTR 3.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTR 3 Pro.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit GTR 4.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit T-Rex 2.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! - You are about to install the %s firmware on your Amazfit Band 7.\n\nYour band will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! + You are about to install the %s firmware on your %s.\n\nYour watch will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Amazfit X.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Amazfit Neo. \n diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021SupportTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021SupportTest.java index 4850c4db5..e0d1146d2 100644 --- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021SupportTest.java +++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021SupportTest.java @@ -31,7 +31,7 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.UUID; -import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021FWHelper; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction; @@ -55,7 +55,7 @@ public class Huami2021SupportTest { } @Override - public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + public Huami2021FWHelper createFWHelper(final Uri uri, final Context context) throws IOException { return null; }