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:
José Rebelo
2026-05-30 00:57:39 +01:00
parent 35d5774c2a
commit ff00649efa
@@ -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) {