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

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

Issue 1394973003: bluetooth: android: Create BluetoothRemoteGattServiceAndroid objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-renames-
Patch Set: Address ortuno 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 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);
}
« no previous file with comments | « device/bluetooth/BUILD.gn ('k') | device/bluetooth/android/java/src/org/chromium/device/bluetooth/Wrappers.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698