summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authorkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-06 21:38:16 +0000
committerkeybuk@chromium.org <keybuk@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-06 21:38:16 +0000
commitb6283774ed9c61fed60fd38f7df675499f497d2b (patch)
tree4363438a38ae46f0336c9ee534be6d39968cfab4 /device
parente39075d131e21e426268efd2ef1167d44875c7b1 (diff)
downloadchromium_src-b6283774ed9c61fed60fd38f7df675499f497d2b.zip
chromium_src-b6283774ed9c61fed60fd38f7df675499f497d2b.tar.gz
chromium_src-b6283774ed9c61fed60fd38f7df675499f497d2b.tar.bz2
Bluetooth: set a name for the adapter
BUG=220820 TEST=bt_console, show R=youngki@chromium.org Review URL: https://chromiumcodereview.appspot.com/14898004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r--device/bluetooth/bluetooth_adapter_experimental_chromeos.cc36
-rw-r--r--device/bluetooth/bluetooth_adapter_experimental_chromeos.h5
-rw-r--r--device/bluetooth/bluetooth_experimental_chromeos_unittest.cc1
3 files changed, 41 insertions, 1 deletions
diff --git a/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc b/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
index 6f3a185c..579dbb5 100644
--- a/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
+++ b/device/bluetooth/bluetooth_adapter_experimental_chromeos.cc
@@ -7,8 +7,10 @@
#include <string>
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/experimental_bluetooth_adapter_client.h"
#include "chromeos/dbus/experimental_bluetooth_device_client.h"
@@ -310,6 +312,8 @@ void BluetoothAdapterExperimentalChromeOS::SetAdapter(
VLOG(1) << object_path_.value() << ": using adapter.";
+ SetAdapterName();
+
ExperimentalBluetoothAdapterClient::Properties* properties =
DBusThreadManager::Get()->GetExperimentalBluetoothAdapterClient()->
GetProperties(object_path_);
@@ -337,6 +341,38 @@ void BluetoothAdapterExperimentalChromeOS::SetAdapter(
}
}
+void BluetoothAdapterExperimentalChromeOS::SetAdapterName() {
+ // Set a better name for the adapter than "BlueZ 5.x"; this isn't an ideal
+ // way to do this but it'll do for now. See http://crbug.com/126732 and
+ // http://crbug.com/126802.
+ std::string board;
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
+ if (command_line->HasSwitch(chromeos::switches::kChromeOSReleaseBoard)) {
+ board = command_line->
+ GetSwitchValueASCII(chromeos::switches::kChromeOSReleaseBoard);
+ }
+
+ std::string alias;
+ if (board.substr(0, 6) == "stumpy") {
+ alias = "Chromebox";
+ } else if (board.substr(0, 4) == "link") {
+ alias = "Chromebook Pixel";
+ } else {
+ alias = "Chromebook";
+ }
+
+ DBusThreadManager::Get()->GetExperimentalBluetoothAdapterClient()->
+ GetProperties(object_path_)->alias.Set(
+ alias,
+ base::Bind(&BluetoothAdapterExperimentalChromeOS::OnSetAlias,
+ weak_ptr_factory_.GetWeakPtr()));
+}
+
+void BluetoothAdapterExperimentalChromeOS::OnSetAlias(bool success) {
+ LOG_IF(WARNING, !success) << object_path_.value()
+ << ": Failed to set adapter alias";
+}
+
void BluetoothAdapterExperimentalChromeOS::RemoveAdapter() {
DCHECK(IsPresent());
VLOG(1) << object_path_.value() << ": adapter removed.";
diff --git a/device/bluetooth/bluetooth_adapter_experimental_chromeos.h b/device/bluetooth/bluetooth_adapter_experimental_chromeos.h
index e761a86..a3a0655 100644
--- a/device/bluetooth/bluetooth_adapter_experimental_chromeos.h
+++ b/device/bluetooth/bluetooth_adapter_experimental_chromeos.h
@@ -95,6 +95,11 @@ class BluetoothAdapterExperimentalChromeOS
// subsequently operate on that adapter until it is removed.
void SetAdapter(const dbus::ObjectPath& object_path);
+ // Set the adapter name to one chosen from the system information, and method
+ // called by dbus:: on completion of the alias property change.
+ void SetAdapterName();
+ void OnSetAlias(bool success);
+
// Remove the currently tracked adapter. IsPresent() will return false after
// this is called.
void RemoveAdapter();
diff --git a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
index 3b8f997..1c6f5b6 100644
--- a/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
+++ b/device/bluetooth/bluetooth_experimental_chromeos_unittest.cc
@@ -338,7 +338,6 @@ TEST_F(BluetoothExperimentalChromeOSTest, AlreadyPresent) {
EXPECT_FALSE(adapter_->IsPowered());
EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterAddress,
adapter_->GetAddress());
- EXPECT_EQ(FakeBluetoothAdapterClient::kAdapterName, adapter_->GetName());
EXPECT_FALSE(adapter_->IsDiscovering());
// There should be a device