mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-02-04 13:04:08 +01:00
Device connection: stop ScanService when quitting application
This commit is contained in:
parent
f5213f39f7
commit
7816e131e9
@ -289,6 +289,7 @@ public class BLEScanService extends Service {
|
|||||||
BroadcastReceiver deviceStateUpdateReceiver = new BroadcastReceiver() {
|
BroadcastReceiver deviceStateUpdateReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
if(GBDevice.ACTION_DEVICE_CHANGED.equals(intent.getAction())) {
|
||||||
GBDevice.DeviceUpdateSubject subject =
|
GBDevice.DeviceUpdateSubject subject =
|
||||||
(GBDevice.DeviceUpdateSubject)
|
(GBDevice.DeviceUpdateSubject)
|
||||||
intent.getSerializableExtra(GBDevice.EXTRA_UPDATE_SUBJECT);
|
intent.getSerializableExtra(GBDevice.EXTRA_UPDATE_SUBJECT);
|
||||||
@ -297,6 +298,16 @@ public class BLEScanService extends Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
restartScan(true);
|
restartScan(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(GBApplication.ACTION_QUIT.equals(intent.getAction())){
|
||||||
|
LOG.debug("stopping scan service...");
|
||||||
|
if(currentState.isDoingAnyScan()){
|
||||||
|
scanner.stopScan(scanCallback);
|
||||||
|
}
|
||||||
|
stopSelf();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -320,9 +331,12 @@ public class BLEScanService extends Service {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private void registerReceivers(){
|
private void registerReceivers(){
|
||||||
|
IntentFilter filter = new IntentFilter();
|
||||||
|
filter.addAction(GBDevice.ACTION_DEVICE_CHANGED);
|
||||||
|
filter.addAction(GBApplication.ACTION_QUIT);
|
||||||
localBroadcastManager.registerReceiver(
|
localBroadcastManager.registerReceiver(
|
||||||
deviceStateUpdateReceiver,
|
deviceStateUpdateReceiver,
|
||||||
new IntentFilter(GBDevice.ACTION_DEVICE_CHANGED)
|
filter
|
||||||
);
|
);
|
||||||
|
|
||||||
registerReceiver(
|
registerReceiver(
|
||||||
|
Loading…
Reference in New Issue
Block a user