From 454d766e8838f7e6ee3cb73fac99f16c1299ac9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Thu, 17 Aug 2023 23:20:43 +0100 Subject: [PATCH] Zepp OS: Add all remaining devices as experimental --- README.md | 5 + .../devices/huami/HuamiConst.java | 6 + .../amazfitbip5/AmazfitBip5Coordinator.java | 103 +++++++++++++++++ .../amazfitbip5/AmazfitBip5FWHelper.java | 44 +++++++ .../AmazfitBip5FWInstallHandler.java | 50 ++++++++ .../AmazfitCheetahProCoordinator.java | 5 - .../AmazfitCheetahRoundCoordinator.java | 108 ++++++++++++++++++ .../AmazfitCheetahRoundFWHelper.java | 44 +++++++ .../AmazfitCheetahRoundFWInstallHandler.java | 50 ++++++++ .../AmazfitCheetahSquareCoordinator.java | 108 ++++++++++++++++++ .../AmazfitCheetahSquareFWHelper.java | 44 +++++++ .../AmazfitCheetahSquareFWInstallHandler.java | 50 ++++++++ .../AmazfitFalconCoordinator.java | 88 ++++++++++++++ .../amazfitfalcon/AmazfitFalconFWHelper.java | 44 +++++++ .../AmazfitFalconFWInstallHandler.java | 50 ++++++++ .../AmazfitGTRMiniCoordinator.java | 103 +++++++++++++++++ .../AmazfitGTRMiniFWHelper.java | 44 +++++++ .../AmazfitGTRMiniFWInstallHandler.java | 50 ++++++++ .../AmazfitTRexUltraCoordinator.java | 103 +++++++++++++++++ .../AmazfitTRexUltraFWHelper.java | 44 +++++++ .../AmazfitTRexUltraFWInstallHandler.java | 50 ++++++++ .../gadgetbridge/model/DeviceType.java | 6 + .../service/DeviceSupportFactory.java | 18 +++ .../AbstractHuami2021FWInstallHandler.java | 1 - .../amazfitbip5/AmazfitBip5FirmwareInfo.java | 58 ++++++++++ .../huami/amazfitbip5/AmazfitBip5Support.java | 33 ++++++ .../AmazfitCheetahRoundFirmwareInfo.java | 58 ++++++++++ .../AmazfitCheetahRoundSupport.java | 33 ++++++ .../AmazfitCheetahSquareFirmwareInfo.java | 58 ++++++++++ .../AmazfitCheetahSquareSupport.java | 33 ++++++ .../AmazfitFalconFirmwareInfo.java | 58 ++++++++++ .../amazfitfalcon/AmazfitFalconSupport.java | 33 ++++++ .../AmazfitGTRMiniFirmwareInfo.java | 58 ++++++++++ .../amazfitgtrmini/AmazfitGTRMiniSupport.java | 33 ++++++ .../AmazfitTRexUltraFirmwareInfo.java | 58 ++++++++++ .../AmazfitTRexUltraSupport.java | 33 ++++++ .../gadgetbridge/util/DeviceHelper.java | 14 ++- app/src/main/res/values/strings.xml | 7 ++ 38 files changed, 1778 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java diff --git a/README.md b/README.md index 7e261a129..af4f364e5 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,16 @@ vendor's servers. - [Bip](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip) - [Bip Lite](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-Lite), [Bip S](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-S), [Bip U](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-U) [**\[!\]**](#special-pairing-procedures) - [Bip 3 Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-3-Pro) [**\[!\]**](#special-pairing-procedures) + - [Bip 5 (experimental)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-5) [**\[!\]**](#special-pairing-procedures) - [Cor](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor), [Cor 2](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor-2) + - [Falcon (experimental)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Falcon) [**\[!\]**](#special-pairing-procedures) - [GTR](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR), [GTR 2/2e](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR), [GTR 3](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-3), [GTR 3 Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-3-Pro), [GTR 4](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-4) [**\[!\]**](#special-pairing-procedures) + - [GTR Mini (experimental)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-Mini) [**\[!\]**](#special-pairing-procedures) - [GTS](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS), [GTS 2/2e](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS), [GTS 3](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-3), [GTS 4](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-4), [GTS 4 Mini](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-4-Mini) [**\[!\]**](#special-pairing-procedures) - [Neo](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Neo) [**\[!\]**](#special-pairing-procedures) - T-Rex, T-Rex Pro, [T-Rex 2](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-T-Rex-2) [**\[!\]**](#special-pairing-procedures) + - [T-Rex Ultra (experimental)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-T-Rex-Ultra) [**\[!\]**](#special-pairing-procedures) + - [Cheetah (Round/Square) (experimental)](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cheetah) [**\[!\]**](#special-pairing-procedures) - [Cheetah Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cheetah-Pro) [**\[!\]**](#special-pairing-procedures) - Verge Lite [**\[!\]**](#special-pairing-procedures) - [X ](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Mi-Band-5) [**\[!\]**](#special-pairing-procedures) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java index 770ec1b1a..11e52af60 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/HuamiConst.java @@ -56,14 +56,20 @@ public class HuamiConst { public static final String AMAZFIT_BAND7_NAME = "Amazfit Band 7"; public static final String AMAZFIT_NEO_NAME = "Amazfit Neo"; public static final String AMAZFIT_X = "Amazfit X"; + public static final String AMAZFIT_BIP5_NAME = "Amazfit Bip 5"; public static final String AMAZFIT_GTS3_NAME = "Amazfit GTS 3"; public static final String AMAZFIT_GTS4_NAME = "Amazfit GTS 4"; public static final String AMAZFIT_GTS4_MINI_NAME = "Amazfit GTS 4 Mini"; public static final String AMAZFIT_GTR3_NAME = "Amazfit GTR 3"; public static final String AMAZFIT_GTR3_PRO_NAME = "Amazfit GTR 3 Pro"; public static final String AMAZFIT_GTR4_NAME = "Amazfit GTR 4"; + public static final String AMAZFIT_GTR_MINI_NAME = "Amazfit GTR Mini"; public static final String AMAZFIT_TREX_2_NAME = "Amazfit T-Rex 2"; + public static final String AMAZFIT_TREX_ULTRA = "Amazfit T-Rex Ultra"; public static final String AMAZFIT_CHEETAH_PRO_NAME = "Amazfit Cheetah Pro"; + public static final String AMAZFIT_CHEETAH_SQUARE_NAME = "Amazfit Cheetah S"; + public static final String AMAZFIT_CHEETAH_ROUND_NAME = "Amazfit Cheetah R"; + public static final String AMAZFIT_FALCON_NAME = "Amazfit Falcon"; public static final String XIAOMI_SMART_BAND7_NAME = "Xiaomi Smart Band 7"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java new file mode 100644 index 000000000..b44296349 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5Coordinator.java @@ -0,0 +1,103 @@ +/* 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.amazfitbip5; + +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 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 AmazfitBip5Coordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip5Coordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_BIP5_NAME)) { + return DeviceType.AMAZFITBIP5; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITBIP5; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitBip5FWInstallHandler(uri, context); + } + + @Override + public boolean supportsContinuousFindDevice() { + return true; + } + + @Override + public boolean supportsGpxUploads() { + return true; + } + + @Override + public boolean supportsControlCenter() { + return true; + } + + @Override + public boolean supportsToDoList() { + return true; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return false; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return false; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.java new file mode 100644 index 000000000..5571113ba --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWHelper.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.amazfitbip5; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5.AmazfitBip5FirmwareInfo; + +public class AmazfitBip5FWHelper extends HuamiFWHelper { + public AmazfitBip5FWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitBip5FirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Bip 5 firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java new file mode 100644 index 000000000..b9d52a685 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbip5/AmazfitBip5FWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfitbip5; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitBip5FWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitBip5FWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_bip5); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitBip5FWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITBIP5; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java index 790de82ac..598e97ca6 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahpro/AmazfitCheetahProCoordinator.java @@ -86,11 +86,6 @@ public class AmazfitCheetahProCoordinator extends Huami2021Coordinator { return true; } - @Override - public boolean supportsAppReordering() { - return true; - } - @Override public boolean supportsWifiHotspot(final GBDevice device) { return true; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java new file mode 100644 index 000000000..bdd29abe7 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundCoordinator.java @@ -0,0 +1,108 @@ +/* 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.amazfitcheetahround; + +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 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 AmazfitCheetahRoundCoordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahRoundCoordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME)) { + return DeviceType.AMAZFITCHEETAHROUND; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITCHEETAHROUND; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitCheetahRoundFWInstallHandler(uri, context); + } + + @Override + public boolean supportsContinuousFindDevice() { + return true; + } + + @Override + public boolean mainMenuHasMoreSection() { + return true; + } + + @Override + public boolean supportsGpxUploads() { + return true; + } + + @Override + public boolean supportsControlCenter() { + return true; + } + + @Override + public boolean supportsToDoList() { + return true; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return true; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return true; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.java new file mode 100644 index 000000000..dad1c755e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWHelper.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.amazfitcheetahround; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround.AmazfitCheetahRoundFirmwareInfo; + +public class AmazfitCheetahRoundFWHelper extends HuamiFWHelper { + public AmazfitCheetahRoundFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitCheetahRoundFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Cheetah (Round) firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java new file mode 100644 index 000000000..8650ef6ad --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfitcheetahround; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitCheetahRoundFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitCheetahRoundFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_round); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitCheetahRoundFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITCHEETAHROUND; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java new file mode 100644 index 000000000..9dae378cd --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareCoordinator.java @@ -0,0 +1,108 @@ +/* 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.amazfitcheetahsquare; + +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 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 AmazfitCheetahSquareCoordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahSquareCoordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME)) { + return DeviceType.AMAZFITCHEETAHSQUARE; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITCHEETAHSQUARE; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitCheetahSquareFWInstallHandler(uri, context); + } + + @Override + public boolean supportsContinuousFindDevice() { + return true; + } + + @Override + public boolean mainMenuHasMoreSection() { + return true; + } + + @Override + public boolean supportsGpxUploads() { + return true; + } + + @Override + public boolean supportsControlCenter() { + return true; + } + + @Override + public boolean supportsToDoList() { + return true; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return true; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return true; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.java new file mode 100644 index 000000000..d8ed7660f --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWHelper.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.amazfitcheetahsquare; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareFirmwareInfo; + +public class AmazfitCheetahSquareFWHelper extends HuamiFWHelper { + public AmazfitCheetahSquareFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitCheetahSquareFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Cheetah (Square) firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java new file mode 100644 index 000000000..ae49ffb7b --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfitcheetahsquare; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitCheetahSquareFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitCheetahSquareFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_square); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitCheetahSquareFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITCHEETAHSQUARE; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java new file mode 100644 index 000000000..27bead94b --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconCoordinator.java @@ -0,0 +1,88 @@ +/* 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.amazfitfalcon; + +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 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 AmazfitFalconCoordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitFalconCoordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_FALCON_NAME)) { + return DeviceType.AMAZFITFALCON; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITFALCON; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitFalconFWInstallHandler(uri, context); + } + + @Override + public boolean sendAgpsAsFileTransfer() { + return false; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return true; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return true; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return false; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.java new file mode 100644 index 000000000..0b85874c1 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWHelper.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.amazfitfalcon; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon.AmazfitFalconFirmwareInfo; + +public class AmazfitFalconFWHelper extends HuamiFWHelper { + public AmazfitFalconFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitFalconFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Falcon firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java new file mode 100644 index 000000000..3c00e64c8 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitfalcon/AmazfitFalconFWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfitfalcon; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitFalconFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitFalconFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_falcon); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitFalconFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITFALCON; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java new file mode 100644 index 000000000..8e3770876 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniCoordinator.java @@ -0,0 +1,103 @@ +/* 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.amazfitgtrmini; + +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 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 AmazfitGTRMiniCoordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTRMiniCoordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR_MINI_NAME)) { + return DeviceType.AMAZFITGTRMINI; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITGTRMINI; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitGTRMiniFWInstallHandler(uri, context); + } + + @Override + public boolean supportsContinuousFindDevice() { + return true; + } + + @Override + public boolean supportsGpxUploads() { + return true; + } + + @Override + public boolean supportsControlCenter() { + return true; + } + + @Override + public boolean supportsToDoList() { + return true; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return false; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return false; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return false; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.java new file mode 100644 index 000000000..9528939ae --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWHelper.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.amazfitgtrmini; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini.AmazfitGTRMiniFirmwareInfo; + +public class AmazfitGTRMiniFWHelper extends HuamiFWHelper { + public AmazfitGTRMiniFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitGTRMiniFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit GTR Mini firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java new file mode 100644 index 000000000..df36edac7 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgtrmini/AmazfitGTRMiniFWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfitgtrmini; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitGTRMiniFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitGTRMiniFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_gtr_mini); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitGTRMiniFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITGTRMINI; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java new file mode 100644 index 000000000..7767c8fb8 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraCoordinator.java @@ -0,0 +1,103 @@ +/* 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.amazfittrexultra; + +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 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 AmazfitTRexUltraCoordinator extends Huami2021Coordinator { + private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexUltraCoordinator.class); + + @Override + public boolean isExperimental() { + return true; + } + + @NonNull + @Override + public DeviceType getSupportedType(final GBDeviceCandidate candidate) { + try { + final BluetoothDevice device = candidate.getDevice(); + final String name = device.getName(); + if (name != null && name.startsWith(HuamiConst.AMAZFIT_TREX_ULTRA)) { + return DeviceType.AMAZFITTREXULTRA; + } + } catch (final Exception e) { + LOG.error("unable to check device support", e); + } + + return DeviceType.UNKNOWN; + } + + @Override + public DeviceType getDeviceType() { + return DeviceType.AMAZFITTREXULTRA; + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitTRexUltraFWInstallHandler(uri, context); + } + + @Override + public boolean supportsContinuousFindDevice() { + return true; + } + + @Override + public boolean supportsGpxUploads() { + return true; + } + + @Override + public boolean supportsControlCenter() { + return true; + } + + @Override + public boolean supportsToDoList() { + return true; + } + + @Override + public boolean supportsWifiHotspot(final GBDevice device) { + return true; + } + + @Override + public boolean supportsFtpServer(final GBDevice device) { + return true; + } + + @Override + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return false; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.java new file mode 100644 index 000000000..1a3d4396e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWHelper.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.amazfittrexultra; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra.AmazfitTRexUltraFirmwareInfo; + +public class AmazfitTRexUltraFWHelper extends HuamiFWHelper { + public AmazfitTRexUltraFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitTRexUltraFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit T-Rex Ultra firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java new file mode 100644 index 000000000..8c89342a5 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfittrexultra/AmazfitTRexUltraFWInstallHandler.java @@ -0,0 +1,50 @@ +/* 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.amazfittrexultra; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitTRexUltraFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitTRexUltraFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_trex_ultra); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitTRexUltraFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITTREXULTRA; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java index 0e032731a..93976d158 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -77,6 +77,12 @@ public enum DeviceType { AMAZFITGTR3PRO(10049, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_gtr3_pro), AMAZFITBIP3PRO(10051, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_bip3_pro), AMAZFITCHEETAHPRO(10050, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_cheetah_pro), + AMAZFITCHEETAHSQUARE(10052, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_cheetah_square), + AMAZFITCHEETAHROUND(10053, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_cheetah_round), + AMAZFITBIP5(10054, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_bip5), + AMAZFITTREXULTRA(10055, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_trex_ultra), + AMAZFITGTRMINI(10056, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_gtr_mini), + AMAZFITFALCON(10057, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_falcon), HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_hplus), MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_makibes_f68), EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_exrizu_k8), 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 ad0177725..889702edb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -45,13 +45,17 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.A 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.amazfitbip3pro.AmazfitBip3ProSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5.AmazfitBip5Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSLiteSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipu.AmazfitBipUSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipupro.AmazfitBipUProSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro.AmazfitCheetahProSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround.AmazfitCheetahRoundSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor.AmazfitCorSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor2.AmazfitCor2Support; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon.AmazfitFalconSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRLiteSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2Support; @@ -59,6 +63,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.Am 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.amazfitgtrmini.AmazfitGTRMiniSupport; 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; @@ -72,6 +77,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpoppro. 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.amazfittrexultra.AmazfitTRexUltraSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.AmazfitVergeLSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitx.AmazfitXSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support; @@ -196,6 +202,18 @@ public class DeviceSupportFactory { return new ServiceDeviceSupport(new MiBand6Support()); case AMAZFITCHEETAHPRO: return new ServiceDeviceSupport(new AmazfitCheetahProSupport()); + case AMAZFITCHEETAHSQUARE: + return new ServiceDeviceSupport(new AmazfitCheetahSquareSupport()); + case AMAZFITCHEETAHROUND: + return new ServiceDeviceSupport(new AmazfitCheetahRoundSupport()); + case AMAZFITBIP5: + return new ServiceDeviceSupport(new AmazfitBip5Support()); + case AMAZFITTREXULTRA: + return new ServiceDeviceSupport(new AmazfitTRexUltraSupport()); + case AMAZFITGTRMINI: + return new ServiceDeviceSupport(new AmazfitGTRMiniSupport()); + case AMAZFITFALCON: + return new ServiceDeviceSupport(new AmazfitFalconSupport()); case AMAZFITGTS3: return new ServiceDeviceSupport(new AmazfitGTS3Support()); case AMAZFITGTR3: 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 index 83669b99d..bcc2eba6b 100644 --- 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 @@ -33,7 +33,6 @@ import java.io.Writer; import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; -import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper; import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java new file mode 100644 index 000000000..c12587496 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfitbip5; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitBip5FirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitBip5FirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_BIP5_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Collections.singletonList(8454401)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITBIP5; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java new file mode 100644 index 000000000..cc4db2b64 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java @@ -0,0 +1,33 @@ +/* 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.amazfitbip5; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5.AmazfitBip5FWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitBip5Support extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitBip5FWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java new file mode 100644 index 000000000..66bd01d9b --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfitcheetahround; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitCheetahRoundFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitCheetahRoundFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(8192256, 8192257)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHROUND; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java new file mode 100644 index 000000000..f5a55bcac --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java @@ -0,0 +1,33 @@ +/* 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.amazfitcheetahround; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround.AmazfitCheetahRoundFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitCheetahRoundSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitCheetahRoundFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java new file mode 100644 index 000000000..3b808afe9 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfitcheetahsquare; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitCheetahSquareFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitCheetahSquareFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Collections.singletonList(8257793)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHSQUARE; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java new file mode 100644 index 000000000..799b2f5c0 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java @@ -0,0 +1,33 @@ +/* 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.amazfitcheetahsquare; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitCheetahSquareSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitCheetahSquareFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java new file mode 100644 index 000000000..aaee2570b --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfitfalcon; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitFalconFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitFalconFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_FALCON_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(414, 415)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITFALCON; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java new file mode 100644 index 000000000..8a5266ea9 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java @@ -0,0 +1,33 @@ +/* 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.amazfitfalcon; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon.AmazfitFalconFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitFalconSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitFalconFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java new file mode 100644 index 000000000..b988083bf --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfitgtrmini; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitGTRMiniFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitGTRMiniFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_GTR_MINI_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(250, 251)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTRMINI; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java new file mode 100644 index 000000000..14e162aba --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java @@ -0,0 +1,33 @@ +/* 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.amazfitgtrmini; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini.AmazfitGTRMiniFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitGTRMiniSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitGTRMiniFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java new file mode 100644 index 000000000..4c705fe1f --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java @@ -0,0 +1,58 @@ +/* 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.amazfittrexultra; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitTRexUltraFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitTRexUltraFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_TREX_ULTRA; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(6553856, 6553857)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREXULTRA; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java new file mode 100644 index 000000000..37ebdba96 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java @@ -0,0 +1,33 @@ +/* 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.amazfittrexultra; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra.AmazfitTRexUltraFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitTRexUltraSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitTRexUltraFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java index d9d49d7f4..77df9c41b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/DeviceHelper.java @@ -27,7 +27,6 @@ import android.bluetooth.BluetoothDevice; import android.content.Context; import android.widget.Toast; -import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.VivomoveHrCoordinator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,23 +76,29 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband5.AmazfitBa import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7.AmazfitBand7Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbips.AmazfitBipSLiteCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro.AmazfitCheetahProCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround.AmazfitCheetahRoundCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS2MiniCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS2eCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitneo.AmazfitNeoCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipLiteCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro.AmazfitBip3ProCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5.AmazfitBip5Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbips.AmazfitBipSCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipu.AmazfitBipUCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipupro.AmazfitBipUProCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor.AmazfitCorCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor2.AmazfitCor2Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon.AmazfitFalconCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRLiteCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2.AmazfitGTR2Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini.AmazfitGTRMiniCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitpop.AmazfitPopCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitpoppro.AmazfitPopProCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexpro.AmazfitTRexProCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra.AmazfitTRexUltraCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitx.AmazfitXCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband6.MiBand6Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7.MiBand7Coordinator; @@ -142,6 +147,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator.BinarySenso import nodomain.freeyourgadget.gadgetbridge.devices.um25.Coordinator.UM25Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.vesc.VescCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.vibratissimo.VibratissimoCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr.VivomoveHrCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.waspos.WaspOSCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.watch9.Watch9DeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.coordinators.SonyWFSP800NCoordinator; @@ -308,6 +314,12 @@ public class DeviceHelper { result.add(new AmazfitBand5Coordinator()); result.add(new AmazfitBand7Coordinator()); result.add(new AmazfitNeoCoordinator()); + result.add(new AmazfitBip5Coordinator()); + result.add(new AmazfitCheetahRoundCoordinator()); + result.add(new AmazfitCheetahSquareCoordinator()); + result.add(new AmazfitFalconCoordinator()); + result.add(new AmazfitGTRMiniCoordinator()); + result.add(new AmazfitTRexUltraCoordinator()); result.add(new MiBand3Coordinator()); result.add(new MiBand4Coordinator()); result.add(new MiBand5Coordinator()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f37802d18..7ef1c9a2d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -166,6 +166,7 @@ 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 Cheetah 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 %s.\n\nYour watch will reboot after installing the .zip file.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Amazfit X.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK! You are about to install the %s firmware on your Amazfit Neo. \n @@ -1272,6 +1273,8 @@ Mi Band 5 Mi Band 6 Xiaomi Smart Band 7 + Amazfit Cheetah (Square) + Amazfit Cheetah (Round) Amazfit Cheetah Pro Amazfit GTS 3 Amazfit GTS 4 @@ -1279,8 +1282,10 @@ Amazfit GTR 3 Amazfit GTR 3 Pro Amazfit Bip 3 Pro + Amazfit Bip 5 Amazfit GTR 4 Amazfit T-Rex 2 + Amazfit T-Rex Ultra Amazfit Band 5 Amazfit Band 7 Amazfit Neo @@ -1290,6 +1295,8 @@ Amazfit Cor 2 Amazfit GTR Amazfit GTR Lite + Amazfit GTR Mini + Amazfit Falcon Amazfit T-Rex Amazfit Bip S Amazfit Bip S Lite