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

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

Issue 2706763002: bluetooth: Increase min api for Android (Closed)
Patch Set: bluetooth: Increase min API Created 3 years, 8 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
« no previous file with comments | « no previous file | device/bluetooth/android/java/src/org/chromium/device/bluetooth/Wrappers.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11
12 import org.chromium.base.Log; 12 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 14 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.base.metrics.RecordHistogram; 15 import org.chromium.base.metrics.RecordHistogram;
16 16
17 import java.util.HashMap; 17 import java.util.HashMap;
18 18
19 /** 19 /**
20 * Exposes android.bluetooth.BluetoothDevice as necessary for C++ 20 * Exposes android.bluetooth.BluetoothDevice as necessary for C++
21 * device::BluetoothDeviceAndroid. 21 * device::BluetoothDeviceAndroid.
22 * 22 *
23 * Lifetime is controlled by device::BluetoothDeviceAndroid. 23 * Lifetime is controlled by device::BluetoothDeviceAndroid.
24 */ 24 */
25 @JNINamespace("device") 25 @JNINamespace("device")
26 @TargetApi(Build.VERSION_CODES.LOLLIPOP) 26 @TargetApi(Build.VERSION_CODES.M)
27 final class ChromeBluetoothDevice { 27 final class ChromeBluetoothDevice {
28 private static final String TAG = "Bluetooth"; 28 private static final String TAG = "Bluetooth";
29 29
30 private long mNativeBluetoothDeviceAndroid; 30 private long mNativeBluetoothDeviceAndroid;
31 final Wrappers.BluetoothDeviceWrapper mDevice; 31 final Wrappers.BluetoothDeviceWrapper mDevice;
32 Wrappers.BluetoothGattWrapper mBluetoothGatt; 32 Wrappers.BluetoothGattWrapper mBluetoothGatt;
33 private final BluetoothGattCallbackImpl mBluetoothGattCallbackImpl; 33 private final BluetoothGattCallbackImpl mBluetoothGattCallbackImpl;
34 final HashMap<Wrappers.BluetoothGattCharacteristicWrapper, 34 final HashMap<Wrappers.BluetoothGattCharacteristicWrapper,
35 ChromeBluetoothRemoteGattCharacteristic> mWrapperToChromeCharacteris ticsMap; 35 ChromeBluetoothRemoteGattCharacteristic> mWrapperToChromeCharacteris ticsMap;
36 final HashMap<Wrappers.BluetoothGattDescriptorWrapper, ChromeBluetoothRemote GattDescriptor> 36 final HashMap<Wrappers.BluetoothGattDescriptorWrapper, ChromeBluetoothRemote GattDescriptor>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Implements BluetoothDeviceAndroid::CreateGattConnectionImpl. 101 // Implements BluetoothDeviceAndroid::CreateGattConnectionImpl.
102 @CalledByNative 102 @CalledByNative
103 private void createGattConnectionImpl(Context context) { 103 private void createGattConnectionImpl(Context context) {
104 Log.i(TAG, "connectGatt"); 104 Log.i(TAG, "connectGatt");
105 105
106 if (mBluetoothGatt != null) mBluetoothGatt.close(); 106 if (mBluetoothGatt != null) mBluetoothGatt.close();
107 107
108 // autoConnect set to false as under experimentation using autoConnect f ailed to complete 108 // autoConnect set to false as under experimentation using autoConnect f ailed to complete
109 // connections. 109 // connections.
110 mBluetoothGatt = 110 mBluetoothGatt =
111 mDevice.connectGatt(context, false /* autoConnect */, mBluetooth GattCallbackImpl); 111 mDevice.connectGatt(context, false /* autoConnect */, mBluetooth GattCallbackImpl,
112 // Prefer LE for dual-mode devices due to lower energy c onsumption.
scheib 2017/04/11 18:08:19 Let's explain that we don't have any use of Blueto
ortuno 2017/04/11 23:12:47 I am tad confused here 🤔. What exactly should we c
scheib 2017/04/12 01:01:54 Oops, I had forgotten this was just the preferred
113 BluetoothDevice.TRANSPORT_LE);
112 } 114 }
113 115
114 // Implements BluetoothDeviceAndroid::DisconnectGatt. 116 // Implements BluetoothDeviceAndroid::DisconnectGatt.
115 @CalledByNative 117 @CalledByNative
116 private void disconnectGatt() { 118 private void disconnectGatt() {
117 Log.i(TAG, "BluetoothGatt.disconnect"); 119 Log.i(TAG, "BluetoothGatt.disconnect");
118 if (mBluetoothGatt != null) mBluetoothGatt.disconnect(); 120 if (mBluetoothGatt != null) mBluetoothGatt.disconnect();
119 } 121 }
120 122
121 // Implements callbacks related to a GATT connection. 123 // Implements callbacks related to a GATT connection.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 long nativeBluetoothDeviceAndroid, int status, boolean connected); 313 long nativeBluetoothDeviceAndroid, int status, boolean connected);
312 314
313 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService. 315 // Binds to BluetoothDeviceAndroid::CreateGattRemoteService.
314 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed. 316 // TODO(http://crbug.com/505554): Replace 'Object' with specific type when J NI fixed.
315 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android, 317 private native void nativeCreateGattRemoteService(long nativeBluetoothDevice Android,
316 String instanceId, Object bluetoothGattServiceWrapper); 318 String instanceId, Object bluetoothGattServiceWrapper);
317 319
318 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered. 320 // Binds to BluetoothDeviceAndroid::GattServicesDiscovered.
319 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid); 321 private native void nativeOnGattServicesDiscovered(long nativeBluetoothDevic eAndroid);
320 } 322 }
OLDNEW
« no previous file with comments | « no previous file | 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