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

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

Issue 2702163002: bluetooth: Close and null out BluetoothGatt on the UI Thread (Closed)
Patch Set: Created 3 years, 10 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
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 5ef691323b78b9b97b3d95102d4951adb5d92fab..ee60580c4d72dbfcd1a66c99d9a08d26c85c7469 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
@@ -126,26 +126,27 @@ final class ChromeBluetoothDevice {
(newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED)
? "Connected"
: "Disconnected");
- if (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED) {
- RecordHistogram.recordSparseSlowlyHistogram(
- "Bluetooth.Web.Android.onConnectionStateChange.Status.Connected", status);
- mBluetoothGatt.discoverServices();
- } else if (newState == android.bluetooth.BluetoothProfile.STATE_DISCONNECTED) {
- RecordHistogram.recordSparseSlowlyHistogram(
- "Bluetooth.Web.Android.onConnectionStateChange.Status.Disconnected",
- status);
- if (mBluetoothGatt != null) {
- mBluetoothGatt.close();
- mBluetoothGatt = null;
- }
- } else {
- RecordHistogram.recordSparseSlowlyHistogram(
- "Bluetooth.Web.Android.onConnectionStateChange.Status.InvalidState",
- status);
- }
Wrappers.ThreadUtilsWrapper.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
+ if (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED) {
+ RecordHistogram.recordSparseSlowlyHistogram(
+ "Bluetooth.Web.Android.onConnectionStateChange.Status.Connected",
+ status);
+ mBluetoothGatt.discoverServices();
+ } else if (newState == android.bluetooth.BluetoothProfile.STATE_DISCONNECTED) {
+ RecordHistogram.recordSparseSlowlyHistogram(
+ "Bluetooth.Web.Android.onConnectionStateChange.Status.Disconnected",
+ status);
+ if (mBluetoothGatt != null) {
+ mBluetoothGatt.close();
+ mBluetoothGatt = null;
+ }
+ } else {
+ RecordHistogram.recordSparseSlowlyHistogram(
+ "Bluetooth.Web.Android.onConnectionStateChange.Status.InvalidState",
+ status);
+ }
if (mNativeBluetoothDeviceAndroid != 0) {
nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);

Powered by Google App Engine
This is Rietveld 408576698