| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 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 Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 16 |  | 
| Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ | 
|  | 18 | #define UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 19 |  | 
|  | 20 | #include <string> | 
|  | 21 |  | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 22 | #include <base/time/time.h> | 
|  | 23 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 24 | #include "update_engine/update_manager/provider.h" | 
|  | 25 | #include "update_engine/update_manager/variable.h" | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 26 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 27 | namespace chromeos_update_manager { | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 28 |  | 
|  | 29 | enum class Stage { | 
|  | 30 | kIdle, | 
|  | 31 | kCheckingForUpdate, | 
|  | 32 | kUpdateAvailable, | 
|  | 33 | kDownloading, | 
|  | 34 | kVerifying, | 
|  | 35 | kFinalizing, | 
|  | 36 | kUpdatedNeedReboot, | 
|  | 37 | kReportingErrorEvent, | 
|  | 38 | kAttemptingRollback, | 
| Amin Hassani | 70a90f5 | 2020-09-15 15:30:09 -0700 | [diff] [blame] | 39 | kCleanupPreviousUpdate, | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 40 | }; | 
|  | 41 |  | 
| Gilad Arnold | ec7f916 | 2014-07-15 13:24:46 -0700 | [diff] [blame] | 42 | enum class UpdateRequestStatus { | 
|  | 43 | kNone, | 
|  | 44 | kInteractive, | 
|  | 45 | kPeriodic, | 
|  | 46 | }; | 
|  | 47 |  | 
| Aaron Wood | bf5a252 | 2017-10-04 10:58:36 -0700 | [diff] [blame] | 48 | // These enum values are a bit-field. | 
|  | 49 | enum UpdateRestrictions : int { | 
|  | 50 | kNone, | 
|  | 51 | kRestrictDownloading = (1 << 0), | 
|  | 52 | }; | 
|  | 53 |  | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 54 | // Provider for Chrome OS update related information. | 
|  | 55 | class UpdaterProvider : public Provider { | 
|  | 56 | public: | 
| Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 57 | ~UpdaterProvider() override {} | 
| David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 58 |  | 
| Alex Deymo | c7ab616 | 2014-04-25 18:32:50 -0700 | [diff] [blame] | 59 | // A variable returning the timestamp when the update engine was started in | 
|  | 60 | // wallclock time. | 
|  | 61 | virtual Variable<base::Time>* var_updater_started_time() = 0; | 
|  | 62 |  | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 63 | // A variable returning the last update check time. | 
|  | 64 | virtual Variable<base::Time>* var_last_checked_time() = 0; | 
|  | 65 |  | 
|  | 66 | // A variable reporting the time when an update was last completed in the | 
|  | 67 | // current boot cycle. Returns an error if an update completed time could not | 
|  | 68 | // be read (e.g. no update was completed in the current boot cycle) or is | 
|  | 69 | // invalid. | 
|  | 70 | // | 
|  | 71 | // IMPORTANT: The time reported is not the wallclock time reading at the time | 
|  | 72 | // of the update, rather it is the point in time when the update completed | 
|  | 73 | // relative to the current wallclock time reading. Therefore, the gap between | 
|  | 74 | // the reported value and the current wallclock time is guaranteed to be | 
|  | 75 | // monotonically increasing. | 
|  | 76 | virtual Variable<base::Time>* var_update_completed_time() = 0; | 
|  | 77 |  | 
|  | 78 | // A variable returning the update progress (0.0 to 1.0). | 
|  | 79 | virtual Variable<double>* var_progress() = 0; | 
|  | 80 |  | 
|  | 81 | // A variable returning the current update status. | 
|  | 82 | virtual Variable<Stage>* var_stage() = 0; | 
|  | 83 |  | 
|  | 84 | // A variable returning the update target version. | 
|  | 85 | virtual Variable<std::string>* var_new_version() = 0; | 
|  | 86 |  | 
| Alex Deymo | f967ebe | 2014-05-05 14:46:17 -0700 | [diff] [blame] | 87 | // A variable returning the update payload size. The payload size is | 
|  | 88 | // guaranteed to be non-negative. | 
| Aaron Wood | 7f92e2b | 2017-08-28 14:51:21 -0700 | [diff] [blame] | 89 | virtual Variable<uint64_t>* var_payload_size() = 0; | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 90 |  | 
|  | 91 | // A variable returning the current channel. | 
|  | 92 | virtual Variable<std::string>* var_curr_channel() = 0; | 
|  | 93 |  | 
|  | 94 | // A variable returning the update target channel. | 
|  | 95 | virtual Variable<std::string>* var_new_channel() = 0; | 
|  | 96 |  | 
| Gilad Arnold | 0adbc94 | 2014-05-12 10:35:43 -0700 | [diff] [blame] | 97 | // A variable indicating whether user settings allow P2P updates. | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 98 | virtual Variable<bool>* var_p2p_enabled() = 0; | 
|  | 99 |  | 
| Gilad Arnold | 0adbc94 | 2014-05-12 10:35:43 -0700 | [diff] [blame] | 100 | // A variable indicating whether user settings allow updates over a cellular | 
|  | 101 | // network. | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 102 | virtual Variable<bool>* var_cellular_enabled() = 0; | 
| David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 103 |  | 
| Gilad Arnold | a6dab94 | 2014-04-25 11:46:03 -0700 | [diff] [blame] | 104 | // A variable returning the number of consecutive failed update checks. | 
|  | 105 | virtual Variable<unsigned int>* var_consecutive_failed_update_checks() = 0; | 
|  | 106 |  | 
| Gilad Arnold | a0258a5 | 2014-07-10 16:21:19 -0700 | [diff] [blame] | 107 | // A server-dictated update check interval in seconds, if one was given. | 
|  | 108 | virtual Variable<unsigned int>* var_server_dictated_poll_interval() = 0; | 
|  | 109 |  | 
| Gilad Arnold | ec7f916 | 2014-07-15 13:24:46 -0700 | [diff] [blame] | 110 | // A variable denoting whether a forced update was request but no update check | 
|  | 111 | // performed yet; also tells whether this request is for an interactive or | 
|  | 112 | // scheduled update. | 
|  | 113 | virtual Variable<UpdateRequestStatus>* var_forced_update_requested() = 0; | 
| Gilad Arnold | 44dc3bf | 2014-07-18 23:39:38 -0700 | [diff] [blame] | 114 |  | 
| Aaron Wood | bf5a252 | 2017-10-04 10:58:36 -0700 | [diff] [blame] | 115 | // A variable that returns the update restriction flags that are set | 
|  | 116 | // for all updates. | 
|  | 117 | virtual Variable<UpdateRestrictions>* var_update_restrictions() = 0; | 
|  | 118 |  | 
| Amin Hassani | 03277de | 2020-07-28 12:32:49 -0700 | [diff] [blame] | 119 | // A variable that returns the number of seconds for the first update check to | 
|  | 120 | // happen. | 
|  | 121 | virtual Variable<int64_t>* var_test_update_check_interval_timeout() = 0; | 
|  | 122 |  | 
| David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 123 | protected: | 
|  | 124 | UpdaterProvider() {} | 
|  | 125 |  | 
|  | 126 | private: | 
|  | 127 | DISALLOW_COPY_AND_ASSIGN(UpdaterProvider); | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 128 | }; | 
|  | 129 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 130 | }  // namespace chromeos_update_manager | 
| Gilad Arnold | ae47a9a | 2014-03-26 12:16:47 -0700 | [diff] [blame] | 131 |  | 
| Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 132 | #endif  // UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ |