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.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder; import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.GBApplication;
@ -76,9 +77,29 @@ import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
public abstract class AbstractDeviceCoordinator implements DeviceCoordinator { public abstract class AbstractDeviceCoordinator implements DeviceCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDeviceCoordinator.class); 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 @Override
public final boolean supports(GBDeviceCandidate candidate) { public boolean supports(GBDeviceCandidate candidate) {
return getSupportedType(candidate).isSupported(); 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 @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 * Returns the type of connection, Classic of BLE
* *

View File

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

View File

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

View File

@ -31,6 +31,7 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.BuildConfig; import nodomain.freeyourgadget.gadgetbridge.BuildConfig;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
@ -64,21 +65,9 @@ public class BangleJSCoordinator extends AbstractBLEDeviceCoordinator {
return Collections.singletonList(filter); return Collections.singletonList(filter);
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
String name = candidate.getName(); return Pattern.compile("Bangle\\.js.*|Pixl\\.js.*|Puck\\.js.*|MDBT42Q.*|Espruino.*");
/* 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;
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,7 +20,6 @@ package nodomain.freeyourgadget.gadgetbridge.devices.fitpro;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.ParcelUuid;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -29,6 +28,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.regex.Pattern;
import de.greenrobot.dao.query.QueryBuilder; import de.greenrobot.dao.query.QueryBuilder;
import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.GBException;
@ -58,28 +58,9 @@ public class FitProDeviceCoordinator extends AbstractBLEDeviceCoordinator {
qb.where(FitProActivitySampleDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities(); qb.where(FitProActivitySampleDao.Properties.DeviceId.eq(deviceId)).buildDelete().executeDeleteWithoutDetachingEntities();
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("M6.*|M4.*|LH716|Sunset 6|Watch7|Fit1900");
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;
} }
@Override @Override

View File

@ -31,11 +31,11 @@ public class FlipperZeroCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull @NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { public boolean supports(GBDeviceCandidate candidate) {
if(candidate.supportsService(UUID.fromString("00003082-0000-1000-8000-00805f9b34fb"))){ 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 @Nullable

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class AmazfitBipCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip Watch", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.Ama
public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator { public class AmazfitBipLiteCoordinator extends AmazfitBipCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipLiteCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipLiteCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip Lite", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro
public class AmazfitBip3ProCoordinator extends HuamiCoordinator { public class AmazfitBip3ProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip3ProCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip3ProCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip 3 Pro", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitBip5Coordinator extends Huami2021Coordinator {
return AmazfitBip5Support.class; return AmazfitBip5Support.class;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_BIP5_NAME + ".*");
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;
} }
@Override @Override

View File

@ -25,30 +25,21 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; 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.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
public class AmazfitBipSCoordinator extends HuamiCoordinator { public class AmazfitBipSCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip S", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
@ -35,18 +37,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.Am
public class AmazfitBipSLiteCoordinator extends AmazfitBipSCoordinator { public class AmazfitBipSLiteCoordinator extends AmazfitBipSCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSLiteCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipSLiteCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Bip S Lite", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class AmazfitBipUCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip U", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -26,6 +26,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -38,18 +40,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipupro
public class AmazfitBipUProCoordinator extends HuamiCoordinator { public class AmazfitBipUProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUProCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitBipUProCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Bip U Pro", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcheetah
public class AmazfitCheetahProCoordinator extends Huami2021Coordinator { public class AmazfitCheetahProCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahProCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitCheetahProCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_PRO_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitCheetahRoundCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_cheetah_round; return R.string.devicetype_amazfit_cheetah_round;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_ROUND_NAME + ".*");
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitCheetahSquareCoordinator extends Huami2021Coordinator {
return AmazfitCheetahSquareSupport.class; return AmazfitCheetahSquareSupport.class;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_CHEETAH_SQUARE_NAME + ".*");
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;
} }
@Override @Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class AmazfitCorCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitCorCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitCorCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Band|Amazfit Cor", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitFalconCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_falcon; return R.string.devicetype_amazfit_falcon;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_FALCON_NAME + ".*");
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;
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3pro
public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator { public class AmazfitGTR3ProCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR3ProCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_GTR3_PRO_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; 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 { public class AmazfitGTR4Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTR4Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_GTR4_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -48,19 +50,9 @@ public class AmazfitGTRMiniCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_gtr_mini; return R.string.devicetype_amazfit_gtr_mini;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_GTR_MINI_NAME + ".*");
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class AmazfitGTSCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTSCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTSCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit GTS", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -36,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.Am
public class AmazfitGTS2MiniCoordinator extends AmazfitGTS2Coordinator { public class AmazfitGTS2MiniCoordinator extends AmazfitGTS2Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS2MiniCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS2MiniCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit GTS2 mini", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; 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 { public class AmazfitGTS3Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS3Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_GTS3_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

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

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -37,19 +39,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4min
public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator { public class AmazfitGTS4MiniCoordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitGTS4MiniCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_GTS4_MINI_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability; import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -41,19 +42,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitneo.Ama
public class AmazfitNeoCoordinator extends HuamiCoordinator { public class AmazfitNeoCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitNeoCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitNeoCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_NEO_NAME, Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipu.AmazfitBipUCoordinator; 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 { public class AmazfitPopCoordinator extends AmazfitBipUCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Pop", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipupro.AmazfitBipUProCoordinator; 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 { public class AmazfitPopProCoordinator extends AmazfitBipUProCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopProCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitPopProCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Pop Pro", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class AmazfitTRexCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRexCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit T-Rex", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; 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 { public class AmazfitTRex2Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitTRex2Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_TREX_2_NAME + ".*");
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;
} }
@NonNull @NonNull

View File

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

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst;
@ -53,19 +55,9 @@ public class AmazfitTRexUltraCoordinator extends Huami2021Coordinator {
return R.string.devicetype_amazfit_trex_ultra; return R.string.devicetype_amazfit_trex_ultra;
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.AMAZFIT_TREX_ULTRA + ".*");
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;
} }
@Override @Override

View File

@ -16,7 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel; package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitvergel;
import android.bluetooth.BluetoothDevice;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
@ -25,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
@ -37,18 +38,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.
public class AmazfitVergeLCoordinator extends HuamiCoordinator { public class AmazfitVergeLCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitVergeLCoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(AmazfitVergeLCoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Amazfit Verge L", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,6 +27,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability; import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -42,19 +43,9 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand
public class MiBand5Coordinator extends HuamiCoordinator { public class MiBand5Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand5Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(MiBand5Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.MI_BAND5_NAME, Pattern.CASE_INSENSITIVE);
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;
} }

View File

@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability; import nodomain.freeyourgadget.gadgetbridge.capabilities.HeartRateCapability;
@ -25,18 +26,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband6.MiBand
public class MiBand6Coordinator extends HuamiCoordinator { public class MiBand6Coordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand6Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(MiBand6Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.MI_BAND6_NAME, Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

@ -24,6 +24,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator; import nodomain.freeyourgadget.gadgetbridge.devices.huami.Huami2021Coordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiConst; 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 { public class MiBand7Coordinator extends Huami2021Coordinator {
private static final Logger LOG = LoggerFactory.getLogger(MiBand7Coordinator.class); private static final Logger LOG = LoggerFactory.getLogger(MiBand7Coordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile(HuamiConst.XIAOMI_SMART_BAND7_NAME + ".*");
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;
} }
@Override @Override

View File

@ -25,6 +25,8 @@ import androidx.annotation.NonNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator; 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 { public class ZeppECoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(ZeppECoordinator.class); private static final Logger LOG = LoggerFactory.getLogger(ZeppECoordinator.class);
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("Zepp E", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

@ -17,17 +17,16 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.itag; package nodomain.freeyourgadget.gadgetbridge.devices.itag;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanFilter;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
@ -44,13 +43,8 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.itag.ITagSupport;
public class ITagCoordinator extends AbstractBLEDeviceCoordinator { public class ITagCoordinator extends AbstractBLEDeviceCoordinator {
@Override @Override
@NonNull protected Pattern getSupportedDeviceName() {
public DeviceType getSupportedType(GBDeviceCandidate candidate) { return Pattern.compile("itag.*", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

@ -58,7 +58,7 @@ public class LefunDeviceCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull @NonNull
@Override @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. // 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())) { if (ADVERTISEMENT_NAME.equals(candidate.getName())) {
// The device does not advertise service UUIDs, so can't check whether it supports // 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 // manufacturer specific data, which consists of the device's MAC address and said
// string. But we're not being given it, so *shrug*. // string. But we're not being given it, so *shrug*.
if (candidate.getServiceUuids().length == 0) { if (candidate.getServiceUuids().length == 0) {
return DeviceType.LEFUN; return true;
} }
} }
return DeviceType.UNKNOWN; return false;
} }
@Nullable @Nullable

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,12 +17,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.miscale2; package nodomain.freeyourgadget.gadgetbridge.devices.miscale2;
import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.bluetooth.le.ScanFilter; import android.bluetooth.le.ScanFilter;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.ParcelUuid; import android.os.ParcelUuid;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -32,6 +30,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.R;
@ -56,18 +55,9 @@ public class MiScale2DeviceCoordinator extends AbstractBLEDeviceCoordinator {
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("MIBCS", Pattern.CASE_INSENSITIVE);
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;
} }
@NonNull @NonNull

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,22 +33,22 @@ public class Roidmi3Coordinator extends RoidmiCoordinator {
@NonNull @NonNull
@Override @Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) { public boolean supports(final GBDeviceCandidate candidate) {
try { try {
final String name = candidate.getName(); final String name = candidate.getName();
if (name == null) { 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")) { 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) { } catch (Exception ex) {
LOG.error("unable to check device support", ex); LOG.error("unable to check device support", ex);
} }
return DeviceType.UNKNOWN; return false;
} }
@Override @Override

View File

@ -14,6 +14,7 @@ import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.regex.Pattern;
import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.GBException;
import nodomain.freeyourgadget.gadgetbridge.R; 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 { protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
} }
@NonNull
@Override @Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) { protected Pattern getSupportedDeviceName() {
try { return Pattern.compile("SMAQ2-.*|SMA-Q2-OSS", Pattern.CASE_INSENSITIVE);
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;
} }
@Override @Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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