fix adb sideload

- "Cancel" button handling requires another thread
- simplify handling of child pid
- merge duplicated code for reinjecting TWRP after installation
- fix error that showed on host PC after sideload finished
- fix problem where adbd sometimes does not stop correctly

Change-Id: I536877f024b606756c6a3289c6ddfdba423a60d6
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index 0b71a42..0db55cd 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -356,7 +356,8 @@
 					gui_print("Starting ADB sideload feature...\n");
 					DataManager::SetValue("tw_has_cancel", 1);
 					DataManager::SetValue("tw_cancel_action", "adbsideloadcancel");
-					ret_val = apply_from_adb(Sideload_File.c_str());
+					pid_t child_pid;
+					ret_val = apply_from_adb(Sideload_File.c_str(), &child_pid);
 					DataManager::SetValue("tw_has_cancel", 0);
 					if (ret_val != 0)
 						ret_val = 1; // failure