1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 11:26:47 +01:00

Device Manager: replaced getSupportedType with supports method

Huami: introduced getSupportedDeviceName

Huami: implemented getSupportedDeviceName

Huami: fixed typo

Device manager: added error on empty getSupportedDeviceName and empty supports()

Device manager: migrated more devices to getSupportedDeviceName

Device manager: simplified default supports implementation

Device manager: added caching for getSupportedDeviceName pattern

Device manager: added caching DeviceType resolution

Device manager: changed pattern matching find()->matches()

Device manager: use Candidate as caching key

Device manager: more verbose variable initialization

Device manager: fixed typo

Device manager: removed device caching from DeviceHelper

Gradle: removed protoc binary

Device manager: moved more devices to getSupportedDeviceName

Device manager: reduced usages of String.format

Device Vesc: removed multiple device types

Device management: regex improvements

Makibes HR3: fixed device recognition regex
This commit is contained in:
Daniel Dakhno 2023-09-29 18:50:32 +03:00 committed by José Rebelo
parent 4919be9f6d
commit ef1d38d9d3
121 changed files with 466 additions and 1154 deletions

View File

@ -42,6 +42,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -76,9 +77,29 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceCoordinator.class);
private Pattern supportedDeviceName = null;
/**
* This method should return a ReGexp pattern that will matched against a found device
* to check whether this coordinator supports that device.
* If more sophisticated logic is needed to determine device support, the supports(GBDeviceCandidate)
* should be overridden.
*
* @return Pattern
* */
protected Pattern getSupportedDeviceName(){
return null;
}
@Override
public final boolean supports(GBDeviceCandidate candidate) {
return getSupportedType(candidate).isSupported();
public boolean supports(GBDeviceCandidate candidate) {
if(supportedDeviceName == null){
supportedDeviceName = getSupportedDeviceName();
}
if(supportedDeviceName == null){
throw new RuntimeException(getClass() + " should either override getSupportedDeviceName or supports(GBDeviceCandidate)");
}
return supportedDeviceName.matcher(candidate.getName()).matches();
}
@Override

View File

@ -112,17 +112,6 @@ public interface DeviceCoordinator {
}
}
/**
* Checks whether this coordinator handles the given candidate.
* Returns the supported device type for the given candidate or
* DeviceType.UNKNOWN
*
* @param candidate
* @return the supported device type for the given candidate.
*/
@NonNull
DeviceType getSupportedType(GBDeviceCandidate candidate);
/**
* Returns the type of connection, Classic of BLE
*

View File

@ -108,8 +108,8 @@ public class UnknownDeviceCoordinator extends AbstractDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
return DeviceType.UNKNOWN;
public boolean supports(GBDeviceCandidate candidate) {
return false;
}
@Override

View File

@ -4,7 +4,6 @@ import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Parcel;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
@ -67,16 +66,16 @@ public class AsteroidOSDeviceCoordinator extends AbstractDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
if (candidate.supportsService(AsteroidOSConstants.SERVICE_UUID)) {
return DeviceType.ASTEROIDOS;
return true;
}
for (String name : AsteroidOSConstants.SUPPORTED_DEVICE_CODENAMES) {
if (candidate.getName().equals(name)) {
return DeviceType.ASTEROIDOS;
return true;
}
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -64,21 +65,9 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
return Collections.singletonList(filter);
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
/* Filter by Espruino devices to avoid getting
the device chooser full of spam devices. */
if (name != null && (
name.startsWith("Bangle.js") ||
name.startsWith("Pixl.js") ||
name.startsWith("Puck.js") ||
name.startsWith("MDBT42Q") ||
name.startsWith("Espruino")))
return DeviceType.BANGLEJS;
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Bangle\\.js.*|Pixl\\.js.*|Puck\\.js.*|MDBT42Q.*|Espruino.*");
}
@Override

View File

