| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (chromeCharacteristic == null) { | 248 if (chromeCharacteristic == null) { |
| 249 // Android events arriving with no Chrome object is expe
cted rarely: only | 249 // Android events arriving with no Chrome object is expe
cted rarely: only |
| 250 // when the event races object destruction. | 250 // when the event races object destruction. |
| 251 Log.v(TAG, "onCharacteristicWrite when chromeCharacteris
tic == null."); | 251 Log.v(TAG, "onCharacteristicWrite when chromeCharacteris
tic == null."); |
| 252 } else { | 252 } else { |
| 253 chromeCharacteristic.onCharacteristicWrite(status); | 253 chromeCharacteristic.onCharacteristicWrite(status); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 }); | 256 }); |
| 257 } | 257 } |
| 258 |
| 259 @Override |
| 260 public void onDescriptorRead( |
| 261 final Wrappers.BluetoothGattDescriptorWrapper descriptor, final
int status) { |
| 262 ThreadUtils.runOnUiThread(new Runnable() { |
| 263 @Override |
| 264 public void run() { |
| 265 ChromeBluetoothRemoteGattDescriptor chromeDescriptor = |
| 266 mWrapperToChromeDescriptorsMap.get(descriptor); |
| 267 if (chromeDescriptor == null) { |
| 268 // Android events arriving with no Chrome object is expe
cted rarely: only |
| 269 // when the event races object destruction. |
| 270 Log.v(TAG, "onDescriptorRead when chromeDescriptor == nu
ll."); |
| 271 } else { |
| 272 chromeDescriptor.onDescriptorRead(status); |
| 273 } |
| 274 } |
| 275 }); |
| 276 } |
| 277 |
| 278 @Override |
| 279 public void onDescriptorWrite( |
| 280 final Wrappers.BluetoothGattDescriptorWrapper descriptor, final
int status) { |
| 281 ThreadUtils.runOnUiThread(new Runnable() { |
| 282 @Override |
| 283 public void run() { |
| 284 ChromeBluetoothRemoteGattDescriptor chromeDescriptor = |
| 285 mWrapperToChromeDescriptorsMap.get(descriptor); |
| 286 if (chromeDescriptor == null) { |
| 287 // Android events arriving with no Chrome object is expe
cted rarely: only |
| 288 // when the event races object destruction. |
| 289 Log.v(TAG, "onDescriptorWrite when chromeDescriptor == n
ull."); |
| 290 } else { |
| 291 chromeDescriptor.onDescriptorWrite(status); |
| 292 } |
| 293 } |
| 294 }); |
| 295 } |
| 258 } | 296 } |
| 259 | 297 |
| 260 // -------------------------------------------------------------------------
-------------------- | 298 // -------------------------------------------------------------------------
-------------------- |
| 261 // BluetoothAdapterDevice C++ methods declared for access from java: | 299 // BluetoothAdapterDevice C++ methods declared for access from java: |
| 262 | 300 |
| 263 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange. | 301 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange. |
| 264 private native void nativeOnConnectionStateChange( | 302 private native void nativeOnConnectionStateChange( |
| 265 long nativeBluetoothDeviceAndroid, int status, boolean connected); | 303 long nativeBluetoothDeviceAndroid, int status, boolean connected); |
| 266 | 304 |
| 267 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. | 305 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. |
| 268 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J
NI fixed. | 306 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J
NI fixed. |
| 269 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice
Android, | 307 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice
Android, |
| 270 String instanceId, Object bluetoothGattServiceWrapper); | 308 String instanceId, Object bluetoothGattServiceWrapper); |
| 271 | 309 |
| 272 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered. | 310 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered. |
| 273 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic
eAndroid); | 311 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic
eAndroid); |
| 274 } | 312 } |
| OLD | NEW |