Chromium Code Reviews| 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); |
| + } |
| + }); |
| } |
| } |
| } |