diff options
author | Ethan Yonker <dees_troy@teamw.in> | 2015-10-28 18:44:49 +0100 |
---|---|---|
committer | Ethan Yonker <dees_troy@teamw.in> | 2015-12-19 15:31:01 +0100 |
commit | 74db157b9406594a549a70415668dd6cbe17d1d3 (patch) | |
tree | d47451181a77cc1b03a55d63d49a9fecc98eb044 /twrp-functions.cpp | |
parent | gui: stock theme rework (diff) | |
download | android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar.gz android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar.bz2 android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar.lz android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar.xz android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.tar.zst android_bootable_recovery-74db157b9406594a549a70415668dd6cbe17d1d3.zip |
Diffstat (limited to '')
-rw-r--r-- | twrp-functions.cpp | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp index 644d5657a..a7a8e8d63 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -45,6 +45,7 @@ #include "bootloader.h" #include "cutils/properties.h" #include "cutils/android_reboot.h" +#include "gui/gui.hpp" #include <sys/reboot.h> #endif // ndef BUILD_TWRPTAR_MAIN #ifndef TW_EXCLUDE_ENCRYPTED_BACKUPS @@ -122,12 +123,12 @@ int TWFunc::Wait_For_Child(pid_t pid, int *status, string Child_Name) { rc_pid = waitpid(pid, status, 0); if (rc_pid > 0) { if (WIFSIGNALED(*status)) { - LOGERR("%s process ended with signal: %d\n", Child_Name.c_str(), WTERMSIG(*status)); // Seg fault or some other non-graceful termination + gui_msg(Msg(msg::kError, "pid_signal={1} process ended with signal: {2}")(Child_Name)(WTERMSIG(*status))); // Seg fault or some other non-graceful termination return -1; } else if (WEXITSTATUS(*status) == 0) { LOGINFO("%s process ended with RC=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Success } else { - LOGERR("%s process ended with ERROR=%d\n", Child_Name.c_str(), WEXITSTATUS(*status)); // Graceful exit, but there was an error + gui_msg(Msg(msg::kError, "pid_error={1} process ended with ERROR: {2}")(Child_Name)(WEXITSTATUS(*status))); // Graceful exit, but there was an error return -1; } } else { // no PID returned @@ -207,13 +208,13 @@ int TWFunc::Try_Decrypting_File(string fn, string password) { f = fopen(fn.c_str(), "rb"); if (f == NULL) { - LOGERR("Failed to open '%s' to try decrypt\n", fn.c_str()); + LOGERR("Failed to open '%s' to try decrypt: %s\n", fn.c_str(), strerror(errno)); oaes_free(&ctx); return -1; } read_len = fread(buffer, sizeof(uint8_t), 4096, f); if (read_len <= 0) { - LOGERR("Read size during try decrypt failed\n"); + LOGERR("Read size during try decrypt failed: %s\n", strerror(errno)); fclose(f); oaes_free(&ctx); return -1; @@ -355,50 +356,50 @@ void TWFunc::install_htc_dumlock(void) { if (!PartitionManager.Mount_By_Path("/data", true)) return; - gui_print("Installing HTC Dumlock to system...\n"); + gui_msg("install_dumlock=Installing HTC Dumlock to system..."); copy_file(TWHTCD_PATH "htcdumlocksys", "/system/bin/htcdumlock", 0755); if (!Path_Exists("/system/bin/flash_image")) { - gui_print("Installing flash_image...\n"); + LOGINFO("Installing flash_image...\n"); copy_file(TWHTCD_PATH "flash_imagesys", "/system/bin/flash_image", 0755); need_libs = 1; } else - gui_print("flash_image is already installed, skipping...\n"); + LOGINFO("flash_image is already installed, skipping...\n"); if (!Path_Exists("/system/bin/dump_image")) { - gui_print("Installing dump_image...\n"); + LOGINFO("Installing dump_image...\n"); copy_file(TWHTCD_PATH "dump_imagesys", "/system/bin/dump_image", 0755); need_libs = 1; } else - gui_print("dump_image is already installed, skipping...\n"); + LOGINFO("dump_image is already installed, skipping...\n"); if (need_libs) { - gui_print("Installing libs needed for flash_image and dump_image...\n"); + LOGINFO("Installing libs needed for flash_image and dump_image...\n"); copy_file(TWHTCD_PATH "libbmlutils.so", "/system/lib/libbmlutils.so", 0644); copy_file(TWHTCD_PATH "libflashutils.so", "/system/lib/libflashutils.so", 0644); copy_file(TWHTCD_PATH "libmmcutils.so", "/system/lib/libmmcutils.so", 0644); copy_file(TWHTCD_PATH "libmtdutils.so", "/system/lib/libmtdutils.so", 0644); } - gui_print("Installing HTC Dumlock app...\n"); + LOGINFO("Installing HTC Dumlock app...\n"); mkdir("/data/app", 0777); unlink("/data/app/com.teamwin.htcdumlock*"); copy_file(TWHTCD_PATH "HTCDumlock.apk", "/data/app/com.teamwin.htcdumlock.apk", 0777); sync(); - gui_print("HTC Dumlock is installed.\n"); + gui_msg("done=Done."); } void TWFunc::htc_dumlock_restore_original_boot(void) { if (!PartitionManager.Mount_By_Path("/sdcard", true)) return; - gui_print("Restoring original boot...\n"); + gui_msg("dumlock_restore=Restoring original boot..."); Exec_Cmd("htcdumlock restore"); - gui_print("Original boot restored.\n"); + gui_msg("done=Done."); } void TWFunc::htc_dumlock_reflash_recovery_to_boot(void) { if (!PartitionManager.Mount_By_Path("/sdcard", true)) return; - gui_print("Reflashing recovery to boot...\n"); + gui_msg("dumlock_reflash=Reflashing recovery to boot..."); Exec_Cmd("htcdumlock recovery noreboot"); - gui_print("Recovery is flashed to boot.\n"); + gui_msg("done=Done."); } int TWFunc::Recursive_Mkdir(string Path) { @@ -411,7 +412,7 @@ int TWFunc::Recursive_Mkdir(string Path) { wholePath = pathCpy.substr(0, pos); if (!TWFunc::Path_Exists(wholePath)) { if (mkdir(wholePath.c_str(), 0777)) { - LOGERR("Unable to create folder: %s (errno=%d)\n", wholePath.c_str(), errno); + gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2})")(wholePath)(strerror(errno))); return false; } else { tw_set_default_metadata(wholePath.c_str()); @@ -570,10 +571,10 @@ void TWFunc::check_and_run_script(const char* script_file, const char* display_n // Check for and run startup script if script exists struct stat st; if (stat(script_file, &st) == 0) { - gui_print("Running %s script...\n", display_name); + gui_msg(Msg("run_script=Running {1} script...")(display_name)); chmod(script_file, S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); TWFunc::Exec_Cmd(script_file); - gui_print("\nFinished running %s script.\n", display_name); + gui_msg("done=Done."); } } @@ -583,7 +584,7 @@ int TWFunc::removeDir(const string path, bool skipParent) { string new_path; if (d == NULL) { - LOGERR("Error opening dir: '%s'\n", path.c_str()); + gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(path)(strerror(errno))); return -1; } @@ -742,7 +743,7 @@ bool TWFunc::Try_Decrypting_Backup(string Restore_Path, string Password) { Restore_Path += "/"; d = opendir(Restore_Path.c_str()); if (d == NULL) { - LOGERR("Error opening '%s'\n", Restore_Path.c_str()); + gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Restore_Path)(strerror(errno))); return false; } @@ -1042,7 +1043,7 @@ void TWFunc::Disable_Stock_Recovery_Replace(void) { // Disable flashing of stock recovery if (TWFunc::Path_Exists("/system/recovery-from-boot.p")) { rename("/system/recovery-from-boot.p", "/system/recovery-from-boot.bak"); - gui_print("Renamed stock recovery file in /system to prevent\nthe stock ROM from replacing TWRP.\n"); + gui_msg("rename_stock=Renamed stock recovery file in /system to prevent the stock ROM from replacing TWRP."); sync(); } PartitionManager.UnMount_By_Path("/system", false); |