| Index: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| diff --git a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| index 6b163d828a2969461823ec1590fbb9d4d8e4a630..88e290f41d7fb6d751fbce861735f768dfecd92a 100644
|
| --- a/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| +++ b/device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java
|
| @@ -59,7 +59,10 @@ final class ChromeBluetoothDevice {
|
| */
|
| @CalledByNative
|
| private void onBluetoothDeviceAndroidDestruction() {
|
| - disconnectGatt();
|
| + if (mBluetoothGatt != null) {
|
| + mBluetoothGatt.close();
|
| + mBluetoothGatt = null;
|
| + }
|
| mNativeBluetoothDeviceAndroid = 0;
|
| }
|
|
|
| @@ -119,6 +122,9 @@ final class ChromeBluetoothDevice {
|
| @CalledByNative
|
| private void createGattConnectionImpl(Context context) {
|
| Log.i(TAG, "connectGatt");
|
| +
|
| + if (mBluetoothGatt != null) mBluetoothGatt.close();
|
| +
|
| // autoConnect set to false as under experimentation using autoConnect failed to complete
|
| // connections.
|
| mBluetoothGatt =
|
| @@ -148,6 +154,11 @@ final class ChromeBluetoothDevice {
|
| : "Disconnected");
|
| if (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED) {
|
| mBluetoothGatt.discoverServices();
|
| + } else if (newState == android.bluetooth.BluetoothProfile.STATE_DISCONNECTED) {
|
| + if (mBluetoothGatt != null) {
|
| + mBluetoothGatt.close();
|
| + mBluetoothGatt = null;
|
| + }
|
| }
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
|
|