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
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index fe0e3b8..a41fb0c 100755
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -3047,6 +3047,12 @@
 	}
 }
 
+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());
diff --git a/partitions.hpp b/partitions.hpp
index 03a603e..0a3fa0a 100755
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -378,6 +378,7 @@
 	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
diff --git a/twrpRepacker.cpp b/twrpRepacker.cpp
index 8a17508..e61d328 100755
--- a/twrpRepacker.cpp
+++ b/twrpRepacker.cpp
@@ -197,9 +197,9 @@
 		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 @@
 		}
 		DataManager::SetProgress(1);
 		TWFunc::removeDir(REPACK_ORIG_DIR, false);
-		PartitionManager.Set_Active_Slot(Current_Slot);
-	}
-	TWFunc::removeDir(REPACK_NEW_DIR, false);
-	return true;
 }