@ -46,14 +46,13 @@ public class BinarySensorCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
Log.d("coordinator", "candidate name: " + candidate.getName());
public boolean supports(GBDeviceCandidate candidate) {
for(ParcelUuid service : candidate.getServiceUuids()){
if(service.getUuid().toString().equals(BinarySensorSupport.BINARY_SENSOR_SERVICE_UUID)){
return DeviceType.BINARY_SENSOR;
return true;
};
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -27,6 +27,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -44,18 +47,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB
public class CasioGB6900DeviceCoordinator extends CasioDeviceCoordinator {
protected static final Logger LOG = LoggerFactory.getLogger(CasioGB6900DeviceCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null) {
if (name.startsWith("CASIO") && (name.contains("6900B") || name.contains("5600B") ||
name.contains("STB-1000"))) {
return DeviceType.CASIOGB6900;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("CASIO.*(6900B|5600B|STB-1000).*");
}
@Override

View File

@ -28,13 +28,14 @@ import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySampleDao;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
@ -48,19 +49,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGB
public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator {
protected static final Logger LOG = LoggerFactory.getLogger(CasioGBX100DeviceCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null) {
if (name.startsWith("CASIO") && (name.endsWith("GBX-100") ||
name.endsWith("GBD-200") || name.endsWith("GBD-100") ||
name.endsWith("GBD-H1000"))) {
return DeviceType.CASIOGBX100;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("CASIO.*(GBX-100|GBD-100|GBD-200|GBD-H1000)");
}
@Override

View File

@ -20,25 +20,16 @@ package nodomain.freeyourgadget.gadgetbridge.devices.casio.gwb5600;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.devices.casio.gwb5600.CasioGWB5600DeviceCoordinator;
public class CasioGMWB5000DeviceCoordinator extends CasioGWB5600DeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null) {
if (name.equals("CASIO GMW-B5000")) {
return DeviceType.CASIOGMWB5000;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("CASIO GMW-B5000");
}
@Override

View File

@ -18,19 +18,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.casio.gwb5600;
import java.util.Collection;
import java.util.Collections;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.bluetooth.le.ScanFilter;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
@ -40,24 +36,14 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600DeviceSupport;
public class CasioGWB5600DeviceCoordinator extends CasioDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null) {
if (name.equals("CASIO GW-B5600")) {
return DeviceType.CASIOGWB5600;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("CASIO GW-B5600");
}
@Override

View File

@ -24,6 +24,7 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.EnumSet;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
@ -40,14 +41,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.domyos.DomyosT540Support;
public class DomyosT540Coordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("Domyos-TC-9610")) {
return DeviceType.DOMYOS_T540;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Domyos-TC-9610.*");
}
@Override

View File

@ -20,7 +20,6 @@ package nodomain.freeyourgadget.gadgetbridge.devices.fitpro;
import android.app.Activity;
import android.content.Context;
import android.net.Uri;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -29,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.EnumSet;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBException;
@ -58,28 +58,9 @@ public class FitProDeviceCoordinator extends AbstractBLEDeviceCoordinator {
qb.where(FitProActivitySampleDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (
name.startsWith("M6") ||
name.startsWith("M4") ||
name.equals("LH716") ||
name.equals("Sunset 6") ||
name.equals("Watch7") ||
name.equals("Fit1900"))
) {
return DeviceType.FITPRO;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("M6.*|M4.*|LH716|Sunset 6|Watch7|Fit1900");
}
@Override

View File

@ -31,11 +31,11 @@ public class FlipperZeroCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
if(candidate.supportsService(UUID.fromString("00003082-0000-1000-8000-00805f9b34fb"))){
return DeviceType.FLIPPER_ZERO; // need to filter for flipper here
return true; // need to filter for flipper here
}
return DeviceType.UNKNOWN;
return false;
}
@Nullable

View File

@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -10,19 +12,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class GalaxyBuds2DeviceCoordinator extends GalaxyBudsGenericCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (
name.startsWith("Galaxy Buds2 (")
)) {
return DeviceType.GALAXY_BUDS2;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Galaxy Buds2 \\(.*");
}
@Override

View File

@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -10,19 +12,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class GalaxyBuds2ProDeviceCoordinator extends GalaxyBudsGenericCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (
name.startsWith("Galaxy Buds2 Pro")
)) {
return DeviceType.GALAXY_BUDS2_PRO;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Galaxy Buds2 Pro.*");
}
@Override

View File

@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
@ -9,19 +11,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class GalaxyBudsDeviceCoordinator extends GalaxyBudsGenericCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (
name.startsWith("Galaxy Buds (")
)) {
return DeviceType.GALAXY_BUDS;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Galaxy Buds \\(.*");
}
@Override

View File

@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
@ -9,19 +11,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class GalaxyBudsLiveDeviceCoordinator extends GalaxyBudsGenericCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (
name.startsWith("Galaxy Buds Live (")
)) {
return DeviceType.GALAXY_BUDS_LIVE;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Galaxy Buds Live \\(.*");
}
@Override

View File

@ -2,6 +2,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.galaxy_buds;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSpecificSettingsCustomizer;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -10,19 +12,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class GalaxyBudsProDeviceCoordinator extends GalaxyBudsGenericCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (
name.startsWith("Galaxy Buds Pro (")
)) {
return DeviceType.GALAXY_BUDS_PRO;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Galaxy Buds Pro \\(.*");
}
@Override

View File

@ -23,6 +23,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.hplus;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
@ -31,16 +33,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
* Pseudo Coordinator for the EXRIZU K8, a sub type of the HPLUS devices
*/
public class EXRIZUK8Coordinator extends HPlusCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if(name != null && name.startsWith("iRun ")){
return DeviceType.EXRIZUK8;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("iRun .*");
}
@Override

View File

@ -17,13 +17,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.hplus;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import org.slf4j.Logger;
@ -32,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.Locale;
import java.util.regex.Pattern;
import androidx.annotation.NonNull;
@ -53,7 +52,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.ServiceDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusSupport;
import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
@ -72,15 +70,9 @@ public class HPlusCoordinator extends AbstractBLEDeviceCoordinator {
return Collections.singletonList(filter);
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("HPLUS")) {
return DeviceType.HPLUS;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("HPLUS.*");
}
@Override

View File

@ -34,13 +34,13 @@ public class MakibesF68Coordinator extends HPlusCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
String name = candidate.getName();
if(name != null && name.startsWith("SPORT") && !name.startsWith("SPORTAGE")){
return DeviceType.MAKIBESF68;
return true;
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -23,6 +23,8 @@ package nodomain.freeyourgadget.gadgetbridge.devices.hplus;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
@ -31,16 +33,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
* Pseudo Coordinator for the Q8, a sub type of the HPLUS devices
*/
public class Q8Coordinator extends HPlusCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if(name != null && name.startsWith("Q8")){
return DeviceType.Q8;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Q8.*");
}
@Override

View File

@ -31,16 +31,16 @@ public class SG2Coordinator extends HPlusCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("SG2")) {
HPlusCoordinator.setNotificationLinesNumber(candidate.getDevice().getAddress(), 9);
HPlusCoordinator.setUnicodeSupport(candidate.getDevice().getAddress(), true);
HPlusCoordinator.setDisplayIncomingMessageIcon(candidate.getDevice().getAddress(), false);
return DeviceType.SG2;
return true;
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -38,21 +40,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5.A
public class AmazfitBand5Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand5Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_BAND5_NAME)) {
return DeviceType.AMAZFITBAND5;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_BAND5_NAME, Pattern.CASE_INSENSITIVE);
}
} catch (SecurityException ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,21 +39,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.A
public class AmazfitBand7Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBand7Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_BAND7_NAME)) {
return DeviceType.AMAZFITBAND7;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_BAND7_NAME + ".*", Pattern.CASE_INSENSITIVE);
}
} catch (SecurityException e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
}
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass() {

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
public class AmazfitBipCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Bip Watch"))) {
return DeviceType.AMAZFITBIP;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip Watch", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipLiteCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit Bip Lite")) {
return DeviceType.AMAZFITBIP_LITE;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip Lite", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro
public class AmazfitBip3ProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip3ProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit Bip 3 Pro")) {
return DeviceType.AMAZFITBIP3PRO;
}
} catch (final Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip 3 Pro", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitBip5Coordinator extends Huami2021Coordinator {
return AmazfitBip5Support.class;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_BIP5_NAME)) {
return DeviceType.AMAZFITBIP5;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_BIP5_NAME + ".*");
}
@Override

