| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.device.bluetooth; | 5 package org.chromium.device.bluetooth; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.bluetooth.BluetoothDevice; | 8 import android.bluetooth.BluetoothDevice; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 @Override | 156 @Override |
| 157 public void onServicesDiscovered(final int status) { | 157 public void onServicesDiscovered(final int status) { |
| 158 Log.i(TAG, "onServicesDiscovered status:%d==%s", status, | 158 Log.i(TAG, "onServicesDiscovered status:%d==%s", status, |
| 159 status == android.bluetooth.BluetoothGatt.GATT_SUCCESS ? "OK
" : "Error"); | 159 status == android.bluetooth.BluetoothGatt.GATT_SUCCESS ? "OK
" : "Error"); |
| 160 ThreadUtils.runOnUiThread(new Runnable() { | 160 ThreadUtils.runOnUiThread(new Runnable() { |
| 161 @Override | 161 @Override |
| 162 public void run() { | 162 public void run() { |
| 163 if (mNativeBluetoothDeviceAndroid != 0) { | 163 if (mNativeBluetoothDeviceAndroid != 0) { |
| 164 for (Wrappers.BluetoothGattServiceWrapper service : | 164 for (Wrappers.BluetoothGattServiceWrapper service : |
| 165 mBluetoothGatt.getServices()) { | 165 mBluetoothGatt.getServices()) { |
| 166 nativeCreateGattRemoteService(mNativeBluetoothDevice
Android, | 166 // Create a device unique service ID. getInstanceId
only differs |
| 167 service.getInstanceId(), service); | 167 // between service instances with the same UUID. |
| 168 String serviceInstanceId = |
| 169 service.getUuid().toString() + service.getIn
stanceId(); |
| 170 nativeCreateGattRemoteService( |
| 171 mNativeBluetoothDeviceAndroid, serviceInstan
ceId, service); |
| 168 } | 172 } |
| 169 } | 173 } |
| 170 } | 174 } |
| 171 }); | 175 }); |
| 172 } | 176 } |
| 173 } | 177 } |
| 174 | 178 |
| 175 // -------------------------------------------------------------------------
-------------------- | 179 // -------------------------------------------------------------------------
-------------------- |
| 176 // BluetoothAdapterDevice C++ methods declared for access from java: | 180 // BluetoothAdapterDevice C++ methods declared for access from java: |
| 177 | 181 |
| 178 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange. | 182 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange. |
| 179 private native void nativeOnConnectionStateChange( | 183 private native void nativeOnConnectionStateChange( |
| 180 long nativeBluetoothDeviceAndroid, int status, boolean connected); | 184 long nativeBluetoothDeviceAndroid, int status, boolean connected); |
| 181 | 185 |
| 182 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. | 186 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. |
| 183 // 'Object' type must be used for |bluetoothGattServiceWrapper| because inne
r class | 187 // 'Object' type must be used for |bluetoothGattServiceWrapper| because inne
r class |
| 184 // Wrappers.BluetoothGattServiceWrapper reference is not handled by jni_gene
rator.py JavaToJni. | 188 // Wrappers.BluetoothGattServiceWrapper reference is not handled by jni_gene
rator.py JavaToJni. |
| 185 // http://crbug.com/505554 | 189 // http://crbug.com/505554 |
| 186 private native void nativeCreateGattRemoteService( | 190 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice
Android, |
| 187 long nativeBluetoothDeviceAndroid, int instanceId, Object bluetoothG
attServiceWrapper); | 191 String instanceId, Object bluetoothGattServiceWrapper); |
| 188 } | 192 } |
| OLD | NEW |