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

Side by Side Diff: device/bluetooth/bluetooth_device_android.cc

Issue 1215303006: bluetooth: android: Initial BluetoothDeviceAndroid implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bta-discovery-
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "device/bluetooth/bluetooth_device_android.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_string.h"
9 #include "jni/ChromeBluetoothDevice_jni.h"
10
11 using base::android::AttachCurrentThread;
12
13 namespace device {
14
15 BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create(
16 jobject java_bluetooth_device_wrapper) {
17 BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid();
18
19 device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
20 AttachCurrentThread(), java_bluetooth_device_wrapper));
21
22 return device;
23 }
24
25 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
26 }
27
28 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) {
29 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs(
30 AttachCurrentThread(), j_device_.obj(), advertised_uuids);
31 }
32
33 // static
34 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
35 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
36 }
37
38 uint32 BluetoothDeviceAndroid::GetBluetoothClass() const {
39 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(),
40 j_device_.obj());
41 }
42
43 std::string BluetoothDeviceAndroid::GetAddress() const {
44 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress(
45 AttachCurrentThread(), j_device_.obj()));
46 }
47
48 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource()
49 const {
50 // Android API does not provide Vendor ID.
51 return VENDOR_ID_UNKNOWN;
52 }
53
54 uint16 BluetoothDeviceAndroid::GetVendorID() const {
55 // Android API does not provide Vendor ID.
56 return 0;
57 }
58
59 uint16 BluetoothDeviceAndroid::GetProductID() const {
60 // Android API does not provide Product ID.
61 return 0;
62 }
63
64 uint16 BluetoothDeviceAndroid::GetDeviceID() const {
65 // Android API does not provide Device ID.
66 return 0;
67 }
68
69 bool BluetoothDeviceAndroid::IsPaired() const {
70 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(),
71 j_device_.obj());
72 }
73
74 bool BluetoothDeviceAndroid::IsConnected() const {
75 NOTIMPLEMENTED();
76 return false;
77 }
78
79 bool BluetoothDeviceAndroid::IsConnectable() const {
80 NOTIMPLEMENTED();
81 return false;
82 }
83
84 bool BluetoothDeviceAndroid::IsConnecting() const {
85 NOTIMPLEMENTED();
86 return false;
87 }
88
89 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
90 int number_of_uuids = Java_ChromeBluetoothDevice_getUuidsCount(
91 AttachCurrentThread(), j_device_.obj());
92 BluetoothDevice::UUIDList uuids;
93 uuids.reserve(number_of_uuids);
94 for (int i = 0; i < number_of_uuids; i++) {
scheib 2015/07/06 23:10:43 Use AppendJavaStringArrayToStringVector instead.
scheib 2015/07/08 00:49:10 Done.
95 std::string uuid_string =
96 ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getUuid(
97 AttachCurrentThread(), j_device_.obj(), i));
98 uuids.push_back(BluetoothUUID(uuid_string));
99 }
100 return uuids;
101 }
102
103 int16 BluetoothDeviceAndroid::GetInquiryRSSI() const {
104 NOTIMPLEMENTED();
105 return kUnknownPower;
106 }
107
108 int16 BluetoothDeviceAndroid::GetInquiryTxPower() const {
109 NOTIMPLEMENTED();
110 return kUnknownPower;
111 }
112
113 bool BluetoothDeviceAndroid::ExpectingPinCode() const {
114 NOTIMPLEMENTED();
115 return false;
116 }
117
118 bool BluetoothDeviceAndroid::ExpectingPasskey() const {
119 NOTIMPLEMENTED();
120 return false;
121 }
122
123 bool BluetoothDeviceAndroid::ExpectingConfirmation() const {
124 NOTIMPLEMENTED();
125 return false;
126 }
127
128 void BluetoothDeviceAndroid::GetConnectionInfo(
129 const ConnectionInfoCallback& callback) {
130 NOTIMPLEMENTED();
131 callback.Run(ConnectionInfo());
132 }
133
134 void BluetoothDeviceAndroid::Connect(
135 PairingDelegate* pairing_delegate,
136 const base::Closure& callback,
137 const ConnectErrorCallback& error_callback) {
138 NOTIMPLEMENTED();
139 }
140
141 void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) {
142 NOTIMPLEMENTED();
143 }
144
145 void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) {
146 NOTIMPLEMENTED();
147 }
148
149 void BluetoothDeviceAndroid::ConfirmPairing() {
150 NOTIMPLEMENTED();
151 }
152
153 void BluetoothDeviceAndroid::RejectPairing() {
154 NOTIMPLEMENTED();
155 }
156
157 void BluetoothDeviceAndroid::CancelPairing() {
158 NOTIMPLEMENTED();
159 }
160
161 void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback,
162 const ErrorCallback& error_callback) {
163 NOTIMPLEMENTED();
164 }
165
166 void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) {
167 NOTIMPLEMENTED();
168 }
169
170 void BluetoothDeviceAndroid::ConnectToService(
171 const BluetoothUUID& uuid,
172 const ConnectToServiceCallback& callback,
173 const ConnectToServiceErrorCallback& error_callback) {
174 NOTIMPLEMENTED();
175 }
176
177 void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
178 const BluetoothUUID& uuid,
179 const ConnectToServiceCallback& callback,
180 const ConnectToServiceErrorCallback& error_callback) {
181 NOTIMPLEMENTED();
182 }
183
184 void BluetoothDeviceAndroid::CreateGattConnection(
185 const GattConnectionCallback& callback,
186 const ConnectErrorCallback& error_callback) {
187 NOTIMPLEMENTED();
188 }
189
190 BluetoothDeviceAndroid::BluetoothDeviceAndroid() {
191 }
192
193 std::string BluetoothDeviceAndroid::GetDeviceName() const {
194 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
195 AttachCurrentThread(), j_device_.obj()));
196 }
197
198 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698