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

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

Issue 1712593002: bluetooth: android: Confirm the notify session after the descriptor has been written. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added the comment that Gio requested Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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;
11 import android.os.ParcelUuid; 11 import android.os.ParcelUuid;
12 12
13 import org.chromium.base.Log; 13 import org.chromium.base.Log;
14 import org.chromium.base.ThreadUtils; 14 import org.chromium.base.ThreadUtils;
15 import org.chromium.base.annotations.CalledByNative; 15 import org.chromium.base.annotations.CalledByNative;
16 import org.chromium.base.annotations.JNINamespace; 16 import org.chromium.base.annotations.JNINamespace;
17 17
18 import java.util.HashMap; 18 import java.util.HashMap;
19 import java.util.HashSet; 19 import java.util.HashSet;
20 import java.util.List; 20 import java.util.List;
21 import java.util.UUID;
21 22
22 /** 23 /**
23 * Exposes android.bluetooth.BluetoothDevice as necessary for C++ 24 * Exposes android.bluetooth.BluetoothDevice as necessary for C++
24 * device::BluetoothDeviceAndroid. 25 * device::BluetoothDeviceAndroid.
25 * 26 *
26 * Lifetime is controlled by device::BluetoothDeviceAndroid. 27 * Lifetime is controlled by device::BluetoothDeviceAndroid.
27 */ 28 */
28 @JNINamespace("device") 29 @JNINamespace("device")
29 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 30 @TargetApi(Build.VERSION_CODES.LOLLIPOP)
30 final class ChromeBluetoothDevice { 31 final class ChromeBluetoothDevice {
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 if (chromeCharacteristic == null) { 249 if (chromeCharacteristic == null) {
249 // Android events arriving with no Chrome object is expe cted rarely: only 250 // Android events arriving with no Chrome object is expe cted rarely: only
250 // when the event races object destruction. 251 // when the event races object destruction.
251 Log.v(TAG, "onCharacteristicWrite when chromeCharacteris tic == null."); 252 Log.v(TAG, "onCharacteristicWrite when chromeCharacteris tic == null.");
252 } else { 253 } else {
253 chromeCharacteristic.onCharacteristicWrite(status); 254 chromeCharacteristic.onCharacteristicWrite(status);
254 } 255 }
255 } 256 }
256 }); 257 });
257 } 258 }
259
260 @Override
261 public void onDescriptorRead(
262 final Wrappers.BluetoothGattDescriptorWrapper descriptor, final int status) {
263 ThreadUtils.runOnUiThread(new Runnable() {
264 @Override
265 public void run() {
266 ChromeBluetoothRemoteGattDescriptor chromeDescriptor =
267 mWrapperToChromeDescriptorsMap.get(descriptor);
268 if (chromeDescriptor == null) {
269 Log.v(TAG, "onDescriptorRead when chromeDescriptor == nu ll.");
scheib 2016/02/26 04:27:01 Copy the comments from characteristics above as we
tommyt 2016/03/01 14:45:14 Done.
270 } else {
271 chromeDescriptor.onDescriptorRead(status);
272 }
273 }
274 });
275 }
276
277 @Override
278 public void onDescriptorWrite(
279 final Wrappers.BluetoothGattDescriptorWrapper descriptor, final int status) {
280 ThreadUtils.runOnUiThread(new Runnable() {
281 @Override
282 public void run() {
283 if (descriptor.getUuid().equals(
284 UUID.fromString("00002902-0000-1000-8000-00805F9 B34FB"))) {
scheib 2016/02/26 04:27:01 // If this is the Client Configuration Characteris
tommyt 2016/03/01 14:45:14 Done.
285 ChromeBluetoothRemoteGattCharacteristic chromeCharacteri stic =
286 mWrapperToChromeCharacteristicsMap.get(
287 descriptor.getCharacteristic());
288 if (chromeCharacteristic != null
289 && chromeCharacteristic.onStartNotifySession(sta tus)) {
290 return;
291 }
292 }
293
294 ChromeBluetoothRemoteGattDescriptor chromeDescriptor =
295 mWrapperToChromeDescriptorsMap.get(descriptor);
296 if (chromeDescriptor == null) {
297 Log.v(TAG, "onDescriptorWrite when chromeDescriptor == n ull.");
298 } else {
299 chromeDescriptor.onDescriptorWrite(status);
300 }
301 }
302 });
303 }
258 } 304 }
259 305
260 // ------------------------------------------------------------------------- -------------------- 306 // ------------------------------------------------------------------------- --------------------
261 // BluetoothAdapterDevice C++ methods declared for access from java: 307 // BluetoothAdapterDevice C++ methods declared for access from java:
262 308
263 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange. 309 // Binds to BluetoothDeviceAndroid::OnConnectionStateChange.
264 private native void nativeOnConnectionStateChange( 310 private native void nativeOnConnectionStateChange(
265 long nativeBluetoothDeviceAndroid, int status, boolean connected); 311 long nativeBluetoothDeviceAndroid, int status, boolean connected);
266 312
267 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. 313 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService.
268 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed. 314 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed.
269 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android, 315 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android,
270 String instanceId, Object bluetoothGattServiceWrapper); 316 String instanceId, Object bluetoothGattServiceWrapper);
271 317
272 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered. 318 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered.
273 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid); 319 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid);
274 } 320 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698