1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 12:00:51 +02:00

Zepp OS: Refactor firmware uploads

Zepp OS 3 firmware upgrades are big (200MB+). Gadgetbridge was crashing,
since the entire firmware file would be pulled into memory.

This commit unifies all the logic for Zepp OS firmware handling.

However, since the needed refactor was big, this commit duplicates some
of the code from Huami classes, namely:
- ZeppOsFirmwareUpdateOperation clones UpdateFirmwareOperation2020
- ZeppOsFwInstallHandler clones AbstractMiBandFWInstallHandler

This avoids changes to older device logic and introducing regressions.

Lost functionality:
- Repackaging firmwares as UIHH (does not seem to be needed, and was not
  used anyway). Code can be recovered from this commit if needed in the
  future
- Whitelisted firmwares by checksum (we do not have a lot of them at
  this point anyway)

Other misc changes:
- Rename ZipFile to GBZipFile not to clash with the java class

Tested by updating the Amazfit GTR 4 to Zepp OS 3.
This commit is contained in:
José Rebelo 2024-02-01 13:36:48 +00:00
parent 4b38a67a58
commit 34fd18885a
111 changed files with 1359 additions and 4787 deletions

View File

@ -25,7 +25,6 @@ import java.io.IOException;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo;
@ -46,42 +45,7 @@ public abstract class HuamiFWHelper extends AbstractMiBandFWHelper {
@NonNull
@Override
public String getFirmwareKind() {
int resId = R.string.kind_invalid;
switch (getFirmwareInfo().getFirmwareType()) {
case FONT:
case FONT_LATIN:
resId = R.string.kind_font;
break;
case GPS:
resId = R.string.kind_gps;
break;
case GPS_ALMANAC:
resId = R.string.kind_gps_almanac;
break;
case GPS_CEP:
resId = R.string.kind_gps_cep;
break;
case AGPS_UIHH:
resId = R.string.kind_agps_bundle;
break;
case RES:
case RES_COMPRESSED:
resId = R.string.kind_resources;
break;
case FIRMWARE:
case FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG:
resId = R.string.kind_firmware;
break;
case WATCHFACE:
resId = R.string.kind_watchface;
break;
case APP:
resId = R.string.kind_app;
break;
case INVALID:
// fall through
}
return GBApplication.getContext().getString(resId);
return GBApplication.getContext().getString(getFirmwareInfo().getFirmwareType().getNameResId());
}
@Override

View File

@ -16,25 +16,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive.AmazfitActiveSupport;
public class AmazfitActiveCoordinator extends ZeppOsCoordinator {
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitActiveSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_ACTIVE_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8323328));
}
@Override
@ -48,11 +48,6 @@ public class AmazfitActiveCoordinator extends ZeppOsCoordinator {
return name.startsWith(HuamiConst.AMAZFIT_ACTIVE_NAME) && !name.contains("Edge");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitActiveFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitActiveFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitActiveFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_active);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitActiveFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITACTIVE;
}
}

View File

@ -16,20 +16,15 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge.AmazfitActiveEdgeSupport;
public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator {
@Override
@ -37,10 +32,14 @@ public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator {
return true;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitActiveEdgeSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_ACTIVE_EDGE_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8388864, 8388865));
}
@Override
@ -53,11 +52,6 @@ public class AmazfitActiveEdgeCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_ACTIVE_EDGE_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitActiveEdgeFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitActiveEdgeFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitActiveEdgeFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_active_edge);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitActiveEdgeFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITACTIVEEDGE;
}
}

View File

@ -16,26 +16,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance.AmazfitBalanceSupport;
public class AmazfitBalanceCoordinator extends ZeppOsCoordinator {
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitBalanceSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_BALANCE_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8519936, 8519937, 8519939));
}
@Override
@ -48,10 +47,6 @@ public class AmazfitBalanceCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_BALANCE_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitBalanceFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 Maxime Reyrolle
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance.AmazfitBalanceFirmwareInfo;
public class AmazfitBalanceFWHelper extends HuamiFWHelper {
public AmazfitBalanceFWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitBalanceFirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit Balance firmware");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 Maxime Reyrolle
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitBalanceFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitBalanceFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_balance);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBalanceFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITBALANCE;
}
}

View File

