Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2989)

Unified Diff: device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothDevice.java

Issue 1618273002: Call BluetoothGatt#close() after disconnecting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call parent class' TearDown Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « no previous file | device/bluetooth/android/java/src/org/chromium/device/bluetooth/ChromeBluetoothRemoteGattCharacteristic.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698