| 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 3cb350333c096ac48063252393b9d9bf83876ea4..037cd959578654e34cf89dca153e408f8a260a35 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
|
| @@ -139,6 +139,9 @@ final class ChromeBluetoothDevice {
|
| (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED)
|
| ? "Connected"
|
| : "Disconnected");
|
| + if (newState == android.bluetooth.BluetoothProfile.STATE_CONNECTED) {
|
| + mBluetoothGatt.discoverServices();
|
| + }
|
| ThreadUtils.runOnUiThread(new Runnable() {
|
| @Override
|
| public void run() {
|
| @@ -149,6 +152,24 @@ final class ChromeBluetoothDevice {
|
| }
|
| });
|
| }
|
| +
|
| + @Override
|
| + public void onServicesDiscovered(final int status) {
|
| + Log.i(TAG, "onServicesDiscovered status:%d==%s", status,
|
| + status == android.bluetooth.BluetoothGatt.GATT_SUCCESS ? "OK" : "Error");
|
| + ThreadUtils.runOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + if (mNativeBluetoothDeviceAndroid != 0) {
|
| + for (Wrappers.BluetoothGattServiceWrapper service :
|
| + mBluetoothGatt.getServices()) {
|
| + nativeCreateGattRemoteService(mNativeBluetoothDeviceAndroid,
|
| + service.getInstanceId(), service);
|
| + }
|
| + }
|
| + }
|
| + });
|
| + }
|
| }
|
|
|
| // ---------------------------------------------------------------------------------------------
|
| @@ -157,4 +178,11 @@ final class ChromeBluetoothDevice {
|
| // Binds to BluetoothDeviceAndroid::OnConnectionStateChange.
|
| private native void nativeOnConnectionStateChange(
|
| long nativeBluetoothDeviceAndroid, int status, boolean connected);
|
| +
|
| + // Binds to BluetoothDeviceAndroid::CreateGattRemoteService.
|
| + // 'Object' type must be used for |bluetoothGattServiceWrapper| because inner class
|
| + // Wrappers.BluetoothGattServiceWrapper reference is not handled by jni_generator.py JavaToJni.
|
| + // http://crbug.com/505554
|
| + private native void nativeCreateGattRemoteService(
|
| + long nativeBluetoothDeviceAndroid, int instanceId, Object bluetoothGattServiceWrapper);
|
| }
|
|
|