Chromium Code Reviews| 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 616aa251950bd8636c01e7e18d2226da5ecdb9ab..f87e0f9446929a38bd60180d61d855413d7ae6f3 100644 |
| --- a/chrome/browser/chromeos/policy/device_status_collector.cc |
| +++ b/chrome/browser/chromeos/policy/device_status_collector.cc |
| @@ -48,6 +48,8 @@ |
| #include "chromeos/network/network_state_handler.h" |
| #include "chromeos/settings/cros_settings_names.h" |
| #include "chromeos/system/statistics_provider.h" |
| +#include "components/arc/arc_bridge_service.h" |
| +#include "components/arc/common/enterprise_reporting.mojom.h" |
| #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| #include "components/policy/proto/device_management_backend.pb.h" |
| #include "components/prefs/pref_registry_simple.h" |
| @@ -216,6 +218,21 @@ std::vector<em::CPUTempInfo> ReadCPUTempInfo() { |
| return contents; |
| } |
| +bool ReadAndroidStatus( |
| + const policy::DeviceStatusCollector::AndroidStatusReceiver& receiver) { |
| + auto* const arc_service = arc::ArcBridgeService::Get(); |
| + if (arc_service == nullptr) |
| + return false; |
| + auto* const instance_holder = arc_service->enterprise_reporting(); |
| + if (instance_holder == nullptr) |
| + return false; |
| + auto* const instance = instance_holder->GetInstanceForMethod("GetStatus", 1); |
| + if (instance == nullptr) |
| + return false; |
| + instance->GetStatus(receiver); |
| + return true; |
| +} |
| + |
| // Returns the DeviceLocalAccount associated with the current kiosk session. |
| // Returns null if there is no active kiosk session, or if that kiosk |
| // session has been removed from policy since the session started, in which |
| @@ -338,6 +355,13 @@ class GetStatusState : public base::RefCountedThreadSafe<GetStatusState> { |
| base::Bind(&GetStatusState::OnCPUTempInfoReceived, this)); |
| } |
| + bool FetchAndroidStatus( |
| + const policy::DeviceStatusCollector::AndroidStatusFetcher& |
| + android_status_fetcher) { |
| + return android_status_fetcher.Run( |
| + base::Bind(&GetStatusState::OnAndroidInfoReceived, this)); |
| + } |
| + |
| private: |
| friend class RefCountedThreadSafe<GetStatusState>; |
| @@ -366,6 +390,14 @@ class GetStatusState : public base::RefCountedThreadSafe<GetStatusState> { |
| *device_status_->add_cpu_temp_info() = info; |
| } |
| + void OnAndroidInfoReceived(mojo::String status, |
| + mojo::String droid_guard_info) { |
| + em::AndroidStatus* android_status = |
| + session_status_->mutable_android_status(); |
| + android_status->set_status_payload(status); |
| + android_status->set_droid_guard_info(droid_guard_info); |
| + } |
| + |
| const scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| policy::DeviceStatusCollector::StatusCallback response_; |
| std::unique_ptr<em::DeviceStatusReportRequest> device_status_ = |
| @@ -379,7 +411,8 @@ DeviceStatusCollector::DeviceStatusCollector( |
| chromeos::system::StatisticsProvider* provider, |
| const VolumeInfoFetcher& volume_info_fetcher, |
| const CPUStatisticsFetcher& cpu_statistics_fetcher, |
| - const CPUTempFetcher& cpu_temp_fetcher) |
| + const CPUTempFetcher& cpu_temp_fetcher, |
| + const AndroidStatusFetcher& android_status_fetcher) |
| : max_stored_past_activity_days_(kMaxStoredPastActivityDays), |
| max_stored_future_activity_days_(kMaxStoredFutureActivityDays), |
| local_state_(local_state), |
| @@ -387,6 +420,7 @@ DeviceStatusCollector::DeviceStatusCollector( |
| volume_info_fetcher_(volume_info_fetcher), |
| cpu_statistics_fetcher_(cpu_statistics_fetcher), |
| cpu_temp_fetcher_(cpu_temp_fetcher), |
| + android_status_fetcher_(android_status_fetcher), |
| statistics_provider_(provider), |
| cros_settings_(chromeos::CrosSettings::Get()), |
| task_runner_(nullptr), |
| @@ -405,6 +439,9 @@ DeviceStatusCollector::DeviceStatusCollector( |
| if (cpu_temp_fetcher_.is_null()) |
| cpu_temp_fetcher_ = base::Bind(&ReadCPUTempInfo); |
| + if (android_status_fetcher_.is_null()) |
| + android_status_fetcher_ = base::Bind(&ReadAndroidStatus); |
| + |
| idle_poll_timer_.Start(FROM_HERE, |
| TimeDelta::FromSeconds(kIdlePollIntervalSeconds), |
| this, &DeviceStatusCollector::CheckIdleState); |
| @@ -515,6 +552,9 @@ void DeviceStatusCollector::UpdateReportingSettings() { |
| report_session_status_ = true; |
| } |
| + // TODO(phweiss): Create policy to control this, and turn it on by default. |
| + report_android_status_ = false; |
| + |
| if (!report_hardware_status_) { |
| ClearCachedResourceUsage(); |
| } else if (!already_reporting_hardware_status) { |
| @@ -1087,6 +1127,8 @@ void DeviceStatusCollector::GetSessionStatus( |
| if (report_session_status_) |
|
ljusten (tachyonic)
2016/10/05 18:19:49
We should rename a few things then to prevent conf
phweiss
2016/10/06 08:56:19
Done.
|
| anything_reported |= GetAccountStatus(status); |
| + if (report_android_status_) |
| + anything_reported |= GetAndroidStatus(status, state); |
| // Wipe pointer if we didn't actually add any data. |
| if (!anything_reported) |
| @@ -1117,6 +1159,12 @@ bool DeviceStatusCollector::GetAccountStatus( |
| return true; |
| } |
| +bool DeviceStatusCollector::GetAndroidStatus( |
| + em::SessionStatusReportRequest* status, |
| + scoped_refptr<GetStatusState> state) { |
| + return state->FetchAndroidStatus(android_status_fetcher_); |
| +} |
| + |
| std::string DeviceStatusCollector::GetAppVersion( |
| const std::string& kiosk_app_id) { |
| Profile* const profile = |