Added support for flash image in both slots

Change-Id: Iafda62a5f77f7c1f564f1a2ec0a59aefaf5e1266
This commit is contained in:
epicX
2021-02-24 23:12:08 +05:30
committed by bigbiff
parent 98203ceebe
commit 8f52c0a73d
7 changed files with 121 additions and 7 deletions

View File

@@ -1810,16 +1810,41 @@ int GUIAction::stopmtp(std::string arg __unused)
int GUIAction::flashimage(std::string arg __unused)
{
int op_status = 0;
bool flag = true;
operation_start("Flash Image");
string path, filename;
DataManager::GetValue("tw_zip_location", path);
DataManager::GetValue("tw_file", filename);
if (PartitionManager.Flash_Image(path, filename))
op_status = 0; // success
else
op_status = 1; // fail
#ifdef AB_OTA_UPDATER
string target = DataManager::GetStrValue("tw_flash_partition");
unsigned int pos = target.find_last_of(';');
string mount_point = pos != string::npos ? target.substr(0, pos) : "";
TWPartition* t_part = PartitionManager.Find_Partition_By_Path(mount_point);
bool flash_in_both_slots = DataManager::GetIntValue("tw_flash_both_slots") ? true : false;
if (t_part != NULL && (flash_in_both_slots && t_part->SlotSelect))
{
string current_slot = PartitionManager.Get_Active_Slot_Display();
bool pre_op_status = PartitionManager.Flash_Image(path, filename);
PartitionManager.Set_Active_Slot(current_slot == "A" ? "B" : "A");
op_status = (int) !(pre_op_status && PartitionManager.Flash_Image(path, filename));
PartitionManager.Set_Active_Slot(current_slot);
DataManager::SetValue("tw_flash_both_slots", 0);
flag = false;
}
#endif
if (flag)
{
if (PartitionManager.Flash_Image(path, filename))
op_status = 0; // success
else
op_status = 1; // fail
}
operation_end(op_status);
return 0;
}