mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 18:45:49 +01:00
Added support for Amazfit GTR 2e. (#2182)
Merge branch 'master' into master Added support for Amazfit GTR 2e. Co-authored-by: Jochen S <tsalin@noreply.codeberg.org> Co-authored-by: arisel <arisel@arisel.de> Reviewed-on: https://codeberg.org/Freeyourgadget/Gadgetbridge/pulls/2182 Co-Authored-By: Jochen S. <tsalin@noreply.codeberg.org> Co-Committed-By: Jochen S. <tsalin@noreply.codeberg.org>
This commit is contained in:
parent
24c2c99890
commit
b945af1531
@ -40,6 +40,7 @@ vendor's servers.
|
|||||||
* Amazfit Cor 2 [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor-2)
|
* Amazfit Cor 2 [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor-2)
|
||||||
* Amazfit GTR (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR)
|
* Amazfit GTR (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR)
|
||||||
* Amazfit GTR 2(WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR)
|
* Amazfit GTR 2(WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR)
|
||||||
|
* Amazfit GTR 2e(WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR)
|
||||||
* Amazfit GTS (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS)
|
* Amazfit GTS (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS)
|
||||||
* Amazfit GTS 2(WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS)
|
* Amazfit GTS 2(WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE) [Wiki](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS)
|
||||||
* Amazfit T-Rex (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE)
|
* Amazfit T-Rex (WARNING: NEEDS VENDOR APP WITH ACCOUNT ONCE)
|
||||||
|
@ -0,0 +1,105 @@
|
|||||||
|
/* Copyright (C) 2017-2021 Andreas Shimokawa, Daniele Gobbetti, João
|
||||||
|
Paulo Barraca, José Rebelo, pangwalla, tiparega
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2e;
|
||||||
|
|
||||||
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
|
|
||||||
|
public class AmazfitGTR2eCoordinator extends HuamiCoordinator {
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR2eCoordinator.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceType getDeviceType() {
|
||||||
|
return DeviceType.AMAZFITGTR2E;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||||
|
try {
|
||||||
|
BluetoothDevice device = candidate.getDevice();
|
||||||
|
String name = device.getName();
|
||||||
|
if (name != null && name.equalsIgnoreCase("Amazfit GTR 2e")) {
|
||||||
|
return DeviceType.AMAZFITGTR2E;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.error("unable to check device support", ex);
|
||||||
|
}
|
||||||
|
return DeviceType.UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
||||||
|
AmazfitGTR2eFWInstallHandler handler = new AmazfitGTR2eFWInstallHandler(uri, context);
|
||||||
|
return handler.isValid() ? handler : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBondingStyle() {
|
||||||
|
return BONDING_STYLE_REQUIRE_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsActivityTracks() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsWeather() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsMusicInfo() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
||||||
|
return new int[]{
|
||||||
|
R.xml.devicesettings_amazfitgtsgtr,
|
||||||
|
R.xml.devicesettings_wearlocation,
|
||||||
|
R.xml.devicesettings_timeformat,
|
||||||
|
R.xml.devicesettings_liftwrist_display,
|
||||||
|
R.xml.devicesettings_disconnectnotification,
|
||||||
|
R.xml.devicesettings_sync_calendar,
|
||||||
|
R.xml.devicesettings_expose_hr_thirdparty,
|
||||||
|
R.xml.devicesettings_bt_connected_advertisement,
|
||||||
|
R.xml.devicesettings_device_actions,
|
||||||
|
R.xml.devicesettings_pairingkey,
|
||||||
|
R.xml.devicesettings_high_mtu
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/* Copyright (C) 2016-2021 Andreas Shimokawa, Carsten Pfeiffer, Daniele
|
||||||
|
Gobbetti, pangwalla
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2e;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRFirmwareInfo;
|
||||||
|
|
||||||
|
public class AmazfitGTR2eFWHelper extends HuamiFWHelper {
|
||||||
|
|
||||||
|
public AmazfitGTR2eFWHelper(Uri uri, Context context) throws IOException {
|
||||||
|
super(uri, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void determineFirmwareInfo(byte[] wholeFirmwareBytes) {
|
||||||
|
firmwareInfo = new AmazfitGTRFirmwareInfo(wholeFirmwareBytes);
|
||||||
|
if (!firmwareInfo.isHeaderValid()) {
|
||||||
|
throw new IllegalArgumentException("Not an Amazfit GTR 2e firmware");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
/* Copyright (C) 2015-2021 Andreas Shimokawa, Carsten Pfeiffer, pangwalla
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2e;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.Uri;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
|
|
||||||
|
class AmazfitGTR2eFWInstallHandler extends AbstractMiBandFWInstallHandler {
|
||||||
|
AmazfitGTR2eFWInstallHandler(Uri uri, Context context) {
|
||||||
|
super(uri, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getFwUpgradeNotice() {
|
||||||
|
return mContext.getString(R.string.fw_upgrade_notice_amazfitgtr, helper.getHumanFirmwareVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AbstractMiBandFWHelper createHelper(Uri uri, Context context) throws IOException {
|
||||||
|
return new AmazfitGTR2eFWHelper(uri, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean isSupportedDeviceType(GBDevice device) {
|
||||||
|
return device.getType() == DeviceType.AMAZFITGTR2E;
|
||||||
|
}
|
||||||
|
}
|
@ -58,6 +58,7 @@ public enum DeviceType {
|
|||||||
AMAZFITNEO(31, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_neo),
|
AMAZFITNEO(31, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_neo),
|
||||||
AMAZFITGTS2_MINI(32, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_gts2_mini),
|
AMAZFITGTS2_MINI(32, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_gts2_mini),
|
||||||
ZEPP_E(33, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_zepp_e),
|
ZEPP_E(33, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_zepp_e),
|
||||||
|
AMAZFITGTR2E(34, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_gtr2e),
|
||||||
HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_hplus),
|
HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_hplus),
|
||||||
MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_makibes_f68),
|
MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_makibes_f68),
|
||||||
EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_exrizu_k8),
|
EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_exrizu_k8),
|
||||||
|
@ -52,6 +52,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor2.Am
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRLiteSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRLiteSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2Support;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2Support;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2e.AmazfitGTR2eSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.AmazfitVergeLSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.AmazfitVergeLSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2Support;
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2Support;
|
||||||
@ -197,6 +198,8 @@ public class DeviceSupportFactory {
|
|||||||
break;
|
break;
|
||||||
case ZEPP_E:
|
case ZEPP_E:
|
||||||
deviceSupport = new ServiceDeviceSupport(new ZeppESupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
deviceSupport = new ServiceDeviceSupport(new ZeppESupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
||||||
|
case AMAZFITGTR2E:
|
||||||
|
deviceSupport = new ServiceDeviceSupport(new AmazfitGTR2eSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
||||||
break;
|
break;
|
||||||
case AMAZFITTREX:
|
case AMAZFITTREX:
|
||||||
deviceSupport = new ServiceDeviceSupport(new AmazfitTRexSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
deviceSupport = new ServiceDeviceSupport(new AmazfitTRexSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
||||||
|
@ -0,0 +1,117 @@
|
|||||||
|
/* Copyright (C) 2017-2021 Andreas Shimokawa, Daniele Gobbetti, Dmytro
|
||||||
|
Bielik, pangwalla
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2e;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
||||||
|
|
||||||
|
public class AmazfitGTR2eFirmwareInfo extends HuamiFirmwareInfo {
|
||||||
|
private static final int FW_OFFSET = 3;
|
||||||
|
|
||||||
|
private static final byte[] FW_HEADER = new byte[]{
|
||||||
|
0x20, (byte) 0x99, 0x12, 0x01, 0x08 // completely nonsense probably
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final byte[] GPS_ALMANAC_HEADER = new byte[]{ // probably wrong
|
||||||
|
(byte) 0xa0, (byte) 0x80, 0x08, 0x00, (byte) 0x8b, 0x07
|
||||||
|
};
|
||||||
|
|
||||||
|
private static final byte[] GPS_CEP_HEADER = new byte[]{ // probably wrong
|
||||||
|
0x2a, 0x12, (byte) 0xa0, 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
// gps detection is totally bogus, just the first 16 bytes
|
||||||
|
private static final byte[][] GPS_HEADERS = {
|
||||||
|
new byte[]{
|
||||||
|
0x73, 0x75, 0x68, (byte) 0xd0, 0x70, 0x73, (byte) 0xbb, 0x5a,
|
||||||
|
0x3e, (byte) 0xc3, (byte) 0xd3, 0x09, (byte) 0x9e, 0x1d, (byte) 0xd3, (byte) 0xc9
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static Map<Integer, String> crcToVersion = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// firmware
|
||||||
|
|
||||||
|
// Latin Firmware
|
||||||
|
|
||||||
|
// resources
|
||||||
|
|
||||||
|
// font
|
||||||
|
|
||||||
|
// gps
|
||||||
|
crcToVersion.put(62532, "18344,eb2f43f,126");
|
||||||
|
}
|
||||||
|
|
||||||
|
public AmazfitGTR2eFirmwareInfo(byte[] bytes) {
|
||||||
|
super(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected HuamiFirmwareType determineFirmwareType(byte[] bytes) {
|
||||||
|
if (ArrayUtils.equals(bytes, NEWRES_HEADER, COMPRESSED_RES_HEADER_OFFSET_NEW)) {
|
||||||
|
return HuamiFirmwareType.RES_COMPRESSED;
|
||||||
|
}
|
||||||
|
if (ArrayUtils.equals(bytes, FW_HEADER, FW_OFFSET)) {
|
||||||
|
if (searchString32BitAligned(bytes, "Amazfit GTR 2e")) {
|
||||||
|
return HuamiFirmwareType.FIRMWARE;
|
||||||
|
}
|
||||||
|
return HuamiFirmwareType.INVALID;
|
||||||
|
}
|
||||||
|
if (ArrayUtils.startsWith(bytes, WATCHFACE_HEADER) || ArrayUtils.equals(bytes, WATCHFACE_HEADER, COMPRESSED_RES_HEADER_OFFSET_NEW) || ArrayUtils.equals(bytes, WATCHFACE_HEADER, COMPRESSED_RES_HEADER_OFFSET)) {
|
||||||
|
return HuamiFirmwareType.WATCHFACE;
|
||||||
|
}
|
||||||
|
if (ArrayUtils.startsWith(bytes, NEWFT_HEADER)) {
|
||||||
|
if (bytes[10] == 0x01) {
|
||||||
|
return HuamiFirmwareType.FONT;
|
||||||
|
} else if (bytes[10] == 0x02) {
|
||||||
|
return HuamiFirmwareType.FONT_LATIN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ArrayUtils.startsWith(bytes, GPS_ALMANAC_HEADER)) {
|
||||||
|
return HuamiFirmwareType.GPS_ALMANAC;
|
||||||
|
}
|
||||||
|
if (ArrayUtils.startsWith(bytes, GPS_CEP_HEADER)) {
|
||||||
|
return HuamiFirmwareType.GPS_CEP;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (byte[] gpsHeader : GPS_HEADERS) {
|
||||||
|
if (ArrayUtils.startsWith(bytes, gpsHeader)) {
|
||||||
|
return HuamiFirmwareType.GPS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return HuamiFirmwareType.INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isGenerallyCompatibleWith(GBDevice device) {
|
||||||
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR2E;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Map<Integer, String> getCrcMap() {
|
||||||
|
return crcToVersion;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
/* Copyright (C) 2017-2021 Andreas Shimokawa, Carsten Pfeiffer, Dmytro
|
||||||
|
Bielik, pangwalla
|
||||||
|
|
||||||
|
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 <http://www.gnu.org/licenses/>. */
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2e;
|
||||||
|
|
||||||
|
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.amazfitgtr2e.AmazfitGTR2eFWHelper;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
|
||||||
|
|
||||||
|
public class AmazfitGTR2eSupport extends AmazfitGTRSupport {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HuamiFWHelper createFWHelper(Uri uri, Context context) throws IOException {
|
||||||
|
return new AmazfitGTR2eFWHelper(uri, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSetCallState(CallSpec callSpec) {
|
||||||
|
onSetCallStateNew(callSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UpdateFirmwareOperation createUpdateFirmwareOperation(Uri uri) {
|
||||||
|
return new UpdateFirmwareOperation2020(uri, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getActivitySampleSize() {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
}
|
@ -66,6 +66,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRC
|
|||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRLiteCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr.AmazfitGTRLiteCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2.AmazfitGTR2Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2.AmazfitGTR2Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppe.ZeppECoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.zeppe.ZeppECoordinator;
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgtr2e.AmazfitGTR2eCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts.AmazfitGTSCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts.AmazfitGTSCoordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS2Coordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS2Coordinator;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel.AmazfitVergeLCoordinator;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel.AmazfitVergeLCoordinator;
|
||||||
@ -237,6 +238,7 @@ public class DeviceHelper {
|
|||||||
result.add(new AmazfitGTRLiteCoordinator());
|
result.add(new AmazfitGTRLiteCoordinator());
|
||||||
result.add(new AmazfitGTR2Coordinator());
|
result.add(new AmazfitGTR2Coordinator());
|
||||||
result.add(new ZeppECoordinator());
|
result.add(new ZeppECoordinator());
|
||||||
|
result.add(new AmazfitGTR2eCoordinator());
|
||||||
result.add(new AmazfitTRexCoordinator());
|
result.add(new AmazfitTRexCoordinator());
|
||||||
result.add(new AmazfitGTSCoordinator());
|
result.add(new AmazfitGTSCoordinator());
|
||||||
result.add(new AmazfitGTS2Coordinator());
|
result.add(new AmazfitGTS2Coordinator());
|
||||||
|
@ -804,6 +804,7 @@
|
|||||||
<string name="devicetype_amazfit_bipu">Amazfit Bip U</string>
|
<string name="devicetype_amazfit_bipu">Amazfit Bip U</string>
|
||||||
<string name="devicetype_amazfit_bipupro">Amazfit Bip U Pro</string>
|
<string name="devicetype_amazfit_bipupro">Amazfit Bip U Pro</string>
|
||||||
<string name="devicetype_amazfit_gtr2">Amazfit GTR 2</string>
|
<string name="devicetype_amazfit_gtr2">Amazfit GTR 2</string>
|
||||||
|
<string name="devicetype_amazfit_gtr2e">Amazfit GTR 2e</string>
|
||||||
<string name="devicetype_amazfit_gts2">Amazfit GTS 2</string>
|
<string name="devicetype_amazfit_gts2">Amazfit GTS 2</string>
|
||||||
<string name="devicetype_amazfit_gts2_mini">Amazfit GTS 2 Mini</string>
|
<string name="devicetype_amazfit_gts2_mini">Amazfit GTS 2 Mini</string>
|
||||||
<string name="devicetype_zepp_e">Zepp E</string>
|
<string name="devicetype_zepp_e">Zepp E</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user