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

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

Issue 2377513004: bluetooth:android: Return the advertised name if advertising (Closed)
Patch Set: Format' Created 4 years, 1 month 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.cc ('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_string.h" 9 #include "base/android/jni_string.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 uint16_t BluetoothDeviceAndroid::GetAppearance() const { 95 uint16_t BluetoothDeviceAndroid::GetAppearance() const {
96 // TODO(crbug.com/588083): Implementing GetAppearance() 96 // TODO(crbug.com/588083): Implementing GetAppearance()
97 // on mac, win, and android platforms for chrome 97 // on mac, win, and android platforms for chrome
98 NOTIMPLEMENTED(); 98 NOTIMPLEMENTED();
99 return 0; 99 return 0;
100 } 100 }
101 101
102 base::Optional<std::string> BluetoothDeviceAndroid::GetName() const { 102 base::Optional<std::string> BluetoothDeviceAndroid::GetName() const {
103 if (!IsGattConnected() && advertised_name_) {
104 return advertised_name_;
105 }
106
103 auto name = 107 auto name =
104 Java_ChromeBluetoothDevice_getName(AttachCurrentThread(), j_device_); 108 Java_ChromeBluetoothDevice_getName(AttachCurrentThread(), j_device_);
105 if (name.is_null()) 109 if (name.is_null())
106 return base::nullopt; 110 return base::nullopt;
107 return ConvertJavaStringToUTF8(name); 111 return ConvertJavaStringToUTF8(name);
108 } 112 }
109 113
110 bool BluetoothDeviceAndroid::IsPaired() const { 114 bool BluetoothDeviceAndroid::IsPaired() const {
111 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), j_device_); 115 return Java_ChromeBluetoothDevice_isPaired(AttachCurrentThread(), j_device_);
112 } 116 }
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 void BluetoothDeviceAndroid::CreateGattConnectionImpl() { 269 void BluetoothDeviceAndroid::CreateGattConnectionImpl() {
266 Java_ChromeBluetoothDevice_createGattConnectionImpl( 270 Java_ChromeBluetoothDevice_createGattConnectionImpl(
267 AttachCurrentThread(), j_device_, base::android::GetApplicationContext()); 271 AttachCurrentThread(), j_device_, base::android::GetApplicationContext());
268 } 272 }
269 273
270 void BluetoothDeviceAndroid::DisconnectGatt() { 274 void BluetoothDeviceAndroid::DisconnectGatt() {
271 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_); 275 Java_ChromeBluetoothDevice_disconnectGatt(AttachCurrentThread(), j_device_);
272 } 276 }
273 277
274 } // namespace device 278 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.cc ('k') | device/bluetooth/bluetooth_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698