0

Tether: never attempt host scans when screen is locked

Tether originally initiated host scans from the lock screen,
in order to provide a list of hosts once the user unlocked the
device. This was changed when it was discovered that Bluetooth issues
meant Tether and SmartLock could not scan simultaneously. It was
assumed that this restriction would no longer apply one the new
MultiDevice APIs were available, but we now never want to allow host
scans on the lock screen; this CL implements that logic.

Bug: 888815
Change-Id: I392e61e8ad404372df42cf2240c65cac81651608
Reviewed-on: https://chromium-review.googlesource.com/1242214
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#594072}
This commit is contained in:
Ryan Hansberry
2018-09-25 20:05:36 +00:00
committed by Commit Bot
parent e890f89311
commit b3ef4d796d
2 changed files with 9 additions and 17 deletions

@ -138,11 +138,7 @@ void HostScanSchedulerImpl::OnSessionStateChanged() {
is_screen_locked_ = session_manager_->IsScreenLocked();
if (is_screen_locked_) {
// If the screen is now locked, stop any ongoing scan. A scan during the
// lock screen could cause bad interactions with EasyUnlock. See
// https://crbug.com/763604.
// Note: Once the SecureChannel API is in use, the scan will no longer have
// to stop.
// If the screen is now locked, stop any ongoing scan.
host_scanner_->StopScan();
if (!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi))
delay_scan_after_unlock_timer_->Stop();
@ -182,11 +178,9 @@ void HostScanSchedulerImpl::AttemptScan() {
if (host_scanner_->IsScanActive())
return;
// If the SecureChannel API is not present, and the screen is locked, a host
// scan should not occur. A scan during the lock screen could cause bad
// interactions with EasyUnlock. See https://crbug.com/763604.
if (!base::FeatureList::IsEnabled(chromeos::features::kMultiDeviceApi) &&
session_manager_->IsScreenLocked()) {
// If the screen is locked, a host scan should not occur.
if (session_manager_->IsScreenLocked()) {
PA_LOG(INFO) << "Skipping scan attempt because the screen is locked.";
return;
}

@ -192,23 +192,21 @@ class HostScanSchedulerImplTest : public NetworkStateTest {
SetMultiDeviceApiEnabled();
// Lock the screen. This should not trigger a scan.
// Lock the screen. This should never trigger a scan.
SetScreenLockedState(true /* is_locked */);
EXPECT_EQ(0u, fake_host_scanner_->num_scans_started());
EXPECT_FALSE(mock_delay_scan_after_unlock_timer_->IsRunning());
// Try to start a scan. Regardless of screen lock state, this should cause a
// scan if the device is offline. The timer should not have been started.
// Try to start a scan. Because the screen is locked, this should not
// cause a scan to be started.
host_scan_scheduler_->AttemptScanIfOffline();
EXPECT_EQ(is_online ? 0u : 1u, fake_host_scanner_->num_scans_started());
EXPECT_EQ(0u, fake_host_scanner_->num_scans_started());
EXPECT_FALSE(mock_delay_scan_after_unlock_timer_->IsRunning());
fake_host_scanner_->StopScan();
// Unlock the screen. If the device is offline, a new scan should have
// started. The timer should be untouched.
SetScreenLockedState(false /* is_locked */);
EXPECT_EQ(is_online ? 0u : 2u, fake_host_scanner_->num_scans_started());
EXPECT_EQ(is_online ? 0u : 1u, fake_host_scanner_->num_scans_started());
EXPECT_FALSE(mock_delay_scan_after_unlock_timer_->IsRunning());
}