View File

@ -25,30 +25,21 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
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;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
public class AmazfitBipSCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Bip S"))) {
return DeviceType.AMAZFITBIPS;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip S", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
@ -35,18 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.Am
public class AmazfitBipSLiteCoordinator extends AmazfitBipSCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSLiteCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Bip S Lite"))) {
return DeviceType.AMAZFITBIPS_LITE;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Bip S Lite", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -38,18 +40,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipu.Am
public class AmazfitBipUCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Bip U"))) {
return DeviceType.AMAZFITBIPU;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip U", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -38,18 +40,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipupro
public class AmazfitBipUProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Bip U Pro"))) {
return DeviceType.AMAZFITBIPUPRO;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Bip U Pro", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetah
public class AmazfitCheetahProCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_CHEETAH_PRO_NAME)) {
return DeviceType.AMAZFITCHEETAHPRO;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_PRO_NAME + ".*");
}
@NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitCheetahRoundCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_cheetah_round;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME)) {
return DeviceType.AMAZFITCHEETAHROUND;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME + ".*");
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitCheetahSquareCoordinator extends Huami2021Coordinator {
return AmazfitCheetahSquareSupport.class;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME)) {
return DeviceType.AMAZFITCHEETAHSQUARE;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME + ".*");
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor.Ama
public class AmazfitCorCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCorCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Band") || name.equalsIgnoreCase("Amazfit Cor"))) {
return DeviceType.AMAZFITCOR;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Band|Amazfit Cor", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor2.Am
public class AmazfitCor2Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCor2Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Band 2") || name.equalsIgnoreCase("Amazfit Cor 2"))) {
return DeviceType.AMAZFITCOR2;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Band 2|Amazfit Cor 2", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitFalconCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_falcon;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_FALCON_NAME)) {
return DeviceType.AMAZFITFALCON;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_FALCON_NAME + ".*");
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,20 +39,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.Ama
public class AmazfitGTRCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTRCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTR")) {
return DeviceType.AMAZFITGTR;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTR", Pattern.CASE_INSENSITIVE);
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
AmazfitGTRFWInstallHandler handler = new AmazfitGTRFWInstallHandler(uri, context);

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.Ama
public class AmazfitGTRLiteCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTRLiteCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTR L")) {
return DeviceType.AMAZFITGTR_LITE;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTR L", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.Am
public class AmazfitGTR2Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR2Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTR 2")) {
return DeviceType.AMAZFITGTR2;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTR 2", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.Am
public class AmazfitGTR2eCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR2eCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.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;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTR 2e", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -39,17 +39,17 @@ public class AmazfitGTR3Coordinator extends Huami2021Coordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR3_NAME) && !name.contains("Pro")) {
return DeviceType.AMAZFITGTR3;
return true;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
return false;
}
@NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro
public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR3_PRO_NAME)) {
return DeviceType.AMAZFITGTR3PRO;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTR3_PRO_NAME + ".*");
}
@NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.Am
public class AmazfitGTR4Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR4_NAME)) {
return DeviceType.AMAZFITGTR4;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTR4_NAME + ".*");
}
@NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitGTRMiniCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_gtr_mini;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTR_MINI_NAME)) {
return DeviceType.AMAZFITGTRMINI;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTR_MINI_NAME + ".*");
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.Ama
public class AmazfitGTSCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTSCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTS")) {
return DeviceType.AMAZFITGTS;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTS", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.Am
public class AmazfitGTS2Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS2Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTS 2")) {
return DeviceType.AMAZFITGTS2;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTS 2", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.Am
public class AmazfitGTS2MiniCoordinator extends AmazfitGTS2Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS2MiniCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTS2 mini")) {
return DeviceType.AMAZFITGTS2_MINI;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTS2 mini", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.Am
public class AmazfitGTS2eCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS2eCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit GTS 2e")) {
return DeviceType.AMAZFITGTS2E;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit GTS 2e", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.Am
public class AmazfitGTS3Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTS3_NAME)) {
return DeviceType.AMAZFITGTS3;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTS3_NAME + ".*");
}
@NonNull

