2021-01-10 23:37:09 +01:00
|
|
|
/* Copyright (C) 2015-2021 0nse, 115ek, Andreas Böhler, Andreas Shimokawa,
|
|
|
|
angelpup, Carsten Pfeiffer, Cre3per, criogenic, DanialHanif, Daniel Dakhno,
|
|
|
|
Daniele Gobbetti, Dmytro Bielik, Gordon Williams, Jean-François Greffier,
|
|
|
|
João Paulo Barraca, José Rebelo, ladbsoft, Manuel Ruß, maxirnilian,
|
|
|
|
mkusnierz, odavo32nof, opavlov, pangwalla, Pavel Elagin, protomors,
|
|
|
|
Quallenauge, Sami Alaoui, Sebastian Kranz, Sergey Trofimov, Sophanimus,
|
|
|
|
Taavi Eomäe, tiparega, Vadim Kaushan, Yukai Li
|
2017-03-10 14:53:19 +01:00
|
|
|
|
|
|
|
This file is part of Gadgetbridge.
|
|
|
|
|
|
|
|
Gadgetbridge is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published
|
|
|
|
by the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Gadgetbridge is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2015-08-04 01:01:14 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.service;
|
|
|
|
|
|
|
|
import android.bluetooth.BluetoothAdapter;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
2015-08-22 01:08:46 +02:00
|
|
|
import java.lang.reflect.Constructor;
|
2015-08-17 21:30:37 +02:00
|
|
|
import java.util.EnumSet;
|
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
2017-01-23 01:08:36 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
2023-01-01 02:47:04 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.asteroidos.AsteroidOSDeviceSupport;
|
2022-06-19 02:55:18 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.binary_sensor.BinarySensorSupport;
|
2021-09-21 16:37:19 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.fitpro.FitProDeviceSupport;
|
2019-11-28 19:02:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.banglejs.BangleJSDeviceSupport;
|
2020-11-14 20:43:19 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport;
|
2020-11-14 23:15:14 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport;
|
2020-09-04 14:45:37 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.domyos.DomyosT540Support;
|
2022-09-04 23:05:57 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.flipper.zero.support.FlipperZeroSupport;
|
2021-10-24 10:02:45 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.galaxy_buds.GalaxyBudsDeviceSupport;
|
2019-01-26 15:52:40 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusSupport;
|
2018-08-01 22:56:01 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
|
2020-10-17 11:58:22 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5.AmazfitBand5Support;
|
2022-10-31 13:04:18 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7Support;
|
2019-10-09 21:33:55 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipLiteSupport;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
|
2020-10-27 12:56:27 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSLiteSupport;
|
2020-06-08 16:38:03 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
|
2020-11-30 17:13:48 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipu.AmazfitBipUSupport;
|
2021-01-03 11:27:27 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipupro.AmazfitBipUProSupport;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor.AmazfitCorSupport;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor2.AmazfitCor2Support;
|
2020-05-02 23:38:58 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRLiteSupport;
|
2019-10-22 21:53:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr.AmazfitGTRSupport;
|
2020-11-09 20:53:02 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2Support;
|
2021-02-04 23:15:16 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr2.AmazfitGTR2eSupport;
|
2022-09-22 00:56:22 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr3.AmazfitGTR3Support;
|
2022-10-22 21:53:45 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgtr4.AmazfitGTR4Support;
|
2019-10-28 22:40:07 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
|
2021-02-06 21:56:28 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2MiniSupport;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2Support;
|
2021-02-06 21:56:28 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts2.AmazfitGTS2eSupport;
|
2022-09-05 23:52:01 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts3.AmazfitGTS3Support;
|
2022-11-08 20:24:17 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4.AmazfitGTS4Support;
|
2022-12-03 14:27:48 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts4mini.AmazfitGTS4MiniSupport;
|
2021-02-06 21:56:28 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitneo.AmazfitNeoSupport;
|
2022-01-18 21:15:12 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpop.AmazfitPopSupport;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitpoppro.AmazfitPopProSupport;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex.AmazfitTRexSupport;
|
2021-06-12 21:19:16 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrexpro.AmazfitTRexProSupport;
|
2021-02-06 21:56:28 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitvergel.AmazfitVergeLSupport;
|
2021-02-07 12:07:02 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitx.AmazfitXSupport;
|
2022-06-14 20:15:51 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support;
|
2018-06-14 18:16:49 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand3Support;
|
2019-08-02 23:49:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4.MiBand4Support;
|
2020-07-28 18:16:56 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband5.MiBand5Support;
|
2021-05-09 22:52:36 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband6.MiBand6Support;
|
2022-08-18 23:03:28 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband7.MiBand7Support;
|
2021-02-06 21:56:28 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.zeppe.ZeppESupport;
|
2018-07-12 14:48:09 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.id115.ID115Support;
|
2020-01-31 05:44:03 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.itag.ITagSupport;
|
2019-08-02 23:49:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.jyou.BFH16DeviceSupport;
|
2020-01-01 05:55:54 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.jyou.TeclastH30.TeclastH30Support;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.jyou.y5.Y5Support;
|
2020-10-05 05:00:56 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.LefunDeviceSupport;
|
2020-11-15 16:25:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.lenovo.watchxplus.WatchXPlusDeviceSupport;
|
2016-11-20 21:23:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.liveview.LiveviewSupport;
|
2019-10-02 22:57:31 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.makibeshr3.MakibesHR3DeviceSupport;
|
2015-08-04 01:01:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
|
2019-08-02 23:49:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.mijia_lywsd02.MijiaLywsd02Support;
|
2019-01-29 22:37:41 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.miscale2.MiScale2DeviceSupport;
|
2017-08-29 17:28:30 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.no1f1.No1F1Support;
|
2021-09-30 22:40:18 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.nothing.Ear1Support;
|
2020-10-02 01:02:13 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.nut.NutSupport;
|
2015-08-04 01:01:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport;
|
2020-08-03 20:19:00 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.pinetime.PineTimeJFSupport;
|
2021-12-27 15:37:04 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qc35.QC35BaseSupport;
|
2019-07-14 19:45:40 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.QHybridSupport;
|
2018-08-31 13:39:51 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.roidmi.RoidmiSupport;
|
2021-07-20 12:08:12 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.smaq2oss.SMAQ2OSSSupport;
|
2021-11-18 22:33:07 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sony.headphones.SonyHeadphonesSupport;
|
2020-09-01 22:15:20 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.SonySWR12DeviceSupport;
|
2022-09-25 21:31:58 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.supercars.SuperCarsSupport;
|
2020-06-29 23:02:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.tlw64.TLW64Support;
|
2020-10-10 16:45:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.um25.Support.UM25Support;
|
2021-12-27 15:47:10 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vesc.VescDeviceSupport;
|
2016-09-19 12:37:41 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport;
|
2020-12-23 21:55:23 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.waspos.WaspOSDeviceSupport;
|
2019-01-26 15:52:40 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.watch9.Watch9DeviceSupport;
|
2018-02-25 12:05:36 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.xwatch.XWatchSupport;
|
2018-02-08 07:21:12 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.zetime.ZeTimeDeviceSupport;
|
2015-08-04 01:01:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
|
|
|
|
|
|
|
public class DeviceSupportFactory {
|
|
|
|
private final BluetoothAdapter mBtAdapter;
|
2015-11-23 23:04:46 +01:00
|
|
|
private final Context mContext;
|
2015-08-04 01:01:14 +02:00
|
|
|
|
2019-08-02 23:49:14 +02:00
|
|
|
DeviceSupportFactory(Context context) {
|
2015-08-04 01:01:14 +02:00
|
|
|
mContext = context;
|
|
|
|
mBtAdapter = BluetoothAdapter.getDefaultAdapter();
|
|
|
|
}
|
|
|
|
|
2015-12-13 00:43:07 +01:00
|
|
|
public synchronized DeviceSupport createDeviceSupport(GBDevice device) throws GBException {
|
2019-08-02 23:49:14 +02:00
|
|
|
DeviceSupport deviceSupport;
|
2015-12-13 00:43:07 +01:00
|
|
|
String deviceAddress = device.getAddress();
|
2015-08-22 01:08:46 +02:00
|
|
|
int indexFirstColon = deviceAddress.indexOf(":");
|
|
|
|
if (indexFirstColon > 0) {
|
|
|
|
if (indexFirstColon == deviceAddress.lastIndexOf(":")) { // only one colon
|
2015-12-13 00:43:07 +01:00
|
|
|
deviceSupport = createTCPDeviceSupport(device);
|
2015-08-22 01:08:46 +02:00
|
|
|
} else {
|
|
|
|
// multiple colons -- bt?
|
2015-12-13 00:43:07 +01:00
|
|
|
deviceSupport = createBTDeviceSupport(device);
|
2015-08-22 01:08:46 +02:00
|
|
|
}
|
2015-08-19 00:03:52 +02:00
|
|
|
} else {
|
2015-08-22 01:08:46 +02:00
|
|
|
// no colon at all, maybe a class name?
|
2015-12-13 00:43:07 +01:00
|
|
|
deviceSupport = createClassNameDeviceSupport(device);
|
2015-08-19 00:03:52 +02:00
|
|
|
}
|
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
if (deviceSupport != null) {
|
|
|
|
return deviceSupport;
|
|
|
|
}
|
|
|
|
|
|
|
|
// no device found, check transport availability and warn
|
|
|
|
checkBtAvailability();
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-12-13 00:43:07 +01:00
|
|
|
private DeviceSupport createClassNameDeviceSupport(GBDevice device) throws GBException {
|
|
|
|
String className = device.getAddress();
|
2015-08-22 01:08:46 +02:00
|
|
|
try {
|
|
|
|
Class<?> deviceSupportClass = Class.forName(className);
|
|
|
|
Constructor<?> constructor = deviceSupportClass.getConstructor();
|
|
|
|
DeviceSupport support = (DeviceSupport) constructor.newInstance();
|
|
|
|
// has to create the device itself
|
2015-12-13 00:43:07 +01:00
|
|
|
support.setContext(device, null, mContext);
|
2015-08-22 01:08:46 +02:00
|
|
|
return support;
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
return null; // not a class, or not known at least
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new GBException("Error creating DeviceSupport instance for " + className, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
private void checkBtAvailability() {
|
|
|
|
if (mBtAdapter == null) {
|
|
|
|
GB.toast(mContext.getString(R.string.bluetooth_is_not_supported_), Toast.LENGTH_SHORT, GB.WARN);
|
|
|
|
} else if (!mBtAdapter.isEnabled()) {
|
|
|
|
GB.toast(mContext.getString(R.string.bluetooth_is_disabled_), Toast.LENGTH_SHORT, GB.WARN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 18:05:41 +02:00
|
|
|
private ServiceDeviceSupport createServiceDeviceSupport(GBDevice device){
|
|
|
|
switch (device.getType()) {
|
|
|
|
case PEBBLE:
|
|
|
|
return new ServiceDeviceSupport(new PebbleSupport());
|
|
|
|
case MIBAND:
|
|
|
|
return new ServiceDeviceSupport(new MiBandSupport(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case MIBAND2:
|
2022-06-14 20:15:51 +02:00
|
|
|
return new ServiceDeviceSupport(new MiBand2Support(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
2022-06-14 18:05:41 +02:00
|
|
|
case MIBAND3:
|
|
|
|
return new ServiceDeviceSupport(new MiBand3Support());
|
|
|
|
case MIBAND4:
|
|
|
|
return new ServiceDeviceSupport(new MiBand4Support());
|
|
|
|
case MIBAND5:
|
|
|
|
return new ServiceDeviceSupport(new MiBand5Support());
|
|
|
|
case MIBAND6:
|
|
|
|
return new ServiceDeviceSupport(new MiBand6Support());
|
2022-09-05 23:52:01 +02:00
|
|
|
case AMAZFITGTS3:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS3Support());
|
2022-09-22 00:56:22 +02:00
|
|
|
case AMAZFITGTR3:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTR3Support());
|
2022-10-22 21:53:45 +02:00
|
|
|
case AMAZFITGTR4:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTR4Support());
|
2022-08-18 23:03:28 +02:00
|
|
|
case MIBAND7:
|
|
|
|
return new ServiceDeviceSupport(new MiBand7Support());
|
2022-10-31 13:04:18 +01:00
|
|
|
case AMAZFITBAND7:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBand7Support());
|
2022-11-08 20:24:17 +01:00
|
|
|
case AMAZFITGTS4:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS4Support());
|
2022-12-03 14:27:48 +01:00
|
|
|
case AMAZFITGTS4MINI:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS4MiniSupport());
|
2022-06-14 18:05:41 +02:00
|
|
|
case AMAZFITBIP:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipSupport());
|
|
|
|
case AMAZFITBIP_LITE:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipLiteSupport());
|
|
|
|
case AMAZFITBIPS:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipSSupport());
|
|
|
|
case AMAZFITBIPS_LITE:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipSLiteSupport());
|
|
|
|
case AMAZFITBIPU:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipUSupport());
|
|
|
|
case AMAZFITBIPUPRO:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBipUProSupport());
|
|
|
|
case AMAZFITPOP:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitPopSupport());
|
|
|
|
case AMAZFITPOPPRO:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitPopProSupport());
|
|
|
|
case AMAZFITGTR:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTRSupport());
|
|
|
|
case AMAZFITGTR_LITE:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTRLiteSupport());
|
|
|
|
case AMAZFITGTR2:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTR2Support());
|
|
|
|
case ZEPP_E:
|
|
|
|
return new ServiceDeviceSupport(new ZeppESupport());
|
|
|
|
case AMAZFITGTR2E:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTR2eSupport());
|
|
|
|
case AMAZFITTREX:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitTRexSupport());
|
|
|
|
case AMAZFITTREXPRO:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitTRexProSupport());
|
|
|
|
case AMAZFITGTS:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTSSupport());
|
|
|
|
case AMAZFITVERGEL:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitVergeLSupport());
|
|
|
|
case AMAZFITGTS2:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS2Support());
|
|
|
|
case AMAZFITGTS2_MINI:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS2MiniSupport());
|
|
|
|
case AMAZFITGTS2E:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitGTS2eSupport());
|
|
|
|
case AMAZFITCOR:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitCorSupport());
|
|
|
|
case AMAZFITCOR2:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitCor2Support());
|
|
|
|
case AMAZFITBAND5:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitBand5Support());
|
|
|
|
case AMAZFITX:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitXSupport());
|
|
|
|
case AMAZFITNEO:
|
|
|
|
return new ServiceDeviceSupport(new AmazfitNeoSupport());
|
|
|
|
case VIBRATISSIMO:
|
|
|
|
return new ServiceDeviceSupport(new VibratissimoSupport(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case LIVEVIEW:
|
|
|
|
return new ServiceDeviceSupport(new LiveviewSupport());
|
|
|
|
case HPLUS:
|
|
|
|
case MAKIBESF68:
|
|
|
|
case EXRIZUK8:
|
|
|
|
case Q8:
|
|
|
|
return new ServiceDeviceSupport(new HPlusSupport(device.getType()));
|
|
|
|
case NO1F1:
|
|
|
|
return new ServiceDeviceSupport(new No1F1Support());
|
|
|
|
case TECLASTH30:
|
|
|
|
return new ServiceDeviceSupport(new TeclastH30Support());
|
|
|
|
case XWATCH:
|
|
|
|
return new ServiceDeviceSupport(new XWatchSupport());
|
|
|
|
case FOSSILQHYBRID:
|
|
|
|
return new ServiceDeviceSupport(new QHybridSupport());
|
|
|
|
case ZETIME:
|
|
|
|
return new ServiceDeviceSupport(new ZeTimeDeviceSupport());
|
|
|
|
case ID115:
|
|
|
|
return new ServiceDeviceSupport(new ID115Support());
|
|
|
|
case WATCH9:
|
|
|
|
return new ServiceDeviceSupport(new Watch9DeviceSupport(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case WATCHXPLUS:
|
|
|
|
return new ServiceDeviceSupport(new WatchXPlusDeviceSupport(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case ROIDMI:
|
|
|
|
return new ServiceDeviceSupport(new RoidmiSupport());
|
|
|
|
case ROIDMI3:
|
|
|
|
return new ServiceDeviceSupport(new RoidmiSupport());
|
|
|
|
case Y5:
|
|
|
|
return new ServiceDeviceSupport(new Y5Support());
|
|
|
|
case CASIOGB6900:
|
|
|
|
return new ServiceDeviceSupport(new CasioGB6900DeviceSupport());
|
|
|
|
case CASIOGBX100:
|
|
|
|
return new ServiceDeviceSupport(new CasioGBX100DeviceSupport());
|
|
|
|
case MISCALE2:
|
|
|
|
return new ServiceDeviceSupport(new MiScale2DeviceSupport());
|
|
|
|
case BFH16:
|
|
|
|
return new ServiceDeviceSupport(new BFH16DeviceSupport());
|
|
|
|
case MIJIA_LYWSD02:
|
|
|
|
return new ServiceDeviceSupport(new MijiaLywsd02Support());
|
|
|
|
case MAKIBESHR3:
|
|
|
|
return new ServiceDeviceSupport(new MakibesHR3DeviceSupport());
|
|
|
|
case ITAG:
|
|
|
|
return new ServiceDeviceSupport(new ITagSupport());
|
|
|
|
case NUTMINI:
|
|
|
|
return new ServiceDeviceSupport(new NutSupport());
|
|
|
|
case BANGLEJS:
|
|
|
|
return new ServiceDeviceSupport(new BangleJSDeviceSupport());
|
|
|
|
case TLW64:
|
|
|
|
return new ServiceDeviceSupport(new TLW64Support());
|
|
|
|
case PINETIME_JF:
|
|
|
|
return new ServiceDeviceSupport(new PineTimeJFSupport());
|
|
|
|
case SG2:
|
|
|
|
return new ServiceDeviceSupport(new HPlusSupport(DeviceType.SG2));
|
|
|
|
case LEFUN:
|
|
|
|
return new ServiceDeviceSupport(new LefunDeviceSupport());
|
|
|
|
case SONY_SWR12:
|
|
|
|
return new ServiceDeviceSupport(new SonySWR12DeviceSupport());
|
|
|
|
case WASPOS:
|
|
|
|
return new ServiceDeviceSupport(new WaspOSDeviceSupport());
|
|
|
|
case SMAQ2OSS:
|
|
|
|
return new ServiceDeviceSupport(new SMAQ2OSSSupport());
|
|
|
|
case UM25:
|
|
|
|
return new ServiceDeviceSupport(new UM25Support());
|
|
|
|
case DOMYOS_T540:
|
|
|
|
return new ServiceDeviceSupport(new DomyosT540Support(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case FITPRO:
|
|
|
|
return new ServiceDeviceSupport(new FitProDeviceSupport(), ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case NOTHING_EAR1:
|
|
|
|
return new ServiceDeviceSupport(new Ear1Support());
|
|
|
|
case GALAXY_BUDS:
|
|
|
|
return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport());
|
|
|
|
case GALAXY_BUDS_LIVE:
|
|
|
|
return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport());
|
|
|
|
case GALAXY_BUDS_PRO:
|
2022-11-07 19:34:41 +01:00
|
|
|
case GALAXY_BUDS2:
|
2022-06-14 18:05:41 +02:00
|
|
|
return new ServiceDeviceSupport(new GalaxyBudsDeviceSupport(), ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case SONY_WH_1000XM3:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
|
|
|
case SONY_WH_1000XM4:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
|
|
|
case SONY_WF_SP800N:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport(), ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
|
|
|
case SONY_WF_1000XM3:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
2022-10-21 00:48:02 +02:00
|
|
|
case SONY_WH_1000XM2:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
2022-10-22 14:14:50 +02:00
|
|
|
case SONY_WF_1000XM4:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
2022-12-30 19:07:18 +01:00
|
|
|
case SONY_LINKBUDS_S:
|
|
|
|
return new ServiceDeviceSupport(new SonyHeadphonesSupport());
|
2022-06-14 18:05:41 +02:00
|
|
|
case VESC_NRF:
|
|
|
|
case VESC_HM10:
|
|
|
|
return new ServiceDeviceSupport(new VescDeviceSupport(device.getType()));
|
|
|
|
case BOSE_QC35:
|
|
|
|
return new ServiceDeviceSupport(new QC35BaseSupport());
|
2022-06-19 02:55:18 +02:00
|
|
|
case BINARY_SENSOR:
|
|
|
|
return new ServiceDeviceSupport(new BinarySensorSupport());
|
2022-09-04 23:05:57 +02:00
|
|
|
case FLIPPER_ZERO:
|
|
|
|
return new ServiceDeviceSupport(new FlipperZeroSupport());
|
2022-09-25 21:31:58 +02:00
|
|
|
case SUPER_CARS:
|
|
|
|
return new ServiceDeviceSupport(new SuperCarsSupport());
|
2023-01-01 02:47:04 +01:00
|
|
|
case ASTEROIDOS:
|
|
|
|
return new ServiceDeviceSupport(new AsteroidOSDeviceSupport());
|
2022-06-14 18:05:41 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-12-13 00:43:07 +01:00
|
|
|
private DeviceSupport createBTDeviceSupport(GBDevice gbDevice) throws GBException {
|
2015-08-04 01:01:14 +02:00
|
|
|
if (mBtAdapter != null && mBtAdapter.isEnabled()) {
|
|
|
|
try {
|
2022-06-14 18:05:41 +02:00
|
|
|
DeviceSupport deviceSupport = createServiceDeviceSupport(gbDevice);
|
2015-08-04 01:01:14 +02:00
|
|
|
if (deviceSupport != null) {
|
|
|
|
deviceSupport.setContext(gbDevice, mBtAdapter, mContext);
|
|
|
|
return deviceSupport;
|
|
|
|
}
|
|
|
|
} catch (Exception e) {
|
2016-07-28 22:42:16 +02:00
|
|
|
throw new GBException(mContext.getString(R.string.cannot_connect_bt_address_invalid_), e);
|
2015-08-04 01:01:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2015-08-19 00:03:52 +02:00
|
|
|
|
2015-12-13 00:43:07 +01:00
|
|
|
private DeviceSupport createTCPDeviceSupport(GBDevice gbDevice) throws GBException {
|
2015-08-19 00:03:52 +02:00
|
|
|
try {
|
2022-06-14 18:05:41 +02:00
|
|
|
DeviceSupport deviceSupport = new ServiceDeviceSupport(new PebbleSupport(), ServiceDeviceSupport.Flags.BUSY_CHECKING);
|
2015-08-19 00:03:52 +02:00
|
|
|
deviceSupport.setContext(gbDevice, mBtAdapter, mContext);
|
|
|
|
return deviceSupport;
|
|
|
|
} catch (Exception e) {
|
2015-12-13 00:43:07 +01:00
|
|
|
throw new GBException("cannot connect to " + gbDevice, e); // FIXME: localize
|
2015-08-19 00:03:52 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-04 01:01:14 +02:00
|
|
|
}
|