diff --git a/README.md b/README.md index a17bfb829..8582f4561 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ vendor's servers. **(WARNING: Some of them WIP and some of them without maintainer)** - Amazfit + - [Amazfit Active](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Active), [Amazfit Active Edge](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Active-Edge) [**\[!\]**](#special-pairing-procedures) - [Balance](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Balance) [**\[!\]**](#special-pairing-procedures) - [Band 5](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Band-5), [Band 7](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Band-7) [**\[!\]**](#special-pairing-procedures) - [Bip](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip) 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 6845c8b13..c3707f131 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 @@ -52,6 +52,8 @@ public class HuamiConst { public static final String MI_BAND4_NAME = "Mi Smart Band 4"; public static final String MI_BAND5_NAME = "Mi Smart Band 5"; public static final String MI_BAND6_NAME = "Mi Smart Band 6"; + public static final String AMAZFIT_ACTIVE_NAME = "Amazfit Active"; + public static final String AMAZFIT_ACTIVE_EDGE_NAME = "Amazfit Active Edge"; public static final String AMAZFIT_BALANCE_NAME = "Amazfit Balance"; public static final String AMAZFIT_BAND5_NAME = "Amazfit Band 5"; public static final String AMAZFIT_BAND7_NAME = "Amazfit Band 7"; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java new file mode 100644 index 000000000..4a37621e1 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveCoordinator.java @@ -0,0 +1,94 @@ +/* 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.amazfitactive; + +import android.content.Context; +import android.net.Uri; + +import androidx.annotation.NonNull; + +import nodomain.freeyourgadget.gadgetbridge.R; +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.service.DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive.AmazfitActiveSupport; + +public class AmazfitActiveCoordinator extends Huami2021Coordinator { + @NonNull + @Override + public Class getDeviceSupportClass() { + return AmazfitActiveSupport.class; + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_amazfit_active; + } + + @Override + public boolean supports(final GBDeviceCandidate candidate) { + final String name = candidate.getName(); + return name.startsWith(HuamiConst.AMAZFIT_ACTIVE_NAME) && !name.contains("Edge"); + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitActiveFWInstallHandler(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; + } + + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.java new file mode 100644 index 000000000..b29af6c77 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWHelper.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.amazfitactive; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive.AmazfitActiveFirmwareInfo; + +public class AmazfitActiveFWHelper extends HuamiFWHelper { + public AmazfitActiveFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitActiveFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Active firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.java new file mode 100644 index 000000000..335767093 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactive/AmazfitActiveFWInstallHandler.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.amazfitactive; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitActiveFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitActiveFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_active); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitActiveFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITACTIVE; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java new file mode 100644 index 000000000..88f6c2ccc --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeCoordinator.java @@ -0,0 +1,94 @@ +/* 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.amazfitactiveedge; + +import android.content.Context; +import android.net.Uri; + +import androidx.annotation.NonNull; + +import java.util.regex.Pattern; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge.AmazfitActiveEdgeSupport; + +public class AmazfitActiveEdgeCoordinator extends Huami2021Coordinator { + @NonNull + @Override + public Class getDeviceSupportClass() { + return AmazfitActiveEdgeSupport.class; + } + + @Override + public int getDeviceNameResource() { + return R.string.devicetype_amazfit_active_edge; + } + + @Override + protected Pattern getSupportedDeviceName() { + return Pattern.compile(HuamiConst.AMAZFIT_ACTIVE_EDGE_NAME + ".*"); + } + + @Override + public AbstractHuami2021FWInstallHandler createFwInstallHandler(final Uri uri, final Context context) { + return new AmazfitActiveEdgeFWInstallHandler(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; + } + + public boolean supportsBluetoothPhoneCalls(final GBDevice device) { + return true; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.java new file mode 100644 index 000000000..961f55242 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWHelper.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.amazfitactiveedge; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge.AmazfitActiveEdgeFirmwareInfo; + +public class AmazfitActiveEdgeFWHelper extends HuamiFWHelper { + public AmazfitActiveEdgeFWHelper(final Uri uri, final Context context) throws IOException { + super(uri, context); + } + + @Override + public long getMaxExpectedFileSize() { + return 1024 * 1024 * 128; // 128.0MB + } + + @Override + protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) { + firmwareInfo = new AmazfitActiveEdgeFirmwareInfo(wholeFirmwareBytes); + if (!firmwareInfo.isHeaderValid()) { + throw new IllegalArgumentException("Not a Amazfit Active Edge firmware"); + } + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.java new file mode 100644 index 000000000..62240e255 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFWInstallHandler.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.amazfitactiveedge; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.R; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; + +class AmazfitActiveEdgeFWInstallHandler extends AbstractHuami2021FWInstallHandler { + AmazfitActiveEdgeFWInstallHandler(final Uri uri, final Context context) { + super(uri, context); + } + + @Override + protected String getFwUpgradeNotice() { + final String deviceName = mContext.getString(R.string.devicetype_amazfit_active_edge); + return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName); + } + + @Override + protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitActiveEdgeFWHelper(uri, context); + } + + @Override + protected boolean isSupportedDeviceType(final GBDevice device) { + return device.getType() == DeviceType.AMAZFITACTIVEEDGE; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java index fdfe72317..97750e4ba 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitbalance/AmazfitBalanceCoordinator.java @@ -21,9 +21,6 @@ import android.net.Uri; import androidx.annotation.NonNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.R; @@ -35,8 +32,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2 import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance.AmazfitBalanceSupport; public class AmazfitBalanceCoordinator extends Huami2021Coordinator { - private static final Logger LOG = LoggerFactory.getLogger(AmazfitBalanceCoordinator.class); - @NonNull @Override public Class getDeviceSupportClass() { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java index 347b5ac4f..3136e374c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/huami/amazfitgts4/AmazfitGTS4Coordinator.java @@ -29,7 +29,6 @@ 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.DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuami2021FWInstallHandler; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4Support; @@ -37,7 +36,6 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.Am public class AmazfitGTS4Coordinator extends Huami2021Coordinator { private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4Coordinator.class); - @NonNull @Override public boolean supports(final GBDeviceCandidate candidate) { try { 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 5f150c75a..05b9a747e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/DeviceType.java @@ -44,6 +44,8 @@ import nodomain.freeyourgadget.gadgetbridge.devices.hplus.HPlusCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.MakibesF68Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.Q8Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.hplus.SG2Coordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive.AmazfitActiveCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge.AmazfitActiveEdgeCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance.AmazfitBalanceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband5.AmazfitBand5Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7.AmazfitBand7Coordinator; @@ -207,6 +209,8 @@ public enum DeviceType { AMAZFITGTRMINI(AmazfitGTRMiniCoordinator.class), AMAZFITFALCON(AmazfitFalconCoordinator.class), AMAZFITBALANCE(AmazfitBalanceCoordinator.class), + AMAZFITACTIVE(AmazfitActiveCoordinator.class), + AMAZFITACTIVEEDGE(AmazfitActiveEdgeCoordinator.class), HPLUS(HPlusCoordinator.class), MAKIBESF68(MakibesF68Coordinator.class), EXRIZUK8(EXRIZUK8Coordinator.class), diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java new file mode 100644 index 000000000..bfc9eca24 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.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.amazfitactive; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitActiveFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitActiveFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_ACTIVE_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(8323328)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVE; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java new file mode 100644 index 000000000..93eba974e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.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.amazfitactive; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive.AmazfitActiveFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitActiveSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitActiveFWHelper(uri, context); + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java new file mode 100644 index 000000000..f935cd093 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.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.amazfitactiveedge; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; +import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; +import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021FirmwareInfo; + +public class AmazfitActiveEdgeFirmwareInfo extends Huami2021FirmwareInfo { + private static final Map crcToVersion = new HashMap() {{ + // firmware + }}; + + public AmazfitActiveEdgeFirmwareInfo(final byte[] bytes) { + super(bytes); + } + + @Override + public String deviceName() { + return HuamiConst.AMAZFIT_ACTIVE_NAME; + } + + @Override + public Set deviceSources() { + return new HashSet<>(Arrays.asList(8388864, 8388865)); + } + + @Override + public boolean isGenerallyCompatibleWith(final GBDevice device) { + return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVEEDGE; + } + + @Override + protected Map getCrcMap() { + return crcToVersion; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java new file mode 100644 index 000000000..8bd1c0cbc --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.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.amazfitactiveedge; + +import android.content.Context; +import android.net.Uri; + +import java.io.IOException; + +import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper; +import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge.AmazfitActiveEdgeFWHelper; +import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.Huami2021Support; + +public class AmazfitActiveEdgeSupport extends Huami2021Support { + @Override + public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException { + return new AmazfitActiveEdgeFWHelper(uri, context); + } +} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c75e3043..e184404e0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1296,6 +1296,8 @@ Mi Band 6 Xiaomi Smart Band 7 Amazfit Balance + Amazfit Active + Amazfit Active Edge Amazfit Cheetah (Square) Amazfit Cheetah (Round) Amazfit Cheetah Pro