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

Side by Side Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 317073011: [Bluetooth] Remove the deprecated BluetoothServiceRecordMac class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_service_record_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_device_mac.h" 5 #include "device/bluetooth/bluetooth_device_mac.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
11 #include "base/sequenced_task_runner.h" 11 #include "base/sequenced_task_runner.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/strings/stringprintf.h" 14 #include "base/strings/stringprintf.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "device/bluetooth/bluetooth_profile_mac.h" 16 #include "device/bluetooth/bluetooth_profile_mac.h"
17 #include "device/bluetooth/bluetooth_service_record_mac.h"
18 #include "device/bluetooth/bluetooth_socket_mac.h" 17 #include "device/bluetooth/bluetooth_socket_mac.h"
19 #include "device/bluetooth/bluetooth_uuid.h" 18 #include "device/bluetooth/bluetooth_uuid.h"
20 19
21 // Replicate specific 10.7 SDK declarations for building with prior SDKs. 20 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
22 #if !defined(MAC_OS_X_VERSION_10_7) || \ 21 #if !defined(MAC_OS_X_VERSION_10_7) || \
23 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 22 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
24 23
25 @interface IOBluetoothDevice (LionSDKDeclarations) 24 @interface IOBluetoothDevice (LionSDKDeclarations)
26 - (NSString*)addressString; 25 - (NSString*)addressString;
27 - (unsigned int)classOfDevice; 26 - (unsigned int)classOfDevice;
28 - (BluetoothConnectionHandle)connectionHandle; 27 - (BluetoothConnectionHandle)connectionHandle;
29 - (BluetoothHCIRSSIValue)rawRSSI; 28 - (BluetoothHCIRSSIValue)rawRSSI;
30 - (NSArray*)services; 29 - (NSArray*)services;
31 @end 30 @end
32 31
33 #endif // MAC_OS_X_VERSION_10_7 32 #endif // MAC_OS_X_VERSION_10_7
34 33
35 // Undocumented API for accessing the Bluetooth transmit power level. 34 // Undocumented API for accessing the Bluetooth transmit power level.
36 // Similar to the API defined here [ http://goo.gl/20Q5vE ]. 35 // Similar to the API defined here [ http://goo.gl/20Q5vE ].
37 @interface IOBluetoothHostController (UndocumentedAPI) 36 @interface IOBluetoothHostController (UndocumentedAPI)
38 - (IOReturn) 37 - (IOReturn)
39 BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection 38 BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection
40 inType:(BluetoothHCITransmitPowerLevelType)type 39 inType:(BluetoothHCITransmitPowerLevelType)type
41 outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level; 40 outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level;
42 @end 41 @end
43 42
43 namespace {
44
45 void ExtractUuid(IOBluetoothSDPDataElement* service_class_data,
46 std::string* uuid) {
47 NSArray* inner_elements = [service_class_data getArrayValue];
48 IOBluetoothSDPUUID* sdp_uuid = nil;
49 for (IOBluetoothSDPDataElement* inner_element in inner_elements) {
50 if ([inner_element getTypeDescriptor] == kBluetoothSDPDataElementTypeUUID) {
51 sdp_uuid = [[inner_element getUUIDValue] getUUIDWithLength:16];
52 break;
53 }
54 }
55 if (sdp_uuid != nil) {
56 const uint8* uuid_bytes = reinterpret_cast<const uint8*>([sdp_uuid bytes]);
57 *uuid = base::StringPrintf(
58 "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
59 uuid_bytes[0], uuid_bytes[1], uuid_bytes[2], uuid_bytes[3],
60 uuid_bytes[4], uuid_bytes[5], uuid_bytes[6], uuid_bytes[7],
61 uuid_bytes[8], uuid_bytes[9], uuid_bytes[10], uuid_bytes[11],
62 uuid_bytes[12], uuid_bytes[13], uuid_bytes[14], uuid_bytes[15]);
63 }
64 }
65
66 } // namespace
67
44 namespace device { 68 namespace device {
45 69
46 BluetoothDeviceMac::BluetoothDeviceMac(IOBluetoothDevice* device) 70 BluetoothDeviceMac::BluetoothDeviceMac(IOBluetoothDevice* device)
47 : device_([device retain]) { 71 : device_([device retain]) {
48 } 72 }
49 73
50 BluetoothDeviceMac::~BluetoothDeviceMac() { 74 BluetoothDeviceMac::~BluetoothDeviceMac() {
51 } 75 }
52 76
53 void BluetoothDeviceMac::AddObserver( 77 void BluetoothDeviceMac::AddObserver(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 } 147 }
124 148
125 bool BluetoothDeviceMac::IsConnectable() const { 149 bool BluetoothDeviceMac::IsConnectable() const {
126 return false; 150 return false;
127 } 151 }
128 152
129 bool BluetoothDeviceMac::IsConnecting() const { 153 bool BluetoothDeviceMac::IsConnecting() const {
130 return false; 154 return false;
131 } 155 }
132 156
133 // TODO(keybuk): BluetoothServiceRecord is deprecated; implement this method
134 // without using BluetoothServiceRecord.
135 BluetoothDevice::UUIDList BluetoothDeviceMac::GetUUIDs() const { 157 BluetoothDevice::UUIDList BluetoothDeviceMac::GetUUIDs() const {
136 UUIDList uuids; 158 UUIDList uuids;
137 for (IOBluetoothSDPServiceRecord* service in [device_ services]) { 159 for (IOBluetoothSDPServiceRecord* service_record in [device_ services]) {
138 BluetoothServiceRecordMac service_record(service); 160 const BluetoothSDPServiceAttributeID service_class_id = 1;
139 uuids.push_back(service_record.uuid()); 161 IOBluetoothSDPDataElement* service_class_data =
162 [service_record getAttributeDataElement:service_class_id];
163 if ([service_class_data getTypeDescriptor] ==
164 kBluetoothSDPDataElementTypeDataElementSequence) {
165 std::string uuid_str;
166 ExtractUuid(service_class_data, &uuid_str);
167 uuids.push_back(BluetoothUUID(uuid_str));
168 }
140 } 169 }
141 return uuids; 170 return uuids;
142 } 171 }
143 172
144 bool BluetoothDeviceMac::ExpectingPinCode() const { 173 bool BluetoothDeviceMac::ExpectingPinCode() const {
145 NOTIMPLEMENTED(); 174 NOTIMPLEMENTED();
146 return false; 175 return false;
147 } 176 }
148 177
149 bool BluetoothDeviceMac::ExpectingPasskey() const { 178 bool BluetoothDeviceMac::ExpectingPasskey() const {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 264
236 return power_level; 265 return power_level;
237 } 266 }
238 267
239 // static 268 // static
240 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) { 269 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) {
241 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); 270 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString]));
242 } 271 }
243 272
244 } // namespace device 273 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth.gyp ('k') | device/bluetooth/bluetooth_service_record_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698