Index: chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util_chromeos.cc |
diff --git a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util_chromeos.cc b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util_chromeos.cc |
index e83e9b7479fcb2f96d0d95b171739e1a5b6d2772..83d1ed7c131d6d79e3a6b84955e507f60a78b3f1 100644 |
--- a/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util_chromeos.cc |
+++ b/chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util_chromeos.cc |
@@ -5,9 +5,6 @@ |
#include "chrome/browser/extensions/api/easy_unlock_private/easy_unlock_private_bluetooth_util.h" |
#include <stdint.h> |
-#include <bluetooth/bluetooth.h> |
-#include <bluetooth/l2cap.h> |
-#include <bluetooth/sdp.h> |
#include <sys/socket.h> |
#include <algorithm> |
#include <vector> |
@@ -17,6 +14,7 @@ |
#include "base/numerics/safe_conversions.h" |
#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_split.h" |
+#include "base/sys_byteorder.h" |
#include "base/task_runner_util.h" |
#include "base/threading/sequenced_worker_pool.h" |
#include "base/time/time.h" |
@@ -24,6 +22,26 @@ |
#include "device/bluetooth/bluetooth_device.h" |
#include "net/socket/socket_descriptor.h" |
+// The bluez headers are (intentionally) not available within the Chromium |
+// repository, so several definitions from these headers are replicated below. |
+ |
+// From <bluetooth/bluetooth.h>: |
+#define BTPROTO_L2CAP 0 |
+struct bdaddr_t { |
+ uint8_t b[6]; |
+} __attribute__((packed)); |
+ |
+// From <bluetooth/l2cap.h>: |
+struct sockaddr_l2 { |
+ sa_family_t l2_family; |
+ unsigned short l2_psm; |
+ bdaddr_t l2_bdaddr; |
+ unsigned short l2_cid; |
+}; |
+ |
+// From <bluetooth/sdp.h>: |
+#define SDP_PSM 0x0001 |
+ |
namespace extensions { |
namespace api { |
namespace easy_unlock { |
@@ -84,7 +102,7 @@ SeekDeviceResult SeekBluetoothDeviceByAddressImpl( |
struct sockaddr_l2 addr; |
memset(&addr, 0, sizeof(addr)); |
addr.l2_family = AF_BLUETOOTH; |
- addr.l2_psm = htobs(SDP_PSM); |
+ addr.l2_psm = base::ByteSwapToLE16(SDP_PSM); |
keybuk
2014/08/21 16:56:25
Are these really equivalent?
htobs() conditionall
Ilya Sherman
2014/08/21 17:03:13
ByteSwapToLE16 is also conditional: https://code.g
|
if (!BluetoothAddressToBdaddr(device_address, &addr.l2_bdaddr)) { |
seek_result.error_message = kInvalidDeviceAddress; |
return seek_result; |