Commit 1ecf92e0 authored by Josh Horwich's avatar Josh Horwich Committed by Commit Bot

arc: Avoid turning on BT discoverable mode.

Current ARC Bluetooth bridge assumes that setting of discoverable
timeout implies the adapter should go into discoverable mode.

This change tracks the discoverable timeout separately from the actual
transition to discoverable mode, and only puts the adapter into
discoverable mode when the scan mode is set to discoverable.

Bug: 945076
Test: OOBE flow on kevin
Change-Id: I5b154af261563bb4d241327c81bb9a819259dcce
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1559992Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
Reviewed-by: default avatarYusuke Sato <yusukes@chromium.org>
Commit-Queue: Josh Horwich <jhorwich@chromium.org>
Cr-Commit-Position: refs/heads/master@{#649262}
parent 25082830
...@@ -1059,7 +1059,7 @@ void ArcBluetoothBridge::SetAdapterProperty( ...@@ -1059,7 +1059,7 @@ void ArcBluetoothBridge::SetAdapterProperty(
if (property->is_discovery_timeout()) { if (property->is_discovery_timeout()) {
uint32_t discovery_timeout = property->get_discovery_timeout(); uint32_t discovery_timeout = property->get_discovery_timeout();
if (discovery_timeout > 0) { if (discovery_timeout > 0) {
SetDiscoverable(true, discovery_timeout); discoverable_off_timeout_ = discovery_timeout;
} else { } else {
OnSetAdapterProperty(mojom::BluetoothStatus::PARM_INVALID, OnSetAdapterProperty(mojom::BluetoothStatus::PARM_INVALID,
std::move(property)); std::move(property));
...@@ -1075,14 +1075,14 @@ void ArcBluetoothBridge::SetAdapterProperty( ...@@ -1075,14 +1075,14 @@ void ArcBluetoothBridge::SetAdapterProperty(
weak_factory_.GetWeakPtr(), mojom::BluetoothStatus::FAIL, weak_factory_.GetWeakPtr(), mojom::BluetoothStatus::FAIL,
base::Passed(&property_clone))); base::Passed(&property_clone)));
} else if (property->is_adapter_scan_mode()) { } else if (property->is_adapter_scan_mode()) {
// Android will set adapter scan mode in these 3 situations. // Only set the BT scan mode to discoverable if requested and Android has
// 1) Set to BT_SCAN_MODE_NONE just before turning BT off. // set a discovery timeout previously.
// 2) Set to BT_SCAN_MODE_CONNECTABLE just after turning on. if (property->get_adapter_scan_mode() ==
// 3) Set to BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE just before set the mojom::BluetoothScanMode::CONNECTABLE_DISCOVERABLE) {
// discoverable timeout. SetDiscoverable(discoverable_off_timeout_ > 0, discoverable_off_timeout_);
// Since turning BT off/on implied scan mode none/connectable and setting } else {
// discovery timeout implied scan mode discoverable, we don't need to SetDiscoverable(/*discoverable=*/false, /*timeout=*/0);
// do anything here. We will just call success callback in this case. }
OnSetAdapterProperty(mojom::BluetoothStatus::SUCCESS, std::move(property)); OnSetAdapterProperty(mojom::BluetoothStatus::SUCCESS, std::move(property));
} else { } else {
// Android does not set any other property type. // Android does not set any other property type.
......
...@@ -544,6 +544,8 @@ class ArcBluetoothBridge ...@@ -544,6 +544,8 @@ class ArcBluetoothBridge
base::OneShotTimer discovery_off_timer_; base::OneShotTimer discovery_off_timer_;
// Timer to turn adapter discoverable off. // Timer to turn adapter discoverable off.
base::OneShotTimer discoverable_off_timer_; base::OneShotTimer discoverable_off_timer_;
// Adapter discoverable timeout value.
uint32_t discoverable_off_timeout_ = 0;
// Queue to track the powered state changes initiated by Android. // Queue to track the powered state changes initiated by Android.
base::queue<AdapterPowerState> remote_power_changes_; base::queue<AdapterPowerState> remote_power_changes_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment