1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-01 06:22:55 +01:00

Auto connect at boot on recent androids respecting the user settings

Automatically connect at boot if gadgetbridge is configured to start at
boot and to attempt an automatic connection when bluetooth is available

Fixes #693 and fixes #891
This commit is contained in:
Daniele Gobbetti 2018-05-16 19:07:41 +02:00
parent 65b0d9da4b
commit f1736808cb

View File

@ -32,7 +32,13 @@ public class AutoStartReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
if (GBApplication.getGBPrefs().getAutoStart() && Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
Log.i(TAG, "Boot completed, starting Gadgetbridge");
GBApplication.deviceService().start();
if (GBApplication.getPrefs().getBoolean("general_autoconnectonbluetooth", false)) {
Log.i(TAG, "Autoconnect is enabled, attempting to connect");
GBApplication.deviceService().connect();
} else {
GBApplication.deviceService().start();
}
PeriodicExporter.enablePeriodicExport(context);
}
}