View File

@ -39,17 +39,17 @@ public class AmazfitGTS4Coordinator extends Huami2021Coordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTS4_NAME) && !name.contains("Mini")) {
return DeviceType.AMAZFITGTS4;
return true;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
return false;
}
@NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4min
public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_GTS4_MINI_NAME)) {
return DeviceType.AMAZFITGTS4MINI;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_GTS4_MINI_NAME + ".*");
}
@NonNull

View File

@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -41,19 +42,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitneo.Ama
public class AmazfitNeoCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitNeoCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_NEO_NAME)) {
return DeviceType.AMAZFITNEO;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_NEO_NAME, Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipu.AmazfitBipUCoordinator;
@ -35,18 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpop.Ama
public class AmazfitPopCoordinator extends AmazfitBipUCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Pop"))) {
return DeviceType.AMAZFITPOP;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Pop", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipupro.AmazfitBipUProCoordinator;
@ -35,18 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpoppro.
public class AmazfitPopProCoordinator extends AmazfitBipUProCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase("Amazfit Pop Pro"))) {
return DeviceType.AMAZFITPOPPRO;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Pop Pro", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex.Am
public class AmazfitTRexCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit T-Rex")) {
return DeviceType.AMAZFITTREX;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit T-Rex", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex2.A
public class AmazfitTRex2Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_TREX_2_NAME)) {
return DeviceType.AMAZFITTREX2;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_TREX_2_NAME + ".*");
}
@NonNull

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexpro
public class AmazfitTRexProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexProCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit T-Rex Pro")) {
return DeviceType.AMAZFITTREXPRO;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit T-Rex Pro", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitTRexUltraCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_trex_ultra;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.AMAZFIT_TREX_ULTRA)) {
return DeviceType.AMAZFITTREXULTRA;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_TREX_ULTRA + ".*");
}
@Override

