Commit 00fc3760 authored by atwilson's avatar atwilson Committed by Commit bot

Disable network state reporting.

Update the DeviceStatusCollector to no longer report network state. We will
re-enable this for M42 once we've added code to detect an auto-launched kiosk
session.

BUG=452968

Review URL: https://codereview.chromium.org/885853002

Cr-Commit-Position: refs/heads/master@{#313717}
parent bf0d63f9
...@@ -381,6 +381,12 @@ void DeviceStatusCollector::IdleStateCallback(ui::IdleState state) { ...@@ -381,6 +381,12 @@ void DeviceStatusCollector::IdleStateCallback(ui::IdleState state) {
last_idle_check_ = now; last_idle_check_ = now;
} }
bool DeviceStatusCollector::IsAutoLaunchedKioskSession() {
// TODO(atwilson): Determine if the currently active session is an
// autolaunched kiosk session (http://crbug.com/452968).
return false;
}
void DeviceStatusCollector::SampleHardwareStatus() { void DeviceStatusCollector::SampleHardwareStatus() {
// If hardware reporting has been disabled, do nothing here. // If hardware reporting has been disabled, do nothing here.
if (!report_hardware_status_) if (!report_hardware_status_)
...@@ -591,6 +597,10 @@ void DeviceStatusCollector::GetNetworkInterfaces( ...@@ -591,6 +597,10 @@ void DeviceStatusCollector::GetNetworkInterfaces(
interface->set_device_path((*device)->path()); interface->set_device_path((*device)->path());
} }
// Don't write any network state if we aren't in a kiosk session.
if (!IsAutoLaunchedKioskSession())
return;
// Walk the various networks and store their state in the status report. // Walk the various networks and store their state in the status report.
chromeos::NetworkStateHandler::NetworkStateList state_list; chromeos::NetworkStateHandler::NetworkStateList state_list;
network_state_handler->GetNetworkListByType( network_state_handler->GetNetworkListByType(
......
...@@ -99,6 +99,11 @@ class DeviceStatusCollector { ...@@ -99,6 +99,11 @@ class DeviceStatusCollector {
// Callback which receives the results of the idle state check. // Callback which receives the results of the idle state check.
void IdleStateCallback(ui::IdleState state); void IdleStateCallback(ui::IdleState state);
// Returns true if the currently active session is an auto-launched
// kiosk session (this enables functionality such as network reporting).
// Virtual to allow mocking.
virtual bool IsAutoLaunchedKioskSession();
// Samples the current CPU and RAM usage and updates our cache of samples. // Samples the current CPU and RAM usage and updates our cache of samples.
void SampleResourceUsage(); void SampleResourceUsage();
......
...@@ -93,7 +93,8 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { ...@@ -93,7 +93,8 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
local_state, local_state,
provider, provider,
location_update_requester, location_update_requester,
volume_info_fetcher) { volume_info_fetcher),
kiosk_mode_(false) {
// Set the baseline time to a fixed value (1 AM) to prevent test flakiness // Set the baseline time to a fixed value (1 AM) to prevent test flakiness
// due to a single activity period spanning two days. // due to a single activity period spanning two days.
SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1)); SetBaselineTime(Time::Now().LocalMidnight() + TimeDelta::FromHours(1));
...@@ -128,6 +129,14 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { ...@@ -128,6 +129,14 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
RefreshSampleResourceUsage(); RefreshSampleResourceUsage();
} }
void set_kiosk_mode(bool is_kiosk) {
kiosk_mode_ = is_kiosk;
}
bool IsAutoLaunchedKioskSession() override {
return kiosk_mode_;
}
void RefreshSampleResourceUsage() { void RefreshSampleResourceUsage() {
// Refresh our samples. Sample more than kMaxHardwareSamples times to // Refresh our samples. Sample more than kMaxHardwareSamples times to
// make sure that the code correctly caps the number of cached samples. // make sure that the code correctly caps the number of cached samples.
...@@ -161,6 +170,8 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector { ...@@ -161,6 +170,8 @@ class TestingDeviceStatusCollector : public policy::DeviceStatusCollector {
int baseline_offset_periods_; int baseline_offset_periods_;
std::vector<double> mock_cpu_usage_; std::vector<double> mock_cpu_usage_;
bool kiosk_mode_;
}; };
// Return the total number of active milliseconds contained in a device // Return the total number of active milliseconds contained in a device
...@@ -1025,7 +1036,18 @@ class DeviceStatusCollectorNetworkInterfacesTest ...@@ -1025,7 +1036,18 @@ class DeviceStatusCollectorNetworkInterfacesTest
} }
}; };
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NoNetworkStateIfNotKiosk) {
// If not in an active kiosk session, there should be network interfaces
// reported, but no network state.
GetStatus();
EXPECT_LT(0, status_.network_interface_size());
EXPECT_EQ(0, status_.network_state_size());
}
TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) { TEST_F(DeviceStatusCollectorNetworkInterfacesTest, NetworkInterfaces) {
// Mock that we are in kiosk mode so we report network state.
status_collector_->set_kiosk_mode(true);
// Interfaces should be reported by default. // Interfaces should be reported by default.
GetStatus(); GetStatus();
EXPECT_LT(0, status_.network_interface_size()); EXPECT_LT(0, status_.network_interface_size());
......
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