repacker: override slot for flashing images instead of using bootctrl

Bootctrl is being unreliable during repacking. This overrides the slot
while repacking recovery in boot.

Change-Id: I0a04357af4e5f24591792bcfb27ccbd10b0a813b
This commit is contained in:
bigbiff
2021-08-07 17:56:19 +00:00
parent 76224bde3d
commit 74a46278c3
3 changed files with 9 additions and 6 deletions
+6
View File
@@ -3047,6 +3047,12 @@ void TWPartitionManager::Remove_Partition_By_Path(string Path) {
}
}
void TWPartitionManager::Override_Active_Slot(const string& Slot) {
LOGINFO("Overriding slot to '%s'\n", Slot.c_str());
Active_Slot_Display = Slot;
DataManager::SetValue("tw_active_slot", Slot);
}
void TWPartitionManager::Set_Active_Slot(const string& Slot) {
if (Slot != "A" && Slot != "B") {
LOGERR("Set_Active_Slot invalid slot '%s'\n", Slot.c_str());
+1
View File
@@ -378,6 +378,7 @@ public:
bool Flash_Image(string& path, string& filename); // Flashes an image to a selected partition from the partition list
bool Restore_Partition(struct PartitionSettings *part_settings); // Restore the partitions based on type
TWAtomicInt stop_backup;
void Override_Active_Slot(const string& Slot); // Override the active slot for repacking
void Set_Active_Slot(const string& Slot); // Sets the active slot to A or B
string Get_Active_Slot_Suffix(); // Returns active slot _a or _b
string Get_Active_Slot_Display(); // Returns active slot A or B for display purposes
+2 -6
View File
@@ -197,9 +197,9 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const
LOGINFO("Switching slots to flash ramdisk to both partitions\n");
string Current_Slot = PartitionManager.Get_Active_Slot_Display();
if (Current_Slot == "A")
PartitionManager.Set_Active_Slot("B");
PartitionManager.Override_Active_Slot("B");
else
PartitionManager.Set_Active_Slot("A");
PartitionManager.Override_Active_Slot("A");
DataManager::SetProgress(.25);
if (!Backup_Image_For_Repack(part, REPACK_ORIG_DIR, Repack_Options.Backup_First, gui_lookup("repack", "Repack")))
return false;
@@ -243,8 +243,4 @@ bool twrpRepacker::Repack_Image_And_Flash(const std::string& Target_Image, const
}
DataManager::SetProgress(1);
TWFunc::removeDir(REPACK_ORIG_DIR, false);
PartitionManager.Set_Active_Slot(Current_Slot);
}
TWFunc::removeDir(REPACK_NEW_DIR, false);
return true;
}