| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_device_android.h" | 5 #include "device/bluetooth/bluetooth_device_android.h" |
| 6 | 6 |
| 7 #include "base/android/context_utils.h" | 7 #include "base/android/context_utils.h" |
| 8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
| 9 #include "base/android/jni_array.h" | 9 #include "base/android/jni_array.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 bluetooth_device_wrapper)); | 43 bluetooth_device_wrapper)); |
| 44 | 44 |
| 45 return device; | 45 return device; |
| 46 } | 46 } |
| 47 | 47 |
| 48 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() { | 48 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() { |
| 49 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction( | 49 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction( |
| 50 AttachCurrentThread(), j_device_.obj()); | 50 AttachCurrentThread(), j_device_.obj()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) { | 53 void BluetoothDeviceAndroid::UpdateAdvertisedUUIDs( |
| 54 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs( | 54 jobjectArray advertised_uuids) { |
| 55 AttachCurrentThread(), j_device_.obj(), advertised_uuids); | 55 JNIEnv* env = AttachCurrentThread(); |
| 56 std::vector<std::string> uuid_strings; |
| 57 AppendJavaStringArrayToStringVector(env, advertised_uuids, &uuid_strings); |
| 58 |
| 59 advertised_uuids_.clear(); |
| 60 for (auto uuid_string : uuid_strings) { |
| 61 advertised_uuids_.emplace(uuid_string); |
| 62 } |
| 56 } | 63 } |
| 57 | 64 |
| 58 // static | 65 // static |
| 59 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) { | 66 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) { |
| 60 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h | 67 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h |
| 61 } | 68 } |
| 62 | 69 |
| 63 base::android::ScopedJavaLocalRef<jobject> | 70 base::android::ScopedJavaLocalRef<jobject> |
| 64 BluetoothDeviceAndroid::GetJavaObject() { | 71 BluetoothDeviceAndroid::GetJavaObject() { |
| 65 return base::android::ScopedJavaLocalRef<jobject>(j_device_); | 72 return base::android::ScopedJavaLocalRef<jobject>(j_device_); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 bool BluetoothDeviceAndroid::IsConnectable() const { | 134 bool BluetoothDeviceAndroid::IsConnectable() const { |
| 128 NOTIMPLEMENTED(); | 135 NOTIMPLEMENTED(); |
| 129 return false; | 136 return false; |
| 130 } | 137 } |
| 131 | 138 |
| 132 bool BluetoothDeviceAndroid::IsConnecting() const { | 139 bool BluetoothDeviceAndroid::IsConnecting() const { |
| 133 NOTIMPLEMENTED(); | 140 NOTIMPLEMENTED(); |
| 134 return false; | 141 return false; |
| 135 } | 142 } |
| 136 | 143 |
| 137 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const { | |
| 138 JNIEnv* env = AttachCurrentThread(); | |
| 139 std::vector<std::string> uuid_strings; | |
| 140 AppendJavaStringArrayToStringVector( | |
| 141 env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(), | |
| 142 &uuid_strings); | |
| 143 BluetoothDevice::UUIDList uuids; | |
| 144 uuids.reserve(uuid_strings.size()); | |
| 145 for (auto uuid_string : uuid_strings) { | |
| 146 uuids.push_back(BluetoothUUID(uuid_string)); | |
| 147 } | |
| 148 return uuids; | |
| 149 } | |
| 150 | |
| 151 int16_t BluetoothDeviceAndroid::GetInquiryRSSI() const { | 144 int16_t BluetoothDeviceAndroid::GetInquiryRSSI() const { |
| 152 NOTIMPLEMENTED(); | 145 NOTIMPLEMENTED(); |
| 153 return kUnknownPower; | 146 return kUnknownPower; |
| 154 } | 147 } |
| 155 | 148 |
| 156 int16_t BluetoothDeviceAndroid::GetInquiryTxPower() const { | 149 int16_t BluetoothDeviceAndroid::GetInquiryTxPower() const { |
| 157 NOTIMPLEMENTED(); | 150 NOTIMPLEMENTED(); |
| 158 return kUnknownPower; | 151 return kUnknownPower; |
| 159 } | 152 } |
| 160 | 153 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 AttachCurrentThread(), j_device_.obj(), | 286 AttachCurrentThread(), j_device_.obj(), |
| 294 base::android::GetApplicationContext()); | 287 base::android::GetApplicationContext()); |
| 295 } | 288 } |
| 296 | 289 |
| 297 void BluetoothDeviceAndroid::DisconnectGatt() { | 290 void BluetoothDeviceAndroid::DisconnectGatt() { |
| 298 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), | 291 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), |
| 299 j_device_.obj()); | 292 j_device_.obj()); |
| 300 } | 293 } |
| 301 | 294 |
| 302 } // namespace device | 295 } // namespace device |
| OLD | NEW |