From f1736808cbace8a9b5dab00bede139d0b4c6f452 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Wed, 16 May 2018 19:07:41 +0200 Subject: [PATCH] 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 --- .../gadgetbridge/externalevents/AutoStartReceiver.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AutoStartReceiver.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AutoStartReceiver.java index 58f1ad894..5fdb1ce6f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AutoStartReceiver.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/AutoStartReceiver.java @@ -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); } }