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
+ *
+ * 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;
+ }
+}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java
index 27059ecce..5bbfcdc20 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/pinetime/PineTimeInstallHandler.java
@@ -16,8 +16,6 @@
along with this program. If not, see . */
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()) {
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java
index 2332225b9..33e224fcd 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/AbstractHuamiOperation.java
@@ -16,9 +16,7 @@
along with this program. If not, see . */
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 {
@@ -31,9 +29,5 @@ public abstract class AbstractHuamiOperation extends AbstractMiBandOperation. */
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;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java
deleted file mode 100644
index 9a5d24492..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitActiveFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_ACTIVE_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(8323328));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVE;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java
deleted file mode 100644
index 05cf14908..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactive/AmazfitActiveSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java
deleted file mode 100644
index 273602e11..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitActiveEdgeFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_ACTIVE_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(8388864, 8388865));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITACTIVEEDGE;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java
deleted file mode 100644
index 2141be205..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitactiveedge/AmazfitActiveEdgeSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java
deleted file mode 100644
index 1618f7799..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitBalanceFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_BALANCE_NAME;
- }
-
- @Override
- public Set 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 getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java
deleted file mode 100644
index 1827f6e32..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbalance/AmazfitBalanceSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java
deleted file mode 100644
index 7e0e09ea8..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- }};
-
- public AmazfitBand7FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_BAND7_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(252, 253, 254));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITBAND7;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java
deleted file mode 100644
index 0b894f292..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitband7/AmazfitBand7Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java
deleted file mode 100644
index bcbfc1f97..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitBip5FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_BIP5_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(8454400, 8454401));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITBIP5;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java
deleted file mode 100644
index 945a5f258..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitbip5/AmazfitBip5Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java
deleted file mode 100644
index a586fad82..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitCheetahProFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_CHEETAH_PRO_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(8126720, 8126721));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHPRO;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java
deleted file mode 100644
index fdb32bdc0..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahpro/AmazfitCheetahProSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java
deleted file mode 100644
index 76e2f6253..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitCheetahRoundFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(8192256, 8192257));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHROUND;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java
deleted file mode 100644
index 59d8019c0..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahround/AmazfitCheetahRoundSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java
deleted file mode 100644
index 1a232f2a5..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitCheetahSquareFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Collections.singletonList(8257793));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITCHEETAHSQUARE;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java
deleted file mode 100644
index 3061f5e5c..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitcheetahsquare/AmazfitCheetahSquareSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java
deleted file mode 100644
index 2252f4732..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitFalconFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_FALCON_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(414, 415));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITFALCON;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java
deleted file mode 100644
index 8dcab31dc..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitfalcon/AmazfitFalconSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java
deleted file mode 100644
index 0056b84ab..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTR3FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTR3_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(226, 227));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java
deleted file mode 100644
index 5d9417862..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3/AmazfitGTR3Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java
deleted file mode 100644
index cc028f625..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTR3ProFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTR3_PRO_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(229, 230, 6095106));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3PRO;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java
deleted file mode 100644
index d88140bcf..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr3pro/AmazfitGTR3ProSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java
deleted file mode 100644
index 3ac35ae35..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // 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 deviceSources() {
- return new HashSet<>(Arrays.asList(7930112, 7930113));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR4;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java
deleted file mode 100644
index 1c8686de2..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtr4/AmazfitGTR4Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java
deleted file mode 100644
index 764d5f849..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTRMiniFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTR_MINI_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(250, 251));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTRMINI;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java
deleted file mode 100644
index b4244827d..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgtrmini/AmazfitGTRMiniSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java
deleted file mode 100644
index 157f3c807..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTS3FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTS3_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(224, 225));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS3;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java
deleted file mode 100644
index e20dc7f5c..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts3/AmazfitGTS3Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java
deleted file mode 100644
index 91e1d8553..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTS4FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTS4_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(7995648, 7995649));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java
deleted file mode 100644
index bd91e9799..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4/AmazfitGTS4Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java
deleted file mode 100644
index 7866b8be1..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitGTS4MiniFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_GTS4_MINI_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(246, 247));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4MINI;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java
deleted file mode 100644
index e85ea3d53..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfitgts4mini/AmazfitGTS4MiniSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java
deleted file mode 100644
index d0b94a115..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitTRex2FirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_TREX_2_NAME;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(418, 419));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREX2;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java
deleted file mode 100644
index 249d8bb2e..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrex2/AmazfitTRex2Support.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java
deleted file mode 100644
index 6041aa299..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraFirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // firmware
- }};
-
- public AmazfitTRexUltraFirmwareInfo(final byte[] bytes) {
- super(bytes);
- }
-
- @Override
- public String deviceName() {
- return HuamiConst.AMAZFIT_TREX_ULTRA;
- }
-
- @Override
- public Set deviceSources() {
- return new HashSet<>(Arrays.asList(6553856, 6553857));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREXULTRA;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java
deleted file mode 100644
index d3a7d40fd..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/amazfittrexultra/AmazfitTRexUltraSupport.java
+++ /dev/null
@@ -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 . */
-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);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java
deleted file mode 100644
index dbf225624..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7FirmwareInfo.java
+++ /dev/null
@@ -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 . */
-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 crcToVersion = new HashMap() {{
- // 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 deviceSources() {
- return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265));
- }
-
- @Override
- public boolean isGenerallyCompatibleWith(final GBDevice device) {
- return isHeaderValid() && device.getType() == DeviceType.MIBAND7;
- }
-
- @Override
- protected Map getCrcMap() {
- return crcToVersion;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java
deleted file mode 100644
index 9dd0bde50..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/miband7/MiBand7Support.java
+++ /dev/null
@@ -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 . */
-package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7;
-
-import android.content.Context;
-import android.net.Uri;
-
-import java.io.IOException;
-
-import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
-import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband7.MiBand7FWHelper;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
-
-public class MiBand7Support extends ZeppOsSupport {
- @Override
- public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
- return new MiBand7FWHelper(uri, context);
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java
index 2d7846746..173e51f79 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation.java
@@ -80,7 +80,7 @@ public class UpdateFirmwareOperation extends AbstractHuamiOperation {
//the firmware will be sent by the notification listener if the band confirms that the metadata are ok.
}
- AbstractHuamiFirmwareInfo createFwInfo(Uri uri, Context context) throws IOException {
+ protected AbstractHuamiFirmwareInfo createFwInfo(Uri uri, Context context) throws IOException {
HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context);
return fwHelper.getFirmwareInfo();
}
@@ -283,7 +283,7 @@ public class UpdateFirmwareOperation extends AbstractHuamiOperation {
builder.queue(getQueue());
}
- AbstractHuamiFirmwareInfo getFirmwareInfo() {
+ protected AbstractHuamiFirmwareInfo getFirmwareInfo() {
return firmwareInfo;
}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java
deleted file mode 100644
index 891e53226..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/operations/UpdateFirmwareOperation2021.java
+++ /dev/null
@@ -1,124 +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 . */
-package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations;
-
-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.HuamiService;
-import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
-import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
-import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
-
-public class UpdateFirmwareOperation2021 extends UpdateFirmwareOperation2020 {
- private static final Logger LOG = LoggerFactory.getLogger(UpdateFirmwareOperation2021.class);
-
- public UpdateFirmwareOperation2021(final Uri uri, final ZeppOsSupport support) {
- super(uri, support);
- }
-
- @Override
- AbstractHuamiFirmwareInfo createFwInfo(final Uri uri, final Context context) throws IOException {
- return super.createFwInfo(uri, context);
-
- /* This does not actually seem to be needed, but it's what the official app does
- final HuamiFWHelper fwHelper = getSupport().createFWHelper(uri, context);
- final AbstractHuamiFirmwareInfo firmwareInfo = fwHelper.getFirmwareInfo();
-
- if (!(firmwareInfo instanceof Huami2021FirmwareInfo)) {
- throw new IllegalArgumentException("Firmware not Huami2021FirmwareInfo");
- }
-
- final Huami2021FirmwareInfo firmwareInfo2021 = (Huami2021FirmwareInfo) firmwareInfo;
- if (firmwareInfo2021.getFirmwareType() == HuamiFirmwareType.FIRMWARE) {
- // This does not actually seem to be needed, but it's what the official app does
- return firmwareInfo2021.repackFirmwareInUIHH();
- }
-
- return firmwareInfo;
- */
- }
-
- @Override
- public ZeppOsSupport getSupport() {
- return (ZeppOsSupport) super.getSupport();
- }
-
- @Override
- protected void handleNotificationNotif(byte[] value) {
- super.handleNotificationNotif(value);
-
- if (ArrayUtils.startsWith(value, new byte[]{HuamiService.RESPONSE, COMMAND_FINALIZE_UPDATE, HuamiService.SUCCESS})) {
- if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.APP) {
- // After an app is installed, request the display items from the band (new app will be at the end)
- try {
- TransactionBuilder builder = performInitialized("request display items and apps");
- getSupport().requestDisplayItems(builder);
- getSupport().requestApps(builder);
- builder.queue(getQueue());
- } catch (final IOException e) {
- LOG.error("Failed to request display items after app install", e);
- }
- } else if (getFirmwareInfo().getFirmwareType() == HuamiFirmwareType.WATCHFACE) {
- // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end)
- try {
- TransactionBuilder builder = performInitialized("request watchfaces and apps");
- getSupport().requestWatchfaces(builder);
- getSupport().requestApps(builder);
- builder.queue(getQueue());
- } catch (final IOException e) {
- LOG.error("Failed to request watchfaces after watchface install", e);
- }
- }
- }
- }
-
- @Override
- protected byte[] buildFirmwareInfoCommand() {
- final int fwSize = firmwareInfo.getSize();
- final int crc32 = firmwareInfo.getCrc32();
-
- final byte[] sizeBytes = BLETypeConversions.fromUint32(fwSize);
- final byte[] chunkSizeBytes = BLETypeConversions.fromUint16(mChunkLength);
- final byte[] crcBytes = BLETypeConversions.fromUint32(crc32);
-
- return new byte[]{
- COMMAND_SEND_FIRMWARE_INFO,
- getFirmwareInfo().getFirmwareType().getValue(),
- sizeBytes[0],
- sizeBytes[1],
- sizeBytes[2],
- sizeBytes[3],
- crcBytes[0],
- crcBytes[1],
- crcBytes[2],
- crcBytes[3],
- chunkSizeBytes[0],
- chunkSizeBytes[1],
- 0, // 0 to update in foreground, 1 for background
- (byte) 0xff, // ??
- };
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java
deleted file mode 100644
index ecca27e0e..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/AbstractZeppOsFwInstallHandler.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright (C) 2022-2024 Daniel Dakhno, José Rebelo
-
- This file is part of Gadgetbridge.
-
- Gadgetbridge is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Gadgetbridge is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see . */
-package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos;
-
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.net.Uri;
-
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
-import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
-import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler;
-import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
-import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo;
-import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
-
-public abstract class AbstractZeppOsFwInstallHandler extends AbstractMiBandFWInstallHandler {
- private static final Logger LOG = LoggerFactory.getLogger(AbstractZeppOsFwInstallHandler.class);
-
- public AbstractZeppOsFwInstallHandler(final Uri uri, final Context context) {
- super(uri, context);
- }
-
- @Override
- public void onStartInstall(final GBDevice device) {
- final AbstractHuamiFirmwareInfo firmwareInfo = getHelper().getFirmwareInfo();
- final boolean shouldCache = firmwareInfo.getFirmwareType().isApp() || firmwareInfo.getFirmwareType().isWatchface();
- if (shouldCache) {
- if (firmwareInfo instanceof ZeppOsFirmwareInfo) {
- saveToCache((ZeppOsFirmwareInfo) firmwareInfo, device);
- } else {
- LOG.warn("firmwareInfo is {} - this should never happen", firmwareInfo.getClass());
- }
- }
-
- // Unset the firmware bytes
- // Huami2021 firmwares are large (> 130MB). With the current architecture, the update operation
- // will re-read them to memory, and we run out-of-memory.
- helper.unsetFwBytes();
- }
-
- protected abstract HuamiFWHelper createHelper(Uri uri, Context context) throws IOException;
-
- public HuamiFWHelper getHelper() {
- return (HuamiFWHelper) helper;
- }
-
- private void saveToCache(final ZeppOsFirmwareInfo firmwareInfo, final GBDevice device) {
- final DeviceCoordinator coordinator = device.getDeviceCoordinator();
-
- final File appCacheDir;
- try {
- appCacheDir = coordinator.getAppCacheDir();
- } catch (final IOException e) {
- LOG.error("Failed to get app cache dir", e);
- return ;
- }
-
- final GBDeviceApp app = firmwareInfo.getAppInfo();
-
- // write app zip
- final File appOutputFile = new File(appCacheDir, app.getUUID().toString() + coordinator.getAppFileExtension());
- try {
- appCacheDir.mkdirs();
- FileUtils.copyURItoFile(getContext(), getUri(), appOutputFile);
- } catch (final IOException e) {
- LOG.error("Failed to save app to cache", e);
- return;
- }
-
- // write app metadata
- final File metadataOutputFile = new File(appCacheDir, app.getUUID().toString() + ".json");
- try (Writer writer = new BufferedWriter(new FileWriter(metadataOutputFile))) {
- final JSONObject appJSON = app.getJSON();
- writer.write(appJSON.toString());
- } catch (final IOException e) {
- LOG.error("Failed to write app metadata", e);
- return;
- }
-
- if (app.getPreviewImage() != null) {
- final File previewOutputFile = new File(appCacheDir, app.getUUID().toString() + "_preview.png");
- try (FileOutputStream fos = new FileOutputStream(previewOutputFile)) {
- app.getPreviewImage().compress(Bitmap.CompressFormat.PNG, 9, fos);
- } catch (final IOException e) {
- LOG.error("Failed to write app preview", e);
- }
- }
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java
deleted file mode 100644
index 6225b70ec..000000000
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFirmwareInfo.java
+++ /dev/null
@@ -1,471 +0,0 @@
-/* Copyright (C) 2022-2024 José Rebelo, MPeter
-
- This file is part of Gadgetbridge.
-
- Gadgetbridge is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- Gadgetbridge is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see . */
-
-package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-import androidx.annotation.Nullable;
-
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
-
-import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
-import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.AbstractHuamiFirmwareInfo;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.UIHHContainer;
-import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
-import nodomain.freeyourgadget.gadgetbridge.util.BitmapUtil;
-import nodomain.freeyourgadget.gadgetbridge.util.ZipFile;
-import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
-
-
-public abstract class ZeppOsFirmwareInfo extends AbstractHuamiFirmwareInfo {
- private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFirmwareInfo.class);
-
- private final String preComputedVersion;
- private GBDeviceApp gbDeviceApp;
-
- public ZeppOsFirmwareInfo(final byte[] bytes) {
- super(bytes);
- this.preComputedVersion = preComputeVersion();
- }
-
- /**
- * The device name, to search on firmware.bin in order to determine compatibility.
- */
- public abstract String deviceName();
-
- /**
- * The device sources, to match compatible packages.
- * As per: https://docs.zepp.com/docs/reference/related-resources/device-list/
- */
- public abstract Set deviceSources();
-
- @Override
- protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) {
- if (ArrayUtils.equals(bytes, UIHHContainer.UIHH_HEADER, 0)) {
- return handleUihhPackage(bytes);
- } else if (ZipFile.isZipFile(bytes)) {
- return handleZipPackage(bytes);
- } else {
- return HuamiFirmwareType.INVALID;
- }
- }
-
- private HuamiFirmwareType handleUihhPackage(byte[] bytes) {
- final UIHHContainer uihh = UIHHContainer.fromRawBytes(bytes);
- if (uihh == null) {
- LOG.warn("Invalid UIHH file");
- return HuamiFirmwareType.INVALID;
- }
-
- final Set agpsEpoTypes = new HashSet<>();
- UIHHContainer.FileEntry uihhFirmwareZipFile = null;
- boolean hasChangelog = false;
- for (final UIHHContainer.FileEntry file : uihh.getFiles()) {
- switch (file.getType()) {
- case FIRMWARE_ZIP:
- uihhFirmwareZipFile = file;
- continue;
- case FIRMWARE_CHANGELOG:
- hasChangelog = true;
- continue;
- case AGPS_EPO_GR_3:
- case AGPS_EPO_GAL_7:
- case AGPS_EPO_BDS_3:
- agpsEpoTypes.add(file.getType());
- continue;
- default:
- LOG.warn("Unexpected file for {}", file.getType());
- }
- }
-
- if (uihhFirmwareZipFile != null && hasChangelog) {
- // UIHH firmware update
- final ZipFile zipFile = new ZipFile(uihhFirmwareZipFile.getContent());
- final byte[] firmwareBin;
- try {
- firmwareBin = zipFile.getFileFromZip("META/firmware.bin");
- } catch (final ZipFileException e) {
- LOG.error("Failed to read zip from UIHH", e);
- return HuamiFirmwareType.INVALID;
- }
-
- if (isCompatibleFirmwareBin(firmwareBin)) {
- return HuamiFirmwareType.FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG;
- }
- }
-
- if (agpsEpoTypes.size() == 3) {
- // AGPS EPO update
- return HuamiFirmwareType.AGPS_UIHH;
- }
-
- return HuamiFirmwareType.INVALID;
- }
-
- private HuamiFirmwareType handleZipPackage(byte[] bytes) {
- final ZipFile zipFile = new ZipFile(bytes);
-
- // Attempt to handle as a firmware
- try {
- final byte[] firmwareBin = zipFile.getFileFromZip("META/firmware.bin");
- if (isCompatibleFirmwareBin(firmwareBin)) {
- return HuamiFirmwareType.FIRMWARE;
- } else {
- return HuamiFirmwareType.INVALID;
- }
- } catch (final ZipFileException e) {
- LOG.warn("Failed to get firmware.bin from zip file", e);
- }
-
- // 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);
- return HuamiFirmwareType.INVALID;
- }
-
- final HuamiFirmwareType huamiFirmwareType;
- final GBDeviceApp.Type gbDeviceAppType;
- switch (appType) {
- case "watchface":
- huamiFirmwareType = HuamiFirmwareType.WATCHFACE;
- gbDeviceAppType = GBDeviceApp.Type.WATCHFACE;
- break;
- case "app":
- huamiFirmwareType = HuamiFirmwareType.APP;
- gbDeviceAppType = GBDeviceApp.Type.APP_GENERIC;
- break;
- default:
- LOG.warn("Unknown app type {}", appType);
- return HuamiFirmwareType.INVALID;
- }
-
- Bitmap icon = null;
- try {
- final byte[] iconBytes = zipFile.getFileFromZip("assets/" + appIconPath);
- if (BitmapUtil.isPng(iconBytes)) {
- icon = BitmapFactory.decodeByteArray(iconBytes, 0, iconBytes.length);
- } else {
- icon = BitmapUtil.decodeTga(iconBytes);
- }
- } catch (final ZipFileException e) {
- LOG.error("Failed to get app icon from zip", e);
- }
-
- gbDeviceApp = new GBDeviceApp(
- UUID.fromString(String.format("%08x-0000-0000-0000-000000000000", appId)),
- appName,
- appCreator,
- appVersion,
- gbDeviceAppType,
- icon
- );
-
- return huamiFirmwareType;
- }
-
- // Attempt to handle as a zab file
- final byte[] zpk = handleZabPackage(zipFile);
- if (zpk != null) {
- setBytes(zpk);
- return handleZipPackage(zpk);
- }
-
- return HuamiFirmwareType.INVALID;
- }
-
- /**
- * A zab package is a zip file with:
- * - manifest.json
- * - .sc (source code)
- * - One or more zpk files
- *
- * 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 = zipFile.getFileFromZip(name);
- if (!ZipFile.isZipFile(zpkBytes)) {
- LOG.warn("bytes for {} not a zip file", name);
- continue;
- }
- final ZipFile zpkFile = new ZipFile(zpkBytes);
- final byte[] deviceZip = zpkFile.getFileFromZip("device.zip");
- if (!ZipFile.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;
- }
-
- @Override
- public String toVersion(int crc16) {
- final String crcMapVersion = getCrcMap().get(crc16);
- if (crcMapVersion != null) {
- return crcMapVersion;
- }
-
- return preComputedVersion;
- }
-
- public String preComputeVersion() {
- try {
- switch (firmwareType) {
- case FIRMWARE_UIHH_2021_ZIP_WITH_CHANGELOG:
- final UIHHContainer uihh = UIHHContainer.fromRawBytes(getBytes());
- if (uihh == null) {
- return null;
- }
- return getFirmwareVersion(uihh.getFile(UIHHContainer.FileType.FIRMWARE_ZIP));
- case FIRMWARE:
- return getFirmwareVersion(getBytes());
- case WATCHFACE:
- final String watchfaceName = getAppName(new ZipFile(getBytes()));
- if (watchfaceName == null) {
- return "(unknown watchface)";
- }
- return String.format("%s (watchface)", watchfaceName);
- case APP:
- final String appName = getAppName(new ZipFile(getBytes()));
- if (appName == null) {
- return "(unknown app)";
- }
- return String.format("%s (app)", appName);
- }
- } catch (final Exception e) {
- LOG.error("Failed to pre compute version", e);
- }
-
- return null;
- }
-
- public GBDeviceApp getAppInfo() {
- return gbDeviceApp;
- }
-
- @Nullable
- @Override
- public Bitmap getPreview() {
- if (gbDeviceApp != null) {
- return gbDeviceApp.getPreviewImage();
- }
-
- return null;
- }
-
- public ZeppOsFirmwareInfo repackFirmwareInUIHH() throws IOException {
- if (!firmwareType.equals(HuamiFirmwareType.FIRMWARE)) {
- throw new IllegalStateException("Can only repack FIRMWARE");
- }
-
- final UIHHContainer uihh = packFirmwareInUIHH(getBytes());
-
- try {
- final Constructor extends ZeppOsFirmwareInfo> constructor = this.getClass().getConstructor(byte[].class);
- return constructor.newInstance((Object) uihh.toRawBytes());
- } catch (final Exception e) {
- throw new IOException("Failed to construct new " + getClass().getName(), e);
- }
- }
-
- private static UIHHContainer packFirmwareInUIHH(final byte[] zipBytes) {
- final UIHHContainer uihh = new UIHHContainer();
- final byte[] timestampBytes = BLETypeConversions.fromUint32((int) (System.currentTimeMillis() / 1000L));
- final String changelogText = "Unknown changelog";
- final byte[] changelogBytes = BLETypeConversions.join(
- timestampBytes,
- changelogText.getBytes(StandardCharsets.UTF_8)
- );
- uihh.addFile(UIHHContainer.FileType.FIRMWARE_ZIP, zipBytes);
- uihh.addFile(UIHHContainer.FileType.FIRMWARE_CHANGELOG, changelogBytes);
- return uihh;
- }
-
- 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[] fwBytes) {
- final ZipFile zipFile = new ZipFile(fwBytes);
- final byte[] firmwareBin;
- try {
- firmwareBin = zipFile.getFileFromZip("META/firmware.bin");
- } catch (final ZipFileException e) {
- LOG.error("Failed to get firmware.bin from zip", e);
- return null;
- }
-
- 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));
- }
-
- public String getAppName(final ZipFile zipFile) {
- // TODO check i18n section?
- // TODO Show preview icon?
-
- final JSONObject appJson = getJson(zipFile, "app.json");
- if (appJson == null) {
- return null;
- }
-
- try {
- return appJson.getJSONObject("app").getString("appName");
- } catch (final Exception e) {
- LOG.error("Failed to get appName from app.json", e);
- }
-
- return null;
- }
-
- private static JSONObject getJson(final ZipFile zipFile, final String path) {
- final byte[] appJsonBin;
- try {
- appJsonBin = zipFile.getFileFromZip(path);
- } catch (final ZipFileException e) {
- LOG.error("Failed to read " + path, e);
- 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;
- }
-
- 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;
- }
-}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java
new file mode 100644
index 000000000..3a7fa6521
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsFwInstallHandler.java
@@ -0,0 +1,177 @@
+/* Copyright (C) 2022-2024 Daniel Dakhno, José Rebelo
+
+ This file is part of Gadgetbridge.
+
+ Gadgetbridge is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Gadgetbridge is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see . */
+package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos;
+
+import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType.AGPS_UIHH;
+
+import android.content.Context;
+import android.graphics.Bitmap;
+import android.net.Uri;
+
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Set;
+
+import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.activities.InstallActivity;
+import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
+import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsFwHelper;
+import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
+import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceApp;
+import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
+import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
+
+public class ZeppOsFwInstallHandler implements InstallHandler {
+ private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFwInstallHandler.class);
+
+ private final Uri mUri;
+ private final Context mContext;
+
+ private final ZeppOsFwHelper mHelper;
+
+ public ZeppOsFwInstallHandler(final Uri uri, final Context context, final String deviceName, final Set deviceSources) {
+ mUri = uri;
+ mContext = context;
+ mHelper = new ZeppOsFwHelper(uri, context, deviceName, deviceSources);
+ }
+
+ @Override
+ public boolean isValid() {
+ return mHelper.isValid();
+ }
+
+ @Override
+ public void validateInstallation(InstallActivity installActivity, GBDevice device) {
+ if (device.isBusy()) {
+ installActivity.setInfoText(device.getBusyTask());
+ installActivity.setInstallEnabled(false);
+ return;
+ }
+
+ if (!device.isInitialized()) {
+ installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_ready));
+ installActivity.setInstallEnabled(false);
+ return;
+ }
+
+ if (!mHelper.isValid()) {
+ installActivity.setInfoText(mContext.getString(R.string.fwapp_install_device_not_supported));
+ installActivity.setInstallEnabled(false);
+ return;
+ }
+
+ final DeviceCoordinator coordinator = device.getDeviceCoordinator();
+
+ final GenericItem fwItem = new GenericItem(mContext.getString(
+ R.string.installhandler_firmware_name,
+ device.getAliasOrName(),
+ mHelper.getFirmwareType(), // TODO human name
+ mHelper.getFirmwareVersion()
+ ));
+ fwItem.setIcon(coordinator.getDefaultIconResource());
+
+ final StringBuilder sb = new StringBuilder();
+ if (!mHelper.getFirmwareType().isWatchface() && !mHelper.getFirmwareType().isApp() && mHelper.getFirmwareType() != AGPS_UIHH) {
+ sb.append(mContext.getString(
+ R.string.fw_upgrade_notice,
+ mContext.getString(R.string.fw_upgrade_notice_zepp_os, mHelper.getFirmwareVersion(), device.getAliasOrName())
+ ));
+
+ // TODO whitelisted firmware
+ //if (mHelper.isFirmwareWhitelisted()) {
+ // sb.append(" ").append(mContext.getString(R.string.miband_firmware_known));
+ // fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_compatible_version));
+ // // TODO: set a CHECK (OKAY) button
+ //} else {
+ sb.append(" ").append(mContext.getString(R.string.miband_firmware_unknown_warning)).append(" \n\n")
+ .append(mContext.getString(R.string.miband_firmware_suggest_whitelist, String.valueOf(mHelper.getFirmwareVersion())));
+ fwItem.setDetails(mContext.getString(R.string.miband_fwinstaller_untested_version));
+ // TODO: set a UNKNOWN (question mark) button
+ //}
+ }
+
+ installActivity.setPreview(mHelper.getPreview());
+
+ installActivity.setInfoText(sb.toString());
+ installActivity.setInstallItem(fwItem);
+ installActivity.setInstallEnabled(true);
+ }
+
+ @Override
+ public void onStartInstall(final GBDevice device) {
+ final boolean shouldCache = mHelper.getFirmwareType().isApp() || mHelper.getFirmwareType().isWatchface();
+ if (shouldCache) {
+ saveToCache(device);
+ }
+ }
+
+ private void saveToCache(final GBDevice device) {
+ final DeviceCoordinator coordinator = device.getDeviceCoordinator();
+
+ final File appCacheDir;
+ try {
+ appCacheDir = coordinator.getAppCacheDir();
+ } catch (final IOException e) {
+ LOG.error("Failed to get app cache dir", e);
+ return;
+ }
+
+ final GBDeviceApp app = mHelper.getAppInfo();
+ if (app == null) {
+ LOG.warn("Unable to cache app, appInfo is null");
+ return;
+ }
+
+ // write app zip
+ final File appOutputFile = new File(appCacheDir, app.getUUID().toString() + coordinator.getAppFileExtension());
+ try {
+ appCacheDir.mkdirs();
+ FileUtils.copyURItoFile(mContext, mUri, appOutputFile);
+ } catch (final IOException e) {
+ LOG.error("Failed to save app to cache", e);
+ return;
+ }
+
+ // write app metadata
+ final File metadataOutputFile = new File(appCacheDir, app.getUUID().toString() + ".json");
+ try (Writer writer = new BufferedWriter(new FileWriter(metadataOutputFile))) {
+ final JSONObject appJSON = app.getJSON();
+ writer.write(appJSON.toString());
+ } catch (final IOException e) {
+ LOG.error("Failed to write app metadata", e);
+ return;
+ }
+
+ if (app.getPreviewImage() != null) {
+ final File previewOutputFile = new File(appCacheDir, app.getUUID().toString() + "_preview.png");
+ try (FileOutputStream fos = new FileOutputStream(previewOutputFile)) {
+ app.getPreviewImage().compress(Bitmap.CompressFormat.PNG, 9, fos);
+ } catch (final IOException e) {
+ LOG.error("Failed to write app preview", e);
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java
index c42643902..6a7aeffa1 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/ZeppOsSupport.java
@@ -38,6 +38,7 @@ import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService.ConfigArg.TEMPERATURE_UNIT;
import static nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsConfigService.ConfigArg.TIME_FORMAT;
+import android.content.Context;
import android.location.Location;
import android.net.Uri;
import android.os.Handler;
@@ -78,6 +79,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSilentMode;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventUpdatePreferences;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Service;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@@ -111,7 +113,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiPhoneGpsS
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiVibrationPatternNotificationType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2021;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsFirmwareUpdateOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsAgpsUpdateOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations.ZeppOsGpxRouteUploadOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.services.ZeppOsAgpsService;
@@ -143,7 +145,7 @@ import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
import nodomain.freeyourgadget.gadgetbridge.util.SilentMode;
-public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback {
+public final class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTransferService.Callback {
private static final Logger LOG = LoggerFactory.getLogger(ZeppOsSupport.class);
// Tracks whether realtime HR monitoring is already started, so we can just
@@ -592,6 +594,11 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr
writeToChunked2021("toggle realtime steps", CHUNKED2021_ENDPOINT_STEPS, cmd, false);
}
+ @Override
+ public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) {
+ throw new UnsupportedOperationException("this method should not be used");
+ }
+
@Override
public void onInstallApp(final Uri uri) {
final ZeppOsAgpsInstallHandler agpsHandler = new ZeppOsAgpsInstallHandler(uri, getContext());
@@ -635,7 +642,7 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr
return;
}
- new UpdateFirmwareOperation2021(Uri.parse(uihhFile.toURI().toString()), this).perform();
+ new ZeppOsFirmwareUpdateOperation(Uri.parse(uihhFile.toURI().toString()), this).perform();
}
} catch (final Exception e) {
@@ -656,11 +663,13 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr
} catch (final Exception e) {
GB.toast(getContext(), "Gpx route file cannot be installed: " + e.getMessage(), Toast.LENGTH_LONG, GB.ERROR, e);
}
-
- return;
}
- super.onInstallApp(uri);
+ try {
+ new ZeppOsFirmwareUpdateOperation(uri, this).perform();
+ } catch (final IOException ex) {
+ GB.toast(getContext(), "Firmware cannot be installed: " + ex.getMessage(), Toast.LENGTH_LONG, GB.ERROR, ex);
+ }
}
@Override
@@ -999,6 +1008,12 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr
servicesService.requestServices(builder);
}
+ @Override
+ @Deprecated
+ public final HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
+ throw new UnsupportedOperationException("This function should not be used for Zepp OS devices");
+ }
+
public void addSupportedService(final short endpoint, final boolean encrypted) {
mSupportedServices.add(endpoint);
if (encrypted) {
@@ -1054,11 +1069,6 @@ public abstract class ZeppOsSupport extends HuamiSupport implements ZeppOsFileTr
return mServiceMap.get(endpoint);
}
- @Override
- public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) {
- return new UpdateFirmwareOperation2021(uri, this);
- }
-
@Override
public int getActivitySampleSize() {
return 8;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java
index f13ac8953..9b2727af5 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsAgpsFile.java
@@ -23,7 +23,7 @@ import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.UIHHContainer;
-import nodomain.freeyourgadget.gadgetbridge.util.ZipFile;
+import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
public class ZeppOsAgpsFile {
@@ -36,11 +36,11 @@ public class ZeppOsAgpsFile {
}
public boolean isValid() {
- if (!ZipFile.isZipFile(zipBytes)) {
+ if (!GBZipFile.isZipFile(zipBytes)) {
return false;
}
- final ZipFile zipFile = new ZipFile(zipBytes);
+ final GBZipFile zipFile = new GBZipFile(zipBytes);
try {
final byte[] manifestBin = zipFile.getFileFromZip("META-INF/MANIFEST.MF");
@@ -67,7 +67,7 @@ public class ZeppOsAgpsFile {
public byte[] getUihhBytes() {
final UIHHContainer uihh = new UIHHContainer();
- final ZipFile zipFile = new ZipFile(zipBytes);
+ final GBZipFile zipFile = new GBZipFile(zipBytes);
try {
uihh.addFile(UIHHContainer.FileType.AGPS_EPO_GR_3, zipFile.getFileFromZip("EPO_GR_3.DAT"));
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java
new file mode 100644
index 000000000..2fc48b5e6
--- /dev/null
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/zeppos/operations/ZeppOsFirmwareUpdateOperation.java
@@ -0,0 +1,376 @@
+/* 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 . */
+package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.operations;
+
+import android.bluetooth.BluetoothGatt;
+import android.bluetooth.BluetoothGattCharacteristic;
+import android.net.Uri;
+import android.widget.Toast;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.util.UUID;
+
+import nodomain.freeyourgadget.gadgetbridge.R;
+import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventDisplayMessage;
+import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiService;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsCoordinator;
+import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppos.ZeppOsFwHelper;
+import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
+import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
+import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
+import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction;
+import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppos.ZeppOsSupport;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.AbstractMiBandOperation;
+import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
+import nodomain.freeyourgadget.gadgetbridge.util.GB;
+
+/**
+ * This class is basically UpdateFirmwareOperation2020. However, Zepp OS firmwares are growing huge (200+MB),
+ * which crash Gadgetbridge. In order to refactor the upgrade process for Zepp OS devices without having to
+ * refactor all 52 devices, the code was moved to this class so it can be refactored with a smaller impact.
+ *
+ * The protocol for Zepp OS devices differs from UpdateFirmwareOperation2020 in the following points:
+ * - no crc16 support (not needed for zepp os)
+ * - buildFirmwareInfoCommand is slightly different
+ * - at the end of the update, we request display items / watchfaces depending on what was installed, to refresh the
+ * preferences in the UI
+ */
+public class ZeppOsFirmwareUpdateOperation extends AbstractMiBandOperation {
+ private static final Logger LOG = LoggerFactory.getLogger(ZeppOsFirmwareUpdateOperation.class);
+
+ private final Uri uri;
+ private final BluetoothGattCharacteristic fwCControlChar;
+ private final BluetoothGattCharacteristic fwCDataChar;
+ private ZeppOsFwHelper fwHelper;
+ private RandomAccessFile raf;
+
+ protected int mChunkLength = -1;
+
+ public ZeppOsFirmwareUpdateOperation(final Uri uri, final ZeppOsSupport support) {
+ super(support);
+ this.uri = uri;
+ this.fwCControlChar = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_FIRMWARE);
+ this.fwCDataChar = getCharacteristic(HuamiService.UUID_CHARACTERISTIC_FIRMWARE_DATA);
+ }
+
+ @Override
+ protected void enableNeededNotifications(TransactionBuilder builder, boolean enable) {
+ builder.notify(fwCControlChar, enable);
+ }
+
+ @Override
+ protected void enableOtherNotifications(final TransactionBuilder builder, final boolean enable) {
+ // Disable 2021 chunked reads, otherwise firmware upgrades and activity sync get interrupted
+ // FIXME is this still needed?
+ builder.notify(getCharacteristic(HuamiService.UUID_CHARACTERISTIC_CHUNKEDTRANSFER_2021_READ), enable);
+ }
+
+ @Override
+ protected void doPerform() throws IOException {
+ final GBDevice device = getDevice();
+ final DeviceCoordinator coordinator = device.getDeviceCoordinator();
+ if (!(coordinator instanceof ZeppOsCoordinator)) {
+ throw new IOException("Not a Zepp OS coordinator for " + getDevice().getAddress());
+ }
+
+ fwHelper = new ZeppOsFwHelper(
+ uri,
+ getContext(),
+ ((ZeppOsCoordinator) coordinator).getDeviceBluetoothName(),
+ ((ZeppOsCoordinator) coordinator).getDeviceSources()
+ );
+
+ if (!fwHelper.isValid()) {
+ throw new IOException("Firmware is not valid for: " + getDevice().getAddress());
+ }
+
+ raf = new RandomAccessFile(fwHelper.getFile(), "r");
+
+ if (!requestParameters()) {
+ displayErrorMessage("Error requesting parameters, aborting.");
+ done();
+ }
+ }
+
+ protected void done() {
+ LOG.info("Operation done.");
+ operationFinished();
+ unsetBusy();
+ }
+
+ @Override
+ public boolean onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
+ if (status != BluetoothGatt.GATT_SUCCESS) {
+ operationFailed();
+ }
+ return super.onCharacteristicWrite(gatt, characteristic, status);
+ }
+
+ void operationFailed() {
+ GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_write_failed), false, 0, getContext());
+ }
+
+ @Override
+ public boolean onCharacteristicChanged(BluetoothGatt gatt,
+ BluetoothGattCharacteristic characteristic) {
+ UUID characteristicUUID = characteristic.getUuid();
+ if (fwCControlChar.getUuid().equals(characteristicUUID)) {
+ handleNotificationNotif(characteristic.getValue());
+ return true; // don't let anyone else handle it
+ } else {
+ super.onCharacteristicChanged(gatt, characteristic);
+ }
+ return false;
+ }
+
+ protected void handleNotificationNotif(byte[] value) {
+ boolean success = (value[2] == HuamiService.SUCCESS) || ((value[1] == UpdateFirmwareOperation2020.REPLY_UPDATE_PROGRESS) && value.length >= 6); // ugly
+
+ if (value[0] == HuamiService.RESPONSE && success) {
+ try {
+ switch (value[1]) {
+ case UpdateFirmwareOperation2020.COMMAND_REQUEST_PARAMETERS: {
+ mChunkLength = (value[4] & 0xff) | ((value[5] & 0xff) << 8);
+ LOG.info("got chunk length of " + mChunkLength);
+ sendFwInfo();
+ break;
+ }
+ case UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO:
+ sendTransferStart();
+ break;
+ case UpdateFirmwareOperation2020.COMMAND_START_TRANSFER:
+ sendFirmwareDataChunk(0);
+ break;
+ // not used in zepp os
+ //case HuamiService.COMMAND_FIRMWARE_START_DATA:
+ // sendChecksum();
+ // break;
+ case UpdateFirmwareOperation2020.REPLY_UPDATE_PROGRESS:
+ int offset = (value[2] & 0xff) | ((value[3] & 0xff) << 8) | ((value[4] & 0xff) << 16) | ((value[5] & 0xff) << 24);
+ LOG.info("update progress " + offset + " bytes");
+ sendFirmwareDataChunk(offset);
+ break;
+ case UpdateFirmwareOperation2020.COMMAND_COMPLETE_TRANSFER:
+ sendFinalize();
+ break;
+ case UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE: {
+ if (fwHelper.getFirmwareType() == HuamiFirmwareType.FIRMWARE) {
+ TransactionBuilder builder = performInitialized("reboot");
+ getSupport().sendReboot(builder);
+ builder.queue(getQueue());
+ } else {
+ GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext());
+ done();
+ }
+ break;
+ }
+ case HuamiService.COMMAND_FIRMWARE_REBOOT: {
+ LOG.info("Reboot command successfully sent.");
+ GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_update_complete), false, 100, getContext());
+ done();
+ break;
+ }
+ default: {
+ LOG.error("Unexpected response during firmware update: ");
+ getSupport().logMessageContent(value);
+ operationFailed();
+ displayErrorMessage(getContext().getString(R.string.updatefirmwareoperation_updateproblem_do_not_reboot));
+ done();
+ }
+ }
+ } catch (Exception ex) {
+ displayErrorMessage(getContext().getString(R.string.updatefirmwareoperation_updateproblem_do_not_reboot));
+ done();
+ }
+ } else {
+ LOG.error("Unexpected notification during firmware update: ");
+ operationFailed();
+ getSupport().logMessageContent(value);
+ int errorMessage = R.string.updatefirmwareoperation_metadata_updateproblem;
+ // Display a more specific error message for known errors
+
+ if (value[0] == HuamiService.RESPONSE && value[1] == UpdateFirmwareOperation2020.COMMAND_START_TRANSFER && value[2] == UpdateFirmwareOperation2020.REPLY_ERROR_FREE_SPACE) {
+ // Not enough free space on the device
+ errorMessage = R.string.updatefirmwareoperation_updateproblem_free_space;
+ } else if (value[0] == HuamiService.RESPONSE && value[1] == UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO && value[2] == UpdateFirmwareOperation2020.REPLY_ERROR_LOW_BATTERY) {
+ // Battery is too low
+ errorMessage = R.string.updatefirmwareoperation_updateproblem_low_battery;
+ }
+ displayErrorMessage(getContext().getString(errorMessage));
+ done();
+ }
+
+ if (ArrayUtils.startsWith(value, new byte[]{HuamiService.RESPONSE, UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE, HuamiService.SUCCESS})) {
+ if (fwHelper.getFirmwareType() == HuamiFirmwareType.APP) {
+ // After an app is installed, request the display items from the band (new app will be at the end)
+ try {
+ TransactionBuilder builder = performInitialized("request display items and apps");
+ getSupport().requestDisplayItems(builder);
+ getSupport().requestApps(builder);
+ builder.queue(getQueue());
+ } catch (final IOException e) {
+ LOG.error("Failed to request display items after app install", e);
+ }
+ } else if (fwHelper.getFirmwareType() == HuamiFirmwareType.WATCHFACE) {
+ // After a watchface is installed, request the watchfaces from the band (new watchface will be at the end)
+ try {
+ TransactionBuilder builder = performInitialized("request watchfaces and apps");
+ getSupport().requestWatchfaces(builder);
+ getSupport().requestApps(builder);
+ builder.queue(getQueue());
+ } catch (final IOException e) {
+ LOG.error("Failed to request watchfaces after watchface install", e);
+ }
+ }
+ }
+ }
+
+ private void displayErrorMessage(String message) {
+ getSupport().handleGBDeviceEvent(new GBDeviceEventDisplayMessage(message, Toast.LENGTH_LONG, GB.ERROR));
+ }
+
+ public void sendFwInfo() {
+ try {
+ TransactionBuilder builder = performInitialized("send firmware info");
+ builder.add(new SetDeviceBusyAction(getDevice(), getContext().getString(R.string.updating_firmware), getContext()));
+ builder.write(fwCControlChar, buildFirmwareInfoCommand());
+ builder.queue(getQueue());
+ } catch (IOException e) {
+ LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e);
+ }
+ }
+
+ protected byte[] buildFirmwareInfoCommand() {
+ final int fwSize = fwHelper.getSize();
+ final int crc32 = fwHelper.getCrc32();
+
+ final byte[] sizeBytes = BLETypeConversions.fromUint32(fwSize);
+ final byte[] chunkSizeBytes = BLETypeConversions.fromUint16(mChunkLength);
+ final byte[] crcBytes = BLETypeConversions.fromUint32(crc32);
+
+ return new byte[]{
+ UpdateFirmwareOperation2020.COMMAND_SEND_FIRMWARE_INFO,
+ fwHelper.getFirmwareType().getValue(),
+ sizeBytes[0],
+ sizeBytes[1],
+ sizeBytes[2],
+ sizeBytes[3],
+ crcBytes[0],
+ crcBytes[1],
+ crcBytes[2],
+ crcBytes[3],
+ chunkSizeBytes[0],
+ chunkSizeBytes[1],
+ 0, // 0 to update in foreground, 1 for background
+ (byte) 0xff, // ??
+ };
+ }
+
+ public boolean requestParameters() {
+ try {
+ TransactionBuilder builder = performInitialized("get update capabilities");
+ byte[] bytes = new byte[]{UpdateFirmwareOperation2020.COMMAND_REQUEST_PARAMETERS};
+ builder.write(fwCControlChar, bytes);
+ builder.queue(getQueue());
+ return true;
+ } catch (IOException e) {
+ LOG.error("Error sending firmware info: " + e.getLocalizedMessage(), e);
+ return false;
+ }
+ }
+
+ private void sendFirmwareDataChunk(int offset) {
+ int len = fwHelper.getSize();
+ int remaining = len - offset;
+ final int packetLength = getSupport().getMTU() - 3;
+
+ int chunkLength = mChunkLength;
+ if (remaining < mChunkLength) {
+ chunkLength = remaining;
+ }
+
+ int packets = chunkLength / packetLength;
+ int chunkProgress = 0;
+
+ try {
+ if (remaining <= 0) {
+ sendTransferComplete();
+ return;
+ }
+
+ TransactionBuilder builder = performInitialized("send firmware packets");
+
+ for (int i = 0; i < packets; i++) {
+ raf.seek(offset + (long) i * packetLength);
+ byte[] fwChunk = new byte[packetLength];
+ raf.read(fwChunk);
+
+ builder.write(fwCDataChar, fwChunk);
+ chunkProgress += packetLength;
+ }
+
+ if (chunkProgress < chunkLength) {
+ raf.seek(offset + (long) packets * packetLength);
+ byte[] lastChunk = new byte[chunkLength - chunkProgress];
+ raf.read(lastChunk);
+ builder.write(fwCDataChar, lastChunk);
+ }
+
+ int progressPercent = (int) ((((float) (offset + chunkLength)) / len) * 100);
+
+ builder.add(new SetProgressAction(getContext().getString(R.string.updatefirmwareoperation_update_in_progress), true, progressPercent, getContext()));
+
+ builder.queue(getQueue());
+
+ } catch (final IOException e) {
+ LOG.error("Unable to send fw to device", e);
+ GB.updateInstallNotification(getContext().getString(R.string.updatefirmwareoperation_firmware_not_sent), false, 0, getContext());
+ }
+ }
+
+ protected void sendTransferStart() throws IOException {
+ final TransactionBuilder builder = performInitialized("transfer complete");
+ builder.write(fwCControlChar, new byte[]{
+ UpdateFirmwareOperation2020.COMMAND_START_TRANSFER, 1,
+ });
+ builder.queue(getQueue());
+ }
+
+ protected void sendTransferComplete() throws IOException {
+ final TransactionBuilder builder = performInitialized("transfer complete");
+ builder.write(fwCControlChar, new byte[]{
+ UpdateFirmwareOperation2020.COMMAND_COMPLETE_TRANSFER,
+ });
+ builder.queue(getQueue());
+ }
+
+ protected void sendFinalize() throws IOException {
+ final TransactionBuilder builder = performInitialized("finalize firmware");
+ builder.write(fwCControlChar, new byte[]{
+ UpdateFirmwareOperation2020.COMMAND_FINALIZE_UPDATE,
+ });
+ builder.queue(getQueue());
+ }
+}
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java
similarity index 93%
rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java
rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java
index 4d194569b..08c33e192 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/ZipFile.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/GBZipFile.java
@@ -27,13 +27,11 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipInputStream;
-import androidx.annotation.Nullable;
-
/**
* Utility class for recognition and reading of ZIP archives.
*/
-public class ZipFile {
- private static final Logger LOG = LoggerFactory.getLogger(ZipFile.class);
+public class GBZipFile {
+ private static final Logger LOG = LoggerFactory.getLogger(GBZipFile.class);
public static final byte[] ZIP_HEADER = new byte[]{
0x50, 0x4B, 0x03, 0x04
};
@@ -44,7 +42,7 @@ public class ZipFile {
* Open ZIP file from byte array already in memory.
* @param zipBytes data to handle as a ZIP file.
*/
- public ZipFile(byte[] zipBytes) {
+ public GBZipFile(byte[] zipBytes) {
this.zipBytes = zipBytes;
}
@@ -53,7 +51,7 @@ public class ZipFile {
* This will read the entire file into memory at once.
* @param inputStream data to handle as a ZIP file.
*/
- public ZipFile(InputStream inputStream) throws IOException {
+ public GBZipFile(InputStream inputStream) throws IOException {
this.zipBytes = readAllBytes(inputStream);
}
@@ -118,7 +116,7 @@ public class ZipFile {
}
}
- private static byte[] readAllBytes(final InputStream is) throws IOException {
+ public static byte[] readAllBytes(final InputStream is) throws IOException {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int n;
diff --git a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java
similarity index 93%
rename from app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java
rename to app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java
index e9934b135..d634643d6 100644
--- a/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/ZipFileTest.java
+++ b/app/src/test/java/nodomain/freeyourgadget/gadgetbridge/test/GBZipFileTest.java
@@ -12,10 +12,10 @@ import java.nio.charset.StandardCharsets;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
-import nodomain.freeyourgadget.gadgetbridge.util.ZipFile;
+import nodomain.freeyourgadget.gadgetbridge.util.GBZipFile;
import nodomain.freeyourgadget.gadgetbridge.util.ZipFileException;
-public class ZipFileTest extends TestBase {
+public class GBZipFileTest extends TestBase {
private static final String TEST_FILE_NAME = "manifest.json";
private static final String TEST_NESTED_FILE_NAME = "directory/manifest.json";
private static final String TEST_FILE_CONTENTS_1 = "{ \"mykey\": \"myvalue\", \"myarr\": [0, 1, 2, 3] }";
@@ -44,7 +44,7 @@ public class ZipFileTest extends TestBase {
byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents);
- ZipFile zipFile = new ZipFile(zipArchive);
+ GBZipFile zipFile = new GBZipFile(zipArchive);
String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME));
Assert.assertEquals(contents, readContents);
@@ -56,7 +56,7 @@ public class ZipFileTest extends TestBase {
byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents);
- ZipFile zipFile = new ZipFile(zipArchive);
+ GBZipFile zipFile = new GBZipFile(zipArchive);
String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME));
Assert.assertEquals(contents, readContents);
@@ -68,7 +68,7 @@ public class ZipFileTest extends TestBase {
byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents);
- ZipFile zipFile = new ZipFile(zipArchive);
+ GBZipFile zipFile = new GBZipFile(zipArchive);
String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME));
Assert.assertEquals(contents, readContents);
@@ -80,7 +80,7 @@ public class ZipFileTest extends TestBase {
byte[] zipArchive = createZipArchive(TEST_FILE_NAME, contents);
- ZipFile zipFile = new ZipFile(zipArchive);
+ GBZipFile zipFile = new GBZipFile(zipArchive);
String readContents = new String(zipFile.getFileFromZip(TEST_FILE_NAME));
Assert.assertEquals(contents, readContents);
@@ -92,7 +92,7 @@ public class ZipFileTest extends TestBase {
byte[] zipArchive = createZipArchive(TEST_NESTED_FILE_NAME, contents);
- ZipFile zipFile = new ZipFile(zipArchive);
+ GBZipFile zipFile = new GBZipFile(zipArchive);
String readContents = new String(zipFile.getFileFromZip(TEST_NESTED_FILE_NAME));
Assert.assertEquals(contents, readContents);
@@ -112,7 +112,7 @@ public class ZipFileTest extends TestBase {
writeFileToZip(contents3, "file3", zipWriteStream);
zipWriteStream.close();
- ZipFile zipFile = new ZipFile(baos.toByteArray());
+ GBZipFile zipFile = new GBZipFile(baos.toByteArray());
String readContents2 = new String(zipFile.getFileFromZip("file2"));
String readContents1 = new String(zipFile.getFileFromZip("file1"));
String readContents3 = new String(zipFile.getFileFromZip("file3"));
@@ -132,7 +132,7 @@ public class ZipFileTest extends TestBase {
writeFileToZip("Hello, World!", "folder1/file3", zipWriteStream);
zipWriteStream.close();
- final ZipFile zipFile = new ZipFile(baos.toByteArray());
+ final GBZipFile zipFile = new GBZipFile(baos.toByteArray());
Assert.assertTrue(zipFile.fileExists("file2"));
Assert.assertTrue(zipFile.fileExists("file1"));
Assert.assertTrue(zipFile.fileExists("folder1/file3"));