@ -16,41 +16,31 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7Support;
public class AmazfitBand7Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand7Coordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_BAND7_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(252, 253, 254));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_BAND7_NAME + ".*", Pattern.CASE_INSENSITIVE);
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitBand7Support.class;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitBand7FWInstallHandler(uri, context);
}
@Override
public boolean supportsAgpsUpdates() {
@ -68,7 +58,6 @@ public class AmazfitBand7Coordinator extends ZeppOsCoordinator {
return R.string.devicetype_amazfit_band7;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_default;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7FirmwareInfo;
public class AmazfitBand7FWHelper extends HuamiFWHelper {
public AmazfitBand7FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 32; // 32.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitBand7FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not an Amazfit Band 7 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitBand7FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitBand7FWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_band7, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBand7FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITBAND7;
}
}

View File

@ -16,31 +16,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5.AmazfitBip5Support;
public class AmazfitBip5Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip5Coordinator.class);
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitBip5Support.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_BIP5_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8454400, 8454401));
}
@Override
@ -48,11 +42,6 @@ public class AmazfitBip5Coordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_BIP5_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitBip5FWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;
@ -88,13 +77,11 @@ public class AmazfitBip5Coordinator extends ZeppOsCoordinator {
return true;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_bip5;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitBip5FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitBip5FWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_bip5);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBip5FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITBIP5;
}
}

View File

