mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
BtBRQueue: Fix WAITING_FOR_RECONNECT state leak after dispose
When BT was turned off while a device was mid-connect, BtBRQueue would end up in WAITING_FOR_RECONNECT even though the queue had been disposed, causing AutoConnectIntervalReceiver to schedule reconnects even while bluetooth is already off.
This commit is contained in:
@@ -186,7 +186,7 @@ public final class BtBRQueue {
|
|||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
if (!GBApplication.getPrefs().getAutoReconnect(mGbDevice)) {
|
if (mDisposed.get() || !GBApplication.getPrefs().getAutoReconnect(mGbDevice)) {
|
||||||
mGbDevice.setUpdateState(GBDevice.State.NOT_CONNECTED, mContext);
|
mGbDevice.setUpdateState(GBDevice.State.NOT_CONNECTED, mContext);
|
||||||
} else {
|
} else {
|
||||||
mGbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, mContext);
|
mGbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, mContext);
|
||||||
@@ -196,7 +196,7 @@ public final class BtBRQueue {
|
|||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
if (!GBApplication.getPrefs().getAutoReconnect(mGbDevice)) {
|
if (mDisposed.get() || !GBApplication.getPrefs().getAutoReconnect(mGbDevice)) {
|
||||||
mGbDevice.setUpdateState(GBDevice.State.NOT_CONNECTED, mContext);
|
mGbDevice.setUpdateState(GBDevice.State.NOT_CONNECTED, mContext);
|
||||||
} else {
|
} else {
|
||||||
mGbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, mContext);
|
mGbDevice.setUpdateState(GBDevice.State.WAITING_FOR_RECONNECT, mContext);
|
||||||
@@ -298,7 +298,7 @@ public final class BtBRQueue {
|
|||||||
LOG.debug("finished thread {}", mWriteHandlerThread.getName());
|
LOG.debug("finished thread {}", mWriteHandlerThread.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mBtSocket != null && mBtSocket.isConnected()) {
|
if (mBtSocket != null) {
|
||||||
try {
|
try {
|
||||||
mBtSocket.close();
|
mBtSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user