blob: 74150df6c428e53b638178e6f19b53fea3c14047 [file] [log] [blame]
#include "update_engine/payload_properties_handler_action.h"
#include "update_engine/payload_state.h"
namespace chromeos_update_engine {
PayloadPropertiesHandlerAction::PayloadPropertiesHandlerAction(SystemState* system_state)
: system_state_(system_state)
{
}
PayloadPropertiesHandlerAction::~PayloadPropertiesHandlerAction()
{
}
void PayloadPropertiesHandlerAction::PerformAction()
{
// Get the InstallPlan and read it
CHECK(HasInputObject());
const PayloadProperties &payload_prop = GetInputObject();
LOG(INFO) << "Update URL " << system_state_->payload_state()->GetCurrentUrl();;
install_plan_.download_url = system_state_->payload_state()->GetCurrentUrl();;
install_plan_.payload_type = InstallPayloadType::kFull;
install_plan_.source_slot = system_state_->boot_control()->GetCurrentSlot();
if (install_plan_.source_slot == BootControlInterface::kInvalidSlot)
{
LOG(ERROR) << "Current slot is invalid! Exit with error.";
processor_->ActionComplete(this, ErrorCode::kError);
return;
}
if (!system_state_->boot_control()->IsSlotBootable(install_plan_.source_slot))
{
LOG(ERROR) << "Current slot " << system_state_->boot_control()
<< " is not bootable. Exit with error.";
processor_->ActionComplete(this, ErrorCode::kError);
return;
}
install_plan_.target_slot = (install_plan_.source_slot + 1) % system_state_->boot_control()->GetNumSlots();
install_plan_.hash_checks_mandatory = true;
install_plan_.powerwash_required = false;
install_plan_.version = payload_prop.version;
install_plan_.payload_size = payload_prop.size;
install_plan_.payload_hash = payload_prop.hash;
install_plan_.metadata_size = payload_prop.metadata_size;
install_plan_.is_resume = false;
if (HasOutputPipe())
SetOutputObject(install_plan_);
LOG(INFO) << "Using this install plan:";
install_plan_.Dump();
processor_->ActionComplete(this, ErrorCode::kSuccess);
}
}; // chromeos_update_engine