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

Unified Diff: components/pairing/bluetooth_host_pairing_controller.cc

Issue 2888033002: Devices shoule not be found by Android enrollment app after successful enrollment. (Closed)
Patch Set: Add UUID as filter when detecting devices. Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/pairing/bluetooth_host_pairing_controller.cc
diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
index 8b0b201521495019db5cac03930a610c0a98a362..dbf7010246b20fa56133beed8e39daefb67aea49 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -23,21 +23,6 @@ namespace pairing_chromeos {
namespace {
const int kReceiveSize = 16384;
-std::string GetChromeOSDeviceType() {
- switch (chromeos::GetDeviceType()) {
- case chromeos::DeviceType::kChromebox:
- return std::string(kDeviceNamePrefix) + "box";
- case chromeos::DeviceType::kChromebase:
- return std::string(kDeviceNamePrefix) + "base";
- case chromeos::DeviceType::kChromebit:
- return std::string(kDeviceNamePrefix) + "bit";
- case chromeos::DeviceType::kChromebook:
- return std::string(kDeviceNamePrefix) + "book";
- default:
- return std::string(kDeviceNamePrefix) + "device";
- }
-}
-
pairing_api::HostStatusParameters::Connectivity PairingApiConnectivityStatus(
HostPairingController::Connectivity connectivity_status) {
switch (connectivity_status) {
@@ -187,29 +172,14 @@ void BluetoothHostPairingController::OnGetAdapter(
adapter_ = adapter;
if (adapter_->IsPresent()) {
- SetName();
+ SetPowered();
} else {
// Set the name once the adapter is present.
adapter_->AddObserver(this);
}
}
-void BluetoothHostPairingController::SetName() {
- // Hash the bluetooth address and take the lower 2 bytes to create a human
- // readable device name.
- const uint32_t device_id = base::Hash(adapter_->GetAddress()) & 0xFFFF;
- device_name_ =
- base::StringPrintf("%s_%04X", GetChromeOSDeviceType().c_str(), device_id);
-
- adapter_->SetName(
- device_name_,
- base::Bind(&BluetoothHostPairingController::OnSetName,
- ptr_factory_.GetWeakPtr()),
- base::Bind(&BluetoothHostPairingController::OnSetError,
- ptr_factory_.GetWeakPtr()));
-}
-
-void BluetoothHostPairingController::OnSetName() {
+void BluetoothHostPairingController::SetPowered() {
DCHECK(thread_checker_.CalledOnValidThread());
if (adapter_->IsPowered()) {
was_powered_ = true;
@@ -453,7 +423,7 @@ void BluetoothHostPairingController::AdapterPresentChanged(
DCHECK_EQ(adapter, adapter_.get());
if (present) {
adapter_->RemoveObserver(this);
- SetName();
+ SetPowered();
}
}
@@ -484,7 +454,7 @@ void BluetoothHostPairingController::StartPairing() {
}
std::string BluetoothHostPairingController::GetDeviceName() {
- return device_name_;
+ return adapter_.get() ? adapter_->GetName() : std::string();
}
std::string BluetoothHostPairingController::GetConfirmationCode() {
« no previous file with comments | « components/pairing/bluetooth_host_pairing_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698