mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-28 03:25:49 +01:00
Device management: store deviceType name in DB
This commit is contained in:
parent
0da552aa33
commit
c2a9f5d805
@ -45,7 +45,7 @@ public class GBDaoGenerator {
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final Schema schema = new Schema(60, MAIN_PACKAGE + ".entities");
|
||||
final Schema schema = new Schema(62, MAIN_PACKAGE + ".entities");
|
||||
|
||||
Entity userAttributes = addUserAttributes(schema);
|
||||
Entity user = addUserInfo(schema, userAttributes);
|
||||
@ -203,7 +203,8 @@ public class GBDaoGenerator {
|
||||
device.addStringProperty("name").notNull();
|
||||
device.addStringProperty("manufacturer").notNull();
|
||||
device.addStringProperty("identifier").notNull().unique().javaDocGetterAndSetter("The fixed identifier, i.e. MAC address of the device.");
|
||||
device.addIntProperty("type").notNull().javaDocGetterAndSetter("The DeviceType key, i.e. the GBDevice's type.");
|
||||
device.addIntProperty("type").notNull().javaDocGetterAndSetter("The DeviceType key, i.e. the GBDevice's type.").codeBeforeGetterAndSetter("@Deprecated");
|
||||
device.addStringProperty("typeName").notNull().javaDocGetterAndSetter("The DeviceType enum name, for example SONY_WH_1000XM3");
|
||||
device.addStringProperty("model").javaDocGetterAndSetter("An optional model, further specifying the kind of device.");
|
||||
device.addStringProperty("alias");
|
||||
device.addStringProperty("parentFolder").javaDocGetterAndSetter("Folder name containing this device.");
|
||||
|
122
app/src/main/assets/migrations/devicetype.json
Normal file
122
app/src/main/assets/migrations/devicetype.json
Normal file
@ -0,0 +1,122 @@
|
||||
{
|
||||
"by-id": {
|
||||
"-1": "UNKNOWN",
|
||||
"1": "PEBBLE",
|
||||
"10": "MIBAND",
|
||||
"11": "MIBAND2",
|
||||
"1001": "MIBAND2_HRX",
|
||||
"12": "AMAZFITBIP",
|
||||
"13": "AMAZFITCOR",
|
||||
"14": "MIBAND3",
|
||||
"15": "AMAZFITCOR2",
|
||||
"16": "MIBAND4",
|
||||
"17": "AMAZFITBIP_LITE",
|
||||
"18": "AMAZFITGTR",
|
||||
"19": "AMAZFITGTS",
|
||||
"20": "AMAZFITBIPS",
|
||||
"21": "AMAZFITGTR_LITE",
|
||||
"22": "AMAZFITTREX",
|
||||
"23": "MIBAND5",
|
||||
"24": "AMAZFITBAND5",
|
||||
"25": "AMAZFITBIPS_LITE",
|
||||
"26": "AMAZFITGTR2",
|
||||
"27": "AMAZFITGTS2",
|
||||
"28": "AMAZFITBIPU",
|
||||
"29": "AMAZFITVERGEL",
|
||||
"30": "AMAZFITBIPUPRO",
|
||||
"31": "AMAZFITNEO",
|
||||
"32": "AMAZFITGTS2_MINI",
|
||||
"33": "ZEPP_E",
|
||||
"34": "AMAZFITGTR2E",
|
||||
"35": "AMAZFITGTS2E",
|
||||
"36": "AMAZFITX",
|
||||
"37": "MIBAND6",
|
||||
"38": "AMAZFITTREXPRO",
|
||||
"39": "AMAZFITPOP",
|
||||
"10040": "AMAZFITPOPPRO",
|
||||
"10041": "MIBAND7",
|
||||
"10042": "AMAZFITGTS3",
|
||||
"10043": "AMAZFITGTR3",
|
||||
"10044": "AMAZFITGTR4",
|
||||
"10045": "AMAZFITBAND7",
|
||||
"10046": "AMAZFITGTS4",
|
||||
"10047": "AMAZFITGTS4MINI",
|
||||
"10048": "AMAZFITTREX2",
|
||||
"10049": "AMAZFITGTR3PRO",
|
||||
"10051": "AMAZFITBIP3PRO",
|
||||
"10050": "AMAZFITCHEETAHPRO",
|
||||
"10052": "AMAZFITCHEETAHSQUARE",
|
||||
"10053": "AMAZFITCHEETAHROUND",
|
||||
"10054": "AMAZFITBIP5",
|
||||
"10055": "AMAZFITTREXULTRA",
|
||||
"10056": "AMAZFITGTRMINI",
|
||||
"10057": "AMAZFITFALCON",
|
||||
"10058": "AMAZFITBALANCE",
|
||||
"40": "HPLUS",
|
||||
"41": "MAKIBESF68",
|
||||
"42": "EXRIZUK8",
|
||||
"43": "Q8",
|
||||
"44": "SG2",
|
||||
"50": "NO1F1",
|
||||
"60": "TECLASTH30",
|
||||
"61": "Y5",
|
||||
"70": "XWATCH",
|
||||
"80": "ZETIME",
|
||||
"90": "ID115",
|
||||
"100": "WATCH9",
|
||||
"102": "WATCHXPLUS",
|
||||
"110": "ROIDMI",
|
||||
"112": "ROIDMI3",
|
||||
"120": "CASIOGB6900",
|
||||
"121": "CASIOGBX100",
|
||||
"122": "CASIOGWB5600",
|
||||
"123": "CASIOGMWB5000",
|
||||
"131": "MISCALE2",
|
||||
"140": "BFH16",
|
||||
"150": "MAKIBESHR3",
|
||||
"160": "BANGLEJS",
|
||||
"170": "FOSSILQHYBRID",
|
||||
"180": "TLW64",
|
||||
"190": "PINETIME_JF",
|
||||
"200": "MIJIA_LYWSD02",
|
||||
"210": "LEFUN",
|
||||
"211": "BOHEMIC_SMART_BRACELET",
|
||||
"220": "SMAQ2OSS",
|
||||
"230": "FITPRO",
|
||||
"250": "ITAG",
|
||||
"251": "NUTMINI",
|
||||
"260": "VIVOMOVE_HR",
|
||||
"300": "VIBRATISSIMO",
|
||||
"310": "SONY_SWR12",
|
||||
"320": "LIVEVIEW",
|
||||
"330": "WASPOS",
|
||||
"350": "UM25",
|
||||
"400": "DOMYOS_T540",
|
||||
"410": "NOTHING_EAR1",
|
||||
"418": "GALAXY_BUDS_PRO",
|
||||
"419": "GALAXY_BUDS_LIVE",
|
||||
"420": "GALAXY_BUDS",
|
||||
"421": "GALAXY_BUDS2",
|
||||
"422": "GALAXY_BUDS2_PRO",
|
||||
"430": "SONY_WH_1000XM3",
|
||||
"431": "SONY_WF_SP800N",
|
||||
"432": "SONY_WH_1000XM4",
|
||||
"433": "SONY_WF_1000XM3",
|
||||
"434": "SONY_WH_1000XM2",
|
||||
"435": "SONY_WF_1000XM4",
|
||||
"436": "SONY_LINKBUDS_S",
|
||||
"437": "SONY_WH_1000XM5",
|
||||
"438": "SONY_WF_1000XM5",
|
||||
"440": "BOSE_QC35",
|
||||
"500": "VESC",
|
||||
"510": "BINARY_SENSOR",
|
||||
"520": "FLIPPER_ZERO",
|
||||
"530": "SUPER_CARS",
|
||||
"540": "ASTEROIDOS",
|
||||
"550": "SOFLOW_SO6",
|
||||
"560": "WITHINGS_STEEL_HR",
|
||||
"570": "SONY_WENA_3",
|
||||
"580": "FEMOMETER_VINCA2",
|
||||
"1000": "TEST"
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@ -97,13 +98,13 @@ import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.MIBAND3;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.PEBBLE;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.TLW64;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.WATCHXPLUS;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.model.DeviceType.fromKey;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_CHANNEL_HIGH_PRIORITY_ID;
|
||||
import static nodomain.freeyourgadget.gadgetbridge.util.GB.NOTIFICATION_ID_ERROR;
|
||||
|
||||
import com.jakewharton.threetenabp.AndroidThreeTen;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Main Application class that initializes and provides access to certain things like
|
||||
@ -120,7 +121,7 @@ public class GBApplication extends Application {
|
||||
private static SharedPreferences sharedPrefs;
|
||||
private static final String PREFS_VERSION = "shared_preferences_version";
|
||||
//if preferences have to be migrated, increment the following and add the migration logic in migratePrefs below; see http://stackoverflow.com/questions/16397848/how-can-i-migrate-android-preferences-with-a-new-version
|
||||
private static final int CURRENT_PREFS_VERSION = 22;
|
||||
private static final int CURRENT_PREFS_VERSION = 25;
|
||||
|
||||
private static LimitedQueue mIDSenderLookup = new LimitedQueue(16);
|
||||
private static Prefs prefs;
|
||||
@ -637,7 +638,7 @@ public class GBApplication extends Application {
|
||||
SharedPreferences deviceSpecificSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
if (deviceSpecificSharedPrefs != null) {
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSpecificSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
if (deviceTypes.contains(deviceType)) {
|
||||
Log.i(TAG, "migrating global string preference " + globalPref + " for " + deviceType.name() + " " + dbDevice.getIdentifier() );
|
||||
@ -663,7 +664,7 @@ public class GBApplication extends Application {
|
||||
SharedPreferences deviceSpecificSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
if (deviceSpecificSharedPrefs != null) {
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSpecificSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
if (deviceTypes.contains(deviceType)) {
|
||||
Log.i(TAG, "migrating global boolean preference " + globalPref + " for " + deviceType.name() + " " + dbDevice.getIdentifier() );
|
||||
@ -681,6 +682,36 @@ public class GBApplication extends Application {
|
||||
|
||||
private void migratePrefs(int oldVersion) {
|
||||
SharedPreferences.Editor editor = sharedPrefs.edit();
|
||||
|
||||
// this comes before all other migrations since the new column DeviceTypeName was added as non-null
|
||||
if (oldVersion < 25){
|
||||
try (DBHandler db = acquireDB()) {
|
||||
final InputStream inputStream = getAssets().open("migrations/devicetype.json");
|
||||
final byte[] buffer = new byte[inputStream.available()];
|
||||
inputStream.read(buffer);
|
||||
inputStream.close();
|
||||
final JSONObject deviceMapping = new JSONObject(new String(buffer));
|
||||
final JSONObject deviceIdNameMapping = deviceMapping.getJSONObject("by-id");
|
||||
|
||||
final DaoSession daoSession = db.getDaoSession();
|
||||
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
|
||||
|
||||
for (Device dbDevice : activeDevices) {
|
||||
String deviceTypeName = dbDevice.getTypeName();
|
||||
if(deviceTypeName.isEmpty()){
|
||||
deviceTypeName = deviceIdNameMapping.optString(
|
||||
String.valueOf(dbDevice.getType()),
|
||||
"UNKNOWN"
|
||||
);
|
||||
dbDevice.setTypeName(deviceTypeName);
|
||||
daoSession.getDeviceDao().update(dbDevice);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.w(TAG, "error acquiring DB lock");
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion == 0) {
|
||||
String legacyGender = sharedPrefs.getString("mi_user_gender", null);
|
||||
String legacyHeight = sharedPrefs.getString("mi_user_height_cm", null);
|
||||
@ -738,7 +769,7 @@ public class GBApplication extends Application {
|
||||
String newLanguage = null;
|
||||
Set<String> displayItems = null;
|
||||
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
if (deviceType == AMAZFITBIP || deviceType == AMAZFITCOR || deviceType == AMAZFITCOR2) {
|
||||
int oldLanguage = prefs.getInt("amazfitbip_language", -1);
|
||||
@ -836,7 +867,7 @@ public class GBApplication extends Application {
|
||||
for (Device dbDevice : activeDevices) {
|
||||
SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
if (deviceType == MIBAND) {
|
||||
int deviceTimeOffsetHours = deviceSharedPrefs.getInt("device_time_offset_hours",0);
|
||||
@ -857,7 +888,7 @@ public class GBApplication extends Application {
|
||||
SharedPreferences deviceSpecificSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
if (deviceSpecificSharedPrefs != null) {
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSpecificSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
String newWearside = null;
|
||||
String newOrientation = null;
|
||||
@ -957,7 +988,7 @@ public class GBApplication extends Application {
|
||||
for (Device dbDevice : activeDevices) {
|
||||
SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
|
||||
if (deviceType == GALAXY_BUDS) {
|
||||
GB.log("migrating Galaxy Buds volume", GB.INFO, null);
|
||||
@ -977,7 +1008,7 @@ public class GBApplication extends Application {
|
||||
for (Device dbDevice : activeDevices) {
|
||||
SharedPreferences deviceSharedPrefs = GBApplication.getDeviceSpecificSharedPrefs(dbDevice.getIdentifier());
|
||||
SharedPreferences.Editor deviceSharedPrefsEdit = deviceSharedPrefs.edit();
|
||||
DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
if (deviceType == WATCHXPLUS || deviceType == FITPRO || deviceType == LEFUN) {
|
||||
deviceSharedPrefsEdit.putBoolean("inactivity_warnings_enable", deviceSharedPrefs.getBoolean("pref_longsit_switch", false));
|
||||
deviceSharedPrefsEdit.remove("pref_longsit_switch");
|
||||
@ -1290,11 +1321,11 @@ public class GBApplication extends Application {
|
||||
final List<Device> activeDevices = DBHelper.getActiveDevices(daoSession);
|
||||
|
||||
for (Device dbDevice : activeDevices) {
|
||||
final DeviceType deviceType = fromKey(dbDevice.getType());
|
||||
final DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
if (deviceType == MIBAND2) {
|
||||
final String name = dbDevice.getName();
|
||||
if ("Mi Band HRX".equalsIgnoreCase(name) || "Mi Band 2i".equalsIgnoreCase(name)) {
|
||||
dbDevice.setType(DeviceType.MIBAND2_HRX.getKey());
|
||||
dbDevice.setTypeName(DeviceType.MIBAND2_HRX.name());
|
||||
daoSession.getDeviceDao().update(dbDevice);
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
};
|
||||
private Spinner sendTypeSpinner;
|
||||
private EditText editContent;
|
||||
public static final long SELECT_DEVICE = 999L;
|
||||
public static final long SELECT_DEVICE = -1;
|
||||
private long selectedTestDeviceKey = SELECT_DEVICE;
|
||||
private String selectedTestDeviceMAC;
|
||||
|
||||
@ -1003,7 +1003,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
if (deviceKey == SELECT_DEVICE) {
|
||||
return;
|
||||
}
|
||||
DeviceType deviceType = DeviceType.fromKey((int) deviceKey);
|
||||
DeviceType deviceType = DeviceType.values()[(int) deviceKey];
|
||||
try (
|
||||
DBHandler db = GBApplication.acquireDB()) {
|
||||
DaoSession daoSession = db.getDaoSession();
|
||||
@ -1153,7 +1153,7 @@ public class DebugActivity extends AbstractGBActivity {
|
||||
DeviceCoordinator coordinator = deviceType.getDeviceCoordinator();
|
||||
int icon = coordinator.getDefaultIconResource();
|
||||
String name = app.getString(coordinator.getDeviceNameResource()) + " (" + coordinator.getManufacturer() + ")";
|
||||
long deviceId = deviceType.getKey();
|
||||
long deviceId = deviceType.ordinal();
|
||||
newMap.put(name, new Pair(deviceId, icon));
|
||||
}
|
||||
TreeMap <String, Pair<Long, Integer>> sortedMap = new TreeMap<>(newMap);
|
||||
|
@ -437,7 +437,7 @@ public class DBHelper {
|
||||
device.setAlias(gbDevice.getAlias());
|
||||
DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
device.setManufacturer(coordinator.getManufacturer());
|
||||
device.setType(gbDevice.getType().getKey());
|
||||
device.setTypeName(gbDevice.getType().name());
|
||||
device.setModel(gbDevice.getModel());
|
||||
|
||||
if (device.getId() == null) {
|
||||
@ -462,7 +462,7 @@ public class DBHelper {
|
||||
if (!Objects.equals(device.getManufacturer(), coordinator.getManufacturer())) {
|
||||
return false;
|
||||
}
|
||||
if (device.getType() != gbDevice.getType().getKey()) {
|
||||
if(!gbDevice.getType().name().equals(device.getTypeName())){
|
||||
return false;
|
||||
}
|
||||
if (!Objects.equals(device.getModel(), gbDevice.getModel())) {
|
||||
|
@ -0,0 +1,38 @@
|
||||
/* Copyright (C) 2023 Daniel Dakhno
|
||||
|
||||
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/>. */
|
||||
package nodomain.freeyourgadget.gadgetbridge.database.schema;
|
||||
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBUpdateScript;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DeviceDao;
|
||||
|
||||
public class GadgetbridgeUpdate_62 implements DBUpdateScript {
|
||||
@Override
|
||||
public void upgradeSchema(SQLiteDatabase db) {
|
||||
if (!DBHelper.existsColumn(DeviceDao.TABLENAME, DeviceDao.Properties.TypeName.columnName, db)) {
|
||||
String ADD_COLUMN_CPONTAINED_FOLDER = "ALTER TABLE " + DeviceDao.TABLENAME + " ADD COLUMN "
|
||||
+ DeviceDao.Properties.TypeName.columnName + " TEXT NOT NULL DEFAULT \"\"";
|
||||
db.execSQL(ADD_COLUMN_CPONTAINED_FOLDER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downgradeSchema(SQLiteDatabase db) {
|
||||
}
|
||||
}
|
@ -148,152 +148,144 @@ import nodomain.freeyourgadget.gadgetbridge.devices.zetime.ZeTimeCoordinator;
|
||||
/**
|
||||
* For every supported device, a device type constant must exist.
|
||||
*
|
||||
* Note: they key of every constant is stored in the DB, so it is fixed forever,
|
||||
* Note: they name of the enum is stored in the DB, so it is fixed forever,
|
||||
* and may not be changed.
|
||||
*/
|
||||
public enum DeviceType {
|
||||
UNKNOWN(-1, UnknownDeviceCoordinator.class),
|
||||
PEBBLE(1, PebbleCoordinator.class),
|
||||
MIBAND(10, MiBandCoordinator.class),
|
||||
MIBAND2(11, MiBand2Coordinator.class),
|
||||
MIBAND2_HRX(1001, MiBand2HRXCoordinator.class),
|
||||
AMAZFITBIP(12, AmazfitBipCoordinator.class),
|
||||
AMAZFITCOR(13, AmazfitCorCoordinator.class),
|
||||
MIBAND3(14, MiBand3Coordinator.class),
|
||||
AMAZFITCOR2(15, AmazfitCor2Coordinator.class),
|
||||
MIBAND4(16, MiBand4Coordinator.class),
|
||||
AMAZFITBIP_LITE(17, AmazfitBipLiteCoordinator.class),
|
||||
AMAZFITGTR(18, AmazfitGTRCoordinator.class),
|
||||
AMAZFITGTS(19, AmazfitGTSCoordinator.class),
|
||||
AMAZFITBIPS(20, AmazfitBipSCoordinator.class),
|
||||
AMAZFITGTR_LITE(21, AmazfitGTRLiteCoordinator.class),
|
||||
AMAZFITTREX(22, AmazfitTRexCoordinator.class),
|
||||
MIBAND5(23, MiBand5Coordinator.class),
|
||||
AMAZFITBAND5(24, AmazfitBand5Coordinator.class),
|
||||
AMAZFITBIPS_LITE(25, AmazfitBipSLiteCoordinator.class),
|
||||
AMAZFITGTR2(26, AmazfitGTR2Coordinator.class),
|
||||
AMAZFITGTS2(27, AmazfitGTS2Coordinator.class),
|
||||
AMAZFITBIPU(28, AmazfitBipUCoordinator.class),
|
||||
AMAZFITVERGEL(29, AmazfitVergeLCoordinator.class),
|
||||
AMAZFITBIPUPRO(30, AmazfitBipUProCoordinator.class),
|
||||
AMAZFITNEO(31, AmazfitNeoCoordinator.class),
|
||||
AMAZFITGTS2_MINI(32, AmazfitGTS2MiniCoordinator.class),
|
||||
ZEPP_E(33, ZeppECoordinator.class),
|
||||
AMAZFITGTR2E(34, AmazfitGTR2eCoordinator.class),
|
||||
AMAZFITGTS2E(35, AmazfitGTS2eCoordinator.class),
|
||||
AMAZFITX(36, AmazfitXCoordinator.class),
|
||||
MIBAND6(37, MiBand6Coordinator.class),
|
||||
AMAZFITTREXPRO(38, AmazfitTRexProCoordinator.class),
|
||||
AMAZFITPOP(39, AmazfitPopCoordinator.class),
|
||||
AMAZFITPOPPRO(10040, AmazfitPopProCoordinator.class),
|
||||
MIBAND7(10041, MiBand7Coordinator.class),
|
||||
AMAZFITGTS3(10042, AmazfitGTS3Coordinator.class),
|
||||
AMAZFITGTR3(10043, AmazfitGTR3Coordinator.class),
|
||||
AMAZFITGTR4(10044, AmazfitGTR4Coordinator.class),
|
||||
AMAZFITBAND7(10045, AmazfitBand7Coordinator.class),
|
||||
AMAZFITGTS4(10046, AmazfitGTS4Coordinator.class),
|
||||
AMAZFITGTS4MINI(10047, AmazfitGTS4MiniCoordinator.class),
|
||||
AMAZFITTREX2(10048, AmazfitTRex2Coordinator.class),
|
||||
AMAZFITGTR3PRO(10049, AmazfitGTR3ProCoordinator.class),
|
||||
AMAZFITBIP3PRO(10051, AmazfitBip3ProCoordinator.class),
|
||||
AMAZFITCHEETAHPRO(10050, AmazfitCheetahProCoordinator.class),
|
||||
AMAZFITCHEETAHSQUARE(10052, AmazfitCheetahSquareCoordinator.class),
|
||||
AMAZFITCHEETAHROUND(10053, AmazfitCheetahRoundCoordinator.class),
|
||||
AMAZFITBIP5(10054, AmazfitBip5Coordinator.class),
|
||||
AMAZFITTREXULTRA(10055, AmazfitTRexUltraCoordinator.class),
|
||||
AMAZFITGTRMINI(10056, AmazfitGTRMiniCoordinator.class),
|
||||
AMAZFITFALCON(10057, AmazfitFalconCoordinator.class),
|
||||
AMAZFITBALANCE(10058, AmazfitBalanceCoordinator.class),
|
||||
HPLUS(40, HPlusCoordinator.class),
|
||||
MAKIBESF68(41, MakibesF68Coordinator.class),
|
||||
EXRIZUK8(42, EXRIZUK8Coordinator.class),
|
||||
Q8(43, Q8Coordinator.class),
|
||||
SG2(44, SG2Coordinator.class),
|
||||
NO1F1(50, No1F1Coordinator.class),
|
||||
TECLASTH30(60, TeclastH30Coordinator.class),
|
||||
Y5(61, Y5Coordinator.class),
|
||||
XWATCH(70, XWatchCoordinator.class),
|
||||
ZETIME(80, ZeTimeCoordinator.class),
|
||||
ID115(90, ID115Coordinator.class),
|
||||
WATCH9(100, Watch9DeviceCoordinator.class),
|
||||
WATCHXPLUS(102, WatchXPlusDeviceCoordinator.class),
|
||||
ROIDMI(110, Roidmi1Coordinator.class),
|
||||
ROIDMI3(112, Roidmi3Coordinator.class),
|
||||
CASIOGB6900(120, CasioGB6900DeviceCoordinator.class),
|
||||
CASIOGBX100(121, CasioGBX100DeviceCoordinator.class),
|
||||
CASIOGWB5600(122, CasioGWB5600DeviceCoordinator.class),
|
||||
CASIOGMWB5000(123, CasioGMWB5000DeviceCoordinator.class),
|
||||
MISCALE2(131, MiScale2DeviceCoordinator.class),
|
||||
BFH16(140, BFH16DeviceCoordinator.class),
|
||||
MAKIBESHR3(150, MakibesHR3Coordinator.class),
|
||||
BANGLEJS(160, BangleJSCoordinator.class),
|
||||
FOSSILQHYBRID(170, QHybridCoordinator.class),
|
||||
TLW64(180, TLW64Coordinator.class),
|
||||
PINETIME_JF(190, PineTimeJFCoordinator.class),
|
||||
MIJIA_LYWSD02(200, MijiaLywsd02Coordinator.class),
|
||||
LEFUN(210, LefunDeviceCoordinator.class),
|
||||
BOHEMIC_SMART_BRACELET(211, BohemicSmartBraceletDeviceCoordinator.class),
|
||||
SMAQ2OSS(220, SMAQ2OSSCoordinator.class),
|
||||
FITPRO(230, FitProDeviceCoordinator.class),
|
||||
ITAG(250, ITagCoordinator.class),
|
||||
NUTMINI(251, NutCoordinator.class),
|
||||
VIVOMOVE_HR(260, VivomoveHrCoordinator.class),
|
||||
VIBRATISSIMO(300, VibratissimoCoordinator.class),
|
||||
SONY_SWR12(310, SonySWR12DeviceCoordinator.class),
|
||||
LIVEVIEW(320, LiveviewCoordinator.class),
|
||||
WASPOS(330, WaspOSCoordinator.class),
|
||||
UM25(350, UM25Coordinator.class),
|
||||
DOMYOS_T540(400, DomyosT540Coordinator.class),
|
||||
NOTHING_EAR1(410, Ear1Coordinator.class),
|
||||
GALAXY_BUDS_PRO(418, GalaxyBudsProDeviceCoordinator.class),
|
||||
GALAXY_BUDS_LIVE(419, GalaxyBudsLiveDeviceCoordinator.class),
|
||||
GALAXY_BUDS(420, GalaxyBudsDeviceCoordinator.class),
|
||||
GALAXY_BUDS2(421, GalaxyBuds2DeviceCoordinator.class),
|
||||
GALAXY_BUDS2_PRO(422, GalaxyBuds2ProDeviceCoordinator.class),
|
||||
SONY_WH_1000XM3(430, SonyWH1000XM3Coordinator.class),
|
||||
SONY_WF_SP800N(431, SonyWFSP800NCoordinator.class),
|
||||
SONY_WH_1000XM4(432, SonyWH1000XM4Coordinator.class),
|
||||
SONY_WF_1000XM3(433, SonyWF1000XM3Coordinator.class),
|
||||
SONY_WH_1000XM2(434, SonyWH1000XM2Coordinator.class),
|
||||
SONY_WF_1000XM4(435, SonyWF1000XM4Coordinator.class),
|
||||
SONY_LINKBUDS_S(436, SonyLinkBudsSCoordinator.class),
|
||||
SONY_WH_1000XM5(437, SonyWH1000XM5Coordinator.class),
|
||||
SONY_WF_1000XM5(438, SonyWF1000XM5Coordinator.class),
|
||||
BOSE_QC35(440, QC35Coordinator.class),
|
||||
VESC(500, VescCoordinator.class),
|
||||
BINARY_SENSOR(510, BinarySensorCoordinator.class),
|
||||
FLIPPER_ZERO(520, FlipperZeroCoordinator.class),
|
||||
SUPER_CARS(530, SuperCarsCoordinator.class),
|
||||
ASTEROIDOS(540, AsteroidOSDeviceCoordinator.class),
|
||||
SOFLOW_SO6(550, SoFlowCoordinator.class),
|
||||
WITHINGS_STEEL_HR(560, WithingsSteelHRDeviceCoordinator.class),
|
||||
SONY_WENA_3(570, SonyWena3Coordinator.class),
|
||||
|
||||
FEMOMETER_VINCA2(580, FemometerVinca2DeviceCoordinator.class),
|
||||
TEST(1000, TestDeviceCoordinator.class);
|
||||
|
||||
private final int key;
|
||||
UNKNOWN(UnknownDeviceCoordinator.class),
|
||||
PEBBLE(PebbleCoordinator.class),
|
||||
MIBAND(MiBandCoordinator.class),
|
||||
MIBAND2(MiBand2Coordinator.class),
|
||||
MIBAND2_HRX(MiBand2HRXCoordinator.class),
|
||||
AMAZFITBIP(AmazfitBipCoordinator.class),
|
||||
AMAZFITCOR(AmazfitCorCoordinator.class),
|
||||
MIBAND3(MiBand3Coordinator.class),
|
||||
AMAZFITCOR2(AmazfitCor2Coordinator.class),
|
||||
MIBAND4(MiBand4Coordinator.class),
|
||||
AMAZFITBIP_LITE(AmazfitBipLiteCoordinator.class),
|
||||
AMAZFITGTR(AmazfitGTRCoordinator.class),
|
||||
AMAZFITGTS(AmazfitGTSCoordinator.class),
|
||||
AMAZFITBIPS(AmazfitBipSCoordinator.class),
|
||||
AMAZFITGTR_LITE(AmazfitGTRLiteCoordinator.class),
|
||||
AMAZFITTREX(AmazfitTRexCoordinator.class),
|
||||
MIBAND5(MiBand5Coordinator.class),
|
||||
AMAZFITBAND5(AmazfitBand5Coordinator.class),
|
||||
AMAZFITBIPS_LITE(AmazfitBipSLiteCoordinator.class),
|
||||
AMAZFITGTR2(AmazfitGTR2Coordinator.class),
|
||||
AMAZFITGTS2(AmazfitGTS2Coordinator.class),
|
||||
AMAZFITBIPU(AmazfitBipUCoordinator.class),
|
||||
AMAZFITVERGEL(AmazfitVergeLCoordinator.class),
|
||||
AMAZFITBIPUPRO(AmazfitBipUProCoordinator.class),
|
||||
AMAZFITNEO(AmazfitNeoCoordinator.class),
|
||||
AMAZFITGTS2_MINI(AmazfitGTS2MiniCoordinator.class),
|
||||
ZEPP_E(ZeppECoordinator.class),
|
||||
AMAZFITGTR2E(AmazfitGTR2eCoordinator.class),
|
||||
AMAZFITGTS2E(AmazfitGTS2eCoordinator.class),
|
||||
AMAZFITX(AmazfitXCoordinator.class),
|
||||
MIBAND6(MiBand6Coordinator.class),
|
||||
AMAZFITTREXPRO(AmazfitTRexProCoordinator.class),
|
||||
AMAZFITPOP(AmazfitPopCoordinator.class),
|
||||
AMAZFITPOPPRO(AmazfitPopProCoordinator.class),
|
||||
MIBAND7(MiBand7Coordinator.class),
|
||||
AMAZFITGTS3(AmazfitGTS3Coordinator.class),
|
||||
AMAZFITGTR3(AmazfitGTR3Coordinator.class),
|
||||
AMAZFITGTR4(AmazfitGTR4Coordinator.class),
|
||||
AMAZFITBAND7(AmazfitBand7Coordinator.class),
|
||||
AMAZFITGTS4(AmazfitGTS4Coordinator.class),
|
||||
AMAZFITGTS4MINI(AmazfitGTS4MiniCoordinator.class),
|
||||
AMAZFITTREX2(AmazfitTRex2Coordinator.class),
|
||||
AMAZFITGTR3PRO(AmazfitGTR3ProCoordinator.class),
|
||||
AMAZFITBIP3PRO(AmazfitBip3ProCoordinator.class),
|
||||
AMAZFITCHEETAHPRO(AmazfitCheetahProCoordinator.class),
|
||||
AMAZFITCHEETAHSQUARE(AmazfitCheetahSquareCoordinator.class),
|
||||
AMAZFITCHEETAHROUND(AmazfitCheetahRoundCoordinator.class),
|
||||
AMAZFITBIP5(AmazfitBip5Coordinator.class),
|
||||
AMAZFITTREXULTRA(AmazfitTRexUltraCoordinator.class),
|
||||
AMAZFITGTRMINI(AmazfitGTRMiniCoordinator.class),
|
||||
AMAZFITFALCON(AmazfitFalconCoordinator.class),
|
||||
AMAZFITBALANCE(AmazfitBalanceCoordinator.class),
|
||||
HPLUS(HPlusCoordinator.class),
|
||||
MAKIBESF68(MakibesF68Coordinator.class),
|
||||
EXRIZUK8(EXRIZUK8Coordinator.class),
|
||||
Q8(Q8Coordinator.class),
|
||||
SG2(SG2Coordinator.class),
|
||||
NO1F1(No1F1Coordinator.class),
|
||||
TECLASTH30(TeclastH30Coordinator.class),
|
||||
Y5(Y5Coordinator.class),
|
||||
XWATCH(XWatchCoordinator.class),
|
||||
ZETIME(ZeTimeCoordinator.class),
|
||||
ID115(ID115Coordinator.class),
|
||||
WATCH9(Watch9DeviceCoordinator.class),
|
||||
WATCHXPLUS(WatchXPlusDeviceCoordinator.class),
|
||||
ROIDMI(Roidmi1Coordinator.class),
|
||||
ROIDMI3(Roidmi3Coordinator.class),
|
||||
CASIOGB6900(CasioGB6900DeviceCoordinator.class),
|
||||
CASIOGBX100(CasioGBX100DeviceCoordinator.class),
|
||||
CASIOGWB5600(CasioGWB5600DeviceCoordinator.class),
|
||||
CASIOGMWB5000(CasioGMWB5000DeviceCoordinator.class),
|
||||
MISCALE2(MiScale2DeviceCoordinator.class),
|
||||
BFH16(BFH16DeviceCoordinator.class),
|
||||
MAKIBESHR3(MakibesHR3Coordinator.class),
|
||||
BANGLEJS(BangleJSCoordinator.class),
|
||||
FOSSILQHYBRID(QHybridCoordinator.class),
|
||||
TLW64(TLW64Coordinator.class),
|
||||
PINETIME_JF(PineTimeJFCoordinator.class),
|
||||
MIJIA_LYWSD02(MijiaLywsd02Coordinator.class),
|
||||
LEFUN(LefunDeviceCoordinator.class),
|
||||
BOHEMIC_SMART_BRACELET(BohemicSmartBraceletDeviceCoordinator.class),
|
||||
SMAQ2OSS(SMAQ2OSSCoordinator.class),
|
||||
FITPRO(FitProDeviceCoordinator.class),
|
||||
ITAG(ITagCoordinator.class),
|
||||
NUTMINI(NutCoordinator.class),
|
||||
VIVOMOVE_HR(VivomoveHrCoordinator.class),
|
||||
VIBRATISSIMO(VibratissimoCoordinator.class),
|
||||
SONY_SWR12(SonySWR12DeviceCoordinator.class),
|
||||
LIVEVIEW(LiveviewCoordinator.class),
|
||||
WASPOS(WaspOSCoordinator.class),
|
||||
UM25(UM25Coordinator.class),
|
||||
DOMYOS_T540(DomyosT540Coordinator.class),
|
||||
NOTHING_EAR1(Ear1Coordinator.class),
|
||||
GALAXY_BUDS_PRO(GalaxyBudsProDeviceCoordinator.class),
|
||||
GALAXY_BUDS_LIVE(GalaxyBudsLiveDeviceCoordinator.class),
|
||||
GALAXY_BUDS(GalaxyBudsDeviceCoordinator.class),
|
||||
GALAXY_BUDS2(GalaxyBuds2DeviceCoordinator.class),
|
||||
GALAXY_BUDS2_PRO(GalaxyBuds2ProDeviceCoordinator.class),
|
||||
SONY_WH_1000XM3(SonyWH1000XM3Coordinator.class),
|
||||
SONY_WF_SP800N(SonyWFSP800NCoordinator.class),
|
||||
SONY_WH_1000XM4(SonyWH1000XM4Coordinator.class),
|
||||
SONY_WF_1000XM3(SonyWF1000XM3Coordinator.class),
|
||||
SONY_WH_1000XM2(SonyWH1000XM2Coordinator.class),
|
||||
SONY_WF_1000XM4(SonyWF1000XM4Coordinator.class),
|
||||
SONY_LINKBUDS_S(SonyLinkBudsSCoordinator.class),
|
||||
SONY_WH_1000XM5(SonyWH1000XM5Coordinator.class),
|
||||
SONY_WF_1000XM5(SonyWF1000XM5Coordinator.class),
|
||||
BOSE_QC35(QC35Coordinator.class),
|
||||
VESC(VescCoordinator.class),
|
||||
BINARY_SENSOR(BinarySensorCoordinator.class),
|
||||
FLIPPER_ZERO(FlipperZeroCoordinator.class),
|
||||
SUPER_CARS(SuperCarsCoordinator.class),
|
||||
ASTEROIDOS(AsteroidOSDeviceCoordinator.class),
|
||||
SOFLOW_SO6(SoFlowCoordinator.class),
|
||||
WITHINGS_STEEL_HR(WithingsSteelHRDeviceCoordinator.class),
|
||||
SONY_WENA_3(SonyWena3Coordinator.class),
|
||||
FEMOMETER_VINCA2(FemometerVinca2DeviceCoordinator.class),
|
||||
TEST(TestDeviceCoordinator.class);
|
||||
|
||||
private DeviceCoordinator coordinator;
|
||||
|
||||
private Class<? extends DeviceCoordinator> coordinatorClass;
|
||||
|
||||
DeviceType(int key, Class<? extends DeviceCoordinator> coordinatorClass) {
|
||||
this.key = key;
|
||||
DeviceType(Class<? extends DeviceCoordinator> coordinatorClass) {
|
||||
this.coordinatorClass = coordinatorClass;
|
||||
}
|
||||
|
||||
public int getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public boolean isSupported() {
|
||||
return this != UNKNOWN;
|
||||
}
|
||||
|
||||
public static DeviceType fromKey(int key) {
|
||||
public static DeviceType fromName(String name) {
|
||||
for (DeviceType type : values()) {
|
||||
if (type.key == key) {
|
||||
if (type.name().equals(name)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class RoidmiSupport extends AbstractSerialDeviceSupport {
|
||||
case ROIDMI3:
|
||||
return new Roidmi3Protocol(getDevice());
|
||||
default:
|
||||
LOG.error("Unsupported device type {} with key = {}", deviceType, deviceType.getKey());
|
||||
LOG.error("Unsupported device type {} with key = {}", deviceType, deviceType.name());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -171,7 +171,7 @@ public class DeviceHelper {
|
||||
* @return
|
||||
*/
|
||||
public GBDevice toGBDevice(Device dbDevice) {
|
||||
DeviceType deviceType = DeviceType.fromKey(dbDevice.getType());
|
||||
DeviceType deviceType = DeviceType.fromName(dbDevice.getTypeName());
|
||||
GBDevice gbDevice = new GBDevice(dbDevice.getIdentifier(), dbDevice.getName(), dbDevice.getAlias(), dbDevice.getParentFolder(), deviceType);
|
||||
DeviceCoordinator coordinator = gbDevice.getDeviceCoordinator();
|
||||
for (BatteryConfig batteryConfig : coordinator.getBatteryConfig()) {
|
||||
|
@ -30,7 +30,7 @@ public class CommonSymbolsTransliterator extends SimpleTransliterator {
|
||||
put('©', "(c)"); put('®', "(r)"); put('™', "(tm)"); put('°', "*"); put('€', "EUR");
|
||||
put('–', "-"); put('⸺', "-"); put('˗', "-"); put('ᐨ', "-"); put('‐', "-"); put('‑', "-"); put('‒', "-"); put('—', "-"); put('―', "-"); put('−', "-");
|
||||
put('⎯', "-"); put('⏤', "-"); put('─', "-"); put('➖', "-"); put('⸻', "-"); put('ㅡ', "-"); put('ᅳ', "-"); put('ー', "-"); put('一', "-"); put('﹘', "-");
|
||||
put('﹣', "-"); put('-', "-"); put('𑁋', "-"); put('𑁒', "-"); put('˜', "~"); put('⁓', "~"); put('∼', "~"); put('〜', "~"); put('〰', "~~"); put('~', "~");
|
||||
put('﹣', "-"); put('-', "-"); put('\udc4b', "-"); put('\udc52', "-"); put('˜', "~"); put('⁓', "~"); put('∼', "~"); put('〜', "~"); put('〰', "~~"); put('~', "~");
|
||||
put('⁰', "0"); put('¹', "1"); put('²', "2"); put('³', "3"); put('⁴', "4"); put('⁵', "5"); put('⁶', "6"); put('⁷', "7"); put('⁸', "8"); put('⁹', "9");
|
||||
put('₀', "0"); put('₁', "1"); put('₂', "2"); put('₃', "3"); put('₄', "4"); put('₅', "5"); put('₆', "6"); put('₇', "7"); put('₈', "8"); put('₉', "9");
|
||||
}});
|
||||
|
Loading…
Reference in New Issue
Block a user