mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-19 23:27:48 +01:00
Xiaomi: Cache firmware version
This commit is contained in:
parent
db57072dd3
commit
afaf0baa79
@ -88,10 +88,6 @@ public class XiaomiEncryptedSupport extends XiaomiSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startAuthentication(final TransactionBuilder builder) {
|
protected void startAuthentication(final TransactionBuilder builder) {
|
||||||
// FIXME why is this needed? We get an NPE without it
|
|
||||||
getDevice().setFirmwareVersion("...");
|
|
||||||
//getDevice().setFirmwareVersion2("...");
|
|
||||||
|
|
||||||
authService.startEncryptedHandshake(builder);
|
authService.startEncryptedHandshake(builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,8 @@ public abstract class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
protected final XiaomiSystemService systemService = new XiaomiSystemService(this);
|
protected final XiaomiSystemService systemService = new XiaomiSystemService(this);
|
||||||
protected final XiaomiCalendarService calendarService = new XiaomiCalendarService(this);
|
protected final XiaomiCalendarService calendarService = new XiaomiCalendarService(this);
|
||||||
|
|
||||||
|
private String mFirmwareVersion = null;
|
||||||
|
|
||||||
private final Map<Integer, AbstractXiaomiService> mServiceMap = new LinkedHashMap<Integer, AbstractXiaomiService>() {{
|
private final Map<Integer, AbstractXiaomiService> mServiceMap = new LinkedHashMap<Integer, AbstractXiaomiService>() {{
|
||||||
put(XiaomiAuthService.COMMAND_TYPE, authService);
|
put(XiaomiAuthService.COMMAND_TYPE, authService);
|
||||||
put(XiaomiMusicService.COMMAND_TYPE, musicService);
|
put(XiaomiMusicService.COMMAND_TYPE, musicService);
|
||||||
@ -107,6 +109,11 @@ public abstract class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
final BluetoothGattCharacteristic btCharacteristicActivityData = getCharacteristic(getCharacteristicActivityData());
|
final BluetoothGattCharacteristic btCharacteristicActivityData = getCharacteristic(getCharacteristicActivityData());
|
||||||
final BluetoothGattCharacteristic btCharacteristicDataUpload = getCharacteristic(getCharacteristicDataUpload());
|
final BluetoothGattCharacteristic btCharacteristicDataUpload = getCharacteristic(getCharacteristicDataUpload());
|
||||||
|
|
||||||
|
// FIXME unsetDynamicState unsets the fw version, which causes problems..
|
||||||
|
if (getDevice().getFirmwareVersion() == null && mFirmwareVersion != null) {
|
||||||
|
getDevice().setFirmwareVersion(mFirmwareVersion);
|
||||||
|
}
|
||||||
|
|
||||||
if (btCharacteristicCommandRead == null || btCharacteristicCommandWrite == null) {
|
if (btCharacteristicCommandRead == null || btCharacteristicCommandWrite == null) {
|
||||||
LOG.warn("Characteristics are null, will attempt to reconnect");
|
LOG.warn("Characteristics are null, will attempt to reconnect");
|
||||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.WAITING_FOR_RECONNECT, getContext()));
|
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.WAITING_FOR_RECONNECT, getContext()));
|
||||||
@ -150,6 +157,11 @@ public abstract class XiaomiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContext(final GBDevice gbDevice, final BluetoothAdapter btAdapter, final Context context) {
|
public void setContext(final GBDevice gbDevice, final BluetoothAdapter btAdapter, final Context context) {
|
||||||
|
// FIXME unsetDynamicState unsets the fw version, which causes problems..
|
||||||
|
if (mFirmwareVersion == null && gbDevice.getFirmwareVersion() != null) {
|
||||||
|
mFirmwareVersion = gbDevice.getFirmwareVersion();
|
||||||
|
}
|
||||||
|
|
||||||
super.setContext(gbDevice, btAdapter, context);
|
super.setContext(gbDevice, btAdapter, context);
|
||||||
for (final AbstractXiaomiService service : mServiceMap.values()) {
|
for (final AbstractXiaomiService service : mServiceMap.values()) {
|
||||||
service.setContext(context);
|
service.setContext(context);
|
||||||
|
Loading…
Reference in New Issue
Block a user