Linux: Depend on liberation-fonts package for RPMs.
[chromium-blink-merge.git] / device / bluetooth / bluetooth_device_android.cc
blob483d95e05a0e4a3d46088439e5df7656f2ed9ffa
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 return IsGattConnected();
82 bool BluetoothDeviceAndroid::IsGattConnected() const {
83 return gatt_connected_;
86 bool BluetoothDeviceAndroid::IsConnectable() const {
87 NOTIMPLEMENTED();
88 return false;
91 bool BluetoothDeviceAndroid::IsConnecting() const {
92 NOTIMPLEMENTED();
93 return false;
96 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
97 JNIEnv* env = AttachCurrentThread();
98 std::vector<std::string> uuid_strings;
99 AppendJavaStringArrayToStringVector(
100 env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(),
101 &uuid_strings);
102 BluetoothDevice::UUIDList uuids;
103 uuids.reserve(uuid_strings.size());
104 for (auto uuid_string : uuid_strings) {
105 uuids.push_back(BluetoothUUID(uuid_string));
107 return uuids;
110 int16 BluetoothDeviceAndroid::GetInquiryRSSI() const {
111 NOTIMPLEMENTED();
112 return kUnknownPower;
115 int16 BluetoothDeviceAndroid::GetInquiryTxPower() const {
116 NOTIMPLEMENTED();
117 return kUnknownPower;
120 bool BluetoothDeviceAndroid::ExpectingPinCode() const {
121 NOTIMPLEMENTED();
122 return false;
125 bool BluetoothDeviceAndroid::ExpectingPasskey() const {
126 NOTIMPLEMENTED();
127 return false;
130 bool BluetoothDeviceAndroid::ExpectingConfirmation() const {
131 NOTIMPLEMENTED();
132 return false;
135 void BluetoothDeviceAndroid::GetConnectionInfo(
136 const ConnectionInfoCallback& callback) {
137 NOTIMPLEMENTED();
138 callback.Run(ConnectionInfo());
141 void BluetoothDeviceAndroid::Connect(
142 PairingDelegate* pairing_delegate,
143 const base::Closure& callback,
144 const ConnectErrorCallback& error_callback) {
145 NOTIMPLEMENTED();
148 void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) {
149 NOTIMPLEMENTED();
152 void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) {
153 NOTIMPLEMENTED();
156 void BluetoothDeviceAndroid::ConfirmPairing() {
157 NOTIMPLEMENTED();
160 void BluetoothDeviceAndroid::RejectPairing() {
161 NOTIMPLEMENTED();
164 void BluetoothDeviceAndroid::CancelPairing() {
165 NOTIMPLEMENTED();
168 void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback,
169 const ErrorCallback& error_callback) {
170 NOTIMPLEMENTED();
173 void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) {
174 NOTIMPLEMENTED();
177 void BluetoothDeviceAndroid::ConnectToService(
178 const BluetoothUUID& uuid,
179 const ConnectToServiceCallback& callback,
180 const ConnectToServiceErrorCallback& error_callback) {
181 NOTIMPLEMENTED();
184 void BluetoothDeviceAndroid::ConnectToServiceInsecurely(
185 const BluetoothUUID& uuid,
186 const ConnectToServiceCallback& callback,
187 const ConnectToServiceErrorCallback& error_callback) {
188 NOTIMPLEMENTED();
191 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
192 : BluetoothDevice(adapter) {}
194 std::string BluetoothDeviceAndroid::GetDeviceName() const {
195 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName(
196 AttachCurrentThread(), j_device_.obj()));
199 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
200 // Implemented in following patch https://codereview.chromium.org/1256313002
201 NOTIMPLEMENTED();
202 DidFailToConnectGatt(ERROR_UNKNOWN);
205 void BluetoothDeviceAndroid::DisconnectGatt() {
206 // Implemented in following patch https://codereview.chromium.org/1256313002
207 NOTIMPLEMENTED();
210 } // namespace device