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

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

Issue 1369463004: bluetooth: android: Disconnect GATT upon BluetoothDeviceAndroid object destruction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/bluetooth_device_android.cc » ('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 925d78fb68327b700048104cbb50c73474b35068..fc76c3220ad0f89226b4a4357c0aee012d654821 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
@@ -27,7 +27,7 @@ import java.util.List;
final class ChromeBluetoothDevice {
private static final String TAG = "Bluetooth";
- private final long mNativeBluetoothDeviceAndroid;
+ private long mNativeBluetoothDeviceAndroid;
final Wrappers.BluetoothDeviceWrapper mDevice;
private List<ParcelUuid> mUuidsFromScan;
Wrappers.BluetoothGattWrapper mBluetoothGatt;
@@ -41,6 +41,15 @@ final class ChromeBluetoothDevice {
Log.v(TAG, "ChromeBluetoothDevice created.");
}
+ /**
+ * Handles C++ object being destroyed.
+ */
+ @CalledByNative
+ private void onBluetoothDeviceAndroidDestruction() {
+ disconnectGatt();
+ mNativeBluetoothDeviceAndroid = 0;
+ }
+
// ---------------------------------------------------------------------------------------------
// BluetoothDeviceAndroid methods implemented in java:
@@ -112,7 +121,7 @@ final class ChromeBluetoothDevice {
@CalledByNative
private void disconnectGatt() {
Log.i(TAG, "BluetoothGatt.disconnect");
- mBluetoothGatt.disconnect();
+ if (mBluetoothGatt != null) mBluetoothGatt.disconnect();
}
// Implements BluetoothDeviceAndroid::GetDeviceName.
@@ -129,8 +138,10 @@ final class ChromeBluetoothDevice {
(newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED)
? "Connected"
: "Disconnected");
- nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
- newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
+ if (mNativeBluetoothDeviceAndroid != 0) {
+ nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
+ newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
+ }
}
}
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698