mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-13 11:17:33 +01:00
Xiaomi: implement setAutoReconnect on XiaomiSupport
The DeviceCommunicationService calls `#setAutoReconnect` on new device supports before it calls the connect method. Since this method did not get relayed to the connection-specific support classes, Xiaomi devices using a BLE connection did not automatically reconnect because the `mAutoReconnect` field in `AbstractBTLEDeviceSupport` never got set.
This commit is contained in:
parent
d39f86f3c8
commit
5e6bf798a4
@ -62,6 +62,11 @@ public class XiaomiBleSupport extends XiaomiConnectionSupport {
|
||||
return XiaomiUuids.BLE_UUIDS.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAutoReconnect() {
|
||||
return mXiaomiSupport.getAutoReconnect();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TransactionBuilder initializeDevice(final TransactionBuilder builder) {
|
||||
XiaomiUuids.XiaomiBleUuidSet uuidSet = null;
|
||||
@ -267,6 +272,11 @@ public class XiaomiBleSupport extends XiaomiConnectionSupport {
|
||||
this.characteristicDataUpload.write(taskName, chunk, callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoReconnect(boolean enabled) {
|
||||
this.commsSupport.setAutoReconnect(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Realistically, this function should only be used during auth, as we must schedule the command after
|
||||
* notifications were enabled on the characteristics, and for that we need the builder to guarantee the
|
||||
|
@ -33,4 +33,5 @@ public abstract class XiaomiConnectionSupport {
|
||||
public abstract void setContext(final GBDevice device, final BluetoothAdapter adapter, final Context context);
|
||||
public abstract void sendCommand(final String taskName, final XiaomiProto.Command command);
|
||||
public abstract void sendDataChunk(final String taskName, final byte[] chunk, @Nullable final XiaomiCharacteristic.SendCallback callback);
|
||||
public abstract void setAutoReconnect(final boolean enabled);
|
||||
}
|
||||
|
@ -323,4 +323,10 @@ public class XiaomiSppSupport extends XiaomiConnectionSupport {
|
||||
callback.onSend();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoReconnect(boolean enabled) {
|
||||
// for sanity, but this is not supposed to be set on BT Classic devices
|
||||
this.commsSupport.setAutoReconnect(enabled);
|
||||
}
|
||||
}
|
||||
|
@ -114,6 +114,14 @@ public class XiaomiSupport extends AbstractDeviceSupport {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoReconnect(boolean enabled) {
|
||||
super.setAutoReconnect(enabled);
|
||||
if (this.connectionSupport != null) {
|
||||
this.connectionSupport.setAutoReconnect(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getImplicitCallbackModify() {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user