Chromium Code Reviews| OLD | NEW |
|---|---|
| (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_array.h" | |
| 9 #include "base/android/jni_string.h" | |
| 10 #include "jni/ChromeBluetoothDevice_jni.h" | |
| 11 | |
| 12 using base::android::AttachCurrentThread; | |
| 13 using base::android::AppendJavaStringArrayToStringVector; | |
| 14 | |
| 15 namespace device { | |
| 16 | |
| 17 BluetoothDeviceAndroid* BluetoothDeviceAndroid::Create( | |
| 18 jobject java_bluetooth_device_wrapper) { | |
| 19 BluetoothDeviceAndroid* device = new BluetoothDeviceAndroid(); | |
| 20 | |
| 21 device->j_device_.Reset(Java_ChromeBluetoothDevice_create( | |
| 22 AttachCurrentThread(), java_bluetooth_device_wrapper)); | |
| 23 | |
| 24 return device; | |
| 25 } | |
| 26 | |
| 27 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() { | |
| 28 } | |
| 29 | |
| 30 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) { | |
| 31 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs( | |
| 32 AttachCurrentThread(), j_device_.obj(), advertised_uuids); | |
| 33 } | |
| 34 | |
| 35 // static | |
| 36 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) { | |
| 37 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h | |
| 38 } | |
| 39 | |
| 40 uint32 BluetoothDeviceAndroid::GetBluetoothClass() const { | |
| 41 return Java_ChromeBluetoothDevice_getBluetoothClass(AttachCurrentThread(), | |
| 42 j_device_.obj()); | |
| 43 } | |
| 44 | |
| 45 std::string BluetoothDeviceAndroid::GetAddress() const { | |
| 46 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getAddress( | |
| 47 AttachCurrentThread(), j_device_.obj())); | |
| 48 } | |
| 49 | |
| 50 BluetoothDevice::VendorIDSource BluetoothDeviceAndroid::GetVendorIDSource() | |
| 51 const { | |
| 52 // Android API does not provide Vendor ID. | |
| 53 return VENDOR_ID_UNKNOWN; | |
| 54 } | |
| 55 | |
| 56 uint16 BluetoothDeviceAndroid::GetVendorID() const { | |
| 57 // Android API does not provide Vendor ID. | |
| 58 return 0; | |
| 59 } | |
| 60 | |
| 61 uint16 BluetoothDeviceAndroid::GetProductID() const { | |
| 62 // Android API does not provide Product ID. | |
| 63 return 0; | |
| 64 } | |
| 65 | |
| 66 uint16 BluetoothDeviceAndroid::GetDeviceID() const { | |
| 67 // Android API does not provide Device ID. | |
| 68 return 0; | |
| 69 } | |
| 70 | |
| 71 bool BluetoothDeviceAndroid::IsPaired() const { | |
| 72 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), | |
| 73 j_device_.obj()); | |
| 74 } | |
| 75 | |
| 76 bool BluetoothDeviceAndroid::IsConnected() const { | |
| 77 NOTIMPLEMENTED(); | |
| 78 return false; | |
| 79 } | |
| 80 | |
| 81 bool BluetoothDeviceAndroid::IsConnectable() const { | |
| 82 NOTIMPLEMENTED(); | |
| 83 return false; | |
| 84 } | |
| 85 | |
| 86 bool BluetoothDeviceAndroid::IsConnecting() const { | |
| 87 NOTIMPLEMENTED(); | |
| 88 return false; | |
| 89 } | |
| 90 | |
| 91 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const { | |
| 92 JNIEnv* env = AttachCurrentThread(); | |
| 93 std::vector<std::string> uuid_strings; | |
| 94 AppendJavaStringArrayToStringVector( | |
|
Jeffrey Yasskin
2015/07/08 17:19:39
Returning the array is an improvement, but maybe i
scheib
2015/07/08 23:02:35
I thought about it, and I'm hesitant to duplicate
Jeffrey Yasskin
2015/07/08 23:18:24
SGTM.
| |
| 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)); | |
| 101 } | |
| 102 return uuids; | |
| 103 } | |
| 104 | |
| 105 int16 BluetoothDeviceAndroid::GetInquiryRSSI() const { | |
| 106 NOTIMPLEMENTED(); | |
| 107 return kUnknownPower; | |
| 108 } | |
| 109 | |
| 110 int16 BluetoothDeviceAndroid::GetInquiryTxPower() const { | |
| 111 NOTIMPLEMENTED(); | |
| 112 return kUnknownPower; | |
| 113 } | |
| 114 | |
| 115 bool BluetoothDeviceAndroid::ExpectingPinCode() const { | |
| 116 NOTIMPLEMENTED(); | |
| 117 return false; | |
| 118 } | |
| 119 | |
| 120 bool BluetoothDeviceAndroid::ExpectingPasskey() const { | |
| 121 NOTIMPLEMENTED(); | |
| 122 return false; | |
| 123 } | |
| 124 | |
| 125 bool BluetoothDeviceAndroid::ExpectingConfirmation() const { | |
| 126 NOTIMPLEMENTED(); | |
| 127 return false; | |
| 128 } | |
| 129 | |
| 130 void BluetoothDeviceAndroid::GetConnectionInfo( | |
| 131 const ConnectionInfoCallback& callback) { | |
| 132 NOTIMPLEMENTED(); | |
| 133 callback.Run(ConnectionInfo()); | |
| 134 } | |
| 135 | |
| 136 void BluetoothDeviceAndroid::Connect( | |
| 137 PairingDelegate* pairing_delegate, | |
| 138 const base::Closure& callback, | |
| 139 const ConnectErrorCallback& error_callback) { | |
| 140 NOTIMPLEMENTED(); | |
| 141 } | |
| 142 | |
| 143 void BluetoothDeviceAndroid::SetPinCode(const std::string& pincode) { | |
| 144 NOTIMPLEMENTED(); | |
| 145 } | |
| 146 | |
| 147 void BluetoothDeviceAndroid::SetPasskey(uint32 passkey) { | |
| 148 NOTIMPLEMENTED(); | |
| 149 } | |
| 150 | |
| 151 void BluetoothDeviceAndroid::ConfirmPairing() { | |
| 152 NOTIMPLEMENTED(); | |
| 153 } | |
| 154 | |
| 155 void BluetoothDeviceAndroid::RejectPairing() { | |
| 156 NOTIMPLEMENTED(); | |
| 157 } | |
| 158 | |
| 159 void BluetoothDeviceAndroid::CancelPairing() { | |
| 160 NOTIMPLEMENTED(); | |
| 161 } | |
| 162 | |
| 163 void BluetoothDeviceAndroid::Disconnect(const base::Closure& callback, | |
| 164 const ErrorCallback& error_callback) { | |
| 165 NOTIMPLEMENTED(); | |
| 166 } | |
| 167 | |
| 168 void BluetoothDeviceAndroid::Forget(const ErrorCallback& error_callback) { | |
| 169 NOTIMPLEMENTED(); | |
| 170 } | |
| 171 | |
| 172 void BluetoothDeviceAndroid::ConnectToService( | |
| 173 const BluetoothUUID& uuid, | |
| 174 const ConnectToServiceCallback& callback, | |
| 175 const ConnectToServiceErrorCallback& error_callback) { | |
| 176 NOTIMPLEMENTED(); | |
| 177 } | |
| 178 | |
| 179 void BluetoothDeviceAndroid::ConnectToServiceInsecurely( | |
| 180 const BluetoothUUID& uuid, | |
| 181 const ConnectToServiceCallback& callback, | |
| 182 const ConnectToServiceErrorCallback& error_callback) { | |
| 183 NOTIMPLEMENTED(); | |
| 184 } | |
| 185 | |
| 186 void BluetoothDeviceAndroid::CreateGattConnection( | |
| 187 const GattConnectionCallback& callback, | |
| 188 const ConnectErrorCallback& error_callback) { | |
| 189 NOTIMPLEMENTED(); | |
| 190 } | |
| 191 | |
| 192 BluetoothDeviceAndroid::BluetoothDeviceAndroid() { | |
| 193 } | |
| 194 | |
| 195 std::string BluetoothDeviceAndroid::GetDeviceName() const { | |
| 196 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( | |
| 197 AttachCurrentThread(), j_device_.obj())); | |
| 198 } | |
| 199 | |
| 200 } // namespace device | |
| OLD | NEW |