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

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

Issue 1389553002: bluetooth: Detect and fix incorrect thread usage of BluetoothDispatcherHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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 fc76c3220ad0f89226b4a4357c0aee012d654821..3d1007b98fa453cd4651550e7d31be762e310347 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
@@ -11,6 +11,7 @@ import android.os.Build;
import android.os.ParcelUuid;
import org.chromium.base.Log;
+import org.chromium.base.ThreadUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
@@ -133,14 +134,19 @@ final class ChromeBluetoothDevice {
// Implements callbacks related to a GATT connection.
private class BluetoothGattCallbackImpl extends Wrappers.BluetoothGattCallbackWrapper {
@Override
- public void onConnectionStateChange(int status, int newState) {
+ public void onConnectionStateChange(final int status, final int newState) {
Log.i(TAG, "onConnectionStateChange status:%d newState:%s", status,
(newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED)
? "Connected"
: "Disconnected");
if (mNativeBluetoothDeviceAndroid != 0) {
qinmin 2015/10/05 18:38:54 this is not threadsafe, see my comments below
scheib 2015/10/05 21:01:33 Done.
- nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
- newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
+ ThreadUtils.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ nativeOnConnectionStateChange(mNativeBluetoothDeviceAndroid, status,
qinmin 2015/10/05 18:38:54 when this gets called, mNativeBluetoothDeviceAndro
scheib 2015/10/05 21:01:33 Done.
+ newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED);
+ }
+ });
}
}
}

Powered by Google App Engine
This is Rietveld 408576698