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 // 16 17 #ifndef UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ 18 #define UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ 19 20 #include <string> 21 22 #include <base/time/time.h> 23 24 #include "update_engine/update_manager/provider.h" 25 #include "update_engine/update_manager/variable.h" 26 27 namespace chromeos_update_manager { 28 29 enum class Stage { 30 kIdle, 31 kCheckingForUpdate, 32 kUpdateAvailable, 33 kDownloading, 34 kVerifying, 35 kFinalizing, 36 kUpdatedNeedReboot, 37 kReportingErrorEvent, 38 kAttemptingRollback, 39 }; 40 41 enum class UpdateRequestStatus { 42 kNone, 43 kInteractive, 44 kPeriodic, 45 }; 46 47 // Provider for Chrome OS update related information. 48 class UpdaterProvider : public Provider { 49 public: ~UpdaterProvider()50 ~UpdaterProvider() override {} 51 52 // A variable returning the timestamp when the update engine was started in 53 // wallclock time. 54 virtual Variable<base::Time>* var_updater_started_time() = 0; 55 56 // A variable returning the last update check time. 57 virtual Variable<base::Time>* var_last_checked_time() = 0; 58 59 // A variable reporting the time when an update was last completed in the 60 // current boot cycle. Returns an error if an update completed time could not 61 // be read (e.g. no update was completed in the current boot cycle) or is 62 // invalid. 63 // 64 // IMPORTANT: The time reported is not the wallclock time reading at the time 65 // of the update, rather it is the point in time when the update completed 66 // relative to the current wallclock time reading. Therefore, the gap between 67 // the reported value and the current wallclock time is guaranteed to be 68 // monotonically increasing. 69 virtual Variable<base::Time>* var_update_completed_time() = 0; 70 71 // A variable returning the update progress (0.0 to 1.0). 72 virtual Variable<double>* var_progress() = 0; 73 74 // A variable returning the current update status. 75 virtual Variable<Stage>* var_stage() = 0; 76 77 // A variable returning the update target version. 78 virtual Variable<std::string>* var_new_version() = 0; 79 80 // A variable returning the update payload size. The payload size is 81 // guaranteed to be non-negative. 82 virtual Variable<int64_t>* var_payload_size() = 0; 83 84 // A variable returning the current channel. 85 virtual Variable<std::string>* var_curr_channel() = 0; 86 87 // A variable returning the update target channel. 88 virtual Variable<std::string>* var_new_channel() = 0; 89 90 // A variable indicating whether user settings allow P2P updates. 91 virtual Variable<bool>* var_p2p_enabled() = 0; 92 93 // A variable indicating whether user settings allow updates over a cellular 94 // network. 95 virtual Variable<bool>* var_cellular_enabled() = 0; 96 97 // A variable returning the number of consecutive failed update checks. 98 virtual Variable<unsigned int>* var_consecutive_failed_update_checks() = 0; 99 100 // A server-dictated update check interval in seconds, if one was given. 101 virtual Variable<unsigned int>* var_server_dictated_poll_interval() = 0; 102 103 // A variable denoting whether a forced update was request but no update check 104 // performed yet; also tells whether this request is for an interactive or 105 // scheduled update. 106 virtual Variable<UpdateRequestStatus>* var_forced_update_requested() = 0; 107 108 protected: UpdaterProvider()109 UpdaterProvider() {} 110 111 private: 112 DISALLOW_COPY_AND_ASSIGN(UpdaterProvider); 113 }; 114 115 } // namespace chromeos_update_manager 116 117 #endif // UPDATE_ENGINE_UPDATE_MANAGER_UPDATER_PROVIDER_H_ 118