int GUIAction::flash(std::string arg) { int i, ret_val = 0, wipe_cache = 0; // We're going to jump to this page first, like a loading page gui_changePage(arg); for (i=0; i<zip_queue_index; i++) { operation_start("Flashing"); DataManager::SetValue("tw_filename", zip_queue[i]); DataManager::SetValue(TW_ZIP_INDEX, (i + 1)); TWFunc::SetPerformanceMode(true); ret_val = flash_zip(zip_queue[i], &wipe_cache); TWFunc::SetPerformanceMode(false); if (ret_val != 0) { gui_print("Error flashing zip '%s'\n", zip_queue[i].c_str()); ret_val = 1; break; } } zip_queue_index = 0; if (wipe_cache) { gui_print("One or more zip requested a cache wipe\nWiping cache now.\n"); PartitionManager.Wipe_By_Path("/cache"); } reinject_after_flash(); PartitionManager.Update_System_Details(); operation_end(ret_val); DataManager::SetValue(TW_ZIP_QUEUE_COUNT, zip_queue_index); return 0; }
int GUIAction::adbsideload(std::string arg) { operation_start("Sideload"); if (simulate) { simulate_progress_bar(); operation_end(0); } else { gui_print("Starting ADB sideload feature...\n"); bool mtp_was_enabled = TWFunc::Toggle_MTP(false); // wait for the adb connection int ret = apply_from_adb("/", &sideload_child_pid); DataManager::SetValue("tw_has_cancel", 0); // Remove cancel button from gui now that the zip install is going to start if (ret != 0) { if (ret == -2) gui_print("You need adb 1.0.32 or newer to sideload to this device.\n"); ret = 1; // failure } else { int wipe_cache = 0; int wipe_dalvik = 0; DataManager::GetValue("tw_wipe_dalvik", wipe_dalvik); if (TWinstall_zip(FUSE_SIDELOAD_HOST_PATHNAME, &wipe_cache) == 0) { if (wipe_cache || DataManager::GetIntValue("tw_wipe_cache")) PartitionManager.Wipe_By_Path("/cache"); if (wipe_dalvik) PartitionManager.Wipe_Dalvik_Cache(); } else { ret = 1; // failure } } if (sideload_child_pid) { LOGINFO("Signaling child sideload process to exit.\n"); struct stat st; // Calling stat() on this magic filename signals the minadbd // subprocess to shut down. stat(FUSE_SIDELOAD_HOST_EXIT_PATHNAME, &st); int status; LOGINFO("Waiting for child sideload process to exit.\n"); waitpid(sideload_child_pid, &status, 0); } property_set("ctl.start", "adbd"); TWFunc::Toggle_MTP(mtp_was_enabled); reinject_after_flash(); operation_end(ret); } return 0; }