| Index: chromeos/components/tether/host_scanner.cc
|
| diff --git a/chromeos/components/tether/host_scanner.cc b/chromeos/components/tether/host_scanner.cc
|
| index b407386b4a20238826e81d5ce9126126f2f2763a..8aa5786eed157788a1f61923413982a197712cce 100644
|
| --- a/chromeos/components/tether/host_scanner.cc
|
| +++ b/chromeos/components/tether/host_scanner.cc
|
| @@ -8,7 +8,6 @@
|
|
|
| #include "base/bind.h"
|
| #include "chromeos/components/tether/device_id_tether_network_guid_map.h"
|
| -#include "chromeos/components/tether/host_scan_cache.h"
|
| #include "chromeos/components/tether/tether_host_fetcher.h"
|
| #include "chromeos/network/network_state.h"
|
| #include "components/cryptauth/remote_device_loader.h"
|
| @@ -38,16 +37,16 @@
|
| BleConnectionManager* connection_manager,
|
| HostScanDevicePrioritizer* host_scan_device_prioritizer,
|
| TetherHostResponseRecorder* tether_host_response_recorder,
|
| + NetworkStateHandler* network_state_handler,
|
| NotificationPresenter* notification_presenter,
|
| - DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map,
|
| - HostScanCache* host_scan_cache)
|
| + DeviceIdTetherNetworkGuidMap* device_id_tether_network_guid_map)
|
| : tether_host_fetcher_(tether_host_fetcher),
|
| connection_manager_(connection_manager),
|
| host_scan_device_prioritizer_(host_scan_device_prioritizer),
|
| tether_host_response_recorder_(tether_host_response_recorder),
|
| + network_state_handler_(network_state_handler),
|
| notification_presenter_(notification_presenter),
|
| device_id_tether_network_guid_map_(device_id_tether_network_guid_map),
|
| - host_scan_cache_(host_scan_cache),
|
| is_fetching_hosts_(false),
|
| weak_ptr_factory_(this) {}
|
|
|
| @@ -88,15 +87,43 @@
|
| std::vector<HostScannerOperation::ScannedDeviceInfo>&
|
| scanned_device_list_so_far,
|
| bool is_final_scan_result) {
|
| - if (scanned_device_list_so_far.empty()) {
|
| - // If a new scan is just starting up, remove existing cache entries; if they
|
| - // are still within range to communicate with the current device, they will
|
| - // show up in a subsequent OnTetherAvailabilityResponse() invocation.
|
| - host_scan_cache_->ClearCacheExceptForActiveHost();
|
| - } else {
|
| - // Add all results received so far to the cache.
|
| + most_recent_scan_results_ = scanned_device_list_so_far;
|
| +
|
| + if (!scanned_device_list_so_far.empty()) {
|
| + // TODO(hansberry): Clear out old scanned hosts from NetworkStateHandler.
|
| + // TODO(khorimoto): Use UpdateTetherNetworkProperties if the network already
|
| + // exists.
|
| for (auto& scanned_device_info : scanned_device_list_so_far) {
|
| - SetCacheEntry(scanned_device_info);
|
| + const DeviceStatus& status = scanned_device_info.device_status;
|
| + const cryptauth::RemoteDevice& remote_device =
|
| + scanned_device_info.remote_device;
|
| +
|
| + const std::string carrier =
|
| + (!status.has_cell_provider() || status.cell_provider().empty())
|
| + ? kDefaultCellCarrierName
|
| + : status.cell_provider();
|
| +
|
| + // If battery or signal strength are missing, assume they are 100. For
|
| + // battery percentage, force the value to be between 0 and 100. For signal
|
| + // strength, convert from Android signal strength to Chrome OS signal
|
| + // strength and force the value to be between 0 and 100.
|
| + const int32_t battery_percentage =
|
| + status.has_battery_percentage()
|
| + ? ForceBetweenZeroAndOneHundred(status.battery_percentage())
|
| + : 100;
|
| + const int32_t signal_strength =
|
| + status.has_connection_strength()
|
| + ? ForceBetweenZeroAndOneHundred(
|
| + kAndroidTetherHostToChromeOSSignalStrengthMultiplier *
|
| + status.connection_strength())
|
| + : 100;
|
| +
|
| + // TODO(khorimoto): Pass a HasConnectedToHost parameter to this function.
|
| + network_state_handler_->AddTetherNetworkState(
|
| + device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId(
|
| + remote_device.GetDeviceId()),
|
| + remote_device.name, carrier, battery_percentage, signal_strength,
|
| + false /* has_connected_to_host */);
|
| }
|
|
|
| if (scanned_device_list_so_far.size() == 1) {
|
| @@ -115,40 +142,6 @@
|
| }
|
| }
|
|
|
| -void HostScanner::SetCacheEntry(
|
| - const HostScannerOperation::ScannedDeviceInfo& scanned_device_info) {
|
| - const DeviceStatus& status = scanned_device_info.device_status;
|
| - const cryptauth::RemoteDevice& remote_device =
|
| - scanned_device_info.remote_device;
|
| -
|
| - // Use a sentinel value if carrier information is not available. This value is
|
| - // special-cased and replaced with a localized string in the settings UI.
|
| - const std::string carrier =
|
| - (!status.has_cell_provider() || status.cell_provider().empty())
|
| - ? kDefaultCellCarrierName
|
| - : status.cell_provider();
|
| -
|
| - // If battery or signal strength are missing, assume they are 100. For
|
| - // battery percentage, force the value to be between 0 and 100. For signal
|
| - // strength, convert from Android signal strength to Chrome OS signal
|
| - // strength and force the value to be between 0 and 100.
|
| - const int32_t battery_percentage =
|
| - status.has_battery_percentage()
|
| - ? ForceBetweenZeroAndOneHundred(status.battery_percentage())
|
| - : 100;
|
| - const int32_t signal_strength =
|
| - status.has_connection_strength()
|
| - ? ForceBetweenZeroAndOneHundred(
|
| - kAndroidTetherHostToChromeOSSignalStrengthMultiplier *
|
| - status.connection_strength())
|
| - : 100;
|
| -
|
| - host_scan_cache_->SetHostScanResult(
|
| - device_id_tether_network_guid_map_->GetTetherNetworkGuidForDeviceId(
|
| - remote_device.GetDeviceId()),
|
| - remote_device.name, carrier, battery_percentage, signal_strength);
|
| -}
|
| -
|
| } // namespace tether
|
|
|
| } // namespace chromeos
|
|
|