Index: chromeos/components/tether/host_scanner.cc |
diff --git a/chromeos/components/tether/host_scanner.cc b/chromeos/components/tether/host_scanner.cc |
index 7296d8471e40a6c5c646736b973cf6ff3a5c5d20..e74407454e4f667e68e155838ecd6926e7b86104 100644 |
--- a/chromeos/components/tether/host_scanner.cc |
+++ b/chromeos/components/tether/host_scanner.cc |
@@ -6,6 +6,7 @@ |
#include "base/bind.h" |
#include "chromeos/components/tether/tether_host_fetcher.h" |
+#include "chromeos/network/network_state.h" |
#include "components/cryptauth/remote_device_loader.h" |
namespace chromeos { |
@@ -15,10 +16,14 @@ namespace tether { |
HostScanner::HostScanner( |
TetherHostFetcher* tether_host_fetcher, |
BleConnectionManager* connection_manager, |
- HostScanDevicePrioritizer* host_scan_device_prioritizer) |
+ HostScanDevicePrioritizer* host_scan_device_prioritizer, |
+ NetworkStateHandler* network_state_handler, |
+ NotificationPresenter* notification_presenter) |
: tether_host_fetcher_(tether_host_fetcher), |
connection_manager_(connection_manager), |
host_scan_device_prioritizer_(host_scan_device_prioritizer), |
+ network_state_handler_(network_state_handler), |
+ notification_presenter_(notification_presenter), |
is_fetching_hosts_(false), |
weak_ptr_factory_(this) {} |
@@ -60,7 +65,23 @@ void HostScanner::OnTetherAvailabilityResponse( |
bool is_final_scan_result) { |
most_recent_scan_results_ = scanned_device_list_so_far; |
- // TODO(hansberry): Hook up to networking code. |
+ if (!scanned_device_list_so_far.empty()) { |
+ // TODO (hansberry): Clear out old scanned hosts from NetworkStateHandler. |
+ // TODO (hansberry): Add battery and cell strength properties once |
+ // available. |
+ for (auto& scanned_device_info : scanned_device_list_so_far) { |
+ cryptauth::RemoteDevice remote_device = scanned_device_info.remote_device; |
+ network_state_handler_->AddTetherNetworkState(remote_device.GetDeviceId(), |
+ remote_device.name); |
+ } |
+ |
+ if (scanned_device_list_so_far.size() == 1) { |
+ notification_presenter_->NotifyPotentialHotspotNearby( |
+ scanned_device_list_so_far.at(0).remote_device); |
+ } else { |
+ notification_presenter_->NotifyMultiplePotentialHotspotsNearby(); |
+ } |
+ } |
if (is_final_scan_result) { |
// If the final scan result has been received, the operation is finished. |