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

Unified Diff: content/browser/bluetooth/bluetooth_device_chooser_controller.cc

Issue 2271413002: bluetooth: Implement RSSI indicator on android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-impl-rssi-tx-power
Patch Set: Draft of LevelListDrawable and StateListDrawable Created 4 years, 2 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
Index: content/browser/bluetooth/bluetooth_device_chooser_controller.cc
diff --git a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
index 3c53e2cf8fa58d93e4b3c08cd52713780e134113..79290877d0b75490fd09eb3d33d44aecfab43678 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -218,6 +218,7 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController(
// destructor starts.
base::Unretained(this)),
/*is_repeating=*/false),
+ should_update_chooser_(false),
weak_ptr_factory_(this) {
CHECK(adapter_);
}
@@ -335,6 +336,7 @@ void BluetoothDeviceChooserController::GetDevice(
return;
}
+ should_update_chooser_ = true;
PopulateConnectedDevices();
if (!chooser_.get()) {
// If the dialog's closing, no need to do any of the rest of this.
@@ -352,7 +354,8 @@ void BluetoothDeviceChooserController::GetDevice(
void BluetoothDeviceChooserController::AddFilteredDevice(
const device::BluetoothDevice& device) {
- if (chooser_.get() && MatchesFilters(device, options_->filters)) {
+ if (should_update_chooser_ && chooser_.get() &&
+ MatchesFilters(device, options_->filters)) {
base::Optional<int8_t> rssi = device.GetInquiryRSSI();
chooser_->AddOrUpdateDevice(
device.GetAddress(), !!device.GetName() /* should_update_name */,
@@ -429,6 +432,7 @@ void BluetoothDeviceChooserController::StartDeviceDiscovery() {
void BluetoothDeviceChooserController::StopDeviceDiscovery() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ should_update_chooser_ = false;
StopDiscoverySession(std::move(discovery_session_));
if (chooser_) {
chooser_->ShowDiscoveryState(BluetoothChooser::DiscoveryState::IDLE);
@@ -463,6 +467,7 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
switch (event) {
case BluetoothChooser::Event::RESCAN:
+ should_update_chooser_ = true;
PopulateConnectedDevices();
DCHECK(chooser_);
StartDeviceDiscovery();

Powered by Google App Engine
This is Rietveld 408576698