1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Xiaomi: temporary fix for database errors when reconnecting

This commit is contained in:
MrYoranimo 2024-01-16 13:55:06 +01:00 committed by José Rebelo
parent 7f68dc5449
commit b395e889c3
3 changed files with 9 additions and 5 deletions

View File

@ -113,8 +113,10 @@ public class XiaomiBleSupport extends XiaomiConnectionSupport {
} }
// FIXME unsetDynamicState unsets the fw version, which causes problems.. // FIXME unsetDynamicState unsets the fw version, which causes problems..
if (getDevice().getFirmwareVersion() == null && mXiaomiSupport.getCachedFirmwareVersion() != null) { if (getDevice().getFirmwareVersion() == null) {
getDevice().setFirmwareVersion(mXiaomiSupport.getCachedFirmwareVersion()); getDevice().setFirmwareVersion(mXiaomiSupport.getCachedFirmwareVersion() != null ?
mXiaomiSupport.getCachedFirmwareVersion() :
"N/A");
} }
if (btCharacteristicCommandRead == null || btCharacteristicCommandWrite == null) { if (btCharacteristicCommandRead == null || btCharacteristicCommandWrite == null) {

View File

@ -71,8 +71,10 @@ public class XiaomiSppSupport extends XiaomiConnectionSupport {
@Override @Override
protected TransactionBuilder initializeDevice(TransactionBuilder builder) { protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
// FIXME unsetDynamicState unsets the fw version, which causes problems.. // FIXME unsetDynamicState unsets the fw version, which causes problems..
if (getDevice().getFirmwareVersion() == null && mXiaomiSupport.getCachedFirmwareVersion() != null) { if (getDevice().getFirmwareVersion() == null) {
getDevice().setFirmwareVersion(mXiaomiSupport.getCachedFirmwareVersion()); getDevice().setFirmwareVersion(mXiaomiSupport.getCachedFirmwareVersion() != null ?
mXiaomiSupport.getCachedFirmwareVersion() :
"N/A");
} }
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext())); builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));

View File

@ -178,7 +178,7 @@ public class XiaomiSupport extends AbstractDeviceSupport {
public void setContext(final GBDevice device, final BluetoothAdapter adapter, final Context context) { public void setContext(final GBDevice device, final BluetoothAdapter adapter, final Context context) {
// FIXME unsetDynamicState unsets the fw version, which causes problems.. // FIXME unsetDynamicState unsets the fw version, which causes problems..
if (getCachedFirmwareVersion() == null && device.getFirmwareVersion() != null) { if (device.getFirmwareVersion() != null) {
setCachedFirmwareVersion(device.getFirmwareVersion()); setCachedFirmwareVersion(device.getFirmwareVersion());
} }