@ -16,48 +16,37 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro.AmazfitCheetahProSupport;
public class AmazfitCheetahProCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahProCoordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_CHEETAH_PRO_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8126720, 8126721));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_PRO_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitCheetahProSupport.class;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_cheetah_pro;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitCheetahProFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,45 +0,0 @@
/* Copyright (C) 2023-2024 Raghd Hamzeh
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro.AmazfitCheetahProFirmwareInfo;
public class AmazfitCheetahProFWHelper extends HuamiFWHelper {
public AmazfitCheetahProFWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitCheetahProFirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a " + DeviceType.AMAZFITCHEETAHPRO + " firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2023-2024 Raghd Hamzeh
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitCheetahProFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitCheetahProFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_cheetah_pro, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahProFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITCHEETAHPRO;
}
}

View File

@ -16,36 +16,30 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround.AmazfitCheetahRoundSupport;
public class AmazfitCheetahRoundCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahRoundCoordinator.class);
@Override
public boolean isExperimental() {
return true;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitCheetahRoundSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(8192256, 8192257));
}
@Override
@ -58,11 +52,6 @@ public class AmazfitCheetahRoundCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitCheetahRoundFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitCheetahRoundFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitCheetahRoundFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_round);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahRoundFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITCHEETAHROUND;
}
}

View File

@ -16,36 +16,30 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareSupport;
public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahSquareCoordinator.class);
@Override
public boolean isExperimental() {
return true;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitCheetahSquareSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Collections.singletonList(8257793));
}
@Override
@ -53,11 +47,6 @@ public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitCheetahSquareFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;
@ -98,13 +87,11 @@ public class AmazfitCheetahSquareCoordinator extends ZeppOsCoordinator {
return true;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_cheetah_square;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitCheetahSquareFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitCheetahSquareFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_cheetah_square);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahSquareFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITCHEETAHSQUARE;
}
}

View File

@ -16,36 +16,30 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon.AmazfitFalconSupport;
public class AmazfitFalconCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitFalconCoordinator.class);
@Override
public boolean isExperimental() {
return true;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitFalconSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_FALCON_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(414, 415));
}
@Override
@ -58,11 +52,6 @@ public class AmazfitFalconCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_FALCON_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitFalconFWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
return false;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitFalconFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitFalconFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_falcon);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitFalconFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITFALCON;
}
}

View File

@ -16,45 +16,34 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3Support;
public class AmazfitGTR3Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3Coordinator.class);
@NonNull
@Override
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR3_NAME) && !name.contains("Pro")) {
return true;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTR3_NAME;
}
return false;
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(226, 227));
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTR3Support.class;
public boolean supports(final GBDeviceCandidate candidate) {
final String name = candidate.getName();
return name.startsWith(HuamiConst.AMAZFIT_GTR3_NAME) && !name.contains("Pro");
}
@Override
@ -62,11 +51,6 @@ public class AmazfitGTR3Coordinator extends ZeppOsCoordinator {
return R.string.devicetype_amazfit_gtr3;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTR3FWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
return false;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, thermatk
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3FirmwareInfo;
public class AmazfitGTR3FWHelper extends HuamiFWHelper {
public AmazfitGTR3FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTR3FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTR 3 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, thermatk
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTR3FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTR3FWInstallHandler(Uri uri, Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr3, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTR3FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTR3;
}
}

View File

@ -16,48 +16,37 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro.AmazfitGTR3ProSupport;
public class AmazfitGTR3ProCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTR3_PRO_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(229, 230, 6095106));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTR3_PRO_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTR3ProSupport.class;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_gtr3_pro;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTR3ProFWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
return false;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro.AmazfitGTR3ProFirmwareInfo;
public class AmazfitGTR3ProFWHelper extends HuamiFWHelper {
public AmazfitGTR3ProFWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTR3ProFirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTR 3 Pro firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTR3ProFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTR3ProFWInstallHandler(Uri uri, Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr3_pro, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTR3ProFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTR3PRO;
}
}

View File

@ -16,36 +16,45 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4Support;
public class AmazfitGTR4Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTR4_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(7930112, 7930113, 7864577));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTR4_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTR4Support.class;
protected Map<Integer, String> getCrcMap() {
return new HashMap<Integer, String>() {{
// firmware
put(1699, "3.17.0.2");
put(20712, "3.18.1.1 (diff from 3.17.0.2)");
put(49685, "3.23.3.1 (diff from 3.21.0.1)");
}};
}
@Override
@ -53,11 +62,6 @@ public class AmazfitGTR4Coordinator extends ZeppOsCoordinator {
return R.string.devicetype_amazfit_gtr4;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTR4FWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4FirmwareInfo;
public class AmazfitGTR4FWHelper extends HuamiFWHelper {
public AmazfitGTR4FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTR4FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTR 4 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTR4FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTR4FWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gtr4, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTR4FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTR4;
}
}

View File

@ -16,31 +16,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini.AmazfitGTRMiniSupport;
public class AmazfitGTRMiniCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTRMiniCoordinator.class);
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTRMiniSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTR_MINI_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(250, 251));
}
@Override
@ -53,11 +47,6 @@ public class AmazfitGTRMiniCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_GTR_MINI_NAME + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTRMiniFWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
// Even though it's a Zepp OS 2.0 device, it doesn't seem to support the AGPS service

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTRMiniFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTRMiniFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_gtr_mini);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTRMiniFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTRMINI;
}
}

View File

@ -16,43 +16,32 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3Support;
public class AmazfitGTS3Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTS3_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(224, 225));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTS3_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTS3Support.class;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTS3FWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
return false;
@ -63,13 +52,11 @@ public class AmazfitGTS3Coordinator extends ZeppOsCoordinator {
return false;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_gts3;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, sedy89
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3FirmwareInfo;
public class AmazfitGTS3FWHelper extends HuamiFWHelper {
public AmazfitGTS3FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTS3FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTS 3 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, sedy89
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTS3FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTS3FWInstallHandler(Uri uri, Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts3, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTS3FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTS3;
}
}

View File

@ -16,49 +16,31 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4Support;
public class AmazfitGTS4Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4Coordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTS4_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(7995648, 7995649));
}
@Override
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTS4_NAME) && !name.contains("Mini")) {
return true;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return false;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTS4Support.class;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTS4FWInstallHandler(uri, context);
final String name = candidate.getName();
return name.startsWith(HuamiConst.AMAZFIT_GTS4_NAME) && !name.contains("Mini");
}
@Override
@ -96,13 +78,11 @@ public class AmazfitGTS4Coordinator extends ZeppOsCoordinator {
return true;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_gts4;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4FirmwareInfo;
public class AmazfitGTS4FWHelper extends HuamiFWHelper {
public AmazfitGTS4FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTS4FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTS 4 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTS4FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTS4FWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts4, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTS4FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTS4;
}
}

View File

@ -16,42 +16,32 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniSupport;
public class AmazfitGTS4MiniCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_GTS4_MINI_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(246, 247));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTS4_MINI_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitGTS4MiniSupport.class;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitGTS4MiniFWInstallHandler(uri, context);
}
@Override
public boolean sendAgpsAsFileTransfer() {
@ -63,13 +53,11 @@ public class AmazfitGTS4MiniCoordinator extends ZeppOsCoordinator {
return false;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_gts4_mini;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_amazfit_bip;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniFirmwareInfo;
public class AmazfitGTS4MiniFWHelper extends HuamiFWHelper {
public AmazfitGTS4MiniFWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitGTS4MiniFirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit GTS 4 Mini firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitGTS4MiniFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitGTS4MiniFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_gts4_mini, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTS4MiniFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITGTS4MINI;
}
}

View File

@ -16,48 +16,37 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.AmazfitTRex2Support;
public class AmazfitTRex2Coordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class);
@Override
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_TREX_2_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(418, 419));
}
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_TREX_2_NAME + ".*");
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitTRex2Support.class;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_amazfit_trex_2;
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitTRex2FWInstallHandler(uri, context);
}
@Override
public boolean supportsControlCenter() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.AmazfitTRex2FirmwareInfo;
public class AmazfitTRex2FWHelper extends HuamiFWHelper {
public AmazfitTRex2FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 128; // 128.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitTRex2FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Amazfit T-Rex 2 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitTRex2FWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitTRex2FWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfit_trex2, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitTRex2FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITTREX2;
}
}

View File

@ -16,31 +16,25 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra.AmazfitTRexUltraSupport;
public class AmazfitTRexUltraCoordinator extends ZeppOsCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexUltraCoordinator.class);
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return AmazfitTRexUltraSupport.class;
public String getDeviceBluetoothName() {
return HuamiConst.AMAZFIT_TREX_ULTRA;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(6553856, 6553857));
}
@Override
@ -53,11 +47,6 @@ public class AmazfitTRexUltraCoordinator extends ZeppOsCoordinator {
return Pattern.compile(HuamiConst.AMAZFIT_TREX_ULTRA + ".*");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new AmazfitTRexUltraFWInstallHandler(uri, context);
}
@Override
public boolean supportsContinuousFindDevice() {
return true;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
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");
}
}
}

View File

@ -1,50 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class AmazfitTRexUltraFWInstallHandler extends AbstractZeppOsFwInstallHandler {
AmazfitTRexUltraFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
final String deviceName = mContext.getString(R.string.devicetype_amazfit_trex_ultra);
return mContext.getString(R.string.fw_upgrade_notice_zepp_os, helper.getHumanFirmwareVersion(), deviceName);
}
@Override
protected HuamiFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitTRexUltraFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITTREXULTRA;
}
}

View File

@ -16,32 +16,46 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7Support;
public class MiBand7Coordinator extends ZeppOsCoordinator {
@Override
public String getDeviceBluetoothName() {
return HuamiConst.XIAOMI_SMART_BAND7_NAME;
}
@Override
public Set<Integer> getDeviceSources() {
return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265));
}
@Override
protected Map<Integer, String> getCrcMap() {
return new HashMap<Integer, String>() {{
// firmware
put(26036, "1.20.3.1");
put(55449, "1.27.0.4");
put(14502, "2.0.0.2");
put(25658, "2.1.0.1");
}};
}
@Override
public boolean supports(final GBDeviceCandidate candidate) {
final String name = candidate.getName();
return name.startsWith(HuamiConst.XIAOMI_SMART_BAND7_NAME) && !name.contains("Pro");
}
@Override
public AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context) {
return new MiBand7FWInstallHandler(uri, context);
}
@Override
public boolean supportsAgpsUpdates() {
return false;
@ -52,24 +66,16 @@ public class MiBand7Coordinator extends ZeppOsCoordinator {
return false;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {
return MiBand7Support.class;
}
@Override
public boolean supportsBluetoothPhoneCalls(final GBDevice device) {
return false;
}
@Override
public int getDeviceNameResource() {
return R.string.devicetype_miband7;
}
@Override
public int getDefaultIconResource() {
return R.drawable.ic_device_miband6;

View File

@ -1,44 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7FirmwareInfo;
public class MiBand7FWHelper extends HuamiFWHelper {
public MiBand7FWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
public long getMaxExpectedFileSize() {
return 1024 * 1024 * 32; // 32.0MB
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new MiBand7FirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not a Xiaomi Smart Band 7 firmware");
}
}
}

View File

@ -1,49 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
class MiBand7FWInstallHandler extends AbstractZeppOsFwInstallHandler {
MiBand7FWInstallHandler(Uri uri, Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_miband7, helper.getHumanFirmwareVersion());
}
@Override
protected HuamiFWHelper createHelper(Uri uri, Context context) throws IOException {
return new MiBand7FWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(GBDevice device) {
return device.getType() == DeviceType.MIBAND7;
}
}

View File

@ -28,7 +28,10 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.appmanager.AppManagerActivity;
@ -54,7 +57,9 @@ import nodomain.freeyourgadget.gadgetbridge.entities.HuamiSpo2SampleDao;
import nodomain.freeyourgadget.gadgetbridge.entities.HuamiStressSampleDao;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySummaryParser;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.AbstractZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFwInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAlexaService;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsContactsService;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsLogsService;
@ -69,7 +74,20 @@ import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public abstract class ZeppOsCoordinator extends HuamiCoordinator {
public abstract AbstractZeppOsFwInstallHandler createFwInstallHandler(final Uri uri, final Context context);
public abstract String getDeviceBluetoothName();
public abstract Set<Integer> getDeviceSources();
protected Map<Integer, String> getCrcMap() {
// A map from CRC16 to human-readable version for flashable files
return Collections.emptyMap();
}
@NonNull
@Override
public final Class<? extends DeviceSupport> getDeviceSupportClass() {
return ZeppOsSupport.class;
}
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
@ -87,7 +105,12 @@ public abstract class ZeppOsCoordinator extends HuamiCoordinator {
}
}
final AbstractZeppOsFwInstallHandler handler = createFwInstallHandler(uri, context);
final ZeppOsFwInstallHandler handler = new ZeppOsFwInstallHandler(
uri,
context,
getDeviceBluetoothName(),
getDeviceSources()
);
return handler.isValid() ? handler : null;
}

View File

@ -0,0 +1,453 @@
/* Copyright (C) 2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import androidx.annotation.Nullable;
import org.json.JSONArray;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Set;
import java.util.UUID;
import java.util.zip.CRC32;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil;
import nodomain.freeyourgadget.gadgetbridge.util.CheckSums;
import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
public class ZeppOsFwHelper {
private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFwHelper.class);
private final Uri uri;
private final Context context;
private final String deviceName;
private final Set<Integer> deviceSources;
private HuamiFirmwareType firmwareType = HuamiFirmwareType.INVALID;
private File file = null;
private int crc32;
private String version = "Unknown";
private GBDeviceApp gbDeviceApp = null;
public ZeppOsFwHelper(final Uri uri, final Context context, final String deviceName, final Set<Integer> deviceSources) {
this.uri = uri;
this.context = context;
this.deviceName = deviceName;
this.deviceSources = deviceSources;
processUri();
}
public HuamiFirmwareType getFirmwareType() {
return firmwareType;
}
public String getFirmwareVersion() {
return version;
}
public File getFile() {
if (file == null) {
throw new IllegalStateException("file is null");
}
return file;
}
public int getSize() {
if (file == null) {
throw new IllegalStateException("file is null");
}
return (int) file.length();
}
public int getCrc32() {
return crc32;
}
private void processUri() {
// Copy file to cache first
final File cacheDir = context.getCacheDir();
final File zpkCacheDir = new File(cacheDir, "zeppos");
zpkCacheDir.mkdir();
try {
file = File.createTempFile("fwhelper","bin", context.getCacheDir());
file.deleteOnExit();
} catch (final IOException e) {
LOG.error("Failed to create temp file for zpk", e);
return;
}
final UriHelper uriHelper;
try {
uriHelper = UriHelper.get(uri, context);
} catch (final IOException e) {
LOG.error("Failed to get uri helper", e);
return;
}
final CRC32 crc = new CRC32();
try (FileOutputStream outputStream = new FileOutputStream(file);
InputStream inputStream = uriHelper.openInputStream()) {
final byte[] buffer = new byte[64 * 1024];
int len;
while ((len = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
crc.update(buffer, 0, len);
}
crc32 = (int) crc.getValue();
} catch (final IOException e) {
LOG.error("Failed to write bytes to temporary file", e);
return;
}
try (ZipFile zipFile = new ZipFile(file, java.util.zip.ZipFile.OPEN_READ)) {
processZipFile(zipFile);
} catch (final ZipException e) {
LOG.warn("{} is not a valid zip file", uri, e);
} catch (final IOException e) {
LOG.warn("Error while processing {}", uri, e);
}
// TODO process as UIHH
}
private void processZipFile(final ZipFile zipFile) {
// Attempt to handle as a firmware
final byte[] firmwareBin = getFileFromZip(zipFile, "META/firmware.bin");
if (firmwareBin != null) {
if (isCompatibleFirmwareBin(firmwareBin)) {
firmwareType = HuamiFirmwareType.FIRMWARE;
final JSONObject fwInfoRoot = getJson(zipFile, "META/fw_info");
if (fwInfoRoot != null) {
final JSONArray fwInfoArr = fwInfoRoot.optJSONArray("fw_info");
if (fwInfoArr != null) {
for (int i = 0; i < fwInfoArr.length(); i++) {
final JSONObject fwInfo = fwInfoArr.optJSONObject(i);
if (fwInfo == null) {
continue;
}
if ("firmware".equals(fwInfo.optString("name"))) {
version = fwInfo.optString("version");
break;
}
}
}
} else {
version = getFirmwareVersion(firmwareBin);
}
} else {
firmwareType = HuamiFirmwareType.INVALID;
}
return;
}
// Attempt to handle as an app / watchface
final JSONObject appJson = getJson(zipFile, "app.json");
if (appJson != null) {
final int appId;
final String appName;
final String appVersion;
final String appType;
final String appCreator;
final String appIconPath;
final JSONObject appJsonApp;
try {
appJsonApp = appJson.getJSONObject("app");
appId = appJsonApp.getInt("appId");
appName = appJsonApp.getString("appName");
appVersion = appJsonApp.getJSONObject("version").getString("name");
appType = appJsonApp.getString("appType");
appCreator = appJsonApp.getString("vender");
appIconPath = appJsonApp.getString("icon");
} catch (final Exception e) {
LOG.error("Failed to get appType from app.json", e);
firmwareType = HuamiFirmwareType.INVALID;
return;
}
final GBDeviceApp.Type gbDeviceAppType;
switch (appType) {
case "watchface":
firmwareType = HuamiFirmwareType.WATCHFACE;
gbDeviceAppType = GBDeviceApp.Type.WATCHFACE;
version = String.format("%s (watchface)", appName);
break;
case "app":
firmwareType = HuamiFirmwareType.APP;
gbDeviceAppType = GBDeviceApp.Type.APP_GENERIC;
version = String.format("%s (app)", appName);
break;
default:
LOG.warn("Unknown app type {}", appType);
firmwareType = HuamiFirmwareType.INVALID;
return;
}
Bitmap icon = null;
final byte[] iconBytes = getFileFromZip(zipFile, "assets/" + appIconPath);
if (iconBytes != null) {
if (BitmapUtil.isPng(iconBytes)) {
icon = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
} else {
icon = BitmapUtil.decodeTga(iconBytes);
}
}
gbDeviceApp = new GBDeviceApp(
UUID.fromString(String.format("%08x-0000-0000-0000-000000000000", appId)),
appName,
appCreator,
appVersion,
gbDeviceAppType,
icon
);
return;
}
// Attempt to handle as a zab file
final byte[] zpkBytes = handleZabPackage(zipFile);
if (zpkBytes != null) {
final File cacheDir = context.getCacheDir();
final File zpkCacheDir = new File(cacheDir, "zpk");
zpkCacheDir.mkdir();
final File zpkFile;
try {
zpkFile = File.createTempFile("zpk","zip", context.getCacheDir());
zpkFile.deleteOnExit();
} catch (final IOException e) {
LOG.error("Failed to create temp file for zpk", e);
return;
}
try (FileOutputStream outputStream = new FileOutputStream(zpkFile)) {
outputStream.write(zpkBytes);
} catch (final IOException e) {
LOG.error("Failed to write zpk bytes to temporary file", e);
return;
}
try (ZipFile zpkZpkFile = new ZipFile(zpkFile, java.util.zip.ZipFile.OPEN_READ)) {
processZipFile(zpkZpkFile);
} catch (final ZipException e) {
LOG.warn("{} is not a valid zip file", uri, e);
} catch (final IOException e) {
LOG.warn("Error while processing {}", uri, e);
}
if (firmwareType != HuamiFirmwareType.INVALID) {
file = zpkFile;
crc32 = CheckSums.getCRC32(zpkBytes);
}
}
}
/**
* A zab package is a zip file with:
* - manifest.json
* - .sc (source code)
* - One or more zpk files
* <p>
* Right now, we only handle the first compatible zpk file that is supported by the connected device.
*/
private byte[] handleZabPackage(final ZipFile zipFile) {
final JSONObject manifest = getJson(zipFile, "manifest.json");
if (manifest == null) {
return null;
}
final JSONArray zpks;
try {
zpks = manifest.getJSONArray("zpks");
} catch (final Exception e) {
LOG.error("Failed to get zpks from manifest.json", e);
return null;
}
// Iterate all zpks until a compatible one is found
for (int i = 0; i < zpks.length(); i++) {
try {
final JSONObject zpkEntry = zpks.getJSONObject(i);
final JSONArray platforms = zpkEntry.getJSONArray("platforms");
// Check if this zpk is compatible with the current device
for (int j = 0; j < platforms.length(); j++) {
final JSONObject platform = platforms.getJSONObject(j);
if (deviceSources.contains(platform.getInt("deviceSource"))) {
// It's compatible with the device, fetch device.zip
final String name = zpkEntry.getString("name");
final byte[] zpkBytes = getFileFromZip(zipFile, name);
if (!GBZipFile.isZipFile(zpkBytes)) {
LOG.warn("bytes for {} not a zip file", name);
continue;
}
final GBZipFile zpkFile = new GBZipFile(zpkBytes);
final byte[] deviceZip = zpkFile.getFileFromZip("device.zip");
if (!GBZipFile.isZipFile(zpkBytes)) {
LOG.warn("bytes for device.zip of zpk {} not a zip file", name);
continue;
}
return deviceZip;
}
}
} catch (final Exception e) {
LOG.warn("Failed to parse zpk", e);
}
}
LOG.warn("No compatible zpk found in zab file");
return null;
}
@Nullable
public GBDeviceApp getAppInfo() {
return gbDeviceApp;
}
public boolean isValid() {
return firmwareType != HuamiFirmwareType.INVALID;
}
@Nullable
public Bitmap getPreview() {
if (gbDeviceApp != null) {
return gbDeviceApp.getPreviewImage();
}
return null;
}
private boolean isCompatibleFirmwareBin(final byte[] firmwareBin) {
if (firmwareBin == null) {
LOG.error("firmware bin is null");
return false;
}
if (!searchString(firmwareBin, deviceName)) {
LOG.warn("Failed to find {} in fwBytes", deviceName);
return false;
}
return true;
}
public static String getFirmwareVersion(final byte[] firmwareBin) {
int startIdx = 10;
int endIdx = -1;
for (int i = startIdx; i < startIdx + 20; i++) {
byte c = firmwareBin[i];
if (c == 0) {
endIdx = i;
break;
}
if (c != '.' && (c < '0' || c > '9')) {
// not a valid version character
break;
}
}
if (endIdx == -1) {
LOG.warn("Failed to find firmware version in expected offset");
return null;
}
return new String(Arrays.copyOfRange(firmwareBin, startIdx, endIdx));
}
@Nullable
private static JSONObject getJson(final ZipFile zipFile, final String path) {
final byte[] appJsonBin = getFileFromZip(zipFile, path);
if (appJsonBin == null) {
return null;
}
try {
final String appJsonString = new String(appJsonBin, StandardCharsets.UTF_8)
// Remove UTF-8 BOM if present
.replace("\uFEFF", "");
return new JSONObject(appJsonString);
} catch (final Exception e) {
LOG.error("Failed to parse " + path, e);
}
return null;
}
@Nullable
private static byte[] getFileFromZip(final ZipFile zipFile, final String path) {
try {
final ZipEntry entry = zipFile.getEntry(path);
if (entry == null) {
return null;
}
return GBZipFile.readAllBytes(zipFile.getInputStream(entry));
} catch (final IOException e) {
LOG.error("Failed to read " + path, e);
return null;
}
}
public static boolean searchString(final byte[] fwBytes, final String str) {
final byte[] strBytes = (str + "\0").getBytes(StandardCharsets.UTF_8);
for (int i = 0; i < fwBytes.length - strBytes.length + 1; i++) {
boolean found = true;
for (int j = 0; j < strBytes.length; j++) {
if (fwBytes[i + j] != strBytes[j]) {
found = false;
break;
}
}
if (found) {
return true;
}
}
return false;
}
}