View File

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.net.Uri;
@ -25,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.
public class AmazfitVergeLCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitVergeLCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Amazfit Verge L")) {
return DeviceType.AMAZFITVERGEL;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Amazfit Verge L", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -25,11 +25,12 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitx.AmazfitXFWInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
@ -39,21 +40,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitx.Amazf
public class AmazfitXCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitXCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.AMAZFIT_X)) {
return DeviceType.AMAZFITX;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.AMAZFIT_X, Pattern.CASE_INSENSITIVE);
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {

View File

@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.EnumSet;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -41,21 +42,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand
public class MiBand2Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.MI_BAND2_NAME)) {
return DeviceType.MIBAND2;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.MI_BAND2_NAME, Pattern.CASE_INSENSITIVE);
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {
MiBand2FWInstallHandler handler = new MiBand2FWInstallHandler(uri, context);

View File

@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import java.util.EnumSet;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -41,18 +42,12 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand
public class MiBand2HRXCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand2HRXCoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (HuamiConst.MI_BAND2_NAME_HRX.equalsIgnoreCase(name) || "Mi Band 2i".equalsIgnoreCase(name)) {
return DeviceType.MIBAND2_HRX;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(
HuamiConst.MI_BAND2_NAME_HRX + "|Mi Band 2i",
Pattern.CASE_INSENSITIVE
);
}
@Override

View File

@ -26,6 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -43,19 +44,12 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public class MiBand3Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand3Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && (name.equalsIgnoreCase(HuamiConst.MI_BAND3_NAME) || name.equalsIgnoreCase(HuamiConst.MI_BAND3_NAME_2))) {
return DeviceType.MIBAND3;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(
HuamiConst.MI_BAND3_NAME + "|" + HuamiConst.MI_BAND3_NAME_2,
Pattern.CASE_INSENSITIVE
);
}
@Override

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -43,21 +44,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4.MiBand
public class MiBand4Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand4Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.MI_BAND4_NAME)) {
return DeviceType.MIBAND4;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.MI_BAND4_NAME, Pattern.CASE_INSENSITIVE);
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(Uri uri, Context context) {

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -42,19 +43,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand
public class MiBand5Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand5Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.MI_BAND5_NAME)) {
return DeviceType.MIBAND5;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.MI_BAND5_NAME, Pattern.CASE_INSENSITIVE);
}

