mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-25 19:36:50 +01:00
Zepp OS: Match zpk compatibility by deviceSource
This commit is contained in:
parent
1fa8936544
commit
1730064f11
@ -27,6 +27,7 @@ import java.io.IOException;
|
|||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
||||||
@ -49,6 +50,12 @@ public abstract class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo {
|
|||||||
*/
|
*/
|
||||||
public abstract String deviceName();
|
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<Integer> deviceSources();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) {
|
protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) {
|
||||||
if (ArrayUtils.equals(bytes, UIHHContainer.UIHH_HEADER, 0)) {
|
if (ArrayUtils.equals(bytes, UIHHContainer.UIHH_HEADER, 0)) {
|
||||||
@ -178,7 +185,7 @@ public abstract class Huami2021FirmwareInfo extends AbstractHuamiFirmwareInfo {
|
|||||||
for (int j = 0; j < platforms.length(); j++) {
|
for (int j = 0; j < platforms.length(); j++) {
|
||||||
final JSONObject platform = platforms.getJSONObject(j);
|
final JSONObject platform = platforms.getJSONObject(j);
|
||||||
|
|
||||||
if (deviceName().equals(platform.getString("name"))) {
|
if (!deviceSources().contains(platform.getInt("deviceSource"))) {
|
||||||
// It's compatible with the device, fetch device.zip
|
// It's compatible with the device, fetch device.zip
|
||||||
final String name = zpkEntry.getString("name");
|
final String name = zpkEntry.getString("name");
|
||||||
final byte[] zpkBytes = zipFile.getFileFromZip(name);
|
final byte[] zpkBytes = zipFile.getFileFromZip(name);
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -37,6 +40,11 @@ public class AmazfitBand7FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_BAND7_NAME;
|
return HuamiConst.AMAZFIT_BAND7_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(252, 253, 254));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBAND7;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBAND7;
|
||||||
|
@ -19,8 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -43,6 +46,11 @@ public class AmazfitGTR3FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTR3_NAME;
|
return HuamiConst.AMAZFIT_GTR3_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(226, 227));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3;
|
||||||
|
@ -19,8 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pr
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -43,6 +46,11 @@ public class AmazfitGTR3ProFirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTR3_PRO_NAME;
|
return HuamiConst.AMAZFIT_GTR3_PRO_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(229, 230, 6095106));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3PRO;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR3PRO;
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -40,6 +43,11 @@ public class AmazfitGTR4FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTR4_NAME;
|
return HuamiConst.AMAZFIT_GTR4_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(7930112, 7930113));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR4;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTR4;
|
||||||
|
@ -19,8 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -43,6 +46,11 @@ public class AmazfitGTS3FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTS3_NAME;
|
return HuamiConst.AMAZFIT_GTS3_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(224, 225));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS3;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS3;
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -38,6 +41,11 @@ public class AmazfitGTS4FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTS4_NAME;
|
return HuamiConst.AMAZFIT_GTS4_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(7995648, 7995649));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4;
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -38,6 +41,11 @@ public class AmazfitGTS4MiniFirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_GTS4_MINI_NAME;
|
return HuamiConst.AMAZFIT_GTS4_MINI_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(246, 247));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4MINI;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITGTS4MINI;
|
||||||
|
@ -16,8 +16,11 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2;
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -38,6 +41,11 @@ public class AmazfitTRex2FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.AMAZFIT_TREX_2_NAME;
|
return HuamiConst.AMAZFIT_TREX_2_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(418, 419));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREX2;
|
return isHeaderValid() && device.getType() == DeviceType.AMAZFITTREX2;
|
||||||
|
@ -19,8 +19,11 @@ package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||||
@ -44,6 +47,11 @@ public class MiBand7FirmwareInfo extends Huami2021FirmwareInfo {
|
|||||||
return HuamiConst.XIAOMI_SMART_BAND7_NAME;
|
return HuamiConst.XIAOMI_SMART_BAND7_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<Integer> deviceSources() {
|
||||||
|
return new HashSet<>(Arrays.asList(260, 262, 263, 264, 265));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
public boolean isGenerallyCompatibleWith(final GBDevice device) {
|
||||||
return isHeaderValid() && device.getType() == DeviceType.MIBAND7;
|
return isHeaderValid() && device.getType() == DeviceType.MIBAND7;
|
||||||
|
Loading…
Reference in New Issue
Block a user