View File

@ -16,8 +16,6 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.pinetime;
import static java.nio.charset.StandardCharsets.UTF_8;
import android.content.Context;
import android.net.Uri;
@ -38,7 +36,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
import nodomain.freeyourgadget.gadgetbridge.util.UriHelper;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
public class PineTimeInstallHandler implements InstallHandler {
@ -57,7 +55,7 @@ public class PineTimeInstallHandler implements InstallHandler {
try {
uriHelper = UriHelper.get(uri, this.context);
ZipFile dfuPackage = new ZipFile(uriHelper.openInputStream());
GBZipFile dfuPackage = new GBZipFile(uriHelper.openInputStream());
String manifest = new String(dfuPackage.getFileFromZip("manifest.json"));
if (!manifest.trim().isEmpty()) {

View File

@ -16,9 +16,7 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.AbstractMiBandOperation;
public abstract class AbstractHuamiOperation extends AbstractMiBandOperation<HuamiSupport> {
@ -31,9 +29,5 @@ public abstract class AbstractHuamiOperation extends AbstractMiBandOperation<Hua
// TODO: check which notifications we should disable and re-enable here
// builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable)
// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable);
if (getSupport() instanceof ZeppOsSupport) {
// Disable 2021 chunked reads, otherwise firmware upgrades and activity sync get interrupted
builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ), enable);
}
}
}

View File

@ -16,35 +16,47 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami;
import androidx.annotation.StringRes;
import nodomain.freeyourgadget.gadgetbridge.R;
public enum HuamiFirmwareType {
FIRMWARE((byte) 0),
CHANGELOG_TXT((byte) 16),
FIRMWARE((byte) 0, R.string.kind_firmware),
CHANGELOG_TXT((byte) 16, R.string.action_changelog),
// MB7 firmwares are sent as UIHH packing FIRMWARE (zip) + CHANGELOG_TXT, type 0xfd
FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG((byte) -3),
FONT((byte) 1),
RES((byte) 2),
RES_COMPRESSED((byte) 130),
GPS((byte) 3),
GPS_CEP((byte) 4),
AGPS_UIHH((byte) -4),
GPS_ALMANAC((byte) 5),
WATCHFACE((byte) 8),
APP((byte) 8),
FONT_LATIN((byte) 11),
ZEPPOS_UNKNOWN_0X13((byte) 0x13),
ZEPPOS_APP((byte) 0xa0),
INVALID(Byte.MIN_VALUE);
FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG((byte) -3, R.string.kind_firmware),
FONT((byte) 1, R.string.kind_font),
RES((byte) 2, R.string.kind_resources),
RES_COMPRESSED((byte) 130, R.string.kind_resources),
GPS((byte) 3, R.string.kind_gps),
GPS_CEP((byte) 4, R.string.kind_gps_cep),
AGPS_UIHH((byte) -4, R.string.kind_agps_bundle),
GPS_ALMANAC((byte) 5, R.string.kind_gps_almanac),
WATCHFACE((byte) 8, R.string.kind_watchface),
APP((byte) 8, R.string.kind_app),
FONT_LATIN((byte) 11, R.string.kind_font),
ZEPPOS_UNKNOWN_0X13((byte) 0x13, R.string.unknown),
ZEPPOS_APP((byte) 0xa0, R.string.kind_app),
INVALID(Byte.MIN_VALUE, R.string.kind_invalid),
;
private final byte value;
private final int nameResId;
HuamiFirmwareType(byte value) {
HuamiFirmwareType(byte value, int nameResId) {
this.value = value;
this.nameResId = nameResId;
}
public byte getValue() {
return value;
}
@StringRes
public int getNameResId() {
return nameResId;
}
public boolean isApp() {
return this == APP || this == ZEPPOS_APP;
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitActiveFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitActiveFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_ACTIVE_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8323328));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVE;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactive;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactive.AmazfitActiveFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitActiveSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitActiveFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitActiveEdgeFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitActiveEdgeFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_ACTIVE_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8388864, 8388865));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVEEDGE;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitactiveedge;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitactiveedge.AmazfitActiveEdgeFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitActiveEdgeSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitActiveEdgeFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 Maxime Reyrolle
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitBalanceFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitBalanceFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_BALANCE_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8519936, 8519937, 8519939));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBALANCE;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 Maxime Reyrolle
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbalance;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbalance.AmazfitBalanceFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitBalanceSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBalanceFWHelper(uri, context);
}
}

