Fixes the bluetooth MAC address not contained in ble_advertisement if invalid. Add the reserved bytes.

PiperOrigin-RevId: 390290878
This commit is contained in:
edwinwu
2021-08-11 22:14:32 -07:00
committed by Copybara-Service
parent dc2d249cc4
commit bf41ac7e9f
+6 -1
View File
@@ -238,11 +238,16 @@ BleAdvertisement::operator ByteArray() const {
// clang-format on
// The next 6 bytes are the bluetooth mac address. If bluetooth_mac_address
// is invalid or empty, we get back a empty byte array.
// is invalid or empty, we get back an empty byte array.
auto bluetooth_mac_address_bytes{
BluetoothUtils::FromString(bluetooth_mac_address_)};
if (!bluetooth_mac_address_bytes.Empty()) {
absl::StrAppend(&out, std::string(bluetooth_mac_address_bytes));
} else {
// If bluetooth MAC address is invalid, then reserve the bytes.
auto fake_bt_mac_address_bytes =
ByteArray(BluetoothUtils::kBluetoothMacAddressLength);
absl::StrAppend(&out, std::string(fake_bt_mac_address_bytes));
}
}