2020-01-09 10:44:32 +01:00
|
|
|
/* Copyright (C) 2015-2020 0nse, Andreas Böhler, Andreas Shimokawa, Carsten
|
2019-12-15 22:10:00 +01:00
|
|
|
Pfeiffer, Cre3per, criogenic, Daniel Dakhno, Daniele Gobbetti, Gordon Williams,
|
|
|
|
Jean-François Greffier, João Paulo Barraca, José Rebelo, Kranz, ladbsoft,
|
2020-01-09 10:44:32 +01:00
|
|
|
Manuel Ruß, maxirnilian, Pavel Elagin, protomors, Quallenauge, Sami Alaoui,
|
|
|
|
Sergey Trofimov, Sophanimus, tiparega, Vadim Kaushan
|
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;
|
2019-11-28 19:02:47 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.banglejs.BangleJSDeviceSupport;
|
2018-12-28 13:27:03 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.casiogb6900.CasioGB6900DeviceSupport;
|
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;
|
2019-10-09 21:33:55 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipLiteSupport;
|
2020-06-08 16:38:03 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
|
2019-01-26 15:52:40 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
|
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-06-24 17:43:23 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfittrex.AmazfitTRexSupport;
|
2017-10-24 22:01:25 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor.AmazfitCorSupport;
|
2019-08-02 23:49:14 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor2.AmazfitCor2Support;
|
2019-10-28 22:40:07 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitgts.AmazfitGTSSupport;
|
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;
|
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-10-05 05:00:56 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.LefunDeviceSupport;
|
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;
|
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;
|
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;
|
2020-09-01 22:15:20 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.sonyswr12.SonySWR12DeviceSupport;
|
2020-06-29 23:02:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.tlw64.TLW64Support;
|
2016-09-19 12:37:41 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport;
|
2019-01-26 15:52:40 +01:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.watch9.Watch9DeviceSupport;
|
2018-09-27 00:05:40 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.jyou.y5.Y5Support;
|
2019-10-23 22:07:38 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.lenovo.watchxplus.WatchXPlusDeviceSupport;
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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()) {
|
|
|
|
DeviceSupport deviceSupport = null;
|
|
|
|
|
|
|
|
try {
|
2015-12-13 00:43:07 +01:00
|
|
|
switch (gbDevice.getType()) {
|
|
|
|
case PEBBLE:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new PebbleSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
|
|
|
case MIBAND:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MiBandSupport(), EnumSet.of(ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2016-08-14 23:24:24 +02:00
|
|
|
case MIBAND2:
|
2018-08-01 22:56:01 +02:00
|
|
|
deviceSupport = new ServiceDeviceSupport(new HuamiSupport(), EnumSet.of(ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2016-08-14 23:24:24 +02:00
|
|
|
break;
|
2018-06-14 18:16:49 +02:00
|
|
|
case MIBAND3:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MiBand3Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-06-19 22:15:42 +02:00
|
|
|
case MIBAND4:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MiBand4Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-07-28 18:16:56 +02:00
|
|
|
case MIBAND5:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MiBand5Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2017-08-13 16:31:11 +02:00
|
|
|
case AMAZFITBIP:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitBipSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-10-09 21:33:55 +02:00
|
|
|
case AMAZFITBIP_LITE:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitBipLiteSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-03-23 11:02:22 +01:00
|
|
|
case AMAZFITBIPS:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitBipSSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-10-22 21:53:38 +02:00
|
|
|
case AMAZFITGTR:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitGTRSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-05-02 23:38:58 +02:00
|
|
|
case AMAZFITGTR_LITE:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitGTRLiteSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-06-24 17:43:23 +02:00
|
|
|
case AMAZFITTREX:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitTRexSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-10-28 22:40:07 +01:00
|
|
|
case AMAZFITGTS:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitGTSSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2017-10-24 22:01:25 +02:00
|
|
|
case AMAZFITCOR:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitCorSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-05-09 12:42:59 +02:00
|
|
|
case AMAZFITCOR2:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new AmazfitCor2Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2016-09-19 12:37:41 +02:00
|
|
|
case VIBRATISSIMO:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new VibratissimoSupport(), EnumSet.of(ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2016-11-20 21:23:47 +01:00
|
|
|
case LIVEVIEW:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new LiveviewSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2016-12-21 13:51:25 +01:00
|
|
|
case HPLUS:
|
2017-01-23 01:08:36 +01:00
|
|
|
deviceSupport = new ServiceDeviceSupport(new HPlusSupport(DeviceType.HPLUS), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
|
|
|
case MAKIBESF68:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new HPlusSupport(DeviceType.MAKIBESF68), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2016-12-21 13:51:25 +01:00
|
|
|
break;
|
2017-09-10 20:40:10 +02:00
|
|
|
case EXRIZUK8:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new HPlusSupport(DeviceType.EXRIZUK8), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-05-20 19:15:22 +02:00
|
|
|
case Q8:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new HPlusSupport(DeviceType.Q8), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2017-08-29 17:28:30 +02:00
|
|
|
case NO1F1:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new No1F1Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2017-09-04 08:43:34 +02:00
|
|
|
case TECLASTH30:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new TeclastH30Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-02-25 12:05:36 +01:00
|
|
|
case XWATCH:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new XWatchSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2018-07-27 15:39:01 +02:00
|
|
|
break;
|
2019-07-14 19:45:40 +02:00
|
|
|
case FOSSILQHYBRID:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new QHybridSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
|
|
|
case ZETIME:
|
2018-02-08 07:21:12 +01:00
|
|
|
deviceSupport = new ServiceDeviceSupport(new ZeTimeDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2018-07-12 14:48:09 +02:00
|
|
|
break;
|
|
|
|
case ID115:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new ID115Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-08-05 18:52:44 +02:00
|
|
|
case WATCH9:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new Watch9DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-10-18 00:02:53 +02:00
|
|
|
case WATCHXPLUS:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new WatchXPlusDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.THROTTLING, ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-08-31 13:39:51 +02:00
|
|
|
case ROIDMI:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new RoidmiSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
|
|
|
case ROIDMI3:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new RoidmiSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-09-27 00:05:40 +02:00
|
|
|
case Y5:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new Y5Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2018-12-28 13:27:03 +01:00
|
|
|
case CASIOGB6900:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new CasioGB6900DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2019-03-06 16:33:47 +01:00
|
|
|
break;
|
2019-06-19 22:15:42 +02:00
|
|
|
case MISCALE2:
|
2019-01-29 22:37:41 +01:00
|
|
|
deviceSupport = new ServiceDeviceSupport(new MiScale2DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2018-12-28 13:27:03 +01:00
|
|
|
break;
|
2019-04-02 23:06:21 +02:00
|
|
|
case BFH16:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new BFH16DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-08-02 23:49:14 +02:00
|
|
|
case MIJIA_LYWSD02:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MijiaLywsd02Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
2019-10-02 22:57:31 +02:00
|
|
|
break;
|
|
|
|
case MAKIBESHR3:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new MakibesHR3DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-01-31 05:44:03 +01:00
|
|
|
case ITAG:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new ITagSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-10-02 01:02:13 +02:00
|
|
|
case NUTMINI:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new NutSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2019-11-28 19:02:47 +01:00
|
|
|
case BANGLEJS:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new BangleJSDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-06-29 23:02:38 +02:00
|
|
|
case TLW64:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new TLW64Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-08-03 20:19:00 +02:00
|
|
|
case PINETIME_JF:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new PineTimeJFSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-08-25 04:24:07 +02:00
|
|
|
case SG2:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new HPlusSupport(DeviceType.SG2), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-10-05 05:00:56 +02:00
|
|
|
case LEFUN:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new LefunDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
2020-09-01 22:15:20 +02:00
|
|
|
case SONY_SWR12:
|
|
|
|
deviceSupport = new ServiceDeviceSupport(new SonySWR12DeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
break;
|
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 {
|
|
|
|
DeviceSupport deviceSupport = new ServiceDeviceSupport(new PebbleSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
|
|
|
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
|
|
|
}
|