View File

@ -1,57 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitBand7FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
}};
public AmazfitBand7FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_BAND7_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(252, 253, 254));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBAND7;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitband7.AmazfitBand7FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitBand7Support extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBand7FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitBip5FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitBip5FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_BIP5_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8454400, 8454401));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBIP5;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip5;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip5.AmazfitBip5FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitBip5Support extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBip5FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 Raghd Hamzeh
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitCheetahProFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitCheetahProFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_CHEETAH_PRO_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8126720, 8126721));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHPRO;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 Raghd Hamzeh
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahpro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahpro.AmazfitCheetahProFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitCheetahProSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahProFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitCheetahRoundFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitCheetahRoundFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(8192256, 8192257));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHROUND;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahround;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahround.AmazfitCheetahRoundFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitCheetahRoundSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahRoundFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitCheetahSquareFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitCheetahSquareFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Collections.singletonList(8257793));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHSQUARE;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetahsquare;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcheetahsquare.AmazfitCheetahSquareFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitCheetahSquareSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitCheetahSquareFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitFalconFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitFalconFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_FALCON_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(414, 415));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITFALCON;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitfalcon;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitfalcon.AmazfitFalconFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitFalconSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitFalconFWHelper(uri, context);
}
}

View File

