Commit 306f6525 authored by Jordy Greenblatt's avatar Jordy Greenblatt Committed by Commit Bot

[CrOS Tether] Add chromeos switch for ignoring wired connections

This adds a chromeos switch to allow tether host scans to occur in
spite of ethernet connections. This is a followup to CL 1332693.

-----

TESTING:

I confirmed manually that turning off the switch prevented a host scan
when ethernet is plugged in while turning it on allowed the 'tether
host found' notification.


Bug: 904609
Change-Id: If0938796841228415c72fb6ccc9b0a52c3d64786
Reviewed-on: https://chromium-review.googlesource.com/c/1334206
Commit-Queue: Jordy Greenblatt <jordynass@chromium.org>
Reviewed-by: default avatarJeremy Klein <jlklein@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607878}
parent 48c6865a
...@@ -558,6 +558,13 @@ const char kTestEncryptionMigrationUI[] = "test-encryption-migration-ui"; ...@@ -558,6 +558,13 @@ const char kTestEncryptionMigrationUI[] = "test-encryption-migration-ui";
// of fake networks desired, e.g. 'tether-stub=2'. // of fake networks desired, e.g. 'tether-stub=2'.
const char kTetherStub[] = "tether-stub"; const char kTetherStub[] = "tether-stub";
// Tells the Chromebook to scan for a tethering host even if there is already a
// wired connection. This allows end-to-end tests to be deployed over ethernet
// without that connection preventing scans and thereby blocking the testing of
// cases with no preexisting connection. Should be used only for testing.
const char kTetherHostScansIgnoreWiredConnections[] =
"tether-host-scans-ignore-wired-connecitons";
// List of locales supported by voice interaction. // List of locales supported by voice interaction.
const char kVoiceInteractionLocales[] = "voice-interaction-supported-locales"; const char kVoiceInteractionLocales[] = "voice-interaction-supported-locales";
...@@ -703,6 +710,11 @@ bool IsInstantTetheringBackgroundAdvertisingSupported() { ...@@ -703,6 +710,11 @@ bool IsInstantTetheringBackgroundAdvertisingSupported() {
kInstantTetheringBackgroundAdvertisementSupport); kInstantTetheringBackgroundAdvertisementSupport);
} }
bool ShouldTetherHostScansIgnoreWiredConnections() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
kTetherHostScansIgnoreWiredConnections);
}
bool ShouldShowPlayStoreInDemoMode() { bool ShouldShowPlayStoreInDemoMode() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(kShowPlayInDemoMode); return base::CommandLine::ForCurrentProcess()->HasSwitch(kShowPlayInDemoMode);
} }
......
...@@ -155,6 +155,7 @@ CHROMEOS_EXPORT extern const char kShowPlayInDemoMode[]; ...@@ -155,6 +155,7 @@ CHROMEOS_EXPORT extern const char kShowPlayInDemoMode[];
CHROMEOS_EXPORT extern const char kStubCrosSettings[]; CHROMEOS_EXPORT extern const char kStubCrosSettings[];
CHROMEOS_EXPORT extern const char kTestEncryptionMigrationUI[]; CHROMEOS_EXPORT extern const char kTestEncryptionMigrationUI[];
CHROMEOS_EXPORT extern const char kTetherStub[]; CHROMEOS_EXPORT extern const char kTetherStub[];
CHROMEOS_EXPORT extern const char kTetherHostScansIgnoreWiredConnections[];
CHROMEOS_EXPORT extern const char kVoiceInteractionLocales[]; CHROMEOS_EXPORT extern const char kVoiceInteractionLocales[];
CHROMEOS_EXPORT extern const char kWaitForInitialPolicyFetchForTest[]; CHROMEOS_EXPORT extern const char kWaitForInitialPolicyFetchForTest[];
CHROMEOS_EXPORT extern const char kWakeOnWifiPacket[]; CHROMEOS_EXPORT extern const char kWakeOnWifiPacket[];
...@@ -216,9 +217,14 @@ CHROMEOS_EXPORT bool ShouldHideActiveAppsFromShelf(); ...@@ -216,9 +217,14 @@ CHROMEOS_EXPORT bool ShouldHideActiveAppsFromShelf();
CHROMEOS_EXPORT bool ShouldShowShelfHoverPreviews(); CHROMEOS_EXPORT bool ShouldShowShelfHoverPreviews();
// Returns true if Instant Tethering should support hosts which use the // Returns true if Instant Tethering should support hosts which use the
// background advertisement model // background advertisement model.
CHROMEOS_EXPORT bool IsInstantTetheringBackgroundAdvertisingSupported(); CHROMEOS_EXPORT bool IsInstantTetheringBackgroundAdvertisingSupported();
// Returns true if the Chromebook should ignore its wired connections when
// deciding whether to run scans for tethering hosts. Should be used only for
// testing.
CHROMEOS_EXPORT bool ShouldTetherHostScansIgnoreWiredConnections();
// Returns true if Play Store should be available in Demo Mode. // Returns true if Play Store should be available in Demo Mode.
// TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default. // TODO(michaelpg): Remove after M71 branch to re-enable Play Store by default.
CHROMEOS_EXPORT bool ShouldShowPlayStoreInDemoMode(); CHROMEOS_EXPORT bool ShouldShowPlayStoreInDemoMode();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "base/time/default_clock.h" #include "base/time/default_clock.h"
#include "chromeos/chromeos_features.h" #include "chromeos/chromeos_features.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/components/proximity_auth/logging/logging.h" #include "chromeos/components/proximity_auth/logging/logging.h"
#include "chromeos/network/network_handler.h" #include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state.h" #include "chromeos/network/network_state.h"
...@@ -54,7 +55,6 @@ HostScanSchedulerImpl::HostScanSchedulerImpl( ...@@ -54,7 +55,6 @@ HostScanSchedulerImpl::HostScanSchedulerImpl(
host_scan_batch_timer_(std::make_unique<base::OneShotTimer>()), host_scan_batch_timer_(std::make_unique<base::OneShotTimer>()),
clock_(base::DefaultClock::GetInstance()), clock_(base::DefaultClock::GetInstance()),
task_runner_(base::ThreadTaskRunnerHandle::Get()), task_runner_(base::ThreadTaskRunnerHandle::Get()),
ignore_wired_networks_(false),
is_screen_locked_(session_manager_->IsScreenLocked()), is_screen_locked_(session_manager_->IsScreenLocked()),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
network_state_handler_->AddObserver(this, FROM_HERE); network_state_handler_->AddObserver(this, FROM_HERE);
...@@ -84,7 +84,8 @@ HostScanSchedulerImpl::~HostScanSchedulerImpl() { ...@@ -84,7 +84,8 @@ HostScanSchedulerImpl::~HostScanSchedulerImpl() {
void HostScanSchedulerImpl::AttemptScanIfOffline() { void HostScanSchedulerImpl::AttemptScanIfOffline() {
const chromeos::NetworkTypePattern network_type_pattern = const chromeos::NetworkTypePattern network_type_pattern =
ignore_wired_networks_ ? chromeos::NetworkTypePattern::Wireless() chromeos::switches::ShouldTetherHostScansIgnoreWiredConnections()
? chromeos::NetworkTypePattern::Wireless()
: chromeos::NetworkTypePattern::Default(); : chromeos::NetworkTypePattern::Default();
const chromeos::NetworkState* first_network = const chromeos::NetworkState* first_network =
network_state_handler_->FirstNetworkByType(network_type_pattern); network_state_handler_->FirstNetworkByType(network_type_pattern);
......
...@@ -84,11 +84,6 @@ class HostScanSchedulerImpl : public HostScanScheduler, ...@@ -84,11 +84,6 @@ class HostScanSchedulerImpl : public HostScanScheduler,
base::Time last_scan_batch_start_timestamp_; base::Time last_scan_batch_start_timestamp_;
base::Time last_scan_end_timestamp_; base::Time last_scan_end_timestamp_;
// TODO(crbug.com/904609): Read ignore_wired_networks_ from flag defaulting to
// false. Scan for tethering hosts even if there is a wired connection to
// allow end-to-end tests to be deployed and run without unplugging ethernet.
bool ignore_wired_networks_;
bool is_screen_locked_; bool is_screen_locked_;
base::WeakPtrFactory<HostScanSchedulerImpl> weak_ptr_factory_; base::WeakPtrFactory<HostScanSchedulerImpl> weak_ptr_factory_;
......
...@@ -269,7 +269,8 @@ bool HostScannerImpl::IsPotentialHotspotNotificationShowing() { ...@@ -269,7 +269,8 @@ bool HostScannerImpl::IsPotentialHotspotNotificationShowing() {
bool HostScannerImpl::CanAvailableHostNotificationBeShown() { bool HostScannerImpl::CanAvailableHostNotificationBeShown() {
const chromeos::NetworkTypePattern network_type_pattern = const chromeos::NetworkTypePattern network_type_pattern =
ignore_wired_networks_ ? chromeos::NetworkTypePattern::Wireless() chromeos::switches::ShouldTetherHostScansIgnoreWiredConnections()
? chromeos::NetworkTypePattern::Wireless()
: chromeos::NetworkTypePattern::Default(); : chromeos::NetworkTypePattern::Default();
// Note: If a network is active (i.e., connecting or connected), it will be // Note: If a network is active (i.e., connecting or connected), it will be
// returned at the front of the list, so using FirstNetworkByType() guarantees // returned at the front of the list, so using FirstNetworkByType() guarantees
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/observer_list.h" #include "base/observer_list.h"
#include "base/time/clock.h" #include "base/time/clock.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/components/tether/host_scanner.h" #include "chromeos/components/tether/host_scanner.h"
#include "chromeos/components/tether/host_scanner_operation.h" #include "chromeos/components/tether/host_scanner_operation.h"
#include "chromeos/components/tether/notification_presenter.h" #include "chromeos/components/tether/notification_presenter.h"
...@@ -132,10 +133,6 @@ class HostScannerImpl : public HostScanner, ...@@ -132,10 +133,6 @@ class HostScannerImpl : public HostScanner,
ConnectionPreserver* connection_preserver_; ConnectionPreserver* connection_preserver_;
base::Clock* clock_; base::Clock* clock_;
// TODO(crbug.com/904609): Read ignore_wired_networks_ from flag defaulting to
// false. Scan for tethering hosts even if there is a wired connection to
// allow end-to-end tests to be deployed and run without unplugging ethernet.
bool ignore_wired_networks_ = false;
bool is_fetching_hosts_ = false; bool is_fetching_hosts_ = false;
bool was_notification_showing_when_current_scan_started_ = false; bool was_notification_showing_when_current_scan_started_ = false;
bool was_notification_shown_in_current_scan_ = false; bool was_notification_shown_in_current_scan_ = false;
......
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