Roll src/third_party/WebKit 605a979:06cb9e9 (svn 202556:202558)
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_android.cc
blobfb0ea7f06fdb4789d8cb31b41ddbaefc316f09d5
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.
5 #include "device/bluetooth/bluetooth_device_android.h"
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "base/android/jni_string.h"
10 #include "device/bluetooth/bluetooth_adapter_android.h"
11 #include "jni/ChromeBluetoothDevice_jni.h"
13 using base::android::AttachCurrentThread;
14 using base::android::AppendJavaStringArrayToStringVector;
16 namespace device {
18 BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create(
19 BluetoothAdapterAndroid* adapter,
20 jobject bluetooth_device_wrapper) { // Java Type: bluetoothDeviceWrapper
21 BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid(adapter);
23 device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
24 AttachCurrentThread(), bluetooth_device_wrapper));
26 return device;
29 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
32 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) {
33 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs(
34 AttachCurrentThread(), j_device_.obj(), advertised_uuids);
37 // static
38 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
39 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
42 uint32 BluetoothDeviceAndroid::GetBluetoothClass() const {
43 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(),
44 j_device_.obj());
47 std::string BluetoothDeviceAndroid::GetAddress() const {
48 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress(
49 AttachCurrentThread(), j_device_.obj()));
52 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource()
53 const {
54 // Android API does not provide Vendor ID.
55 return VENDOR_ID_UNKNOWN;
58 uint16 BluetoothDeviceAndroid::GetVendorID() const {
59 // Android API does not provide Vendor ID.
60 return 0;
63 uint16 BluetoothDeviceAndroid::GetProductID() const {
64 // Android API does not provide Product ID.
65 return 0;
68 uint16 BluetoothDeviceAndroid::GetDeviceID() const {
69 // Android API does not provide Device ID.
70 return 0;
73 bool BluetoothDeviceAndroid::IsPaired() const {
74 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(),
75 j_device_.obj());
78 bool BluetoothDeviceAndroid::IsConnected() const {
79 NOTIMPLEMENTED();
80 return false;
83 bool BluetoothDeviceAndroid::IsConnectable() const {
84 NOTIMPLEMENTED();
85 return false;
88 bool BluetoothDeviceAndroid::IsConnecting() const {
89 NOTIMPLEMENTED();
90 return false;
93 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
94 JNIEnv* env = AttachCurrentThread();
95 std::vector<std::string> uuid_strings;
96 AppendJavaStringArrayToStringVector(
97 env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(),
98 &uuid_strings);
99 BluetoothDevice::UUIDList uuids;
100 uuids.reserve(uuid_strings.size());
101 for (auto uuid_string : uuid_strings) {
102 uuids.push_back(BluetoothUUID(uuid_string));
104 return uuids;
107 int16 BluetoothDeviceAndroid::GetInquiryRSSI() const {
108 NOTIMPLEMENTED();
109 return kUnknownPower;
112 int16 BluetoothDeviceAndroid::GetInquiryTxPower() const {
113 NOTIMPLEMENTED();
114 return kUnknownPower;
117 bool BluetoothDeviceAndroid::ExpectingPinCode() const {
118 NOTIMPLEMENTED();
119 return false;
122 bool BluetoothDeviceAndroid::ExpectingPasskey() const {
123 NOTIMPLEMENTED();
124 return false;
127 bool BluetoothDeviceAndroid::ExpectingConfirmation() const {
128 NOTIMPLEMENTED();
129 return false;
132 void BluetoothDeviceAndroid::GetConnectionInfo(
133 const ConnectionInfoCallback& callback) {
134 NOTIMPLEMENTED();
135 callback.Run(ConnectionInfo());
138 void BluetoothDeviceAndroid::Connect(
139 PairingDelegate* pairing_delegate,
140 const base::Closure& callback,
141 const ConnectErrorCallback& error_callback) {
142 NOTIMPLEMENTED();
145 void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) {
146 NOTIMPLEMENTED();
149 void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) {
150 NOTIMPLEMENTED();
153 void BluetoothDeviceAndroid::ConfirmPairing() {
154 NOTIMPLEMENTED();
157 void BluetoothDeviceAndroid::RejectPairing() {
158 NOTIMPLEMENTED();
161 void BluetoothDeviceAndroid::CancelPairing() {
162 NOTIMPLEMENTED();
165 void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback,
166 const ErrorCallback& error_callback) {
167 NOTIMPLEMENTED();
170 void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) {
171 NOTIMPLEMENTED();
174 void BluetoothDeviceAndroid::ConnectToService(
175 const BluetoothUUID& uuid,
176 const ConnectToServiceCallback& callback,
177 const ConnectToServiceErrorCallback& error_callback) {
178 NOTIMPLEMENTED();
181 void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
182 const BluetoothUUID& uuid,
183 const ConnectToServiceCallback& callback,
184 const ConnectToServiceErrorCallback& error_callback) {
185 NOTIMPLEMENTED();
188 void BluetoothDeviceAndroid::CreateGattConnection(
189 const GattConnectionCallback& callback,
190 const ConnectErrorCallback& error_callback) {
191 NOTIMPLEMENTED();
194 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
195 : BluetoothDevice(adapter) {}
197 std::string BluetoothDeviceAndroid::GetDeviceName() const {
198 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
199 AttachCurrentThread(), j_device_.obj()));
202 } // namespace device