diff options
author | Tianjie Xu <xunchang@google.com> | 2017-10-10 17:39:03 -0700 |
---|---|---|
committer | Tianjie Xu <xunchang@google.com> | 2017-10-14 22:44:35 +0000 |
commit | 90aaa109e38f147ec4bfc772439d9949f1b237c0 (patch) | |
tree | 1a12f29bdb847a384dfacd3cce214bb3891d0ab8 /metrics_utils.h | |
parent | 012aa5bc825f3efe810cc52864840ace6eae8275 (diff) |
Collect metrics for android update attempt
Report the update attempt/result metrics when an upate finishes;
and abnormally terminated updates/time to reboot when the device
reboots.
Bug: 30989466
Test: update_engine_unittest pass
Change-Id: Iea16b4e8003ae3dab5e9b7c65cf4b38d2219d203
Diffstat (limited to 'metrics_utils.h')
-rw-r--r-- | metrics_utils.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/metrics_utils.h b/metrics_utils.h index 2d62dc07..d08cc4a7 100644 --- a/metrics_utils.h +++ b/metrics_utils.h @@ -17,11 +17,16 @@ #ifndef UPDATE_ENGINE_METRICS_UTILS_H_ #define UPDATE_ENGINE_METRICS_UTILS_H_ +#include <string> + #include <base/time/time.h> +#include "update_engine/common/clock_interface.h" #include "update_engine/common/error_code.h" +#include "update_engine/common/prefs_interface.h" #include "update_engine/connection_utils.h" #include "update_engine/metrics_constants.h" +#include "update_engine/metrics_reporter_interface.h" namespace chromeos_update_engine { @@ -68,6 +73,33 @@ bool MonotonicDurationHelper(SystemState* system_state, int64_t* storage, base::TimeDelta* out_duration); +// Returns the persisted value from prefs for the given key. It also +// validates that the value returned is non-negative. +int64_t GetPersistedValue(const std::string& key, PrefsInterface* prefs); + +// Persists the reboot count of the update attempt to |kPrefsNumReboots|. +void SetNumReboots(int64_t num_reboots, PrefsInterface* prefs); + +// Persists the payload attempt number to |kPrefsPayloadAttemptNumber|. +void SetPayloadAttemptNumber(int64_t payload_attempt_number, + PrefsInterface* prefs); + +// Persists the finished time of an update to the |kPrefsSystemUpdatedMarker|. +void SetSystemUpdatedMarker(ClockInterface* clock, PrefsInterface* prefs); + +// Persists the start time of an update to |kPrefsUpdateTimestampStart|. +void SetUpdateTimestampStart(const base::Time& update_start_time, + PrefsInterface* prefs); + +// Called at program startup if the device booted into a new update. +// The |time_to_reboot| parameter contains the (monotonic-clock) duration +// from when the update successfully completed (the value in +// |kPrefsSystemUpdatedMarker|) until the device was booted into the update +// (current monotonic-clock time). +bool LoadAndReportTimeToReboot(MetricsReporterInterface* metrics_reporter, + PrefsInterface* prefs, + ClockInterface* clock); + } // namespace metrics_utils } // namespace chromeos_update_engine |