@ -1,63 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, thermatk
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTR3FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3FirmwareInfo.class);
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTR3FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTR3_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(226, 227));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,38 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, thermatk
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3;
import android.content.Context;
import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3.AmazfitGTR3FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTR3Support extends ZeppOsSupport {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3Support.class);
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTR3FWHelper(uri, context);
}
}

View File

@ -1,63 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTR3ProFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProFirmwareInfo.class);
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTR3ProFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTR3_PRO_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(229, 230, 6095106));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3PRO;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,38 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro;
import android.content.Context;
import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr3pro.AmazfitGTR3ProFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTR3ProSupport extends ZeppOsSupport {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProSupport.class);
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTR3ProFWHelper(uri, context);
}
}

View File

@ -1,61 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTR4FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
put(1699, "3.17.0.2");
put(20712, "3.18.1.1 (diff from 3.17.0.2)");
put(49685, "3.23.3.1 (diff from 3.21.0.1)");
}};
public AmazfitGTR4FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTR4_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(7930112, 7930113));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR4;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr4.AmazfitGTR4FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTR4Support extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTR4FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTRMiniFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTRMiniFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTR_MINI_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(250, 251));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTRMINI;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtrmini;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtrmini.AmazfitGTRMiniFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTRMiniSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTRMiniFWHelper(uri, context);
}
}

