blob: cb6262385178353d2e1420d44c87e0061876dfad [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070016
Gilad Arnold48415f12014-06-27 07:10:58 -070017#ifndef UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_
18#define UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070019
20#include <string>
21
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070022#include <base/time/time.h>
23
Alex Deymo63784a52014-05-28 10:46:14 -070024#include "update_engine/update_manager/provider.h"
25#include "update_engine/update_manager/variable.h"
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070026
Alex Deymo63784a52014-05-28 10:46:14 -070027namespace chromeos_update_manager {
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070028
29enum class Stage {
30 kIdle,
31 kCheckingForUpdate,
32 kUpdateAvailable,
33 kDownloading,
34 kVerifying,
35 kFinalizing,
36 kUpdatedNeedReboot,
37 kReportingErrorEvent,
38 kAttemptingRollback,
39};
40
Gilad Arnoldec7f9162014-07-15 13:24:46 -070041enum class UpdateRequestStatus {
42 kNone,
43 kInteractive,
44 kPeriodic,
45};
46
Aaron Wood224dfc22017-10-04 10:58:36 -070047// These enum values are a bit-field.
48enum UpdateRestrictions : int {
49 kNone,
50 kRestrictDownloading = (1 << 0),
51};
52
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070053// Provider for Chrome OS update related information.
54class UpdaterProvider : public Provider {
55 public:
Alex Deymo610277e2014-11-11 21:18:11 -080056 ~UpdaterProvider() override {}
David Zeuthen21716e22014-04-23 15:42:05 -070057
Alex Deymoc7ab6162014-04-25 18:32:50 -070058 // A variable returning the timestamp when the update engine was started in
59 // wallclock time.
60 virtual Variable<base::Time>* var_updater_started_time() = 0;
61
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070062 // A variable returning the last update check time.
63 virtual Variable<base::Time>* var_last_checked_time() = 0;
64
65 // A variable reporting the time when an update was last completed in the
66 // current boot cycle. Returns an error if an update completed time could not
67 // be read (e.g. no update was completed in the current boot cycle) or is
68 // invalid.
69 //
70 // IMPORTANT: The time reported is not the wallclock time reading at the time
71 // of the update, rather it is the point in time when the update completed
72 // relative to the current wallclock time reading. Therefore, the gap between
73 // the reported value and the current wallclock time is guaranteed to be
74 // monotonically increasing.
75 virtual Variable<base::Time>* var_update_completed_time() = 0;
76
77 // A variable returning the update progress (0.0 to 1.0).
78 virtual Variable<double>* var_progress() = 0;
79
80 // A variable returning the current update status.
81 virtual Variable<Stage>* var_stage() = 0;
82
83 // A variable returning the update target version.
84 virtual Variable<std::string>* var_new_version() = 0;
85
Alex Deymof967ebe2014-05-05 14:46:17 -070086 // A variable returning the update payload size. The payload size is
87 // guaranteed to be non-negative.
Aaron Wood7f92e2b2017-08-28 14:51:21 -070088 virtual Variable<uint64_t>* var_payload_size() = 0;
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070089
90 // A variable returning the current channel.
91 virtual Variable<std::string>* var_curr_channel() = 0;
92
93 // A variable returning the update target channel.
94 virtual Variable<std::string>* var_new_channel() = 0;
95
Gilad Arnold0adbc942014-05-12 10:35:43 -070096 // A variable indicating whether user settings allow P2P updates.
Gilad Arnoldae47a9a2014-03-26 12:16:47 -070097 virtual Variable<bool>* var_p2p_enabled() = 0;
98
Gilad Arnold0adbc942014-05-12 10:35:43 -070099 // A variable indicating whether user settings allow updates over a cellular
100 // network.
Gilad Arnoldae47a9a2014-03-26 12:16:47 -0700101 virtual Variable<bool>* var_cellular_enabled() = 0;
David Zeuthen21716e22014-04-23 15:42:05 -0700102
Gilad Arnolda6dab942014-04-25 11:46:03 -0700103 // A variable returning the number of consecutive failed update checks.
104 virtual Variable<unsigned int>* var_consecutive_failed_update_checks() = 0;
105
Gilad Arnolda0258a52014-07-10 16:21:19 -0700106 // A server-dictated update check interval in seconds, if one was given.
107 virtual Variable<unsigned int>* var_server_dictated_poll_interval() = 0;
108
Gilad Arnoldec7f9162014-07-15 13:24:46 -0700109 // A variable denoting whether a forced update was request but no update check
110 // performed yet; also tells whether this request is for an interactive or
111 // scheduled update.
112 virtual Variable<UpdateRequestStatus>* var_forced_update_requested() = 0;
Gilad Arnold44dc3bf2014-07-18 23:39:38 -0700113
Aaron Wood224dfc22017-10-04 10:58:36 -0700114 // A variable that returns the update restriction flags that are set
115 // for all updates.
116 virtual Variable<UpdateRestrictions>* var_update_restrictions() = 0;
117
David Zeuthen21716e22014-04-23 15:42:05 -0700118 protected:
119 UpdaterProvider() {}
120
121 private:
122 DISALLOW_COPY_AND_ASSIGN(UpdaterProvider);
Gilad Arnoldae47a9a2014-03-26 12:16:47 -0700123};
124
Alex Deymo63784a52014-05-28 10:46:14 -0700125} // namespace chromeos_update_manager
Gilad Arnoldae47a9a2014-03-26 12:16:47 -0700126
Gilad Arnold48415f12014-06-27 07:10:58 -0700127#endif // UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_