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

Unified Diff: device/bluetooth/bluetooth_adapter_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/bluetooth_adapter_android.h ('k') | device/bluetooth/bluetooth_adapter_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_android.cc
diff --git a/device/bluetooth/bluetooth_adapter_android.cc b/device/bluetooth/bluetooth_adapter_android.cc
index 41228bb635bae3ac24c26c8b50bb22d539a22013..b435ce1677982d603487e35ce94ca5a2b6614ff1 100644
--- a/device/bluetooth/bluetooth_adapter_android.cc
+++ b/device/bluetooth/bluetooth_adapter_android.cc
@@ -180,6 +180,7 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
const JavaParamRef<jobject>&
bluetooth_device_wrapper, // Java Type: bluetoothDeviceWrapper
int32_t rssi,
+ const JavaParamRef<jstring>& device_name,
const JavaParamRef<jobjectArray>& advertised_uuids, // Java Type: String[]
int32_t tx_power) {
std::string device_address = ConvertJavaStringToUTF8(env, address);
@@ -201,6 +202,11 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
}
DCHECK(device_android);
+ base::Optional<std::string> name =
+ device_name.is_null() ? base::nullopt
+ : base::make_optional<std::string>(
+ ConvertJavaStringToUTF8(env, device_name));
+
std::vector<std::string> advertised_uuids_strings;
AppendJavaStringArrayToStringVector(env, advertised_uuids,
&advertised_uuids_strings);
@@ -212,8 +218,8 @@ void BluetoothAdapterAndroid::CreateOrUpdateDeviceOnScan(
int8_t clamped_tx_power = BluetoothDevice::ClampPower(tx_power);
device_android->UpdateAdvertisementData(
- BluetoothDevice::ClampPower(rssi), std::move(advertised_bluetooth_uuids),
- {} /* service_data */,
+ BluetoothDevice::ClampPower(rssi), name ? &name.value() : nullptr,
+ std::move(advertised_bluetooth_uuids), {} /* service_data */,
// Android uses INT32_MIN to indicate no Advertised Tx Power.
// https://developer.android.com/reference/android/bluetooth/le/ScanRecord.html#getTxPowerLevel()
tx_power == INT32_MIN ? nullptr : &clamped_tx_power);
« no previous file with comments | « device/bluetooth/bluetooth_adapter_android.h ('k') | device/bluetooth/bluetooth_adapter_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698