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

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: 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 | « no previous file | 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..689db715ec7af539f7c51282dfc333e4d69d851f 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -196,10 +196,18 @@ void BluetoothHostPairingController::OnGetAdapter(
void BluetoothHostPairingController::SetName() {
zork 2017/05/17 16:59:07 I think a better name for this function would be "
// 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);
+ // readable device name. Clean |device_name_| if pairing is finished. Make
+ // sure the device will not be found by Android enrollment app after
+ // successful enrollment.
+ if (current_stage_ == STAGE_FINISHED) {
xdai1 2017/05/17 17:46:51 Per offline discussion, I would suggest to have a
+ device_name_ = std::string();
+ } else if (device_name_.empty()) {
+ const uint32_t device_id = base::Hash(adapter_->GetAddress()) & 0xFFFF;
+ device_name_ = base::StringPrintf(
+ "%s_%04X", GetChromeOSDeviceType().c_str(), device_id);
+ } else {
+ return;
+ }
adapter_->SetName(
device_name_,
@@ -431,6 +439,7 @@ void BluetoothHostPairingController::OnCompleteSetupMessage(
} else {
// TODO(zork): Handle adding another controller. (http://crbug.com/405757)
ChangeStage(STAGE_FINISHED);
+ SetName();
xdai1 2017/05/17 17:46:51 I think you should reset Bluetooth name for both s
}
Reset();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698