From 853470a2bd81afde251a21d8fd7fbd7fc91c5867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 15 Jun 2023 21:39:22 +0100 Subject: [PATCH] Revert "Zepp OS: Unify support class and fw handling" This reverts commit d59e8c3f62eba11afb68de77919080e0682dd50e. We need to refactor the Huami classes too, otherwise this needs a lot of hacks to work properly. --- .../devices/huami/Huami2021Coordinator.java | 44 +++------- .../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, 1840 insertions(+), 385 deletions(-) delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java delete mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java create 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 9ab9e2a16..49ae67868 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,19 +28,16 @@ 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; @@ -51,19 +48,21 @@ 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.Huami2021FWInstallHandler; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiLanguageType; -import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiVibrationPatternNotificationType; +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.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.service.devices.huami.zeppos.services.ZeppOsConfigService; +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.ZeppOsPhoneService; 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()) { @@ -80,15 +79,7 @@ public abstract class Huami2021Coordinator extends HuamiCoordinator { } } - final Huami2021FWInstallHandler handler = new Huami2021FWInstallHandler( - uri, - context, - deviceName(), - deviceSources(), - getDeviceType(), - getFirmwareCrcMap() - ); - + final AbstractHuami2021FWInstallHandler handler = createFwInstallHandler(uri, context); return handler.isValid() ? handler : null; } @@ -454,21 +445,6 @@ 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 deleted file mode 100644 index 53657cbb5..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/Huami2021FWHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/* 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 f275cc54c..000a906a2 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,23 +17,20 @@ 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); @@ -60,13 +57,8 @@ public class AmazfitBand7Coordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_BAND7_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(252, 253, 254)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitBand7FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..90d01983c --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..659164e72 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitband7/AmazfitBand7FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 d3371e6d6..7fdf02e35 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitGTR3Coordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR3_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(226, 227)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTR3FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..991396c68 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..7220bddcd --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3/AmazfitGTR3FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 1e1573636..a377b82ef 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTR3_PRO_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(229, 230, 6095106)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTR3ProFWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..8e86dadec --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..00a5b1b77 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 5366c8683..bcfb14020 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,23 +17,20 @@ 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); @@ -60,22 +57,8 @@ public class AmazfitGTR4Coordinator extends Huami2021Coordinator { } @Override - 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)"); - }}; + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTR4FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..50a41718f --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..64fcd3fbe --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtr4/AmazfitGTR4FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 445c244dd..d2266ef2e 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitGTS3Coordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS3_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(224, 225)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTS3FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..f37b4eddd --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..f9203b700 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts3/AmazfitGTS3FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 ee6debf31..8f96ffa7c 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitGTS4Coordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS4_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(7995648, 7995649)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTS4FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..707d3a40c --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..ccc5d3f58 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 e22b3de8e..4abf0f513 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_GTS4_MINI_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(246, 247)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTS4MiniFWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..e18020ac9 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..8adcfca39 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 10d3239b8..920ce80d3 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,21 +17,20 @@ 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); @@ -58,13 +57,8 @@ public class AmazfitTRex2Coordinator extends Huami2021Coordinator { } @Override - public String deviceName() { - return HuamiConst.AMAZFIT_TREX_2_NAME; - } - - @Override - public Set deviceSources() { - return new HashSet<>(Arrays.asList(418, 419)); + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitTRex2FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..e22e2c6db --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..9c3a72cb3 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrex2/AmazfitTRex2FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 74c045ef9..057b4f9d6 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,23 +17,20 @@ 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); @@ -60,23 +57,8 @@ public class MiBand7Coordinator extends Huami2021Coordinator { } @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 Map getFirmwareCrcMap() { - return new HashMap() {{ - // firmware - put(26036, "1.20.3.1"); - put(55449, "1.27.0.4"); - put(14502, "2.0.0.2"); - }}; + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new MiBand7FWInstallHandler(uri, context); } @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 new file mode 100644 index 000000000..a3dd2ef41 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWHelper.java @@ -0,0 +1,44 @@ +/* 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 new file mode 100644 index 000000000..7c0c35cae --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/miband7/MiBand7FWInstallHandler.java @@ -0,0 +1,49 @@ +/* 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 3b3867b11..d5ba1829b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -43,8 +43,9 @@ 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.Huami2021Support; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; 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; @@ -57,14 +58,21 @@ 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; @@ -73,6 +81,7 @@ 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; @@ -184,23 +193,23 @@ public class DeviceSupportFactory { case MIBAND6: return new ServiceDeviceSupport(new MiBand6Support()); case AMAZFITGTS3: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTS3Support()); case AMAZFITGTR3: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTR3Support()); case AMAZFITGTR4: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTR4Support()); case MIBAND7: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new MiBand7Support()); case AMAZFITBAND7: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitBand7Support()); case AMAZFITGTS4: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTS4Support()); case AMAZFITGTS4MINI: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTS4MiniSupport()); case AMAZFITTREX2: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitTRex2Support()); case AMAZFITGTR3PRO: - return new ServiceDeviceSupport(new Huami2021Support()); + return new ServiceDeviceSupport(new AmazfitGTR3ProSupport()); 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 new file mode 100644 index 000000000..f053b643a --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuami2021FWInstallHandler.java @@ -0,0 +1,37 @@ +/* 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 deleted file mode 100644 index 1601beed4..000000000 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/Huami2021FWInstallHandler.java +++ /dev/null @@ -1,88 +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 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 cc7bbc677..b097a6dd8 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,21 +23,20 @@ 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; @@ -45,39 +44,27 @@ import nodomain.freeyourgadget.gadgetbridge.util.ZipFile; import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException; -public class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo { +public abstract 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, - final String deviceName, - final Set deviceSources, - final DeviceType deviceType, - final Map crcMap) { + public Huami2021FirmwareInfo(final byte[] bytes) { super(bytes); - this.deviceName = deviceName; - this.deviceSources = deviceSources; - this.deviceType = deviceType; - this.crcMap = crcMap; this.preComputedVersion = preComputeVersion(); } - @Override - public boolean isGenerallyCompatibleWith(final GBDevice device) { - return device.getType() == deviceType; - } + /** + * The device name, to search on firmware.bin in order to determine compatibility. + */ + public abstract String deviceName(); - @Override - protected Map getCrcMap() { - return crcMap; - } + /** + * The device sources, to match compatible packages. + * As per: https://docs.zepp.com/docs/reference/related-resources/device-list/ + */ + public abstract Set deviceSources(); @Override protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) { @@ -250,7 +237,7 @@ public 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); @@ -367,8 +354,8 @@ public 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 ba10383a8..f6565ad98 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,7 +38,6 @@ 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; @@ -81,7 +80,6 @@ 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; @@ -137,7 +135,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.MapUtils; import nodomain.freeyourgadget.gadgetbridge.util.Prefs; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; -public class Huami2021Support extends HuamiSupport implements ZeppOsFileTransferService.Callback { +public abstract 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 @@ -1206,19 +1204,6 @@ public class Huami2021Support extends HuamiSupport implements ZeppOsFileTransfer } } - @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 new file mode 100644 index 000000000..96cd494ec --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java @@ -0,0 +1,57 @@ +/* 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 new file mode 100644 index 000000000..54ec99027 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java @@ -0,0 +1,33 @@ +/* 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 new file mode 100644 index 000000000..ea10da33b --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java @@ -0,0 +1,63 @@ +/* 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 new file mode 100644 index 000000000..74dd268e2 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java @@ -0,0 +1,38 @@ +/* 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 new file mode 100644 index 000000000..649f1c665 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java @@ -0,0 +1,63 @@ +/* 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 new file mode 100644 index 000000000..ae17ebb40 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java @@ -0,0 +1,38 @@ +/* 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 new file mode 100644 index 000000000..f732a10d9 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java @@ -0,0 +1,60 @@ +/* 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 new file mode 100644 index 000000000..bd88707d4 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java @@ -0,0 +1,33 @@ +/* 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 new file mode 100644 index 000000000..e921611f9 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java @@ -0,0 +1,63 @@ +/* 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 new file mode 100644 index 000000000..35e041b4f --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java @@ -0,0 +1,39 @@ +/* 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 new file mode 100644 index 000000000..c4faaec9e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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 new file mode 100644 index 000000000..149131b9e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java @@ -0,0 +1,33 @@ +/* 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 new file mode 100644 index 000000000..7d77e2359 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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 new file mode 100644 index 000000000..f70ce608e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java @@ -0,0 +1,33 @@ +/* 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 new file mode 100644 index 000000000..6d66a29d5 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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 new file mode 100644 index 000000000..76eab59d7 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java @@ -0,0 +1,33 @@ +/* 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 new file mode 100644 index 000000000..9fab786ff --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java @@ -0,0 +1,64 @@ +/* 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 new file mode 100644 index 000000000..863d78ef4 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java @@ -0,0 +1,33 @@ +/* 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 be99b8dbe..944a38aad 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.Huami2021FirmwareInfo; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo; 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,9 +40,8 @@ public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 { } @Override - Huami2021FirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException { - final Huami2021FWHelper fwHelper = getSupport().createFWHelper(uri, context); - return fwHelper.getFirmwareInfo(); + AbstractHuamiFirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException { + return super.createFwInfo(uri, context); /* This does not actually seem to be needed, but it's what the official app does final HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context); @@ -72,7 +71,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().isApp()) { + if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.APP) { // After an app is installed, request the display items from the band (new app will be at the end) try { TransactionBuilder builder = performInitialized("request display items"); @@ -81,7 +80,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().isWatchface()) { + } else if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.WATCHFACE) { // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end) try { TransactionBuilder builder = performInitialized("request watchfaces"); @@ -94,11 +93,6 @@ 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 a238b3832..a1f632f84 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,6 +17,7 @@ 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 fbff6607e..4507d9bca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -154,7 +154,15 @@ 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 %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 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 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 e0d1146d2..4850c4db5 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.Huami2021FWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction; @@ -55,7 +55,7 @@ public class Huami2021SupportTest { } @Override - public Huami2021FWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { return null; }