From ac120dc7d65886bcc4181217dd7eb4a2fc89d579 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Thu, 22 Oct 2015 00:32:16 +0200 Subject: [PATCH] Small improvement to connect() --- .../gadgetbridge/service/btle/BtLEQueue.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java index 8af6f74b6..69d485a12 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BtLEQueue.java @@ -155,12 +155,15 @@ public final class BtLEQueue { } LOG.info("Attempting to connect to " + mGbDevice.getName()); BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteDevice(mGbDevice.getAddress()); + boolean result; synchronized (mGattMonitor) { mBluetoothGatt = remoteDevice.connectGatt(mContext, true, internalGattCallback); - mBluetoothGatt.connect(); + result = mBluetoothGatt.connect(); } - setDeviceConnectionState(State.CONNECTING); - return true; + if (result) { + setDeviceConnectionState(State.CONNECTING); + } + return result; } private void setDeviceConnectionState(State newState) {