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

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

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: jyasskin comments addressed. Pass UUIDs by array. Added more tests. Created 5 years, 5 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.Manifest; 7 import android.Manifest;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.bluetooth.BluetoothAdapter; 9 import android.bluetooth.BluetoothAdapter;
10 import android.bluetooth.BluetoothDevice; 10 import android.bluetooth.BluetoothDevice;
11 import android.bluetooth.le.BluetoothLeScanner; 11 import android.bluetooth.le.BluetoothLeScanner;
12 import android.bluetooth.le.ScanCallback; 12 import android.bluetooth.le.ScanCallback;
13 import android.bluetooth.le.ScanFilter; 13 import android.bluetooth.le.ScanFilter;
14 import android.bluetooth.le.ScanResult; 14 import android.bluetooth.le.ScanResult;
15 import android.bluetooth.le.ScanSettings; 15 import android.bluetooth.le.ScanSettings;
16 import android.content.Context; 16 import android.content.Context;
17 import android.content.pm.PackageManager; 17 import android.content.pm.PackageManager;
18 import android.os.Build; 18 import android.os.Build;
19 import android.os.ParcelUuid;
19 20
20 import org.chromium.base.CalledByNative; 21 import org.chromium.base.CalledByNative;
21 import org.chromium.base.JNINamespace; 22 import org.chromium.base.JNINamespace;
22 import org.chromium.base.Log; 23 import org.chromium.base.Log;
23 24
24 import java.util.ArrayList; 25 import java.util.ArrayList;
25 import java.util.List; 26 import java.util.List;
26 27
27 /** 28 /**
28 * Wrapper classes around android.bluetooth.* classes that provide an 29 * Wrapper classes around android.bluetooth.* classes that provide an
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 * Wraps android.bluetooth.BluetoothLeScanner. 125 * Wraps android.bluetooth.BluetoothLeScanner.
125 */ 126 */
126 static class BluetoothLeScannerWrapper { 127 static class BluetoothLeScannerWrapper {
127 private final BluetoothLeScanner mScanner; 128 private final BluetoothLeScanner mScanner;
128 129
129 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) { 130 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) {
130 mScanner = scanner; 131 mScanner = scanner;
131 } 132 }
132 133
133 public void startScan( 134 public void startScan(
134 List<ScanFilter> filters, int scanSettingsScanMode, ScanCallback Wrapper callback) { 135 List<ScanFilter> filters, int scanSettingsScanMode, ScanCallback Wrapper callback) {
Jeffrey Yasskin 2015/07/08 17:19:39 I'm not sure I like the wrapper having logic in it
scheib 2015/07/08 23:02:35 The alternative I thought of is to create a ScanSe
Jeffrey Yasskin 2015/07/08 23:18:24 You don't need to fake the ScanSettings, since it'
scheib 2015/07/08 23:29:05 Previous code that used ScanSettings while using F
Jeffrey Yasskin 2015/07/09 17:04:09 Ah, right, none of the Android classes are availab
scheib 2015/07/09 17:41:31 Classes introduced in later Android versions may n
135 ScanSettings settings = 136 ScanSettings settings =
136 new ScanSettings.Builder().setScanMode(scanSettingsScanMode) .build(); 137 new ScanSettings.Builder().setScanMode(scanSettingsScanMode) .build();
137 mScanner.startScan(filters, settings, callback); 138 mScanner.startScan(filters, settings, callback);
138 } 139 }
139 140
140 public void stopScan(ScanCallbackWrapper callback) { 141 public void stopScan(ScanCallbackWrapper callback) {
141 mScanner.stopScan(callback); 142 mScanner.stopScan(callback);
142 } 143 }
143 } 144 }
144 145
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 static class ScanResultWrapper { 182 static class ScanResultWrapper {
182 private final ScanResult mScanResult; 183 private final ScanResult mScanResult;
183 184
184 public ScanResultWrapper(ScanResult scanResult) { 185 public ScanResultWrapper(ScanResult scanResult) {
185 mScanResult = scanResult; 186 mScanResult = scanResult;
186 } 187 }
187 188
188 public BluetoothDeviceWrapper getDevice() { 189 public BluetoothDeviceWrapper getDevice() {
189 return new BluetoothDeviceWrapper(mScanResult.getDevice()); 190 return new BluetoothDeviceWrapper(mScanResult.getDevice());
190 } 191 }
192
193 public List<ParcelUuid> getScanRecord_getServiceUuids() {
194 return mScanResult.getScanRecord().getServiceUuids();
195 }
191 } 196 }
192 197
193 /** 198 /**
194 * Wraps android.bluetooth.BluetoothDevice. 199 * Wraps android.bluetooth.BluetoothDevice.
195 */ 200 */
196 static class BluetoothDeviceWrapper { 201 static class BluetoothDeviceWrapper {
197 private final BluetoothDevice mDevice; 202 private final BluetoothDevice mDevice;
198 203
199 public BluetoothDeviceWrapper(BluetoothDevice device) { 204 public BluetoothDeviceWrapper(BluetoothDevice device) {
200 mDevice = device; 205 mDevice = device;
201 } 206 }
202 207
203 public String getAddress() { 208 public String getAddress() {
204 return mDevice.getAddress(); 209 return mDevice.getAddress();
205 } 210 }
206 211
212 public int getBluetoothClass_getDeviceClass() {
213 return mDevice.getBluetoothClass().getDeviceClass();
214 }
215
216 public int getBondState() {
217 return mDevice.getBondState();
218 }
219
207 public String getName() { 220 public String getName() {
208 return mDevice.getName(); 221 return mDevice.getName();
209 } 222 }
210 } 223 }
211 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698