View File

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -25,18 +26,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband6.MiBand
public class MiBand6Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand6Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase(HuamiConst.MI_BAND6_NAME)) {
return DeviceType.MIBAND6;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.MI_BAND6_NAME, Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand
public class MiBand7Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand7Coordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.startsWith(HuamiConst.XIAOMI_SMART_BAND7_NAME)) {
return DeviceType.MIBAND7;
}
} catch (final Exception e) {
LOG.error("unable to check device support", e);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(HuamiConst.XIAOMI_SMART_BAND7_NAME + ".*");
}
@Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppe.ZeppESup
public class ZeppECoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(ZeppECoordinator.class);
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("Zepp E")) {
return DeviceType.ZEPP_E;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Zepp E", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -17,12 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.id115;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import java.util.Collection;
@ -59,11 +57,11 @@ public class ID115Coordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
if (candidate.supportsService(ID115Constants.UUID_SERVICE_ID115)) {
return DeviceType.ID115;
return true;
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -17,17 +17,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.itag;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
@ -44,13 +43,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.itag.ITagSupport;
public class ITagCoordinator extends AbstractBLEDeviceCoordinator {
@Override
@NonNull
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.toLowerCase().startsWith("itag")) { // All four: iTAG, iTag, ITAG and ITag exist
return DeviceType.ITAG;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("itag.*", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -28,6 +28,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.GBException;
@ -67,19 +68,9 @@ public class BFH16DeviceCoordinator extends AbstractBLEDeviceCoordinator
return Collections.singletonList(filter);
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null) {
if (name.startsWith("BFH-16")) {
return DeviceType.BFH16;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("BFH-16.*");
}
@Override

View File

@ -17,12 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.jyou.TeclastH30;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import org.slf4j.Logger;
@ -53,9 +51,6 @@ public class TeclastH30Coordinator extends AbstractBLEDeviceCoordinator {
protected static final Logger LOG = LoggerFactory.getLogger(TeclastH30Coordinator.class);
// e.g. H3-B20F
private Pattern deviceNamePattern = Pattern.compile("^H[13]-[ABCDEF0123456789]{4}$");
@NonNull
@Override
public Collection<? extends ScanFilter> createBLEScanFilters() {
@ -66,22 +61,17 @@ public class TeclastH30Coordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
if (candidate.supportsService(JYouConstants.UUID_SERVICE_JYOU)) {
return DeviceType.TECLASTH30;
return true;
}
String name = candidate.getName();
if (name != null) {
if (name.startsWith("TECLAST_H30") || name.startsWith("TECLAST_H10")) {
return DeviceType.TECLASTH30;
return super.supports(candidate);
}
Matcher deviceNameMatcher = deviceNamePattern.matcher(name);
if (deviceNameMatcher.matches()) {
return DeviceType.TECLASTH30;
}
}
return DeviceType.UNKNOWN;
@Override
protected Pattern getSupportedDeviceName() {
return Pattern.compile("TECLAST_H[13]0.*|H[13]-[ABCDEF0123456789]{4}");
}
@Override

View File

@ -23,6 +23,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -48,20 +50,9 @@ public class Y5Coordinator extends AbstractBLEDeviceCoordinator {
qb.where(JYouActivitySampleDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null) {
if (name.contains("Y5")) {
return DeviceType.Y5;
}
}
} catch (Exception ex) {
ex.getLocalizedMessage();
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*Y5.*");
}
@Nullable

View File

@ -19,20 +19,17 @@ package nodomain.freeyourgadget.gadgetbridge.devices.lefun;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class BohemicSmartBraceletDeviceCoordinator extends LefunDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
if (".bohemic".equals(candidate.getName())) {
return DeviceType.BOHEMIC_SMART_BRACELET;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("\\.bohemic");
}
@Override

View File

@ -58,7 +58,7 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
// There's a bunch of other names other than "Lefun", but let's just focus on one for now.
if (ADVERTISEMENT_NAME.equals(candidate.getName())) {
// The device does not advertise service UUIDs, so can't check whether it supports
@ -67,11 +67,11 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
// manufacturer specific data, which consists of the device's MAC address and said
// string. But we're not being given it, so *shrug*.
if (candidate.getServiceUuids().length == 0) {
return DeviceType.LEFUN;
return true;
}
}
return DeviceType.UNKNOWN;
return false;
}
@Nullable

View File

@ -18,13 +18,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.lenovo.watchxplus;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
@ -90,21 +88,21 @@ public class WatchXPlusDeviceCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
String macAddress = candidate.getMacAddress().toUpperCase();
String deviceName = candidate.getName().toUpperCase();
if (candidate.supportsService(WatchXPlusConstants.UUID_SERVICE_WATCHXPLUS)) {
return DeviceType.WATCHXPLUS;
return true;
} else if (macAddress.startsWith("DC:41:E5")) {
return DeviceType.WATCHXPLUS;
return true;
} else if (deviceName.equalsIgnoreCase("WATCH XPLUS")) {
return DeviceType.WATCHXPLUS;
return true;
// add initial support for Watch X non-plus (forces Watch X to be recognized as Watch XPlus)
// Watch X non-plus have same MAC address as Watch 9 (starts with "1C:87:79")
} else if (deviceName.equalsIgnoreCase("WATCH X")) {
return DeviceType.WATCHXPLUS;
return true;
}
return DeviceType.UNKNOWN;
return false;
}
@Nullable

View File

@ -22,6 +22,9 @@ import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLClassicDeviceCoordinator;
@ -37,14 +40,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.liveview.LiveviewSupport;
public class LiveviewCoordinator extends AbstractBLClassicDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("LiveView")) {
return DeviceType.LIVEVIEW;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("LiveView.*");
}
@Override

View File

@ -22,6 +22,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.regex.Pattern;
import android.app.Activity;
import android.content.Context;
@ -35,7 +36,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst;
@ -150,23 +150,9 @@ public class MakibesHR3Coordinator extends AbstractBLEDeviceCoordinator {
}
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
List<String> deviceNames = new ArrayList<String>(){{
add("Y808"); // Chinese version
add("MAKIBES HR3"); // English version
}};
if (name != null) {
if (deviceNames.contains(name)) {
return DeviceType.MAKIBESHR3;
}
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Y808|MAKIBES HR3");
}
@Override

View File

@ -17,13 +17,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miband;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import androidx.annotation.DrawableRes;
@ -76,15 +74,15 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
String macAddress = candidate.getMacAddress().toUpperCase();
if (macAddress.startsWith(MiBandService.MAC_ADDRESS_FILTER_1_1A)
|| macAddress.startsWith(MiBandService.MAC_ADDRESS_FILTER_1S)) {
return DeviceType.MIBAND;
return true;
}
if (candidate.supportsService(MiBandService.UUID_SERVICE_MIBAND_SERVICE)
&& !candidate.supportsService(MiBandService.UUID_SERVICE_MIBAND2_SERVICE)) {
return DeviceType.MIBAND;
return true;
}
// and a heuristic
try {
@ -92,13 +90,13 @@ public class MiBandCoordinator extends AbstractBLEDeviceCoordinator {
if (isHealthWearable(device)) {
String name = candidate.getName();
if (name != null && name.toUpperCase().startsWith(MiBandConst.MI_GENERAL_NAME_PREFIX.toUpperCase())) {
return DeviceType.MIBAND;
return true;
}
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -23,6 +23,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -37,14 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.mijia_lywsd02.MijiaLywsd02Support;
public class MijiaLywsd02Coordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (name.equals("LYWSD02") || name.equals("LYWSD02MMC"))) {
return DeviceType.MIJIA_LYWSD02;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("LYWSD02|LYWSD02MMC");
}
@Override

View File

@ -17,12 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miscale2;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -32,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -56,18 +55,9 @@ public class MiScale2DeviceCoordinator extends AbstractBLEDeviceCoordinator {
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
if (name != null && name.equalsIgnoreCase("MIBCS")) {
return DeviceType.MISCALE2;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("MIBCS", Pattern.CASE_INSENSITIVE);
}
@NonNull

View File

@ -17,16 +17,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.no1f1;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@ -56,17 +55,10 @@ public class No1F1Coordinator extends AbstractBLEDeviceCoordinator {
return Collections.singletonList(filter);
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (name.startsWith("X-RUN") || name.startsWith("MH30"))) {
return DeviceType.NO1F1;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("X-RUN.*|MH30.*");
}
return DeviceType.UNKNOWN;
}
@Override
public int getBondingStyle() {
return BONDING_STYLE_NONE;

View File

@ -7,6 +7,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLClassicDeviceCoordinator;
@ -23,13 +25,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.nothing.Ear1Support;
public class Ear1Coordinator extends AbstractBLClassicDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if(candidate.getName().equals("Nothing ear (1)"))
return DeviceType.NOTHING_EAR1;
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Nothing ear (1)", Pattern.LITERAL);
}
@Nullable

View File

@ -17,17 +17,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.nut;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
@ -44,13 +43,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.nut.NutSupport;
public class NutCoordinator extends AbstractBLEDeviceCoordinator {
@Override
@NonNull
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.toLowerCase().startsWith("nut")) {
return DeviceType.NUTMINI;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("nut.*", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -28,6 +28,7 @@ import androidx.annotation.StringRes;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -56,14 +57,9 @@ public class PebbleCoordinator extends AbstractBLClassicDeviceCoordinator {
public PebbleCoordinator() {
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("Pebble")) {
return DeviceType.PEBBLE;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Pebble.*");
}
@Override

View File

@ -23,6 +23,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -37,14 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.pinetime.PineTimeJFSupport;
public class PineTimeJFCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && (name.startsWith("Pinetime-JF") || name.startsWith("InfiniTime"))) {
return DeviceType.PINETIME_JF;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Pinetime-JF.*|InfiniTime.*");
}
@Override

View File

@ -23,6 +23,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLClassicDeviceCoordinator;
@ -43,13 +45,9 @@ public class QC35Coordinator extends AbstractBLClassicDeviceCoordinator {
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if (candidate.getName().startsWith("Bose QC 35")) {
return DeviceType.BOSE_QC35;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("Bose QC 35.*");
}
@Nullable

View File

@ -17,12 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.qhybrid;
import android.annotation.TargetApi;
import android.app.Activity;
import android.bluetooth.le.ScanFilter;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid;
import androidx.annotation.NonNull;
@ -37,8 +35,6 @@ import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.GBException;
@ -63,13 +59,13 @@ public class QHybridCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
public boolean supports(GBDeviceCandidate candidate) {
for(ParcelUuid uuid : candidate.getServiceUuids()){
if(uuid.getUuid().toString().equals("3dda0001-957f-7d4a-34a6-74696673696d")){
return DeviceType.FOSSILQHYBRID;
return true;
}
}
return DeviceType.UNKNOWN;
return false;
}
@NonNull

View File

@ -33,18 +33,18 @@ public class Roidmi1Coordinator extends RoidmiCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name != null && name.contains("睿米车载蓝牙播放器")) {
return DeviceType.ROIDMI;
return true;
}
} catch (final Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -33,22 +33,22 @@ public class Roidmi3Coordinator extends RoidmiCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
public boolean supports(final GBDeviceCandidate candidate) {
try {
final String name = candidate.getName();
if (name == null) {
return DeviceType.UNKNOWN;
return false;
}
if (name.contains("Roidmi Music Blue C") || name.contains("Roidmi C BLE") || name.contains("Mojietu Music Blue C")) {
return DeviceType.ROIDMI3;
return true;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
return false;
}
@Override

View File

@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection;
import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R;
@ -43,19 +44,9 @@ public class SMAQ2OSSCoordinator extends AbstractBLEDeviceCoordinator {
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
}
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
try {
String name = candidate.getName();
// TODO still match for "SMA-Q2-OSS" because of backward firmware compatibility - remove eventually
if (name != null && (name.startsWith("SMAQ2-") || name.equalsIgnoreCase("SMA-Q2-OSS"))) {
return DeviceType.SMAQ2OSS;
}
} catch (Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("SMAQ2-.*|SMA-Q2-OSS", Pattern.CASE_INSENSITIVE);
}
@Override

View File

@ -22,6 +22,8 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
@ -36,14 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.soflow.SoFlowSupport;
public class SoFlowCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
String name = candidate.getName();
if (name != null && name.startsWith("SoFlow-")) {
return DeviceType.SOFLOW_SO6;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile("SoFlow-.*");
}
@Override

View File

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
@ -28,14 +29,9 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyLinkBudsSCoordinator extends SonyHeadphonesCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
if (candidate.getName().contains("LinkBuds S")) {
return DeviceType.SONY_LINKBUDS_S;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*LinkBuds S.*");
}
@Override

View File

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
@ -29,15 +30,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyWF1000XM3Coordinator extends SonyHeadphonesCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if (candidate.getName().contains("WF-1000XM3")) {
return DeviceType.SONY_WF_1000XM3;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-1000XM3.*");
}
@Override

View File

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
@ -29,15 +30,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyWF1000XM4Coordinator extends SonyHeadphonesCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if (candidate.getName().contains("WF-1000XM4")) {
return DeviceType.SONY_WF_1000XM4;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-1000XM4.*");
}
@Override

View File

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
@ -29,15 +30,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyWF1000XM5Coordinator extends SonyHeadphonesCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
if (candidate.getName().contains("WF-1000XM5")) {
return DeviceType.SONY_WF_1000XM5;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-1000XM5.*");
}
@Override

View File

@ -20,6 +20,7 @@ import androidx.annotation.NonNull;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.sony.headphones.SonyHeadphonesCapabilities;
@ -29,14 +30,9 @@ import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class SonyWFSP800NCoordinator extends SonyHeadphonesCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
if (candidate.getName().contains("WF-SP800N")) {
return DeviceType.SONY_WF_SP800N;
}
return DeviceType.UNKNOWN;
protected Pattern getSupportedDeviceName() {
return Pattern.compile(".*WF-SP800N.*");
}
@Override

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