1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-06 13:41:35 +02:00

Improve Teclast H1 and H3 device matching #1207

This commit is contained in:
cpfeiffer 2018-08-18 12:57:21 +02:00
parent 50295864f5
commit d93799e72a

View File

@ -45,11 +45,16 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TeclastH30Coordinator extends AbstractDeviceCoordinator {
protected static final Logger LOG = LoggerFactory.getLogger(TeclastH30Coordinator.class);
// e.g. H3-B20F
private Pattern deviceNamePattern = Pattern.compile("^H[13]-[ABCDEF0123456789]{4}$");
@NonNull
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@ -62,10 +67,20 @@ public class TeclastH30Coordinator extends AbstractDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getDevice().getName();
if (name != null && (name.startsWith("TECLAST_H30") || name.startsWith("TECLAST_H10") || name.startsWith("H3-0DE7"))) {
if (candidate.supportsService(JYouConstants.UUID_SERVICE_JYOU)) {
return DeviceType.TECLASTH30;
}
String name = candidate.getDevice().getName();
if (name != null) {
if (name.startsWith("TECLAST_H30") || name.startsWith("TECLAST_H10")) {
return DeviceType.TECLASTH30;
}
Matcher deviceNameMatcher = deviceNamePattern.matcher(name);
if (deviceNameMatcher.matches()) {
return DeviceType.TECLASTH30;
}
}
return DeviceType.UNKNOWN;
}