mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Device connection: allow to disconnect from scanned devices
This commit is contained in:
parent
7816e131e9
commit
3ceba883dd
@ -694,6 +694,18 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void handleAction(Intent intent, String action, GBDevice device) throws DeviceNotFoundException {
|
private void handleAction(Intent intent, String action, GBDevice device) throws DeviceNotFoundException {
|
||||||
|
if(ACTION_DISCONNECT.equals(intent.getAction())) {
|
||||||
|
try {
|
||||||
|
removeDeviceSupport(device);
|
||||||
|
} catch (DeviceNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
device.setState(GBDevice.State.NOT_CONNECTED);
|
||||||
|
device.sendDeviceUpdateIntent(this);
|
||||||
|
updateReceiversState();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceSupport deviceSupport = getDeviceSupport(device);
|
DeviceSupport deviceSupport = getDeviceSupport(device);
|
||||||
|
|
||||||
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
Prefs devicePrefs = new Prefs(GBApplication.getDeviceSpecificSharedPrefs(device.getAddress()));
|
||||||
@ -796,16 +808,6 @@ public class DeviceCommunicationService extends Service implements SharedPrefere
|
|||||||
deviceSupport.onFetchRecordedData(dataTypes);
|
deviceSupport.onFetchRecordedData(dataTypes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_DISCONNECT:
|
|
||||||
try {
|
|
||||||
removeDeviceSupport(device);
|
|
||||||
} catch (DeviceNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
device.setState(GBDevice.State.NOT_CONNECTED);
|
|
||||||
device.sendDeviceUpdateIntent(this);
|
|
||||||
updateReceiversState();
|
|
||||||
break;
|
|
||||||
case ACTION_FIND_DEVICE: {
|
case ACTION_FIND_DEVICE: {
|
||||||
boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false);
|
boolean start = intent.getBooleanExtra(EXTRA_FIND_START, false);
|
||||||
deviceSupport.onFindDevice(start);
|
deviceSupport.onFindDevice(start);
|
||||||
|
Loading…
Reference in New Issue
Block a user