chrome: Remove unneeded dependencies on libxml.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_android.cc
blob890244a9f3c755a61d83c1e3f947080bcbd81b3d
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 "jni/ChromeBluetoothDevice_jni.h"
12 using base::android::AttachCurrentThread;
13 using base::android::AppendJavaStringArrayToStringVector;
15 namespace device {
17 BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create(
18 jobject bluetooth_device_wrapper) { // Java Type: bluetoothDeviceWrapper
19 BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid();
21 device->j_device_.Reset(Java_ChromeBluetoothDevice_create(
22 AttachCurrentThread(), bluetooth_device_wrapper));
24 return device;
27 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
30 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) {
31 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs(
32 AttachCurrentThread(), j_device_.obj(), advertised_uuids);
35 // static
36 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
37 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
40 uint32 BluetoothDeviceAndroid::GetBluetoothClass() const {
41 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(),
42 j_device_.obj());
45 std::string BluetoothDeviceAndroid::GetAddress() const {
46 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress(
47 AttachCurrentThread(), j_device_.obj()));
50 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource()
51 const {
52 // Android API does not provide Vendor ID.
53 return VENDOR_ID_UNKNOWN;
56 uint16 BluetoothDeviceAndroid::GetVendorID() const {
57 // Android API does not provide Vendor ID.
58 return 0;
61 uint16 BluetoothDeviceAndroid::GetProductID() const {
62 // Android API does not provide Product ID.
63 return 0;
66 uint16 BluetoothDeviceAndroid::GetDeviceID() const {
67 // Android API does not provide Device ID.
68 return 0;
71 bool BluetoothDeviceAndroid::IsPaired() const {
72 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(),
73 j_device_.obj());
76 bool BluetoothDeviceAndroid::IsConnected() const {
77 NOTIMPLEMENTED();
78 return false;
81 bool BluetoothDeviceAndroid::IsConnectable() const {
82 NOTIMPLEMENTED();
83 return false;
86 bool BluetoothDeviceAndroid::IsConnecting() const {
87 NOTIMPLEMENTED();
88 return false;
91 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
92 JNIEnv* env = AttachCurrentThread();
93 std::vector<std::string> uuid_strings;
94 AppendJavaStringArrayToStringVector(
95 env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(),
96 &uuid_strings);
97 BluetoothDevice::UUIDList uuids;
98 uuids.reserve(uuid_strings.size());
99 for (auto uuid_string : uuid_strings) {
100 uuids.push_back(BluetoothUUID(uuid_string));
102 return uuids;
105 int16 BluetoothDeviceAndroid::GetInquiryRSSI() const {
106 NOTIMPLEMENTED();
107 return kUnknownPower;
110 int16 BluetoothDeviceAndroid::GetInquiryTxPower() const {
111 NOTIMPLEMENTED();
112 return kUnknownPower;
115 bool BluetoothDeviceAndroid::ExpectingPinCode() const {
116 NOTIMPLEMENTED();
117 return false;
120 bool BluetoothDeviceAndroid::ExpectingPasskey() const {
121 NOTIMPLEMENTED();
122 return false;
125 bool BluetoothDeviceAndroid::ExpectingConfirmation() const {
126 NOTIMPLEMENTED();
127 return false;
130 void BluetoothDeviceAndroid::GetConnectionInfo(
131 const ConnectionInfoCallback& callback) {
132 NOTIMPLEMENTED();
133 callback.Run(ConnectionInfo());
136 void BluetoothDeviceAndroid::Connect(
137 PairingDelegate* pairing_delegate,
138 const base::Closure& callback,
139 const ConnectErrorCallback& error_callback) {
140 NOTIMPLEMENTED();
143 void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) {
144 NOTIMPLEMENTED();
147 void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) {
148 NOTIMPLEMENTED();
151 void BluetoothDeviceAndroid::ConfirmPairing() {
152 NOTIMPLEMENTED();
155 void BluetoothDeviceAndroid::RejectPairing() {
156 NOTIMPLEMENTED();
159 void BluetoothDeviceAndroid::CancelPairing() {
160 NOTIMPLEMENTED();
163 void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback,
164 const ErrorCallback& error_callback) {
165 NOTIMPLEMENTED();
168 void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) {
169 NOTIMPLEMENTED();
172 void BluetoothDeviceAndroid::ConnectToService(
173 const BluetoothUUID& uuid,
174 const ConnectToServiceCallback& callback,
175 const ConnectToServiceErrorCallback& error_callback) {
176 NOTIMPLEMENTED();
179 void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
180 const BluetoothUUID& uuid,
181 const ConnectToServiceCallback& callback,
182 const ConnectToServiceErrorCallback& error_callback) {
183 NOTIMPLEMENTED();
186 void BluetoothDeviceAndroid::CreateGattConnection(
187 const GattConnectionCallback& callback,
188 const ConnectErrorCallback& error_callback) {
189 NOTIMPLEMENTED();
192 BluetoothDeviceAndroid::BluetoothDeviceAndroid() {
195 std::string BluetoothDeviceAndroid::GetDeviceName() const {
196 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
197 AttachCurrentThread(), j_device_.obj()));
200 } // namespace device