mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-14 22:19:29 +01:00
Always cleanup device and receiver in service when disconnecting
Fixes #1093 I have no idea why the code was like this, so the change might have some bad consequences...
This commit is contained in:
parent
00ee9b6828
commit
3f421facab
@ -36,7 +36,7 @@ public class BluetoothStateChangeReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
|
||||
if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) {
|
||||
if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(action)) {
|
||||
if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_ON) {
|
||||
|
||||
Intent refreshIntent = new Intent(DeviceManager.ACTION_REFRESH_DEVICELIST);
|
||||
@ -50,6 +50,7 @@ public class BluetoothStateChangeReceiver extends BroadcastReceiver {
|
||||
LOG.info("Bluetooth turned on => connecting...");
|
||||
GBApplication.deviceService().connect();
|
||||
} else if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_OFF) {
|
||||
LOG.info("Bluetooth turned off => disconnecting...");
|
||||
GBApplication.deviceService().disconnect();
|
||||
}
|
||||
}
|
||||
|
@ -409,11 +409,12 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
||||
}
|
||||
case ACTION_DISCONNECT: {
|
||||
mDeviceSupport.dispose();
|
||||
if (mGBDevice != null && mGBDevice.getState() == GBDevice.State.WAITING_FOR_RECONNECT) {
|
||||
setReceiversEnableState(false, false, null);
|
||||
if (mGBDevice != null) {
|
||||
mGBDevice.setState(GBDevice.State.NOT_CONNECTED);
|
||||
mGBDevice.sendDeviceUpdateIntent(this);
|
||||
}
|
||||
setReceiversEnableState(false, false, null);
|
||||
mGBDevice = null;
|
||||
mDeviceSupport = null;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user