//
// Copyright (C) 2012 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef UPDATE_ENGINE_PAYLOAD_STATE_H_
#define UPDATE_ENGINE_PAYLOAD_STATE_H_
#include <algorithm>
#include <string>
#include <vector>
#include <base/time/time.h>
#include <gtest/gtest_prod.h> // for FRIEND_TEST
#include "update_engine/common/prefs_interface.h"
#include "update_engine/metrics_constants.h"
#include "update_engine/payload_state_interface.h"
namespace chromeos_update_engine {
class SystemState;
// Encapsulates all the payload state required for download. This includes the
// state necessary for handling multiple URLs in Omaha response, the backoff
// state, etc. All state is persisted so that we use the most recently saved
// value when resuming the update_engine process. All state is also cached in
// memory so that we ensure we always make progress based on last known good
// state even when there's any issue in reading/writing from the file system.
class PayloadState : public PayloadStateInterface {
public:
PayloadState();
~PayloadState() override {}
// Initializes a payload state object using the given global system state.
// It performs the initial loading of all persisted state into memory and
// dumps the initial state for debugging purposes. Note: the other methods
// should be called only after calling Initialize on this object.
bool Initialize(SystemState* system_state);
// Implementation of PayloadStateInterface methods.
void SetResponse(const OmahaResponse& response) override;
void DownloadComplete() override;
void DownloadProgress(size_t count) override;
void UpdateResumed() override;
void UpdateRestarted() override;
void UpdateSucceeded() override;
void UpdateFailed(ErrorCode error) override;
void ResetUpdateStatus() override;
bool ShouldBackoffDownload() override;
void Rollback() override;
void ExpectRebootInNewVersion(const std::string& target_version_uid) override;
void SetUsingP2PForDownloading(bool value) override;
void SetUsingP2PForSharing(bool value) override {
using_p2p_for_sharing_ = value;
}
inline std::string GetResponseSignature() override {
return response_signature_;
}
inline int GetFullPayloadAttemptNumber() override {
return full_payload_attempt_number_;
}
inline int GetPayloadAttemptNumber() override {
return payload_attempt_number_;
}
inline std::string GetCurrentUrl() override {
return (payload_index_ < candidate_urls_.size() &&
url_index_ < candidate_urls_[payload_index_].size())
? candidate_urls_[payload_index_][url_index_]
: "";
}
inline uint32_t GetUrlFailureCount() override { return url_failure_count_; }
inline uint32_t GetUrlSwitchCount() override { return url_switch_count_; }
inline int GetNumResponsesSeen() override { return num_responses_seen_; }
inline base::Time GetBackoffExpiryTime() override {
return backoff_expiry_time_;
}
base::TimeDelta GetUpdateDuration() override;
base::TimeDelta GetUpdateDurationUptime() override;
inline uint64_t GetCurrentBytesDownloaded(DownloadSource source) override {
return source < kNumDownloadSources ? current_bytes_downloaded_[source] : 0;
}
inline uint64_t GetTotalBytesDownloaded(DownloadSource source) override {
return source < kNumDownloadSources ? total_bytes_downloaded_[source] : 0;
}
inline uint32_t GetNumReboots() override { return num_reboots_; }
void UpdateEngineStarted() override;
inline bool GetRollbackHappened() override { return rollback_happened_; }
void SetRollbackHappened(bool rollback_happened) override;
inline std::string GetRollbackVersion() override { return rollback_version_; }
int GetP2PNumAttempts() override;
base::Time GetP2PFirstAttemptTimestamp() override;
void P2PNewAttempt() override;
bool P2PAttemptAllowed() override;
bool GetUsingP2PForDownloading() const override {
return using_p2p_for_downloading_;
}
bool GetUsingP2PForSharing() const override { return using_p2p_for_sharing_; }
base::TimeDelta GetScatteringWaitPeriod() override {
return scattering_wait_period_;
}
void SetScatteringWaitPeriod(base::TimeDelta wait_period) override;
void SetStagingWaitPeriod(base::TimeDelta wait_period) override;
void SetP2PUrl(const std::string& url) override { p2p_url_ = url; }
std::string GetP2PUrl() const override { return p2p_url_; }
bool NextPayload() override;
private:
enum class AttemptType {
kUpdate,
kRollback,
};
friend class PayloadStateTest;
FRIEND_TEST(PayloadStateTest, RebootAfterUpdateFailedMetric);
FRIEND_TEST(PayloadStateTest, RebootAfterUpdateSucceed);
FRIEND_TEST(PayloadStateTest, RebootAfterCanceledUpdate);
FRIEND_TEST(PayloadStateTest, RollbackHappened);
FRIEND_TEST(PayloadStateTest, RollbackVersion);
FRIEND_TEST(PayloadStateTest, UpdateSuccessWithWipedPrefs);
// Helper called when an attempt has begun, is called by
// UpdateResumed(), UpdateRestarted() and Rollback().
void AttemptStarted(AttemptType attempt_type);
// Increments the payload attempt number used for metrics.
void IncrementPayloadAttemptNumber();
// Increments the payload attempt number which governs the backoff behavior
// at the time of the next update check.
void IncrementFullPayloadAttemptNumber();
// Advances the current URL index to the next available one. If all URLs have
// been exhausted during the current payload download attempt (as indicated
// by the payload attempt number), then it will increment the payload attempt
// number and wrap around again with the first URL in the list. This also
// updates the URL switch count, if needed.
void IncrementUrlIndex();
// Increments the failure count of the current URL. If the configured max
// failure count is reached for this URL, it advances the current URL index
// to the next URL and resets the failure count for that URL.
void IncrementFailureCount();
// Updates the backoff expiry time exponentially based on the current
// payload attempt number.
void UpdateBackoffExpiryTime();
// Updates the value of current download source based on the current URL
// index. If the download source is not one of the known sources, it's set
// to kNumDownloadSources.
void UpdateCurrentDownloadSource();
// Updates the various metrics corresponding with the given number of bytes
// that were downloaded recently.
void UpdateBytesDownloaded(size_t count);
// Calculates the PayloadType we're using.
PayloadType CalculatePayloadType();
// Collects and reports the various metrics related to an update attempt.
void CollectAndReportAttemptMetrics(ErrorCode code);
// Persists values related to the UpdateEngine.Attempt.* metrics so
// we can identify later if an update attempt ends abnormally.
void PersistAttemptMetrics();
// Clears persistent state previously set using AttemptMetricsPersist().
void ClearPersistedAttemptMetrics();
// Checks if persistent state previously set using AttemptMetricsPersist()
// exists and, if so, emits it with |attempt_result| set to
// metrics::AttemptResult::kAbnormalTermination.
void ReportAndClearPersistedAttemptMetrics();
// Collects and reports the various metrics related to a successful update.
void CollectAndReportSuccessfulUpdateMetrics();
// Checks if we were expecting to be running in the new version but the
// boot into
没有合适的资源?快使用搜索试试~ 我知道了~
android_system_update_engine
共561个文件
cc:253个
h:238个
py:18个
需积分: 15 3 下载量 182 浏览量
2021-03-19
18:20:31
上传
评论
收藏 1.21MB ZIP 举报
温馨提示
android_system_update_engine
资源详情
资源评论
资源推荐
收起资源包目录
android_system_update_engine (561个子文件)
IUpdateEngine.aidl 3KB
IUpdateEngine.aidl 2KB
IUpdateEngineCallback.aidl 862B
IUpdateEngineStatusCallback.aidl 817B
ParcelableUpdateEngineStatus.aidl 752B
Android.bp 23KB
brillo_update_payload 29KB
sample_images.tar.bz2 5KB
omaha_request_action_unittest.cc 135KB
delta_performer.cc 81KB
omaha_request_action.cc 77KB
payload_state_unittest.cc 65KB
update_attempter.cc 65KB
chromeos_policy_unittest.cc 64KB
update_attempter_unittest.cc 62KB
payload_state.cc 52KB
http_fetcher_unittest.cc 48KB
delta_performer_integration_test.cc 45KB
delta_diff_utils.cc 45KB
delta_performer_unittest.cc 43KB
update_attempter_android.cc 39KB
dynamic_partition_control_android.cc 38KB
chromeos_policy.cc 37KB
dynamic_partition_control_android_unittest.cc 34KB
utils.cc 33KB
delta_diff_utils_unittest.cc 31KB
inplace_generator.cc 29KB
generate_delta_main.cc 29KB
libcurl_http_fetcher.cc 27KB
omaha_response_handler_action_unittest.cc 26KB
metrics_reporter_omaha.cc 26KB
inplace_generator_unittest.cc 25KB
download_action_unittest.cc 25KB
p2p_manager.cc 23KB
payload_signer.cc 23KB
ab_generator_unittest.cc 22KB
real_shill_provider_unittest.cc 21KB
test_http_server.cc 21KB
update_engine_client.cc 21KB
utils_unittest.cc 20KB
evaluation_context_unittest.cc 19KB
p2p_manager_unittest.cc 19KB
metrics_reporter_omaha_unittest.cc 19KB
real_updater_provider_unittest.cc 18KB
real_updater_provider.cc 17KB
postinstall_runner_action_unittest.cc 16KB
metrics_utils.cc 16KB
download_action.cc 16KB
common_service.cc 15KB
connection_manager_unittest.cc 15KB
payload_file.cc 14KB
cleanup_previous_update_action.cc 14KB
postinstall_runner_action.cc 14KB
deflate_utils.cc 14KB
real_device_policy_provider_unittest.cc 13KB
ext2_filesystem.cc 12KB
ab_generator.cc 12KB
filesystem_verifier_action_unittest.cc 12KB
update_manager_unittest.cc 12KB
payload_generation_config.cc 12KB
extent_ranges_unittest.cc 11KB
squashfs_filesystem.cc 11KB
boot_control_chromeos.cc 11KB
squashfs_filesystem_unittest.cc 11KB
hardware_chromeos.cc 11KB
prefs_unittest.cc 11KB
payload_generation_config_android_unittest.cc 11KB
extent_ranges.cc 11KB
boxed_value_unittest.cc 10KB
update_engine_client_android.cc 10KB
omaha_response_handler_action.cc 10KB
filesystem_verifier_action.cc 10KB
test_utils.cc 10KB
payload_generation_config_android.cc 10KB
action_processor_unittest.cc 10KB
omaha_request_params_unittest.cc 10KB
subprocess.cc 9KB
payload_signer_unittest.cc 9KB
subprocess_unittest.cc 9KB
cycle_breaker_unittest.cc 9KB
payload_metadata.cc 9KB
logging_android.cc 9KB
binder_service_android.cc 9KB
payload_verifier.cc 9KB
omaha_request_params.cc 9KB
real_system_state.cc 8KB
error_code_utils.cc 8KB
real_device_policy_provider.cc 8KB
image_properties_android.cc 8KB
dbus_service.cc 8KB
client_dbus.cc 8KB
metrics_utils_unittest.cc 8KB
evaluation_context.cc 8KB
weekly_time_unittest.cc 8KB
update_attempter_android_unittest.cc 8KB
binder_service_brillo.cc 8KB
mtd_file_descriptor.cc 8KB
client_binder.cc 8KB
verity_writer_android.cc 8KB
connection_manager.cc 8KB
共 561 条
- 1
- 2
- 3
- 4
- 5
- 6
茶了不几
- 粉丝: 30
- 资源: 4772
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于JSP水产品销售系统源码.zip
- 基于JSP手机商城管理系统源码.zip
- 5.3.1_1二叉树的先中后序遍历.mp420240404-134540.png
- 基于JSP实现一个C语言教学网站平台源码.zip
- 抖音快手-课程网盘链接提取码下载 .txt
- 934742083249391XGOBOTV1.2.4.apk
- 课程设计基于OpenCV的材料缺陷检测程序python源码(含超详细注释).zip
- 基于python和百度EsayDL实现自动驾驶算法+基于ESP32开发板作为智能车主控芯片的自动驾驶智能车项目+源码(高分项目)
- Centos7-离线安装-MySQL5-7-31-tar包安装
- 蓝海平台带货-课程网盘链接提取码下载 .txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0