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

Side by Side Diff: device/bluetooth/bluetooth_device_chromeos.cc

Issue 273953002: Hook up RSSI and host transmit power Bluetooth device properties for ChromeOS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 6 years, 7 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_device_chromeos.h ('k') | no next file » | 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_chromeos.h" 5 #include "device/bluetooth/bluetooth_device_chromeos.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 return product_id; 216 return product_id;
217 } 217 }
218 218
219 uint16 BluetoothDeviceChromeOS::GetDeviceID() const { 219 uint16 BluetoothDeviceChromeOS::GetDeviceID() const {
220 uint16 device_id = 0; 220 uint16 device_id = 0;
221 ParseModalias(object_path_, NULL, NULL, NULL, &device_id); 221 ParseModalias(object_path_, NULL, NULL, NULL, &device_id);
222 return device_id; 222 return device_id;
223 } 223 }
224 224
225 int BluetoothDeviceChromeOS::GetRSSI() const { 225 int BluetoothDeviceChromeOS::GetRSSI() const {
226 NOTIMPLEMENTED(); 226 BluetoothDeviceClient::Properties* properties =
227 return kUnknownPower; 227 DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
228 object_path_);
229 DCHECK(properties);
230
231 return IsConnected() ? properties->connection_rssi.value() : kUnknownPower;
keybuk 2014/05/09 18:27:06 Shouldn't this be "is a connection monitor running
Tim Song 2014/05/09 19:01:35 Done. I added a boolean member variable tracking i
228 } 232 }
229 233
230 int BluetoothDeviceChromeOS::GetCurrentHostTransmitPower() const { 234 int BluetoothDeviceChromeOS::GetCurrentHostTransmitPower() const {
231 NOTIMPLEMENTED(); 235 BluetoothDeviceClient::Properties* properties =
232 return kUnknownPower; 236 DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
237 object_path_);
238 DCHECK(properties);
239
240 return IsConnected() ? properties->connection_tx_power.value()
241 : kUnknownPower;
233 } 242 }
234 243
235 int BluetoothDeviceChromeOS::GetMaximumHostTransmitPower() const { 244 int BluetoothDeviceChromeOS::GetMaximumHostTransmitPower() const {
236 NOTIMPLEMENTED(); 245 BluetoothDeviceClient::Properties* properties =
237 return kUnknownPower; 246 DBusThreadManager::Get()->GetBluetoothDeviceClient()->GetProperties(
247 object_path_);
248 DCHECK(properties);
249
250 return IsConnected() ? properties->connection_tx_power_max.value()
251 : kUnknownPower;
238 } 252 }
239 253
240 bool BluetoothDeviceChromeOS::IsPaired() const { 254 bool BluetoothDeviceChromeOS::IsPaired() const {
241 BluetoothDeviceClient::Properties* properties = 255 BluetoothDeviceClient::Properties* properties =
242 DBusThreadManager::Get()->GetBluetoothDeviceClient()-> 256 DBusThreadManager::Get()->GetBluetoothDeviceClient()->
243 GetProperties(object_path_); 257 GetProperties(object_path_);
244 DCHECK(properties); 258 DCHECK(properties);
245 259
246 // Trusted devices are devices that don't support pairing but that the 260 // Trusted devices are devices that don't support pairing but that the
247 // user has explicitly connected; it makes no sense for UI purposes to 261 // user has explicitly connected; it makes no sense for UI purposes to
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 true, 662 true,
649 base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted, 663 base::Bind(&BluetoothDeviceChromeOS::OnSetTrusted,
650 weak_ptr_factory_.GetWeakPtr())); 664 weak_ptr_factory_.GetWeakPtr()));
651 } 665 }
652 666
653 void BluetoothDeviceChromeOS::OnSetTrusted(bool success) { 667 void BluetoothDeviceChromeOS::OnSetTrusted(bool success) {
654 LOG_IF(WARNING, !success) << object_path_.value() 668 LOG_IF(WARNING, !success) << object_path_.value()
655 << ": Failed to set device as trusted"; 669 << ": Failed to set device as trusted";
656 } 670 }
657 671
672 void BluetoothDeviceChromeOS::StartConnectionMonitor() {
673 DBusThreadManager::Get()->GetBluetoothDeviceClient()->StartConnectionMonitor(
674 object_path_,
675 base::Bind(&base::DoNothing),
676 base::Bind(&BluetoothDeviceChromeOS::OnStartConnectionMonitorError,
677 weak_ptr_factory_.GetWeakPtr()));
678 }
679
680 void BluetoothDeviceChromeOS::OnStartConnectionMonitorError(
681 const std::string& error_name,
682 const std::string& error_message) {
683 LOG(WARNING) << object_path_.value()
684 << ": Failed to start connection monitor: " << error_name << ": "
685 << error_message;
686 }
687
658 void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) { 688 void BluetoothDeviceChromeOS::OnDisconnect(const base::Closure& callback) {
659 VLOG(1) << object_path_.value() << ": Disconnected"; 689 VLOG(1) << object_path_.value() << ": Disconnected";
660 callback.Run(); 690 callback.Run();
661 } 691 }
662 692
663 void BluetoothDeviceChromeOS::OnDisconnectError( 693 void BluetoothDeviceChromeOS::OnDisconnectError(
664 const ErrorCallback& error_callback, 694 const ErrorCallback& error_callback,
665 const std::string& error_name, 695 const std::string& error_name,
666 const std::string& error_message) { 696 const std::string& error_message) {
667 LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: " 697 LOG(WARNING) << object_path_.value() << ": Failed to disconnect device: "
(...skipping 27 matching lines...) Expand all
695 const std::string& error_message) { 725 const std::string& error_message) {
696 BluetoothProfileChromeOS* profile_chromeos = 726 BluetoothProfileChromeOS* profile_chromeos =
697 static_cast<BluetoothProfileChromeOS*>(profile); 727 static_cast<BluetoothProfileChromeOS*>(profile);
698 VLOG(1) << object_path_.value() << ": Profile connection failed: " 728 VLOG(1) << object_path_.value() << ": Profile connection failed: "
699 << profile_chromeos->uuid().canonical_value() << ": " 729 << profile_chromeos->uuid().canonical_value() << ": "
700 << error_name << ": " << error_message; 730 << error_name << ": " << error_message;
701 error_callback.Run(error_message); 731 error_callback.Run(error_message);
702 } 732 }
703 733
704 } // namespace chromeos 734 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698