View File

@ -1,63 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, sedy89
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTS3FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3FirmwareInfo.class);
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTS3FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTS3_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(224, 225));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS3;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,38 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo, sedy89
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3;
import android.content.Context;
import android.net.Uri;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts3.AmazfitGTS3FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTS3Support extends ZeppOsSupport {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Support.class);
@Override
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
return new AmazfitGTS3FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTS4FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTS4FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTS4_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(7995648, 7995649));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4.AmazfitGTS4FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTS4Support extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTS4FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitGTS4MiniFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitGTS4MiniFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_GTS4_MINI_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(246, 247));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4MINI;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts4mini.AmazfitGTS4MiniFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitGTS4MiniSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitGTS4MiniFWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitTRex2FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitTRex2FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_TREX_2_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(418, 419));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREX2;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrex2.AmazfitTRex2FWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitTRex2Support extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitTRex2FWHelper(uri, context);
}
}

View File

@ -1,58 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class AmazfitTRexUltraFirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
}};
public AmazfitTRexUltraFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.AMAZFIT_TREX_ULTRA;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(6553856, 6553857));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREXULTRA;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -1,33 +0,0 @@
/* Copyright (C) 2023-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexultra;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfittrexultra.AmazfitTRexUltraFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
public class AmazfitTRexUltraSupport extends ZeppOsSupport {
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitTRexUltraFWHelper(uri, context);
}
}

View File

@ -1,62 +0,0 @@
/* Copyright (C) 2022-2024 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsFirmwareInfo;
public class MiBand7FirmwareInfo extends ZeppOsFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<Integer, String>() {{
// firmware
put(26036, "1.20.3.1");
put(55449, "1.27.0.4");
put(14502, "2.0.0.2");
put(25658, "2.1.0.1");
}};
public MiBand7FirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
public String deviceName() {
return HuamiConst.XIAOMI_SMART_BAND7_NAME;
}
@Override
public Set<Integer> deviceSources() {
return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265));
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.MIBAND7;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

Some files were not shown because too many files have changed in this diff Show More