Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Side by Side Diff: device/bluetooth/bluetooth_device_android.cc

Issue 2205693003: bluetooth: Replace old advertised uuids (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Mac test and docs Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 bluetooth_device_wrapper)); 44 bluetooth_device_wrapper));
45 45
46 return device; 46 return device;
47 } 47 }
48 48
49 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() { 49 BluetoothDeviceAndroid::~BluetoothDeviceAndroid() {
50 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction( 50 Java_ChromeBluetoothDevice_onBluetoothDeviceAndroidDestruction(
51 AttachCurrentThread(), j_device_.obj()); 51 AttachCurrentThread(), j_device_.obj());
52 } 52 }
53 53
54 bool BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(jobject advertised_uuids) { 54 void BluetoothDeviceAndroid::UpdateAdvertisedUUIDs(
55 return Java_ChromeBluetoothDevice_updateAdvertisedUUIDs( 55 jobjectArray advertised_uuids) {
56 AttachCurrentThread(), j_device_.obj(), advertised_uuids); 56 JNIEnv* env = AttachCurrentThread();
57 std::vector<std::string> uuid_strings;
58 AppendJavaStringArrayToStringVector(env, advertised_uuids, &uuid_strings);
59
60 advertised_uuids_ = UUIDList(uuid_strings.begin(), uuid_strings.end());
57 } 61 }
58 62
59 // static 63 // static
60 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) { 64 bool BluetoothDeviceAndroid::RegisterJNI(JNIEnv* env) {
61 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h 65 return RegisterNativesImpl(env); // Generated in ChromeBluetoothDevice_jni.h
62 } 66 }
63 67
64 base::android::ScopedJavaLocalRef<jobject> 68 base::android::ScopedJavaLocalRef<jobject>
65 BluetoothDeviceAndroid::GetJavaObject() { 69 BluetoothDeviceAndroid::GetJavaObject() {
66 return base::android::ScopedJavaLocalRef<jobject>(j_device_); 70 return base::android::ScopedJavaLocalRef<jobject>(j_device_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 bool BluetoothDeviceAndroid::IsConnectable() const { 132 bool BluetoothDeviceAndroid::IsConnectable() const {
129 NOTIMPLEMENTED(); 133 NOTIMPLEMENTED();
130 return false; 134 return false;
131 } 135 }
132 136
133 bool BluetoothDeviceAndroid::IsConnecting() const { 137 bool BluetoothDeviceAndroid::IsConnecting() const {
134 NOTIMPLEMENTED(); 138 NOTIMPLEMENTED();
135 return false; 139 return false;
136 } 140 }
137 141
138 BluetoothDevice::UUIDList BluetoothDeviceAndroid::GetUUIDs() const {
139 JNIEnv* env = AttachCurrentThread();
140 std::vector<std::string> uuid_strings;
141 AppendJavaStringArrayToStringVector(
142 env, Java_ChromeBluetoothDevice_getUuids(env, j_device_.obj()).obj(),
143 &uuid_strings);
144 BluetoothDevice::UUIDList uuids;
145 uuids.reserve(uuid_strings.size());
146 for (auto uuid_string : uuid_strings) {
147 uuids.push_back(BluetoothUUID(uuid_string));
148 }
149 return uuids;
150 }
151
152 int16_t BluetoothDeviceAndroid::GetInquiryRSSI() const { 142 int16_t BluetoothDeviceAndroid::GetInquiryRSSI() const {
153 NOTIMPLEMENTED(); 143 NOTIMPLEMENTED();
154 return kUnknownPower; 144 return kUnknownPower;
155 } 145 }
156 146
157 int16_t BluetoothDeviceAndroid::GetInquiryTxPower() const { 147 int16_t BluetoothDeviceAndroid::GetInquiryTxPower() const {
158 NOTIMPLEMENTED(); 148 NOTIMPLEMENTED();
159 return kUnknownPower; 149 return kUnknownPower;
160 } 150 }
161 151
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // We assume that if there are any pending connection callbacks there 235 // We assume that if there are any pending connection callbacks there
246 // was a failed connection attempt. 236 // was a failed connection attempt.
247 RecordConnectionFailureResult(status); 237 RecordConnectionFailureResult(status);
248 // TODO(ortuno): Return an error code based on |status| 238 // TODO(ortuno): Return an error code based on |status|
249 // http://crbug.com/578191 239 // http://crbug.com/578191
250 DidFailToConnectGatt(ERROR_FAILED); 240 DidFailToConnectGatt(ERROR_FAILED);
251 } else { 241 } else {
252 // Otherwise an existing connection was terminated. 242 // Otherwise an existing connection was terminated.
253 RecordConnectionTerminatedResult(status); 243 RecordConnectionTerminatedResult(status);
254 gatt_services_.clear(); 244 gatt_services_.clear();
245 service_uuids_.clear();
255 SetGattServicesDiscoveryComplete(false); 246 SetGattServicesDiscoveryComplete(false);
256 DidDisconnectGatt(); 247 DidDisconnectGatt();
257 } 248 }
258 } 249 }
259 250
260 void BluetoothDeviceAndroid::OnGattServicesDiscovered( 251 void BluetoothDeviceAndroid::OnGattServicesDiscovered(
261 JNIEnv* env, 252 JNIEnv* env,
262 const JavaParamRef<jobject>& jcaller) { 253 const JavaParamRef<jobject>& jcaller) {
254 UpdateServiceUUIDs();
263 SetGattServicesDiscoveryComplete(true); 255 SetGattServicesDiscoveryComplete(true);
264 adapter_->NotifyGattServicesDiscovered(this); 256 adapter_->NotifyGattServicesDiscovered(this);
265 } 257 }
266 258
267 void BluetoothDeviceAndroid::CreateGattRemoteService( 259 void BluetoothDeviceAndroid::CreateGattRemoteService(
268 JNIEnv* env, 260 JNIEnv* env,
269 const JavaParamRef<jobject>& caller, 261 const JavaParamRef<jobject>& caller,
270 const JavaParamRef<jstring>& instance_id, 262 const JavaParamRef<jstring>& instance_id,
271 const JavaParamRef<jobject>& 263 const JavaParamRef<jobject>&
272 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper 264 bluetooth_gatt_service_wrapper) { // BluetoothGattServiceWrapper
(...skipping 21 matching lines...) Expand all
294 AttachCurrentThread(), j_device_.obj(), 286 AttachCurrentThread(), j_device_.obj(),
295 base::android::GetApplicationContext()); 287 base::android::GetApplicationContext());
296 } 288 }
297 289
298 void BluetoothDeviceAndroid::DisconnectGatt() { 290 void BluetoothDeviceAndroid::DisconnectGatt() {
299 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 291 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
300 j_device_.obj()); 292 j_device_.obj());
301 } 293 }
302 294
303 } // namespace device 295 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698