上篇已经分析过了InstallPlanAction、DownloadAction、FileSystemVerityAction 三个Action的工作内容,还有一个PostinstallRunnerAction的在这篇中继续分析,每个Action都是从PerformAction开始的:
void PostinstallRunnerAction::PerformAction() {
CHECK(HasInputObject());
install_plan_ = GetInputObject();
//确认下是否需要powerwash_, 如果有设置,一般在ApplyPayload的那个hashKey中会带有POWERWASH的key值
if (install_plan_.powerwash_required) {
if (hardware_->SchedulePowerwash()) {
powerwash_scheduled_ = true;
} else {
return CompletePostinstall(ErrorCode::kPostinstallPowerwashError);
}
}
// 初始化所有升级分区的权重
partition_weight_.resize(install_plan_.partitions.size());
total_weight_ = 0;
for (size_t i = 0; i < install_plan_.partitions.size(); ++i) {
partition_weight_[i] = install_plan_.partitions[i].run_postinstall;
total_weight_ += partition_weight_[i];
}
accumulated_weight_ = 0;
ReportProgress(0);
PerformPartitionPostinstall();
}
上面主要做判断是否需要powerwash_,一般的升级方式不需要powerwash,然后初始升级分区的权重,同时保存这些权重值,之后开始分区升级:
void PostinstallRunnerAction::PerformPartitionPostinstall() {
//判断是否在升级过程中
if (!install_plan_.run_post_install) {
LOG(INFO) << "Skipping post-install according to install plan.";
return CompletePostinstall(ErrorCode::kSuccess);
}
//判断下载路