Commit 9b1023de authored by Eric Roman's avatar Eric Roman Committed by Commit Bot

Re-use device::BluetoothDevice::ParseAddress() when converting to mojo bluetooth address.

Bug: 1021236
Change-Id: I821d12f4a420a59e61722f85a024ff7253b871a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1904759
Auto-Submit: Eric Roman <eroman@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713934}
parent b874ebe9
...@@ -12,10 +12,9 @@ ...@@ -12,10 +12,9 @@
#include "base/json/json_reader.h" #include "base/json/json_reader.h"
#include "base/json/json_writer.h" #include "base/json/json_writer.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/arc/bluetooth/bluetooth_type_converters.h" #include "components/arc/bluetooth/bluetooth_type_converters.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_gatt_service.h" #include "device/bluetooth/bluetooth_gatt_service.h"
#include "device/bluetooth/public/cpp/bluetooth_uuid.h" #include "device/bluetooth/public/cpp/bluetooth_uuid.h"
...@@ -31,16 +30,6 @@ constexpr uint16_t kBrowseGroupList = 0x0005; ...@@ -31,16 +30,6 @@ constexpr uint16_t kBrowseGroupList = 0x0005;
constexpr uint16_t kBluetoothProfileDescriptorList = 0x0009; constexpr uint16_t kBluetoothProfileDescriptorList = 0x0009;
constexpr uint16_t kServiceName = 0x0100; constexpr uint16_t kServiceName = 0x0100;
bool IsNonHex(char c) {
return !isxdigit(c);
}
std::string StripNonHex(const std::string& str) {
std::string result = str;
base::EraseIf(result, IsNonHex);
return result;
}
} // namespace } // namespace
namespace mojo { namespace mojo {
...@@ -52,7 +41,10 @@ TypeConverter<arc::mojom::BluetoothAddressPtr, std::string>::Convert( ...@@ -52,7 +41,10 @@ TypeConverter<arc::mojom::BluetoothAddressPtr, std::string>::Convert(
arc::mojom::BluetoothAddressPtr mojo_addr = arc::mojom::BluetoothAddressPtr mojo_addr =
arc::mojom::BluetoothAddress::New(); arc::mojom::BluetoothAddress::New();
base::HexStringToBytes(StripNonHex(address), &mojo_addr->address);
mojo_addr->address.resize(kAddressSize);
if (!device::BluetoothDevice::ParseAddress(address, mojo_addr->address))
mojo_addr->address.clear();
return mojo_addr; return mojo_addr;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment