Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(834)

Unified Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 776803003: Updated DeviceStatusReportRequest to contain new monitoring data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed more feedback Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/device_status_collector.cc
diff --git a/chrome/browser/chromeos/policy/device_status_collector.cc b/chrome/browser/chromeos/policy/device_status_collector.cc
index 1af72bb4ff1d0f944267bc615fd73172d3fbb414..cc16f6cc2fff4d359f8b40a97c78daf0a019a3a5 100644
--- a/chrome/browser/chromeos/policy/device_status_collector.cc
+++ b/chrome/browser/chromeos/policy/device_status_collector.cc
@@ -23,6 +23,7 @@
#include "chrome/common/pref_names.h"
#include "chromeos/network/device_state.h"
#include "chromeos/network/network_handler.h"
+#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/settings/cros_settings_names.h"
#include "chromeos/system/statistics_provider.h"
@@ -94,6 +95,7 @@ DeviceStatusCollector::DeviceStatusCollector(
report_location_(false),
report_network_interfaces_(false),
report_users_(false),
+ report_hardware_status_(false),
weak_factory_(this) {
if (location_update_requester)
location_update_requester_ = *location_update_requester;
@@ -120,6 +122,8 @@ DeviceStatusCollector::DeviceStatusCollector(
chromeos::kReportDeviceNetworkInterfaces, callback);
users_subscription_ = cros_settings_->AddSettingsObserver(
chromeos::kReportDeviceUsers, callback);
+ hardware_status_subscription_ = cros_settings_->AddSettingsObserver(
+ chromeos::kReportDeviceHardwareStatus, callback);
// The last known location is persisted in local state. This makes location
// information available immediately upon startup and avoids the need to
@@ -182,6 +186,8 @@ void DeviceStatusCollector::UpdateReportingSettings() {
weak_factory_.GetWeakPtr()))) {
return;
}
+
+ // All reporting settings default to 'enabled'.
if (!cros_settings_->GetBoolean(
chromeos::kReportDeviceVersionInfo, &report_version_info_)) {
report_version_info_ = true;
@@ -195,10 +201,6 @@ void DeviceStatusCollector::UpdateReportingSettings() {
report_boot_mode_ = true;
}
if (!cros_settings_->GetBoolean(
- chromeos::kReportDeviceLocation, &report_location_)) {
- report_location_ = false;
- }
- if (!cros_settings_->GetBoolean(
chromeos::kReportDeviceNetworkInterfaces, &report_network_interfaces_)) {
report_network_interfaces_ = true;
}
@@ -206,6 +208,17 @@ void DeviceStatusCollector::UpdateReportingSettings() {
chromeos::kReportDeviceUsers, &report_users_)) {
report_users_ = true;
}
+ if (!cros_settings_->GetBoolean(
+ chromeos::kReportDeviceHardwareStatus, &report_hardware_status_)) {
+ report_hardware_status_ = true;
+ }
+
+ // Device location reporting is disabled by default because it is
+ // not launched yet.
+ if (!cros_settings_->GetBoolean(
+ chromeos::kReportDeviceLocation, &report_location_)) {
+ report_location_ = false;
+ }
if (report_location_) {
ScheduleGeolocationUpdateRequest();
@@ -383,7 +396,7 @@ void DeviceStatusCollector::GetLocation(
void DeviceStatusCollector::GetNetworkInterfaces(
em::DeviceStatusReportRequest* request) {
- // Maps flimflam device type strings to proto enum constants.
+ // Maps shill device type strings to proto enum constants.
static const struct {
const char* type_string;
em::NetworkInterface::NetworkDeviceType type_constant;
@@ -395,9 +408,29 @@ void DeviceStatusCollector::GetNetworkInterfaces(
{ shill::kTypeCellular, em::NetworkInterface::TYPE_CELLULAR, },
};
+ // Maps shill device connection status to proto enum constants.
+ static const struct {
+ const char* state_string;
+ em::NetworkState::ConnectionState state_constant;
+ } kConnectionStateMap[] = {
+ { shill::kStateIdle, em::NetworkState::IDLE },
+ { shill::kStateCarrier, em::NetworkState::CARRIER },
+ { shill::kStateAssociation, em::NetworkState::ASSOCIATION },
+ { shill::kStateConfiguration, em::NetworkState::CONFIGURATION },
+ { shill::kStateReady, em::NetworkState::READY },
+ { shill::kStatePortal, em::NetworkState::PORTAL },
+ { shill::kStateOffline, em::NetworkState::OFFLINE },
+ { shill::kStateOnline, em::NetworkState::ONLINE },
+ { shill::kStateDisconnect, em::NetworkState::DISCONNECT },
+ { shill::kStateFailure, em::NetworkState::FAILURE },
+ { shill::kStateActivationFailure,
+ em::NetworkState::ACTIVATION_FAILURE },
+ };
+
chromeos::NetworkStateHandler::DeviceStateList device_list;
- chromeos::NetworkHandler::Get()->network_state_handler()->GetDeviceList(
- &device_list);
+ chromeos::NetworkStateHandler* network_state_handler =
+ chromeos::NetworkHandler::Get()->network_state_handler();
+ network_state_handler->GetDeviceList(&device_list);
chromeos::NetworkStateHandler::DeviceStateList::const_iterator device;
for (device = device_list.begin(); device != device_list.end(); ++device) {
@@ -421,6 +454,37 @@ void DeviceStatusCollector::GetNetworkInterfaces(
interface->set_meid((*device)->meid());
if (!(*device)->imei().empty())
interface->set_imei((*device)->imei());
+ if (!(*device)->path().empty())
+ interface->set_device_path((*device)->path());
+ }
+
+ // Walk the various networks and store their state in the status report.
+ chromeos::NetworkStateHandler::NetworkStateList state_list;
+ network_state_handler->GetNetworkListByType(
+ chromeos::NetworkTypePattern::Default(),
+ true, // configured_only
+ false, // visible_only,
+ 0, // no limit to number of results
+ &state_list);
+
+ for (const chromeos::NetworkState* state: state_list) {
+ // Determine the connection state and signal strength for |state|.
+ em::NetworkState::ConnectionState connection_state_enum =
+ em::NetworkState::UNKNOWN;
+ std::string connection_state_string(state->connection_state());
pneubeck (no reviews) 2014/12/12 02:02:47 optional nit: you could still change the type to '
Andrew T Wilson (Slow) 2014/12/15 17:00:49 Done.
+ for (size_t i = 0; i < arraysize(kConnectionStateMap); ++i) {
+ if (connection_state_string == kConnectionStateMap[i].state_string) {
+ connection_state_enum = kConnectionStateMap[i].state_constant;
+ break;
+ }
+ }
+
+ // Copy fields from NetworkState into the status report.
+ em::NetworkState* proto_state = request->add_network_state();
+ proto_state->set_connection_state(connection_state_enum);
+ proto_state->set_signal_strength(state->signal_strength());
+ if (!state->device_path().empty())
+ proto_state->set_device_path(state->device_path());
}
}
@@ -447,12 +511,9 @@ void DeviceStatusCollector::GetUsers(em::DeviceStatusReportRequest* request) {
}
}
-void DeviceStatusCollector::GetStatus(em::DeviceStatusReportRequest* request) {
- // TODO(mnissler): Remove once the old cloud policy stack is retired. The old
- // stack doesn't support reporting successful submissions back to here, so
- // just assume whatever ends up in |request| gets submitted successfully.
- GetDeviceStatus(request);
- OnSubmittedSuccessfully();
+void DeviceStatusCollector::GetHardwareStatus(
+ em::DeviceStatusReportRequest* status) {
+ // TODO(atwilson): Fill in hardware status fields.
}
bool DeviceStatusCollector::GetDeviceStatus(
@@ -476,6 +537,9 @@ bool DeviceStatusCollector::GetDeviceStatus(
GetUsers(status);
}
+ if (report_hardware_status_)
+ GetHardwareStatus(status);
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698