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 /gui/gui.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-- | gui/gui.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/gui/gui.cpp b/gui/gui.cpp index 31b61be6d..78e8a7e0c 100644 --- a/gui/gui.cpp +++ b/gui/gui.cpp @@ -517,13 +517,19 @@ static void ors_command_read() fprintf(orsout, "%s", result); LOGINFO("Command cannot be performed, operation in progress.\n"); } else { - if (gui_console_only() == 0) { + if (strlen(command) == 11 && strncmp(command, "dumpstrings", 11) == 0) { + // This cannot be done safely with gui_console_only because gui_console_only updates mCurrentSet + // which makes the resources that we are trying to read unreachable. + gui_set_FILE(orsout); + PageManager::GetResources()->DumpStrings(); + gui_set_FILE(NULL); + } else if (gui_console_only() == 0) { LOGINFO("Console started successfully\n"); gui_set_FILE(orsout); if (strlen(command) > 11 && strncmp(command, "runscript", 9) == 0) { char* filename = command + 11; if (OpenRecoveryScript::copy_script_file(filename) == 0) { - LOGERR("Unable to copy script file\n"); + LOGINFO("Unable to copy script file\n"); } else { OpenRecoveryScript::run_script_file(); } @@ -534,7 +540,7 @@ static void ors_command_read() gui_print("%s = %s\n", varname, temp.c_str()); } else if (strlen(command) > 9 && strncmp(command, "decrypt", 7) == 0) { char* pass = command + 8; - gui_print("Attempting to decrypt data partition via command line.\n"); + gui_msg("decrypt_cmd=Attempting to decrypt data partition via command line."); if (PartitionManager.Decrypt_Device(pass) == 0) { set_page_done = 1; } @@ -753,15 +759,39 @@ std::string gui_parse_text(std::string str) { // This function parses text for DataManager values encompassed by %value% in the XML // and string resources (%@resource_name%) - size_t pos = 0; + size_t pos = 0, next, end; while (1) { - size_t next = str.find('%', pos); + next = str.find("{@", pos); + if (next == std::string::npos) + break; + + end = str.find('}', next + 1); + if (end == std::string::npos) + break; + + std::string var = str.substr(next + 2, (end - next) - 2); + str.erase(next, (end - next) + 1); + + size_t default_loc = var.find('=', 0); + std::string lookup; + if (default_loc == std::string::npos) { + str.insert(next, PageManager::GetResources()->FindString(var)); + } else { + lookup = var.substr(0, default_loc); + std::string default_string = var.substr(default_loc + 1, var.size() - default_loc - 1); + str.insert(next, PageManager::GetResources()->FindString(lookup, default_string)); + } + } + pos = 0; + while (1) + { + next = str.find('%', pos); if (next == std::string::npos) return str; - size_t end = str.find('%', next + 1); + end = str.find('%', next + 1); if (end == std::string::npos) return str; @@ -787,6 +817,10 @@ std::string gui_parse_text(std::string str) } } +std::string gui_lookup(const std::string& resource_name, const std::string& default_value) { + return PageManager::GetResources()->FindString(resource_name, default_value); +} + extern "C" int gui_init(void) { gr_init(); @@ -828,7 +862,7 @@ extern "C" int gui_loadResources(void) { if (PageManager::LoadPackage("TWRP", TWRES "ui.xml", "decrypt")) { - LOGERR("Failed to load base packages.\n"); + gui_err("base_pkg_err=Failed to load base packages."); goto error; } else @@ -849,10 +883,9 @@ extern "C" int gui_loadResources(void) retry_count--; } - if (!PartitionManager.Mount_Settings_Storage(false)) + if (!PartitionManager.Mount_Settings_Storage(true)) { - LOGERR("Unable to mount %s during GUI startup.\n", - theme_path.c_str()); + LOGINFO("Unable to mount %s during GUI startup.\n", theme_path.c_str()); check = 1; } } @@ -863,7 +896,7 @@ extern "C" int gui_loadResources(void) #endif // ifndef TW_OEM_BUILD if (PageManager::LoadPackage("TWRP", TWRES "ui.xml", "main")) { - LOGERR("Failed to load base packages.\n"); + gui_err("base_pkg_err=Failed to load base packages."); goto error; } #ifndef TW_OEM_BUILD @@ -886,7 +919,7 @@ extern "C" int gui_loadCustomResources(void) { #ifndef TW_OEM_BUILD if (!PartitionManager.Mount_Settings_Storage(false)) { - LOGERR("Unable to mount settings storage during GUI startup.\n"); + LOGINFO("Unable to mount settings storage during GUI startup.\n"); return -1; } @@ -898,7 +931,7 @@ extern "C" int gui_loadCustomResources(void) if (PageManager::ReloadPackage("TWRP", theme_path)) { // Custom theme failed to load, try to load stock theme if (PageManager::ReloadPackage("TWRP", TWRES "ui.xml")) { - LOGERR("Failed to load base packages.\n"); + gui_err("base_pkg_err=Failed to load base packages."); goto error; } } |