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

Unified Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 12929003: Implemented BluetoothAdapterMac::AddDevices(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: used pairedDevices instead of recentDevices Created 7 years, 9 months 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
Index: device/bluetooth/bluetooth_device_mac.mm
diff --git a/device/bluetooth/bluetooth_device_mac.mm b/device/bluetooth/bluetooth_device_mac.mm
index d0a676203e29454e61b43c1d73cbdee12ff66462..aeebb9719c3af730e5aa1f50489d803c5b9e8b85 100644
--- a/device/bluetooth/bluetooth_device_mac.mm
+++ b/device/bluetooth/bluetooth_device_mac.mm
@@ -4,23 +4,35 @@
#include "device/bluetooth/bluetooth_device_mac.h"
+#import <IOBluetooth/objc/IOBluetoothDevice.h>
+#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
+
#include <string>
#include "base/basictypes.h"
+#include "base/hash.h"
+#include "base/stringprintf.h"
+#include "base/strings/sys_string_conversions.h"
#include "device/bluetooth/bluetooth_out_of_band_pairing_data.h"
#include "device/bluetooth/bluetooth_service_record_mac.h"
namespace device {
-BluetoothDeviceMac::BluetoothDeviceMac()
- : BluetoothDevice() {
+BluetoothDeviceMac::BluetoothDeviceMac(const IOBluetoothDevice* device)
+ : BluetoothDevice(base::SysNSStringToUTF8([device name]),
+ base::SysNSStringToUTF8([device addressString]),
+ [device classOfDevice],
+ [device isConnected],
+ [device isPaired]),
+ device_fingerprint_(ComputeDeviceFingerprint(device)) {
+ visible_ = true;
}
BluetoothDeviceMac::~BluetoothDeviceMac() {
}
bool BluetoothDeviceMac::IsPaired() const {
- return false;
+ return bonded_;
}
const BluetoothDevice::ServiceList& BluetoothDeviceMac::GetServices() const {
@@ -107,4 +119,25 @@ void BluetoothDeviceMac::ClearOutOfBandPairingData(
NOTIMPLEMENTED();
}
+// static
+uint32 BluetoothDeviceMac::ComputeDeviceFingerprint(
+ const IOBluetoothDevice* device) {
+ std::string device_string = base::StringPrintf("%s|%s|%u|%d|%d",
+ base::SysNSStringToUTF8([device name]).c_str(),
+ base::SysNSStringToUTF8([device addressString]).c_str(),
+ [device classOfDevice],
+ [device isConnected],
+ [device isPaired]);
+
+ for (IOBluetoothSDPServiceRecord* record in [device services]) {
+ base::StringAppendF(
+ &device_string,
+ "|%s|%u",
+ base::SysNSStringToUTF8([record getServiceName]).c_str(),
+ [[record attributes] count]);
+ }
+
+ return base::Hash(device_string);
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698