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

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

Issue 1897873003: bluetooth: Check if device name is null before trying to convert (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 8 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
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper, 274 GetAndroidAdapter(), this, bluetooth_gatt_service_wrapper,
275 instance_id_string, j_device_.obj())); 275 instance_id_string, j_device_.obj()));
276 276
277 adapter_->NotifyGattServiceAdded(service_iterator->second); 277 adapter_->NotifyGattServiceAdded(service_iterator->second);
278 } 278 }
279 279
280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter) 280 BluetoothDeviceAndroid::BluetoothDeviceAndroid(BluetoothAdapterAndroid* adapter)
281 : BluetoothDevice(adapter) {} 281 : BluetoothDevice(adapter) {}
282 282
283 std::string BluetoothDeviceAndroid::GetDeviceName() const { 283 std::string BluetoothDeviceAndroid::GetDeviceName() const {
284 return ConvertJavaStringToUTF8(Java_ChromeBluetoothDevice_getDeviceName( 284 auto device_name = Java_ChromeBluetoothDevice_getDeviceName(
285 AttachCurrentThread(), j_device_.obj())); 285 AttachCurrentThread(), j_device_.obj());
286
287 if (device_name.is_null()) {
288 return "";
289 }
290 return ConvertJavaStringToUTF8(device_name);
286 } 291 }
287 292
288 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 293 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
289 Java_ChromeBluetoothDevice_createGattConnectionImpl( 294 Java_ChromeBluetoothDevice_createGattConnectionImpl(
290 AttachCurrentThread(), j_device_.obj(), 295 AttachCurrentThread(), j_device_.obj(),
291 base::android::GetApplicationContext()); 296 base::android::GetApplicationContext());
292 } 297 }
293 298
294 void BluetoothDeviceAndroid::DisconnectGatt() { 299 void BluetoothDeviceAndroid::DisconnectGatt() {
295 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), 300 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(),
296 j_device_.obj()); 301 j_device_.obj());
297 } 302 }
298 303
299 } // namespace device 304 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.h ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698