| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 41 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 42 #include "chrome/browser/chromeos/settings/cros_settings.h" | 42 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 43 #include "chrome/browser/policy/profile_policy_connector.h" | 43 #include "chrome/browser/policy/profile_policy_connector.h" |
| 44 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 44 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 45 #include "chrome/browser/profiles/profile_manager.h" | 45 #include "chrome/browser/profiles/profile_manager.h" |
| 46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "chromeos/audio/cras_audio_handler.h" | 47 #include "chromeos/audio/cras_audio_handler.h" |
| 48 #include "chromeos/dbus/dbus_thread_manager.h" | 48 #include "chromeos/dbus/dbus_thread_manager.h" |
| 49 #include "chromeos/dbus/update_engine_client.h" | 49 #include "chromeos/dbus/update_engine_client.h" |
| 50 #include "chromeos/disks/disk_mount_manager.h" | 50 #include "chromeos/disks/disk_mount_manager.h" |
| 51 #include "chromeos/login/login_state.h" |
| 51 #include "chromeos/network/device_state.h" | 52 #include "chromeos/network/device_state.h" |
| 52 #include "chromeos/network/network_handler.h" | 53 #include "chromeos/network/network_handler.h" |
| 53 #include "chromeos/network/network_state.h" | 54 #include "chromeos/network/network_state.h" |
| 54 #include "chromeos/network/network_state_handler.h" | 55 #include "chromeos/network/network_state_handler.h" |
| 55 #include "chromeos/settings/cros_settings_names.h" | 56 #include "chromeos/settings/cros_settings_names.h" |
| 56 #include "chromeos/system/statistics_provider.h" | 57 #include "chromeos/system/statistics_provider.h" |
| 57 #include "components/arc/arc_bridge_service.h" | 58 #include "components/arc/arc_bridge_service.h" |
| 58 #include "components/arc/arc_service_manager.h" | 59 #include "components/arc/arc_service_manager.h" |
| 59 #include "components/arc/common/enterprise_reporting.mojom.h" | 60 #include "components/arc/common/enterprise_reporting.mojom.h" |
| 60 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 61 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // a clamped dBm value in the range of -119 to -20dBm. | 295 // a clamped dBm value in the range of -119 to -20dBm. |
| 295 // | 296 // |
| 296 // TODO(atwilson): Tunnel the raw dBm signal strength from Shill instead of | 297 // TODO(atwilson): Tunnel the raw dBm signal strength from Shill instead of |
| 297 // doing the conversion here so we can report non-clamped values | 298 // doing the conversion here so we can report non-clamped values |
| 298 // (crbug.com/463334). | 299 // (crbug.com/463334). |
| 299 DCHECK_GT(signal_strength, 0); | 300 DCHECK_GT(signal_strength, 0); |
| 300 DCHECK_LE(signal_strength, 100); | 301 DCHECK_LE(signal_strength, 100); |
| 301 return signal_strength - 120; | 302 return signal_strength - 120; |
| 302 } | 303 } |
| 303 | 304 |
| 305 bool IsKioskApp() { |
| 306 auto user_type = chromeos::LoginState::Get()->GetLoggedInUserType(); |
| 307 return user_type == chromeos::LoginState::LOGGED_IN_USER_KIOSK_APP || |
| 308 user_type == chromeos::LoginState::LOGGED_IN_USER_ARC_KIOSK_APP; |
| 309 } |
| 310 |
| 304 } // namespace | 311 } // namespace |
| 305 | 312 |
| 306 namespace policy { | 313 namespace policy { |
| 307 | 314 |
| 308 // Helper class for state tracking of async status queries. Creates device and | 315 // Helper class for state tracking of async status queries. Creates device and |
| 309 // session status blobs in the constructor and sends them to the the status | 316 // session status blobs in the constructor and sends them to the the status |
| 310 // response callback in the destructor. | 317 // response callback in the destructor. |
| 311 // | 318 // |
| 312 // Some methods like |SampleVolumeInfo| queue async queries to collect data. The | 319 // Some methods like |SampleVolumeInfo| queue async queries to collect data. The |
| 313 // response callback of these queries, e.g. |OnVolumeInfoReceived|, holds a | 320 // response callback of these queries, e.g. |OnVolumeInfoReceived|, holds a |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 last_cpu_idle_ = 0; | 668 last_cpu_idle_ = 0; |
| 662 } | 669 } |
| 663 | 670 |
| 664 void DeviceStatusCollector::IdleStateCallback(ui::IdleState state) { | 671 void DeviceStatusCollector::IdleStateCallback(ui::IdleState state) { |
| 665 // Do nothing if device activity reporting is disabled. | 672 // Do nothing if device activity reporting is disabled. |
| 666 if (!report_activity_times_) | 673 if (!report_activity_times_) |
| 667 return; | 674 return; |
| 668 | 675 |
| 669 Time now = GetCurrentTime(); | 676 Time now = GetCurrentTime(); |
| 670 | 677 |
| 671 if (state == ui::IDLE_STATE_ACTIVE) { | 678 // For kiosk apps we report total uptime instead of active time. |
| 679 if (state == ui::IDLE_STATE_ACTIVE || IsKioskApp()) { |
| 672 // If it's been too long since the last report, or if the activity is | 680 // If it's been too long since the last report, or if the activity is |
| 673 // negative (which can happen when the clock changes), assume a single | 681 // negative (which can happen when the clock changes), assume a single |
| 674 // interval of activity. | 682 // interval of activity. |
| 675 int active_seconds = (now - last_idle_check_).InSeconds(); | 683 int active_seconds = (now - last_idle_check_).InSeconds(); |
| 676 if (active_seconds < 0 || | 684 if (active_seconds < 0 || |
| 677 active_seconds >= static_cast<int>((2 * kIdlePollIntervalSeconds))) { | 685 active_seconds >= static_cast<int>((2 * kIdlePollIntervalSeconds))) { |
| 678 AddActivePeriod(now - TimeDelta::FromSeconds(kIdlePollIntervalSeconds), | 686 AddActivePeriod(now - TimeDelta::FromSeconds(kIdlePollIntervalSeconds), |
| 679 now); | 687 now); |
| 680 } else { | 688 } else { |
| 681 AddActivePeriod(last_idle_check_, now); | 689 AddActivePeriod(last_idle_check_, now); |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1258 | 1266 |
| 1259 void DeviceStatusCollector::OnOSVersion(const std::string& version) { | 1267 void DeviceStatusCollector::OnOSVersion(const std::string& version) { |
| 1260 os_version_ = version; | 1268 os_version_ = version; |
| 1261 } | 1269 } |
| 1262 | 1270 |
| 1263 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { | 1271 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { |
| 1264 firmware_version_ = version; | 1272 firmware_version_ = version; |
| 1265 } | 1273 } |
| 1266 | 1274 |
| 1267 } // namespace policy | 1275 } // namespace policy |
| OLD | NEW |