mirror of
https://github.com/meizu-m86/twrp_multirom_m86
synced 2025-11-04 06:15:41 +08:00
Multiple Language Support
This is similar to https://gerrit.omnirom.org/#/c/14014 A lot of the features built in the older patch set have been split out into separate patches, most of which have already been merged. The remaining functionality here should all be directly related to language selection and loading. We always load English as a base before loading other languages over the top of the base. The idea is that if another language is missing a translation, then we will still display the English. Maybe still to do: read the /cache/recovery/last_locale file and load a language based on that. For me, this file contains just: en_US We probably won't bother with region specific translations so we would have to look at either trimming off the _US or using some other method like perhaps a symlink or a combination of the two. Thanks to _that for twmsg.cpp class Change-Id: I9647a22e47883a3ddd2de1da51f64aab7c328f74
This commit is contained in:
@@ -329,6 +329,11 @@ endif
|
||||
ifeq ($(shell test $(PLATFORM_SDK_VERSION) -gt 22; echo $$?),0)
|
||||
LOCAL_CFLAGS += -DTW_USE_NEW_MINADBD
|
||||
endif
|
||||
ifneq ($(TW_DEFAULT_LANGUAGE),)
|
||||
LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=$(TW_DEFAULT_LANGUAGE)
|
||||
else
|
||||
LOCAL_CFLAGS += -DTW_DEFAULT_LANGUAGE=en
|
||||
endif
|
||||
|
||||
LOCAL_ADDITIONAL_DEPENDENCIES := \
|
||||
dump_image \
|
||||
|
||||
15
data.cpp
15
data.cpp
@@ -50,6 +50,7 @@
|
||||
#include "find_file.hpp"
|
||||
#include "set_metadata.h"
|
||||
#include <cutils/properties.h>
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
#define DEVID_MAX 64
|
||||
#define HWID_MAX 32
|
||||
@@ -229,7 +230,7 @@ void DataManager::get_device_id(void) {
|
||||
}
|
||||
|
||||
strcpy(device_id, "serialno");
|
||||
LOGERR("=> device id not found, using '%s'\n", device_id);
|
||||
LOGINFO("=> device id not found, using '%s'\n", device_id);
|
||||
mConstValues.insert(make_pair("device_id", device_id));
|
||||
return;
|
||||
}
|
||||
@@ -616,8 +617,10 @@ void DataManager::SetBackupFolder()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (PartitionManager.Fstab_Processed() != 0)
|
||||
LOGERR("Storage partition '%s' not found\n", str.c_str());
|
||||
if (PartitionManager.Fstab_Processed() != 0) {
|
||||
LOGINFO("Storage partition '%s' not found\n", str.c_str());
|
||||
gui_err("unable_locate_storage=Unable to locate storage device.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,6 +893,8 @@ void DataManager::SetDefaultValues()
|
||||
#endif
|
||||
mValues.insert(make_pair("tw_mount_system_ro", make_pair("2", 1)));
|
||||
mValues.insert(make_pair("tw_never_show_system_ro_page", make_pair("0", 1)));
|
||||
mValues.insert(make_pair("tw_language", make_pair(EXPAND(TW_DEFAULT_LANGUAGE), 1)));
|
||||
LOGINFO("LANG: %s\n", EXPAND(TW_DEFAULT_LANGUAGE));
|
||||
|
||||
pthread_mutex_unlock(&m_valuesLock);
|
||||
}
|
||||
@@ -1033,7 +1038,7 @@ void DataManager::Output_Version(void)
|
||||
}
|
||||
FILE *fp = fopen(Path.c_str(), "w");
|
||||
if (fp == NULL) {
|
||||
LOGERR("Unable to open '%s'.\n", Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
|
||||
return;
|
||||
}
|
||||
strcpy(version, TW_VERSION_STR);
|
||||
@@ -1069,7 +1074,7 @@ void DataManager::ReadSettingsFile(void)
|
||||
{
|
||||
usleep(500000);
|
||||
if (!PartitionManager.Mount_Settings_Storage(false))
|
||||
LOGERR("Unable to mount %s when trying to read settings file.\n", settings_file);
|
||||
gui_msg(Msg(msg::kError, "unable_to_mount=Unable to mount {1}")(settings_file));
|
||||
}
|
||||
|
||||
mkdir(mkdir_path, 0777);
|
||||
|
||||
@@ -48,7 +48,7 @@ string Find_File::Find_Internal(const string& filename, const string& starting_p
|
||||
|
||||
d = opendir(starting_path.c_str());
|
||||
if (d == NULL) {
|
||||
LOGERR("Find_File: Error opening '%s'\n", starting_path.c_str());
|
||||
LOGINFO("Find_File: Error opening '%s'\n", starting_path.c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ LOCAL_SRC_FILES := \
|
||||
mousecursor.cpp \
|
||||
scrolllist.cpp \
|
||||
patternpassword.cpp \
|
||||
textbox.cpp
|
||||
textbox.cpp \
|
||||
twmsg.cpp
|
||||
|
||||
ifneq ($(TWRP_CUSTOM_KEYBOARD),)
|
||||
LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
|
||||
@@ -107,6 +108,7 @@ ifeq ($(TW_CUSTOM_THEME),)
|
||||
ifeq ($(TWRP_NEW_THEME),true)
|
||||
TWRP_THEME_LOC := $(commands_recovery_local_path)/gui/theme/$(TW_THEME)
|
||||
TWRP_RES := $(commands_recovery_local_path)/gui/theme/common/fonts
|
||||
TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/languages
|
||||
TWRP_RES += $(commands_recovery_local_path)/gui/theme/common/$(word 1,$(subst _, ,$(TW_THEME))).xml
|
||||
# for future copying of used include xmls and fonts:
|
||||
# UI_XML := $(TWRP_THEME_LOC)/ui.xml
|
||||
|
||||
@@ -197,6 +197,7 @@ GUIAction::GUIAction(xml_node<>* node)
|
||||
ADD_ACTION(cancelbackup);
|
||||
ADD_ACTION(checkpartitionlifetimewrites);
|
||||
ADD_ACTION(mountsystemtoggle);
|
||||
ADD_ACTION(setlanguage);
|
||||
|
||||
// remember actions that run in the caller thread
|
||||
for (mapFunc::const_iterator it = mf.begin(); it != mf.end(); ++it)
|
||||
@@ -340,12 +341,12 @@ int GUIAction::NotifyVarChange(const std::string& varName, const std::string& va
|
||||
|
||||
void GUIAction::simulate_progress_bar(void)
|
||||
{
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (PartitionManager.stop_backup.get_value()) {
|
||||
DataManager::SetValue("tw_cancel_backup", 1);
|
||||
gui_print("Backup Canceled.\n");
|
||||
gui_msg("backup_cancel=Backup Canceled.");
|
||||
DataManager::SetValue("ui_progress", 0);
|
||||
PartitionManager.stop_backup.set_value(0);
|
||||
return;
|
||||
@@ -381,10 +382,10 @@ int GUIAction::flash_zip(std::string filename, int* wipe_cache)
|
||||
{
|
||||
DataManager::SetValue("tw_operation", "Configuring TWRP");
|
||||
DataManager::SetValue("tw_partition", "");
|
||||
gui_print("Configuring TWRP...\n");
|
||||
gui_msg("config_twrp=Configuring TWRP...");
|
||||
if (TWFunc::Exec_Cmd("/sbin/installTwrp reinstall") < 0)
|
||||
{
|
||||
gui_print("Unable to configure TWRP with this kernel.\n");
|
||||
gui_msg("config_twrp_err=Unable to configure TWRP with this kernel.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -587,12 +588,12 @@ int GUIAction::mount(std::string arg)
|
||||
if (!simulate)
|
||||
PartitionManager.usb_storage_enable();
|
||||
else
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
} else if (!simulate) {
|
||||
PartitionManager.Mount_By_Path(arg, true);
|
||||
PartitionManager.Add_MTP_Storage(arg);
|
||||
} else
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -602,12 +603,12 @@ int GUIAction::unmount(std::string arg)
|
||||
if (!simulate)
|
||||
PartitionManager.usb_storage_disable();
|
||||
else
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
DataManager::SetValue(TW_ACTION_BUSY, 0);
|
||||
} else if (!simulate) {
|
||||
PartitionManager.UnMount_By_Path(arg, true);
|
||||
} else
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -615,7 +616,7 @@ int GUIAction::restoredefaultsettings(std::string arg __unused)
|
||||
{
|
||||
operation_start("Restore Defaults");
|
||||
if (simulate) // Simulated so that people don't accidently wipe out the "simulation is on" setting
|
||||
gui_print("Simulating actions...\n");
|
||||
gui_msg("simulating=Simulating actions...");
|
||||
else {
|
||||
DataManager::ResetDefaults();
|
||||
PartitionManager.Update_System_Details();
|
||||
@@ -636,7 +637,7 @@ int GUIAction::copylog(std::string arg __unused)
|
||||
TWFunc::copy_file("/tmp/recovery.log", dst.c_str(), 0755);
|
||||
tw_set_default_metadata(dst.c_str());
|
||||
sync();
|
||||
gui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
|
||||
gui_msg(Msg("copy_log=Copied recovery log to {1}.")(DataManager::GetCurrentStoragePath()));
|
||||
} else
|
||||
simulate_progress_bar();
|
||||
operation_end(0);
|
||||
@@ -733,7 +734,7 @@ int GUIAction::overlay(std::string arg)
|
||||
int GUIAction::queuezip(std::string arg __unused)
|
||||
{
|
||||
if (zip_queue_index >= 10) {
|
||||
gui_print("Maximum zip queue reached!\n");
|
||||
gui_msg("max_queue=Maximum zip queue reached!");
|
||||
return 0;
|
||||
}
|
||||
DataManager::GetValue("tw_filename", zip_queue[zip_queue_index]);
|
||||
@@ -747,7 +748,7 @@ int GUIAction::queuezip(std::string arg __unused)
|
||||
int GUIAction::cancelzip(std::string arg __unused)
|
||||
{
|
||||
if (zip_queue_index <= 0) {
|
||||
gui_print("Minimum zip queue reached!\n");
|
||||
gui_msg("min_queue=Minimum zip queue reached!");
|
||||
return 0;
|
||||
} else {
|
||||
zip_queue_index--;
|
||||
@@ -925,7 +926,7 @@ int GUIAction::screenshot(std::string arg __unused)
|
||||
chmod(path, 0666);
|
||||
chown(path, uid, gid);
|
||||
|
||||
gui_print("Screenshot was saved to %s\n", path);
|
||||
gui_msg(Msg("screenshot_saved=Screenshot was saved to %s")(path));
|
||||
|
||||
// blink to notify that the screenshow was taken
|
||||
gr_color(255, 255, 255, 255);
|
||||
@@ -933,7 +934,7 @@ int GUIAction::screenshot(std::string arg __unused)
|
||||
gr_flip();
|
||||
gui_forceRender();
|
||||
} else {
|
||||
LOGERR("Failed to take a screenshot!\n");
|
||||
gui_err("screenshot_err=Failed to take a screenshot!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -959,7 +960,7 @@ int GUIAction::fileexists(std::string arg)
|
||||
void GUIAction::reinject_after_flash()
|
||||
{
|
||||
if (DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
|
||||
gui_print("Injecting TWRP into boot image...\n");
|
||||
gui_msg("injecttwrp=Injecting TWRP into boot image...");
|
||||
if (simulate) {
|
||||
simulate_progress_bar();
|
||||
} else {
|
||||
@@ -970,7 +971,7 @@ void GUIAction::reinject_after_flash()
|
||||
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
|
||||
TWFunc::Exec_Cmd(injectcmd);
|
||||
}
|
||||
gui_print("TWRP injection complete.\n");
|
||||
gui_msg("done=Done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -993,7 +994,7 @@ int GUIAction::flash(std::string arg)
|
||||
ret_val = flash_zip(zip_path, &wipe_cache);
|
||||
TWFunc::SetPerformanceMode(false);
|
||||
if (ret_val != 0) {
|
||||
gui_print("Error flashing zip '%s'\n", zip_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "zip_err=Error installing zip file '{1}'")(zip_path));
|
||||
ret_val = 1;
|
||||
break;
|
||||
}
|
||||
@@ -1001,7 +1002,7 @@ int GUIAction::flash(std::string arg)
|
||||
zip_queue_index = 0;
|
||||
|
||||
if (wipe_cache) {
|
||||
gui_print("One or more zip requested a cache wipe\nWiping cache now.\n");
|
||||
gui_msg("zip_wipe_cache=One or more zip requested a cache wipe -- Wiping cache now.");
|
||||
PartitionManager.Wipe_By_Path("/cache");
|
||||
}
|
||||
|
||||
@@ -1063,7 +1064,7 @@ int GUIAction::wipe(std::string arg)
|
||||
LOGINFO("wipe_path '%s'\n", wipe_path.c_str());
|
||||
if (wipe_path == "/and-sec") {
|
||||
if (!PartitionManager.Wipe_Android_Secure()) {
|
||||
LOGERR("Unable to wipe android secure\n");
|
||||
gui_msg("and_sec_wipe_err=Unable to wipe android secure");
|
||||
ret_val = false;
|
||||
break;
|
||||
} else {
|
||||
@@ -1071,7 +1072,7 @@ int GUIAction::wipe(std::string arg)
|
||||
}
|
||||
} else if (wipe_path == "DALVIK") {
|
||||
if (!PartitionManager.Wipe_Dalvik_Cache()) {
|
||||
LOGERR("Failed to wipe dalvik\n");
|
||||
gui_err("dalvik_wipe_err=Failed to wipe dalvik");
|
||||
ret_val = false;
|
||||
break;
|
||||
} else {
|
||||
@@ -1087,7 +1088,7 @@ int GUIAction::wipe(std::string arg)
|
||||
}
|
||||
if (!skip) {
|
||||
if (!PartitionManager.Wipe_By_Path(wipe_path)) {
|
||||
LOGERR("Unable to wipe '%s'\n", wipe_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(wipe_path));
|
||||
ret_val = false;
|
||||
break;
|
||||
} else if (wipe_path == DataManager::GetSettingsStoragePath()) {
|
||||
@@ -1152,6 +1153,8 @@ int GUIAction::nandroid(std::string arg)
|
||||
if (arg == "backup") {
|
||||
string Backup_Name;
|
||||
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
|
||||
string auto_gen = gui_lookup("auto_gen", "(Auto Generate)");
|
||||
string curr_date = gui_lookup("curr_date", "(Current Date)");
|
||||
if (Backup_Name == "(Auto Generate)" || Backup_Name == "(Current Date)" || Backup_Name == "0" || Backup_Name == "(" || PartitionManager.Check_Backup_Name(true) == 0) {
|
||||
ret = PartitionManager.Run_Backup();
|
||||
}
|
||||
@@ -1159,7 +1162,7 @@ int GUIAction::nandroid(std::string arg)
|
||||
operation_end(1);
|
||||
return -1;
|
||||
}
|
||||
DataManager::SetValue(TW_BACKUP_NAME, "(Auto Generate)");
|
||||
DataManager::SetValue(TW_BACKUP_NAME, auto_gen);
|
||||
} else if (arg == "restore") {
|
||||
string Restore_Name;
|
||||
DataManager::GetValue("tw_restore", Restore_Name);
|
||||
@@ -1178,7 +1181,7 @@ int GUIAction::nandroid(std::string arg)
|
||||
}
|
||||
else {
|
||||
DataManager::SetValue("tw_cancel_backup", 1);
|
||||
gui_print("Backup Canceled.\n");
|
||||
gui_msg("backup_cancel=Backup Canceled.");
|
||||
ret = 0;
|
||||
}
|
||||
operation_end(ret);
|
||||
@@ -1242,7 +1245,7 @@ int GUIAction::partitionsd(std::string arg __unused)
|
||||
int allow_partition;
|
||||
DataManager::GetValue(TW_ALLOW_PARTITION_SDCARD, allow_partition);
|
||||
if (allow_partition == 0) {
|
||||
gui_print("This device does not have a real SD Card!\nAborting!\n");
|
||||
gui_err("no_real_sdcard=This device does not have a real SD Card! Aborting!");
|
||||
} else {
|
||||
if (!PartitionManager.Partition_SDCard())
|
||||
ret_val = 1; // failed
|
||||
@@ -1332,7 +1335,7 @@ int GUIAction::terminalcommand(std::string arg)
|
||||
|
||||
fp = popen(command.c_str(), "r");
|
||||
if (fp == NULL) {
|
||||
LOGERR("Error opening command to run.\n");
|
||||
LOGERR("Error opening command to run (%s).\n", strerror(errno));
|
||||
} else {
|
||||
int fd = fileno(fp), has_data = 0, check = 0, keep_going = -1, bytes_read = 0;
|
||||
struct timeval timeout;
|
||||
@@ -1391,12 +1394,12 @@ int GUIAction::reinjecttwrp(std::string arg __unused)
|
||||
{
|
||||
int op_status = 0;
|
||||
operation_start("ReinjectTWRP");
|
||||
gui_print("Injecting TWRP into boot image...\n");
|
||||
gui_msg("injecttwrp=Injecting TWRP into boot image...");
|
||||
if (simulate) {
|
||||
simulate_progress_bar();
|
||||
} else {
|
||||
TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash");
|
||||
gui_print("TWRP injection complete.\n");
|
||||
gui_msg("done=Done.");
|
||||
}
|
||||
|
||||
operation_end(op_status);
|
||||
@@ -1462,7 +1465,7 @@ int GUIAction::adbsideload(std::string arg __unused)
|
||||
simulate_progress_bar();
|
||||
operation_end(0);
|
||||
} else {
|
||||
gui_print("Starting ADB sideload feature...\n");
|
||||
gui_msg("start_sideload=Starting ADB sideload feature...");
|
||||
bool mtp_was_enabled = TWFunc::Toggle_MTP(false);
|
||||
|
||||
// wait for the adb connection
|
||||
@@ -1471,7 +1474,7 @@ int GUIAction::adbsideload(std::string arg __unused)
|
||||
|
||||
if (ret != 0) {
|
||||
if (ret == -2)
|
||||
gui_print("You need adb 1.0.32 or newer to sideload to this device.\n");
|
||||
gui_msg("need_new_adb=You need adb 1.0.32 or newer to sideload to this device.");
|
||||
ret = 1; // failure
|
||||
} else {
|
||||
int wipe_cache = 0;
|
||||
@@ -1509,7 +1512,7 @@ int GUIAction::adbsideloadcancel(std::string arg __unused)
|
||||
{
|
||||
struct stat st;
|
||||
DataManager::SetValue("tw_has_cancel", 0); // Remove cancel button from gui
|
||||
gui_print("Cancelling ADB sideload...\n");
|
||||
gui_msg("cancel_sideload=Cancelling ADB sideload...");
|
||||
LOGINFO("Signaling child sideload process to exit.\n");
|
||||
// Calling stat() on this magic filename signals the minadbd
|
||||
// subprocess to shut down.
|
||||
@@ -1543,7 +1546,7 @@ int GUIAction::openrecoveryscript(std::string arg __unused)
|
||||
// Run those first.
|
||||
int reboot = 0;
|
||||
if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
|
||||
gui_print("Processing AOSP recovery commands...\n");
|
||||
gui_msg("running_recovery_commands=Running Recovery Commands");
|
||||
if (OpenRecoveryScript::run_script_file() == 0) {
|
||||
reboot = 1;
|
||||
op_status = 0;
|
||||
@@ -1551,7 +1554,7 @@ int GUIAction::openrecoveryscript(std::string arg __unused)
|
||||
}
|
||||
// Check for the ORS file in /cache and attempt to run those commands.
|
||||
if (OpenRecoveryScript::check_for_script_file()) {
|
||||
gui_print("Processing OpenRecoveryScript file...\n");
|
||||
gui_msg("running_ors=Running OpenRecoveryScript");
|
||||
if (OpenRecoveryScript::run_script_file() == 0) {
|
||||
reboot = 1;
|
||||
op_status = 0;
|
||||
@@ -1640,7 +1643,6 @@ int GUIAction::repair(std::string arg __unused)
|
||||
if (PartitionManager.Repair_By_Path(part_path, true)) {
|
||||
op_status = 0; // success
|
||||
} else {
|
||||
LOGERR("Error repairing file system.\n");
|
||||
op_status = 1; // fail
|
||||
}
|
||||
}
|
||||
@@ -1662,7 +1664,6 @@ int GUIAction::resize(std::string arg __unused)
|
||||
if (PartitionManager.Resize_By_Path(part_path, true)) {
|
||||
op_status = 0; // success
|
||||
} else {
|
||||
LOGERR("Error resizing file system.\n");
|
||||
op_status = 1; // fail
|
||||
}
|
||||
}
|
||||
@@ -1685,7 +1686,7 @@ int GUIAction::changefilesystem(std::string arg __unused)
|
||||
if (PartitionManager.Wipe_By_Path(part_path, file_system)) {
|
||||
op_status = 0; // success
|
||||
} else {
|
||||
LOGERR("Error changing file system.\n");
|
||||
gui_err("change_fs_err=Error changing file system.");
|
||||
op_status = 1; // fail
|
||||
}
|
||||
}
|
||||
@@ -1826,3 +1827,16 @@ int GUIAction::mountsystemtoggle(std::string arg)
|
||||
operation_end(op_status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GUIAction::setlanguage(std::string arg __unused)
|
||||
{
|
||||
int op_status = 0;
|
||||
|
||||
operation_start("Set Language");
|
||||
PageManager::LoadLanguage(DataManager::GetStrValue("tw_language"));
|
||||
PageManager::RequestReload();
|
||||
op_status = 0; // success
|
||||
|
||||
operation_end(op_status);
|
||||
return 0;
|
||||
}
|
||||
|
||||
113
gui/console.cpp
113
gui/console.cpp
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
Copyright 2015 bigbiff/Dees_Troy TeamWin
|
||||
This file is part of TWRP/TeamWin Recovery Project.
|
||||
|
||||
TWRP is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TWRP is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// console.cpp - GUIConsole object
|
||||
|
||||
#include <stdarg.h>
|
||||
@@ -24,10 +42,16 @@ extern "C" {
|
||||
|
||||
#include "rapidxml.hpp"
|
||||
#include "objects.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "twmsg.h"
|
||||
|
||||
#define GUI_CONSOLE_BUFFER_SIZE 512
|
||||
|
||||
static std::vector<std::string> gConsole;
|
||||
static std::vector<std::string> gConsoleColor;
|
||||
size_t last_message_count = 0;
|
||||
std::vector<Message> gMessages;
|
||||
|
||||
std::vector<std::string> gConsole;
|
||||
std::vector<std::string> gConsoleColor;
|
||||
static FILE* ors_file;
|
||||
|
||||
extern "C" void __gui_print(const char *color, char *buf)
|
||||
@@ -58,22 +82,22 @@ extern "C" void __gui_print(const char *color, char *buf)
|
||||
gConsole.push_back(start);
|
||||
gConsoleColor.push_back(color);
|
||||
}
|
||||
if (ors_file) {
|
||||
fprintf(ors_file, "%s\n", buf);
|
||||
fflush(ors_file);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void gui_print(const char *fmt, ...)
|
||||
{
|
||||
char buf[512]; // We're going to limit a single request to 512 bytes
|
||||
char buf[GUI_CONSOLE_BUFFER_SIZE]; // We're going to limit a single request to 512 bytes
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, 512, fmt, ap);
|
||||
vsnprintf(buf, GUI_CONSOLE_BUFFER_SIZE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fputs(buf, stdout);
|
||||
if (ors_file) {
|
||||
fprintf(ors_file, "%s", buf);
|
||||
fflush(ors_file);
|
||||
}
|
||||
|
||||
__gui_print("normal", buf);
|
||||
return;
|
||||
@@ -81,14 +105,18 @@ extern "C" void gui_print(const char *fmt, ...)
|
||||
|
||||
extern "C" void gui_print_color(const char *color, const char *fmt, ...)
|
||||
{
|
||||
char buf[512]; // We're going to limit a single request to 512 bytes
|
||||
char buf[GUI_CONSOLE_BUFFER_SIZE]; // We're going to limit a single request to 512 bytes
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf, 512, fmt, ap);
|
||||
vsnprintf(buf, GUI_CONSOLE_BUFFER_SIZE, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
fputs(buf, stdout);
|
||||
if (ors_file) {
|
||||
fprintf(ors_file, "%s", buf);
|
||||
fflush(ors_file);
|
||||
}
|
||||
|
||||
__gui_print(color, buf);
|
||||
return;
|
||||
@@ -99,6 +127,70 @@ extern "C" void gui_set_FILE(FILE* f)
|
||||
ors_file = f;
|
||||
}
|
||||
|
||||
void gui_msg(const char* text)
|
||||
{
|
||||
if (text) {
|
||||
Message msg = Msg(text);
|
||||
gui_msg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_warn(const char* text)
|
||||
{
|
||||
if (text) {
|
||||
Message msg = Msg(msg::kWarning, text);
|
||||
gui_msg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_err(const char* text)
|
||||
{
|
||||
if (text) {
|
||||
Message msg = Msg(msg::kError, text);
|
||||
gui_msg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_highlight(const char* text)
|
||||
{
|
||||
if (text) {
|
||||
Message msg = Msg(msg::kHighlight, text);
|
||||
gui_msg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void gui_msg(Message msg)
|
||||
{
|
||||
std::string output = msg;
|
||||
output += "\n";
|
||||
fputs(output.c_str(), stdout);
|
||||
if (ors_file) {
|
||||
fprintf(ors_file, "%s", output.c_str());
|
||||
fflush(ors_file);
|
||||
}
|
||||
gMessages.push_back(msg);
|
||||
}
|
||||
|
||||
void GUIConsole::Translate_Now() {
|
||||
size_t message_count = gMessages.size();
|
||||
if (message_count <= last_message_count)
|
||||
return;
|
||||
|
||||
for (size_t m = last_message_count; m < message_count; m++) {
|
||||
std::string message = gMessages[m];
|
||||
std::string color = "normal";
|
||||
if (gMessages[m].GetKind() == msg::kError)
|
||||
color = "error";
|
||||
else if (gMessages[m].GetKind() == msg::kHighlight)
|
||||
color = "highlight";
|
||||
else if (gMessages[m].GetKind() == msg::kWarning)
|
||||
color = "warning";
|
||||
gConsole.push_back(message);
|
||||
gConsoleColor.push_back(color);
|
||||
}
|
||||
last_message_count = message_count;
|
||||
}
|
||||
|
||||
GUIConsole::GUIConsole(xml_node<>* node) : GUIScrollList(node)
|
||||
{
|
||||
xml_node<>* child;
|
||||
@@ -160,6 +252,7 @@ int GUIConsole::RenderSlideout(void)
|
||||
|
||||
int GUIConsole::RenderConsole(void)
|
||||
{
|
||||
Translate_Now();
|
||||
AddLines(&gConsole, &gConsoleColor, &mLastCount, &rConsole, &rConsoleColor);
|
||||
GUIScrollList::Render();
|
||||
|
||||
|
||||
226
gui/devices/common/res/languages/en.xml
Normal file
226
gui/devices/common/res/languages/en.xml
Normal file
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>English</display>
|
||||
|
||||
<resources>
|
||||
<!-- Font overrides - only change these if your language requires special characters -->
|
||||
<resource name="font" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="mediumfont" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="filelist" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
|
||||
<!-- Partition display names -->
|
||||
<string name="system">System</string>
|
||||
<string name="system_image">System Image</string>
|
||||
<string name="vendor">Vendor</string>
|
||||
<string name="vendor_image">Vendor Image</string>
|
||||
<string name="boot">Boot</string>
|
||||
<string name="recovery">Recovery</string>
|
||||
<string name="cache">Cache</string>
|
||||
<string name="data">Data</string>
|
||||
<string name="sdcard">SDCard</string>
|
||||
<string name="internal">Internal Storage</string>
|
||||
<string name="microsd">Micro SDCard</string>
|
||||
<string name="usbotg">USB OTG</string>
|
||||
<string name="android_secure">Android Secure</string>
|
||||
<string name="dalvik">Dalvik / ART Cache</string>
|
||||
<!-- This is a rarely used partition on a Micro SD card for a very old app2sd system -->
|
||||
<string name="sdext">SD-EXT</string>
|
||||
|
||||
<!-- GUI XML strings -->
|
||||
<string name="install_button_text">Install</string>
|
||||
|
||||
<!-- Various console messages - these consist of user displayed messages, oftentimes errors -->
|
||||
<string name="no_kernel_selinux">Kernel does not have support for reading SELinux contexts.</string>
|
||||
<string name="full_selinux">Full SELinux support is present.</string>
|
||||
<string name="no_selinux">No SELinux support (no libselinux).</string>
|
||||
<string name="mtp_enabled">MTP Enabled</string>
|
||||
<string name="mtp_crash">MTP Crashed, not starting MTP on boot.</string>
|
||||
<string name="rebooting">Rebooting...</string>
|
||||
<string name="decrypt_success">Successfully decrypted with default password.</string>
|
||||
<string name="unable_to_decrypt">Unable to decrypt with default password. You may need to perform a Format Data.</string>
|
||||
<string name="generating_md51">Generating MD5</string>
|
||||
<!-- Message displayed during a backup if we are generating an MD5, ideally, leave the leading " * " to help align and separate this text from other console text -->
|
||||
<string name="generating_md52"> * Generating md5...</string>
|
||||
<string name="md5_created"> * MD5 Created.</string>
|
||||
<string name="md5_error"> * MD5 Error!</string>
|
||||
<string name="md5_compute_error"> * Error computing MD5.</string>
|
||||
<string name="md5_created"> * MD5 Created.</string>
|
||||
<string name="current_date">(Current Date)</string>
|
||||
<string name="auto_generate">(Auto Generate)</string>
|
||||
<string name="unable_to_locate_partition">Unable to locate '{1}' partition for backup calculations.</string>
|
||||
<string name="no_partition_selected">No partitions selected for backup.</string>
|
||||
<string name="total_partitions_backup"> * Total number of partitions to back up: {1}</string>
|
||||
<string name="total_backup_size"> * Total size of all data: {1}MB</string>
|
||||
<string name="available_space"> * Available space: {1}MB</string>
|
||||
<string name="unable_locate_storage">Unable to locate storage device.</string>
|
||||
<string name="Not enough free space on storage.">Not enough free space on storage.</string>
|
||||
<string name="backup_started">[BACKUP STARTED]</string>
|
||||
<string name="backup_folder"> * Backup Folder: {1}</string>
|
||||
<string name="fail_backup_folder">Failed to make backup folder.</string>
|
||||
<string name="avg_backup_fs">Average backup rate for file systems: {1} MB/sec</string>
|
||||
<string name="avg_backup_img">Average backup rate for imaged drives: {1} MB/sec</string>
|
||||
<string name="total_backed_size">[{1} MB TOTAL BACKED UP]</string>
|
||||
<string name="backup_completed">[BACKUP COMPLETED IN {1} SECONDS]</string>
|
||||
<string name="restore_started">[RESTORE STARTED]</string>
|
||||
<string name="restore_folder">Restore folder: '%s'</string>
|
||||
<!-- {1} is the partition display name and {2} is the number of seconds -->
|
||||
<string name="restort_part_done">[{1} done ({2} seconds)]</string>
|
||||
<string name="verifying_md5">Verifying MD5</string>
|
||||
<string name="skip_md5">Skipping MD5 check based on user setting.</string>
|
||||
<string name="calc_restore">Calculating restore details...</string>
|
||||
<string name="restore_read_only">Cannot restore %s -- mounted read only.</string>
|
||||
<string name="restore_unable_locate">Unable to locate '{1}' partition for restoring.</string>
|
||||
<string name="no_part_restore">No partitions selected for restore.</string>
|
||||
<string name="restore_part_count">Restoring {1} partitions...</string>
|
||||
<string name="total_restore_size">Total restore size is {1}MB</string>
|
||||
<string name="updating_system_details">Updating System Details</string>
|
||||
<string name="restore_complete">[RESTORE COMPLETED IN {1} SECONDS]</string>
|
||||
<!-- {1} is the path we could not open, {2} is strerror output -->
|
||||
<string name="error_opening_strerr">Error opening: '{1}' ({2})</string>
|
||||
<string name="unable_locate_part_backup_name">Unable to locate partition by backup name: '{1}'</string>
|
||||
<string name="unable_find_part_path">Unable to find partition for path '{1}'</string>
|
||||
<string name="update_part_details">Updating partition details...</string>
|
||||
<string name="update_part_details_done">...done</string>
|
||||
<string name="wiping_dalvik">Wiping Dalvik Cache Directories...</string>
|
||||
<string name="cleaned">Cleaned: {1}...</string>
|
||||
<string name="dalvik_done">-- Dalvik Cache Directories Wipe Complete!</string>
|
||||
<string name="no_andsec">No android secure partitions found.</string>
|
||||
<string name="unable_to_locate">Unable to locate {1}.</string>
|
||||
<string name="wiping_datamedia">Wiping internal storage -- /data/media...</string>
|
||||
<string name="unable_to_mount">Unable to mount {1}</string>
|
||||
<string name="unable_to_mount_internal">Unable to mount internal_storage</string>
|
||||
<string name="unable_to_mount_storage">Unable to mount storage</string>
|
||||
<string name="fail_decrypt">Failed to decrypt data.</string>
|
||||
<string name="no_crypto_support">No crypto support was compiled into this build.</string>
|
||||
<string name="decrypt_success">Data successfully decrypted, new block device: '{1}'</string>
|
||||
<string name="done">Done.</string>
|
||||
<string name="start_partition_sd">Partitioning SD Card...</string>
|
||||
<string name="partition_sd_locate">Unable to locate device to partition.</string>
|
||||
<string name="ext_swap_size">EXT + Swap size is larger than sdcard size.</string>
|
||||
<string name="remove_part_table">Removing partition table...</string>
|
||||
<string name="unable_rm_part">Unable to remove partition table.</string>
|
||||
<string name="create_part">Creating {1} partition...</string>
|
||||
<string name="unable_to_create_part">Unable to create {1} partition.</string>
|
||||
<string name="format_sdext_as">Formatting sd-ext as {1}...</string>
|
||||
<string name="part_complete">Partitioning complete.</string>
|
||||
<string name="unable_to_open">Unable to open '{1}'.</string>
|
||||
<string name="mtp_already_enabled">MTP already enabled</string>
|
||||
<string name="mtp_fail">Failed to enable MTP</string>
|
||||
<string name="no_mtp">MTP support not included</string>
|
||||
<string name="image_flash_start">[IMAGE FLASH STARTED]</string>
|
||||
<string name="img_to_flash">Image to flash: '{1}'</string>
|
||||
<string name="flash_unable_locate">Unable to locate '{1}' partition for flashing.</string>
|
||||
<string name="no_part_flash">No partitions selected for flashing.</string>
|
||||
<string name="too_many_flash">Too many partitions selected for flashing.</string>
|
||||
<string name="invalid_flash">Invalid flash partition specified.</string>
|
||||
<string name="flash_done">IMAGE FLASH COMPLETED]</string>
|
||||
<string name="wiping">Wiping {1}</string>
|
||||
<string name="repair_not_exist">{1} does not exist! Cannot repair!</string>
|
||||
<string name="unable_repair">Unable to repair {1}.</string>
|
||||
<string name="mount_data_footer">Could not mount /data and unable to find crypto footer.</string>
|
||||
<!-- {1} is the folder name that we could not create, {2} is strerror output -->
|
||||
<string name="create_folder_strerr">Can not create '{1}' folder ({2}).</string>
|
||||
<!-- {1} is the folder name that we could not mount, {2} is strerror output -->
|
||||
<string name="fail_mount">Failed to mount '{1}' ({2})</string>
|
||||
<!-- {1} is the folder name that we could not unmount, {2} is strerror output -->
|
||||
<string name="fail_mount">Failed to unmount '{1}' ({2})</string>
|
||||
<string name="cannot_resize">Cannot resize {1}.</string>
|
||||
<string name="repair_resize">Repairing {1} before resizing.</string>
|
||||
<string name="unable_resize">Unable to resize {1}.</string>
|
||||
<string name="no_md5_found">No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.</string>
|
||||
<string name="md5_fail_match">MD5 failed to match on '{1}'.</string>
|
||||
<string name="restoring">Restoring</string>
|
||||
<string name="format_data_msg">You may need to reboot recovery to be able to use /data again.</string>
|
||||
<string name="format_data_err">Unable to format to remove encryption.</string>
|
||||
<string name="formating_using">Formatting {1} using {2}...</string>
|
||||
<string name="unable_to_wipe">Unable to wipe {1}.</string>
|
||||
<string name="remove_all">Removing all files under '{1}'</string>
|
||||
<string name="wiping_data">Wiping data without wiping /data/media ...</string>
|
||||
<string name="backing_up">Backing up {1}...</string>
|
||||
<string name="backing">Backing Up</string>
|
||||
<string name="backup_size">Backup file size for '%s' is 0 bytes.</string>
|
||||
<string name="datamedia_fs_restore">WARNING: This /data backup was made with {1} file system! The backup may not boot unless you change back to {1}.</string>
|
||||
<string name="restoring">Restoring {1}...</string>
|
||||
<string name="restore">Restoring</string>
|
||||
<string name="recreate_folder_err">Unable to recreate {1} folder.</string>
|
||||
<string name="img_size_err">Size of image is larger than target device</string>
|
||||
<string name="flashing">Flashing {1}...</string>
|
||||
<string name="backup_folder">Backup folder set to '{1}'</string>
|
||||
<string name="locate_backup_err">Unable to locate backup '{1}'</string>
|
||||
<string name="set_restore_opt">Setting restore options: '{1}':</string>
|
||||
<string name="md5_check_skip">MD5 check skip is on</string>
|
||||
<string name="ors_encrypt_restore_err">Unable to use OpenRecoveryScript to restore an encrypted backup.</string>
|
||||
<string name="mounting">Mounting</string>
|
||||
<string name="unmounting">Unmounting</string>
|
||||
<string name="mounted">Mounted '{1}'</string>
|
||||
<string name="unmounted">Unmounted '{1}'</string>
|
||||
<string name="setting">Setting '{1}' to '{2}'</string>
|
||||
<string name="setting_empty">Setting '{1}' to empty</string>
|
||||
<string name="making_dir1">Making Directory</string>
|
||||
<string name="making_dir2">Making directory: '{1}'</string>
|
||||
<string name="running_command">Running Command</string>
|
||||
<string name="sideload">ADB Sideload</string>
|
||||
<string name="start_sideload">Starting ADB sideload feature...</string>
|
||||
<string name="need_new_adb">You need adb 1.0.32 or newer to sideload to this device.</string>
|
||||
<string name="no_pwd">No password provided.</string>
|
||||
<string name="done_ors">Done processing script file</string>
|
||||
<string name="injecttwrp">Injecting TWRP into boot image...</string>
|
||||
<string name="zip_err">Error installing zip file '{1}'</string>
|
||||
<string name="installing_zip">Installing zip file '{1}'</string>
|
||||
<string name="select_backup_opt">Setting backup options:</string>
|
||||
<string name="compression_on">Compression is on</string>
|
||||
<string name="md5_off">MD5 Generation is off</string>
|
||||
<string name="backup_fail">Backup Failed</string>
|
||||
<string name="backup_complete">Backup complete!</string>
|
||||
<string name="running_recovery_commands">Running Recovery Commands</string>
|
||||
<string name="recovery_commands_complete">Recovery Commands Complete</string>
|
||||
<string name="running_ors">Running OpenRecoveryScript</string>
|
||||
<string name="ors_complete">OpenRecoveryScript Complete</string>
|
||||
<string name="no_updater_binary">Could not find '{1}' in the zip file.</string>
|
||||
<string name="check_for_md5">Checking for MD5 file...</string>
|
||||
<string name="fail_sysmap">Failed to map file '{1}'</string>
|
||||
<string name="verify_zip_sig">Verifying zip signature...</string>
|
||||
<string name="verify_zip_fail">Zip signature verification failed!</string>
|
||||
<string name="verify_zip_done">Zip signature verified successfully.</string>
|
||||
<string name="zip_corrupt">Zip file is corrupt!</string>
|
||||
<string name="no_md5">Skipping MD5 check: no MD5 file found</string>
|
||||
<string name="md5_fail">MD5 does not match</string>
|
||||
<string name="md5_match">MD5 matched</string>
|
||||
<string name="pid_signal">{1} process ended with signal: {2}</string>
|
||||
<string name="pid_error">{1} process ended with ERROR: {2}</string>
|
||||
<string name="install_dumlock">Installing HTC Dumlock to system...</string>
|
||||
<string name="dumlock_restore">Restoring original boot...</string>
|
||||
<string name="dumlock_reflash">Reflashing recovery to boot...</string>
|
||||
<string name="run_script">Running {1} script...</string>
|
||||
<string name="rename_stock">Renamed stock recovery file in /system to prevent the stock ROM from replacing TWRP.</string>
|
||||
<string name="split_backup">Breaking backup file into multiple archives...</string>
|
||||
<string name="backup_error">Error creating backup.</string>
|
||||
<string name="restore_error">Error during restore process.</string>
|
||||
<string name="split_thread">Splitting thread ID {1} into archive {2}</string>
|
||||
<string name="file_progress">%llu of %llu files, %i%%</string>
|
||||
<string name="size_progress">%lluMB of %lluMB, %i%%</string>
|
||||
<string name="decrypt_cmd">Attempting to decrypt data partition via command line.</string>
|
||||
<string name="base_pkg_err">Failed to load base packages.</string>
|
||||
<string name="simulating">Simulating actions...</string>
|
||||
<string name="backup_cancel">Backup Canceled.</string>
|
||||
<string name="config_twrp">Configuring TWRP...</string>
|
||||
<string name="config_twrp_err">Unable to configure TWRP with this kernel.</string>
|
||||
<string name="copy_log">Copied recovery log to {1}.</string>
|
||||
<string name="max_queue">Maximum zip queue reached!</string>
|
||||
<string name="min_queue">Minimum zip queue reached!</string>
|
||||
<string name="screenshot_err">Failed to take a screenshot!</string>
|
||||
<string name="zip_wipe_cache">One or more zip requested a cache wipe -- Wiping cache now.</string>
|
||||
<string name="and_sec_wipe_err">Unable to wipe android secure</string>
|
||||
<string name="dalvik_wipe_err">Failed to wipe dalvik</string>
|
||||
<string name="auto_gen">(Auto Generate)</string>
|
||||
<string name="curr_date">(Current Date)</string>
|
||||
<string name="backup_name_len">Backup name is too long.</string>
|
||||
<string name="backup_name_invalid">Backup name '{1}' contains invalid character: '{1}'</string>
|
||||
<string name="backup_name_exists">A backup with this name already exists.</string>
|
||||
<string name="no_real_sdcard">This device does not have a real SD Card! Aborting!</string>
|
||||
<string name="cancel_sideload">Cancelling ADB sideload...</string>
|
||||
<string name="change_fs_err">Error changing file system.</string>
|
||||
</resources>
|
||||
</language>
|
||||
13
gui/devices/common/res/languages/es.xml
Normal file
13
gui/devices/common/res/languages/es.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>Español</display>
|
||||
|
||||
<resources>
|
||||
<resource name="font" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="mediumfont" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="filelist" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
<string name="install_button_text">Instalar</string>
|
||||
</resources>
|
||||
</language>
|
||||
13
gui/devices/common/res/languages/fi.xml
Normal file
13
gui/devices/common/res/languages/fi.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>Suomi</display>
|
||||
|
||||
<resources>
|
||||
<resource name="font" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="mediumfont" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="filelist" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
<string name="install_button_text">Asenna</string>
|
||||
</resources>
|
||||
</language>
|
||||
59
gui/gui.cpp
59
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;
|
||||
}
|
||||
}
|
||||
|
||||
33
gui/gui.hpp
Normal file
33
gui/gui.hpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright 2015 bigbiff/Dees_Troy TeamWin
|
||||
This file is part of TWRP/TeamWin Recovery Project.
|
||||
|
||||
TWRP is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TWRP is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUI_HPP_HEADER
|
||||
#define _GUI_HPP_HEADER
|
||||
|
||||
#include "twmsg.h"
|
||||
|
||||
void gui_msg(const char* text);
|
||||
void gui_warn(const char* text);
|
||||
void gui_err(const char* text);
|
||||
void gui_highlight(const char* text);
|
||||
void gui_msg(Message msg);
|
||||
|
||||
std::string gui_parse_text(std::string inText);
|
||||
std::string gui_lookup(const std::string& resource_name, const std::string& default_value);
|
||||
|
||||
#endif //_GUI_HPP_HEADER
|
||||
@@ -26,6 +26,9 @@ extern "C" {
|
||||
#include "rapidxml.hpp"
|
||||
#include "objects.hpp"
|
||||
#include "../data.hpp"
|
||||
#include "pages.hpp"
|
||||
|
||||
extern std::vector<language_struct> Language_List;
|
||||
|
||||
GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
|
||||
{
|
||||
@@ -56,6 +59,21 @@ GUIListBox::GUIListBox(xml_node<>* node) : GUIScrollList(node)
|
||||
DataManager::SetValue(mVariable, attr->value());
|
||||
// Get the currently selected value for the list
|
||||
DataManager::GetValue(mVariable, currentValue);
|
||||
if (mVariable == "tw_language") {
|
||||
std::vector<language_struct>::iterator iter;
|
||||
for (iter = Language_List.begin(); iter != Language_List.end(); iter++) {
|
||||
ListItem data;
|
||||
data.displayName = (*iter).displayvalue;
|
||||
data.variableValue = (*iter).filename;
|
||||
data.action = NULL;
|
||||
if (currentValue == (*iter).filename) {
|
||||
data.selected = 1;
|
||||
DataManager::SetValue("tw_language_display", (*iter).displayvalue);
|
||||
} else
|
||||
data.selected = 0;
|
||||
mListItems.push_back(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
allowSelection = false; // allows using listbox as a read-only list or menu
|
||||
|
||||
@@ -43,6 +43,15 @@ using namespace rapidxml;
|
||||
#define TW_Y_OFFSET 0
|
||||
#endif
|
||||
|
||||
struct translate_later_struct {
|
||||
std::string resource_name; // Name of the string resource for looking up
|
||||
std::string default_value; // Default in case we don't find the string resource
|
||||
std::string color; // Color for the console... normal, highlight, warning, error
|
||||
std::string format; // Formatted extra variables like %i, %s
|
||||
std::string text; // Final, translated, formatted text
|
||||
bool inline_format; // Indicates if the final text includes an inlined format variable
|
||||
};
|
||||
|
||||
class RenderObject
|
||||
{
|
||||
public:
|
||||
@@ -356,6 +365,7 @@ protected:
|
||||
int cancelbackup(std::string arg);
|
||||
int checkpartitionlifetimewrites(std::string arg);
|
||||
int mountsystemtoggle(std::string arg);
|
||||
int setlanguage(std::string arg);
|
||||
|
||||
int simulate;
|
||||
};
|
||||
@@ -734,6 +744,7 @@ public:
|
||||
virtual size_t GetItemCount();
|
||||
virtual void RenderItem(size_t itemindex, int yPos, bool selected);
|
||||
virtual void NotifySelect(size_t item_selected);
|
||||
static void Translate_Now();
|
||||
protected:
|
||||
enum SlideoutState
|
||||
{
|
||||
|
||||
184
gui/pages.cpp
184
gui/pages.cpp
@@ -33,6 +33,7 @@
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "../twrp-functions.hpp"
|
||||
#include "../partitions.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -50,6 +51,14 @@ extern "C" {
|
||||
|
||||
extern int gGuiRunning;
|
||||
|
||||
// From ../twrp.cpp
|
||||
extern bool datamedia;
|
||||
|
||||
// From console.cpp
|
||||
extern size_t last_message_count;
|
||||
extern std::vector<std::string> gConsole;
|
||||
extern std::vector<std::string> gConsoleColor;
|
||||
|
||||
std::map<std::string, PageSet*> PageManager::mPageSets;
|
||||
PageSet* PageManager::mCurrentSet;
|
||||
PageSet* PageManager::mBaseSet = NULL;
|
||||
@@ -57,6 +66,7 @@ MouseCursor *PageManager::mMouseCursor = NULL;
|
||||
HardwareKeyboard *PageManager::mHardwareKeyboard = NULL;
|
||||
bool PageManager::mReloadTheme = false;
|
||||
std::string PageManager::mStartPage = "main";
|
||||
std::vector<language_struct> Language_List;
|
||||
|
||||
int tw_x_offset = 0;
|
||||
int tw_y_offset = 0;
|
||||
@@ -670,7 +680,48 @@ PageSet::~PageSet()
|
||||
delete mResources;
|
||||
}
|
||||
|
||||
int PageSet::Load(ZipArchive* package, char* xmlFile)
|
||||
int PageSet::LoadLanguage(char* languageFile, ZipArchive* package)
|
||||
{
|
||||
xml_document<> lang;
|
||||
xml_node<>* parent;
|
||||
xml_node<>* child;
|
||||
std::string resource_source;
|
||||
|
||||
if (languageFile) {
|
||||
printf("parsing languageFile\n");
|
||||
lang.parse<0>(languageFile);
|
||||
printf("parsing languageFile done\n");
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
parent = lang.first_node("language");
|
||||
if (!parent) {
|
||||
LOGERR("Unable to locate language node in language file.\n");
|
||||
lang.clear();
|
||||
return -1;
|
||||
}
|
||||
|
||||
child = parent->first_node("display");
|
||||
if (child) {
|
||||
DataManager::SetValue("tw_language_display", child->value());
|
||||
resource_source = child->value();
|
||||
} else {
|
||||
LOGERR("language file does not have a display value set\n");
|
||||
DataManager::SetValue("tw_language_display", "Not Set");
|
||||
resource_source = languageFile;
|
||||
}
|
||||
|
||||
child = parent->first_node("resources");
|
||||
if (child)
|
||||
mResources->LoadResources(child, package, resource_source);
|
||||
else
|
||||
return -1;
|
||||
lang.clear();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PageSet::Load(ZipArchive* package, char* xmlFile, char* languageFile)
|
||||
{
|
||||
xml_document<> mDoc;
|
||||
xml_node<>* parent;
|
||||
@@ -735,10 +786,14 @@ int PageSet::Load(ZipArchive* package, char* xmlFile)
|
||||
} else {
|
||||
LOGINFO("XML contains no details tag, no scaling will be applied.\n");
|
||||
}
|
||||
|
||||
if (languageFile)
|
||||
LoadLanguage(languageFile, package);
|
||||
|
||||
LOGINFO("Loading resources...\n");
|
||||
child = parent->first_node("resources");
|
||||
if (child)
|
||||
mResources->LoadResources(child, package);
|
||||
mResources->LoadResources(child, package, "theme");
|
||||
|
||||
LOGINFO("Loading variables...\n");
|
||||
child = parent->first_node("variables");
|
||||
@@ -831,7 +886,7 @@ int PageSet::CheckInclude(ZipArchive* package, xml_document<> *parentDoc)
|
||||
LOGINFO("Loading included resources...\n");
|
||||
child = parent->first_node("resources");
|
||||
if (child)
|
||||
mResources->LoadResources(child, package);
|
||||
mResources->LoadResources(child, package, "theme");
|
||||
|
||||
LOGINFO("Loading included variables...\n");
|
||||
child = parent->first_node("variables");
|
||||
@@ -1121,6 +1176,11 @@ int PageSet::NotifyVarChange(std::string varName, std::string value)
|
||||
return (mCurrentPage ? mCurrentPage->NotifyVarChange(varName, value) : -1);
|
||||
}
|
||||
|
||||
void PageSet::AddStringResource(std::string resource_source, std::string resource_name, std::string value)
|
||||
{
|
||||
mResources->AddStringResource(resource_source, resource_name, value);
|
||||
}
|
||||
|
||||
char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) {
|
||||
size_t len;
|
||||
char* buffer = NULL;
|
||||
@@ -1181,12 +1241,96 @@ char* PageManager::LoadFileToBuffer(std::string filename, ZipArchive* package) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void PageManager::LoadLanguageListDir(string dir) {
|
||||
if (!TWFunc::Path_Exists(dir)) {
|
||||
LOGERR("LoadLanguageListDir '%s' path not found\n", dir.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
DIR *d = opendir(dir.c_str());
|
||||
struct dirent *p;
|
||||
|
||||
if (d == NULL) {
|
||||
LOGERR("LoadLanguageListDir error opening dir: '%s', %s\n", dir.c_str(), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
while ((p = readdir(d))) {
|
||||
if (!strcmp(p->d_name, ".") || !strcmp(p->d_name, "..") || strlen(p->d_name) < 5)
|
||||
continue;
|
||||
|
||||
string file = p->d_name;
|
||||
if (file.substr(strlen(p->d_name) - 4) != ".xml")
|
||||
continue;
|
||||
string path = dir + p->d_name;
|
||||
string file_no_extn = file.substr(0, strlen(p->d_name) - 4);
|
||||
struct language_struct language_entry;
|
||||
language_entry.filename = file_no_extn;
|
||||
char* xmlFile = PageManager::LoadFileToBuffer(dir + p->d_name, NULL);
|
||||
if (xmlFile == NULL) {
|
||||
LOGERR("LoadLanguageListDir unable to load '%s'\n", language_entry.filename.c_str());
|
||||
continue;
|
||||
}
|
||||
xml_document<> *doc = new xml_document<>();
|
||||
doc->parse<0>(xmlFile);
|
||||
|
||||
xml_node<>* parent = doc->first_node("language");
|
||||
if (!parent) {
|
||||
LOGERR("Invalid language XML file '%s'\n", language_entry.filename.c_str());
|
||||
} else {
|
||||
xml_node<>* child = parent->first_node("display");
|
||||
if (child) {
|
||||
language_entry.displayvalue = child->value();
|
||||
} else {
|
||||
LOGERR("No display value for '%s'\n", language_entry.filename.c_str());
|
||||
language_entry.displayvalue = language_entry.filename;
|
||||
}
|
||||
Language_List.push_back(language_entry);
|
||||
}
|
||||
doc->clear();
|
||||
delete doc;
|
||||
free(xmlFile);
|
||||
}
|
||||
closedir(d);
|
||||
}
|
||||
|
||||
void PageManager::LoadLanguageList(ZipArchive* package) {
|
||||
Language_List.clear();
|
||||
if (TWFunc::Path_Exists(TWRES "customlanguages"))
|
||||
TWFunc::removeDir(TWRES "customlanguages", true);
|
||||
if (package) {
|
||||
TWFunc::Recursive_Mkdir(TWRES "customlanguages");
|
||||
struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default
|
||||
mzExtractRecursive(package, "languages", TWRES "customlanguages/", ×tamp, NULL, NULL, NULL);
|
||||
LoadLanguageListDir(TWRES "customlanguages/");
|
||||
} else {
|
||||
LoadLanguageListDir(TWRES "languages/");
|
||||
}
|
||||
}
|
||||
|
||||
void PageManager::LoadLanguage(string filename) {
|
||||
string actual_filename;
|
||||
if (TWFunc::Path_Exists(TWRES "customlanguages/" + filename + ".xml"))
|
||||
actual_filename = TWRES "customlanguages/" + filename + ".xml";
|
||||
else
|
||||
actual_filename = TWRES "languages/" + filename + ".xml";
|
||||
char* xmlFile = PageManager::LoadFileToBuffer(actual_filename, NULL);
|
||||
if (xmlFile == NULL)
|
||||
LOGERR("Unable to load '%s'\n", actual_filename.c_str());
|
||||
else {
|
||||
mCurrentSet->LoadLanguage(xmlFile, NULL);
|
||||
free(xmlFile);
|
||||
}
|
||||
PartitionManager.Translate_Partition_Display_Names();
|
||||
}
|
||||
|
||||
int PageManager::LoadPackage(std::string name, std::string package, std::string startpage)
|
||||
{
|
||||
int fd;
|
||||
ZipArchive zip, *pZip = NULL;
|
||||
long len;
|
||||
char* xmlFile = NULL;
|
||||
char* languageFile = NULL;
|
||||
PageSet* pageSet = NULL;
|
||||
int ret;
|
||||
MemMapping map;
|
||||
@@ -1201,6 +1345,8 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
|
||||
LOGINFO("Load XML directly\n");
|
||||
tw_x_offset = TW_X_OFFSET;
|
||||
tw_y_offset = TW_Y_OFFSET;
|
||||
LoadLanguageList(NULL);
|
||||
languageFile = LoadFileToBuffer(TWRES "languages/en.xml", NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1220,6 +1366,8 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
|
||||
}
|
||||
pZip = &zip;
|
||||
package = "ui.xml";
|
||||
LoadLanguageList(pZip);
|
||||
languageFile = LoadFileToBuffer("languages/en.xml", pZip);
|
||||
}
|
||||
|
||||
xmlFile = LoadFileToBuffer(package, pZip);
|
||||
@@ -1230,8 +1378,11 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
|
||||
// Before loading, mCurrentSet must be the loading package so we can find resources
|
||||
pageSet = mCurrentSet;
|
||||
mCurrentSet = new PageSet(xmlFile);
|
||||
|
||||
ret = mCurrentSet->Load(pZip, xmlFile);
|
||||
ret = mCurrentSet->Load(pZip, xmlFile, languageFile);
|
||||
if (languageFile) {
|
||||
free(languageFile);
|
||||
languageFile = NULL;
|
||||
}
|
||||
if (ret == 0)
|
||||
{
|
||||
mCurrentSet->SetPage(startpage);
|
||||
@@ -1253,6 +1404,8 @@ int PageManager::LoadPackage(std::string name, std::string package, std::string
|
||||
sysReleaseMap(&map);
|
||||
}
|
||||
free(xmlFile);
|
||||
if (languageFile)
|
||||
free(languageFile);
|
||||
return ret;
|
||||
|
||||
error:
|
||||
@@ -1313,7 +1466,7 @@ int PageManager::ReloadPackage(std::string name, std::string package)
|
||||
|
||||
if (LoadPackage(name, package, mStartPage) != 0)
|
||||
{
|
||||
LOGERR("Failed to load package '%s'.\n", package.c_str());
|
||||
LOGINFO("Failed to load package '%s'.\n", package.c_str());
|
||||
mPageSets.insert(std::pair<std::string, PageSet*>(name, set));
|
||||
return -1;
|
||||
}
|
||||
@@ -1322,6 +1475,7 @@ int PageManager::ReloadPackage(std::string name, std::string package)
|
||||
if (mBaseSet == set)
|
||||
mBaseSet = mCurrentSet;
|
||||
delete set;
|
||||
GUIConsole::Translate_Now();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1364,6 +1518,18 @@ int PageManager::RunReload() {
|
||||
ret_val = 1;
|
||||
}
|
||||
}
|
||||
if (ret_val == 0) {
|
||||
if (DataManager::GetStrValue("tw_language") != "en.xml") {
|
||||
LOGINFO("Loading language '%s'\n", DataManager::GetStrValue("tw_language").c_str());
|
||||
LoadLanguage(DataManager::GetStrValue("tw_language"));
|
||||
}
|
||||
}
|
||||
|
||||
// This makes the console re-translate
|
||||
last_message_count = 0;
|
||||
gConsole.clear();
|
||||
gConsoleColor.clear();
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
@@ -1511,6 +1677,12 @@ int PageManager::NotifyVarChange(std::string varName, std::string value)
|
||||
return (mCurrentSet ? mCurrentSet->NotifyVarChange(varName, value) : -1);
|
||||
}
|
||||
|
||||
void PageManager::AddStringResource(std::string resource_source, std::string resource_name, std::string value)
|
||||
{
|
||||
if (mCurrentSet)
|
||||
mCurrentSet->AddStringResource(resource_source, resource_name, value);
|
||||
}
|
||||
|
||||
extern "C" void gui_notifyVarChange(const char *name, const char* value)
|
||||
{
|
||||
if (!gGuiRunning)
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "../minzip/Zip.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "rapidxml.hpp"
|
||||
#include "gui.hpp"
|
||||
using namespace rapidxml;
|
||||
|
||||
enum TOUCH_STATE {
|
||||
@@ -27,12 +29,18 @@ struct COLOR {
|
||||
: red(r), green(g), blue(b), alpha(a) {}
|
||||
};
|
||||
|
||||
struct language_struct {
|
||||
std::string filename;
|
||||
std::string displayvalue;
|
||||
};
|
||||
|
||||
extern std::vector<language_struct> Language_List;
|
||||
|
||||
// Utility Functions
|
||||
int ConvertStrToColor(std::string str, COLOR* color);
|
||||
int gui_forceRender(void);
|
||||
int gui_changePage(std::string newPage);
|
||||
int gui_changeOverlay(std::string newPage);
|
||||
std::string gui_parse_text(string inText);
|
||||
|
||||
class Resource;
|
||||
class ResourceManager;
|
||||
@@ -82,7 +90,8 @@ public:
|
||||
virtual ~PageSet();
|
||||
|
||||
public:
|
||||
int Load(ZipArchive* package, char* xmlFile);
|
||||
int LoadLanguage(char* languageFile, ZipArchive* package);
|
||||
int Load(ZipArchive* package, char* xmlFile, char* languageFile);
|
||||
int CheckInclude(ZipArchive* package, xml_document<> *parentDoc);
|
||||
|
||||
Page* FindPage(std::string name);
|
||||
@@ -103,6 +112,7 @@ public:
|
||||
int NotifyVarChange(std::string varName, std::string value);
|
||||
|
||||
std::vector<xml_node<>*> styles;
|
||||
void AddStringResource(std::string resource_source, std::string resource_name, std::string value);
|
||||
|
||||
protected:
|
||||
int LoadPages(xml_node<>* pages);
|
||||
@@ -121,6 +131,8 @@ class PageManager
|
||||
public:
|
||||
// Used by GUI
|
||||
static char* LoadFileToBuffer(std::string filename, ZipArchive* package);
|
||||
static void LoadLanguageList(ZipArchive* package);
|
||||
static void LoadLanguage(std::string filename);
|
||||
static int LoadPackage(std::string name, std::string package, std::string startpage);
|
||||
static PageSet* SelectPackage(std::string name);
|
||||
static int ReloadPackage(std::string name, std::string package);
|
||||
@@ -155,9 +167,14 @@ public:
|
||||
static HardwareKeyboard *GetHardwareKeyboard();
|
||||
|
||||
static xml_node<>* FindStyle(std::string name);
|
||||
static void AddStringResource(std::string resource_source, std::string resource_name, std::string value);
|
||||
|
||||
protected:
|
||||
static PageSet* FindPackage(std::string name);
|
||||
static void LoadLanguageListDir(std::string dir);
|
||||
static void Translate_Partition(const char* path, const char* resource_name, const char* default_value);
|
||||
static void Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value);
|
||||
static void Translate_Partition_Display_Names();
|
||||
|
||||
protected:
|
||||
static std::map<std::string, PageSet*> mPageSets;
|
||||
|
||||
@@ -99,6 +99,13 @@ void Resource::CheckAndScaleImage(gr_surface source, gr_surface* destination, in
|
||||
|
||||
FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
|
||||
: Resource(node, pZip)
|
||||
{
|
||||
origFontSize = 0;
|
||||
origFont = NULL;
|
||||
LoadFont(node, pZip);
|
||||
}
|
||||
|
||||
void FontResource::LoadFont(xml_node<>* node, ZipArchive* pZip)
|
||||
{
|
||||
std::string file;
|
||||
xml_attribute<>* attr;
|
||||
@@ -116,12 +123,21 @@ FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
|
||||
if(file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0)
|
||||
{
|
||||
m_type = TYPE_TTF;
|
||||
int font_size = 0;
|
||||
|
||||
attr = node->first_attribute("size");
|
||||
if(!attr)
|
||||
return;
|
||||
if (origFontSize != 0) {
|
||||
attr = node->first_attribute("scale");
|
||||
if (attr == NULL)
|
||||
return;
|
||||
font_size = origFontSize * atoi(attr->value()) / 100;
|
||||
} else {
|
||||
attr = node->first_attribute("size");
|
||||
if (attr == NULL)
|
||||
return;
|
||||
font_size = scale_theme_min(atoi(attr->value()));
|
||||
origFontSize = font_size;
|
||||
}
|
||||
|
||||
int size = scale_theme_min(atoi(attr->value()));
|
||||
int dpi = 300;
|
||||
|
||||
attr = node->first_attribute("dpi");
|
||||
@@ -130,13 +146,13 @@ FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
|
||||
|
||||
if (ExtractResource(pZip, "fonts", file, "", TMP_RESOURCE_NAME) == 0)
|
||||
{
|
||||
mFont = gr_ttf_loadFont(TMP_RESOURCE_NAME, size, dpi);
|
||||
mFont = gr_ttf_loadFont(TMP_RESOURCE_NAME, font_size, dpi);
|
||||
unlink(TMP_RESOURCE_NAME);
|
||||
}
|
||||
else
|
||||
{
|
||||
file = std::string(TWRES "fonts/") + file;
|
||||
mFont = gr_ttf_loadFont(file.c_str(), size, dpi);
|
||||
mFont = gr_ttf_loadFont(file.c_str(), font_size, dpi);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -145,13 +161,28 @@ FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
|
||||
}
|
||||
}
|
||||
|
||||
void FontResource::DeleteFont() {
|
||||
if(mFont)
|
||||
gr_ttf_freeFont(mFont);
|
||||
mFont = NULL;
|
||||
if(origFont)
|
||||
gr_ttf_freeFont(origFont);
|
||||
origFont = NULL;
|
||||
}
|
||||
|
||||
void FontResource::Override(xml_node<>* node, ZipArchive* pZip) {
|
||||
if (!origFont) {
|
||||
origFont = mFont;
|
||||
} else if (mFont) {
|
||||
gr_ttf_freeFont(mFont);
|
||||
mFont = NULL;
|
||||
}
|
||||
LoadFont(node, pZip);
|
||||
}
|
||||
|
||||
FontResource::~FontResource()
|
||||
{
|
||||
if(mFont)
|
||||
{
|
||||
if(m_type == TYPE_TTF)
|
||||
gr_ttf_freeFont(mFont);
|
||||
}
|
||||
DeleteFont();
|
||||
}
|
||||
|
||||
ImageResource::ImageResource(xml_node<>* node, ZipArchive* pZip)
|
||||
@@ -255,17 +286,58 @@ AnimationResource* ResourceManager::FindAnimation(const std::string& name) const
|
||||
|
||||
std::string ResourceManager::FindString(const std::string& name) const
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator it = mStrings.find(name);
|
||||
if (it != mStrings.end())
|
||||
return it->second;
|
||||
if (this != NULL) {
|
||||
std::map<std::string, string_resource_struct>::const_iterator it = mStrings.find(name);
|
||||
if (it != mStrings.end())
|
||||
return it->second.value;
|
||||
LOGERR("String resource '%s' not found. No default value.\n", name.c_str());
|
||||
PageManager::AddStringResource("NO DEFAULT", name, "[" + name + ("]"));
|
||||
} else {
|
||||
LOGINFO("String resources not loaded when looking for '%s'. No default value.\n", name.c_str());
|
||||
}
|
||||
return "[" + name + ("]");
|
||||
}
|
||||
|
||||
std::string ResourceManager::FindString(const std::string& name, const std::string& default_string) const
|
||||
{
|
||||
if (this != NULL) {
|
||||
std::map<std::string, string_resource_struct>::const_iterator it = mStrings.find(name);
|
||||
if (it != mStrings.end())
|
||||
return it->second.value;
|
||||
LOGERR("String resource '%s' not found. Using default value.\n", name.c_str());
|
||||
PageManager::AddStringResource("DEFAULT", name, default_string);
|
||||
} else {
|
||||
LOGINFO("String resources not loaded when looking for '%s'. Using default value.\n", name.c_str());
|
||||
}
|
||||
return default_string;
|
||||
}
|
||||
|
||||
void ResourceManager::DumpStrings() const
|
||||
{
|
||||
if (this == NULL) {
|
||||
gui_print("No string resources\n");
|
||||
return;
|
||||
}
|
||||
std::map<std::string, string_resource_struct>::const_iterator it;
|
||||
gui_print("Dumping all strings:\n");
|
||||
for (it = mStrings.begin(); it != mStrings.end(); it++)
|
||||
gui_print("source: %s: '%s' = '%s'\n", it->second.source.c_str(), it->first.c_str(), it->second.value.c_str());
|
||||
gui_print("Done dumping strings\n");
|
||||
}
|
||||
|
||||
ResourceManager::ResourceManager()
|
||||
{
|
||||
}
|
||||
|
||||
void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip)
|
||||
void ResourceManager::AddStringResource(std::string resource_source, std::string resource_name, std::string value)
|
||||
{
|
||||
string_resource_struct res;
|
||||
res.source = resource_source;
|
||||
res.value = value;
|
||||
mStrings[resource_name] = res;
|
||||
}
|
||||
|
||||
void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip, std::string resource_source)
|
||||
{
|
||||
if (!resList)
|
||||
return;
|
||||
@@ -290,6 +362,26 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip)
|
||||
delete res;
|
||||
}
|
||||
}
|
||||
else if (type == "fontoverride")
|
||||
{
|
||||
if (mFonts.size() != 0 && child && child->first_attribute("name")) {
|
||||
string FontName = child->first_attribute("name")->value();
|
||||
size_t font_count = mFonts.size(), i;
|
||||
bool found = false;
|
||||
|
||||
for (i = 0; i < font_count; i++) {
|
||||
if (mFonts[i]->GetName() == FontName) {
|
||||
mFonts[i]->Override(child, pZip);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
LOGERR("Unable to locate font '%s' for override.\n", FontName.c_str());
|
||||
}
|
||||
} else if (mFonts.size() != 0)
|
||||
LOGERR("Unable to locate font name for type fontoverride.\n");
|
||||
}
|
||||
else if (type == "image")
|
||||
{
|
||||
ImageResource* res = new ImageResource(child, pZip);
|
||||
@@ -312,9 +404,12 @@ void ResourceManager::LoadResources(xml_node<>* resList, ZipArchive* pZip)
|
||||
}
|
||||
else if (type == "string")
|
||||
{
|
||||
if (xml_attribute<>* attr = child->first_attribute("name"))
|
||||
mStrings[attr->value()] = child->value();
|
||||
else
|
||||
if (xml_attribute<>* attr = child->first_attribute("name")) {
|
||||
string_resource_struct res;
|
||||
res.source = resource_source;
|
||||
res.value = child->value();
|
||||
mStrings[attr->value()] = res;
|
||||
} else
|
||||
error = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "rapidxml.hpp"
|
||||
|
||||
struct ZipArchive;
|
||||
|
||||
@@ -49,10 +50,19 @@ public:
|
||||
public:
|
||||
void* GetResource() { return this ? mFont : NULL; }
|
||||
int GetHeight() { return gr_getMaxFontHeight(this ? mFont : NULL); }
|
||||
void Override(xml_node<>* node, ZipArchive* pZip);
|
||||
|
||||
protected:
|
||||
void* mFont;
|
||||
Type m_type;
|
||||
|
||||
private:
|
||||
void LoadFont(xml_node<>* node, ZipArchive* pZip);
|
||||
void DeleteFont();
|
||||
|
||||
private:
|
||||
int origFontSize;
|
||||
void* origFont;
|
||||
};
|
||||
|
||||
class ImageResource : public Resource
|
||||
@@ -92,19 +102,26 @@ class ResourceManager
|
||||
public:
|
||||
ResourceManager();
|
||||
virtual ~ResourceManager();
|
||||
void LoadResources(xml_node<>* resList, ZipArchive* pZip);
|
||||
void AddStringResource(std::string resource_source, std::string resource_name, std::string value);
|
||||
void LoadResources(xml_node<>* resList, ZipArchive* pZip, std::string resource_source);
|
||||
|
||||
public:
|
||||
FontResource* FindFont(const std::string& name) const;
|
||||
ImageResource* FindImage(const std::string& name) const;
|
||||
AnimationResource* FindAnimation(const std::string& name) const;
|
||||
std::string FindString(const std::string& name) const;
|
||||
std::string FindString(const std::string& name, const std::string& default_string) const;
|
||||
void DumpStrings() const;
|
||||
|
||||
private:
|
||||
struct string_resource_struct {
|
||||
std::string value;
|
||||
std::string source;
|
||||
};
|
||||
std::vector<FontResource*> mFonts;
|
||||
std::vector<ImageResource*> mImages;
|
||||
std::vector<AnimationResource*> mAnimations;
|
||||
std::map<std::string, std::string> mStrings;
|
||||
std::map<std::string, string_resource_struct> mStrings;
|
||||
};
|
||||
|
||||
#endif // _RESOURCE_HEADER
|
||||
|
||||
1062
gui/theme/common/landscape.xml
Normal file → Executable file
1062
gui/theme/common/landscape.xml
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
666
gui/theme/common/languages/en.xml
Executable file
666
gui/theme/common/languages/en.xml
Executable file
@@ -0,0 +1,666 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>English</display>
|
||||
|
||||
<resources>
|
||||
<!-- Font overrides - only change these if your language requires special characters -->
|
||||
<resource name="font_l" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="font_m" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="font_s" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
|
||||
<!-- Partition display names -->
|
||||
<string name="system">System</string>
|
||||
<string name="system_image">System Image</string>
|
||||
<string name="vendor">Vendor</string>
|
||||
<string name="vendor_image">Vendor Image</string>
|
||||
<string name="boot">Boot</string>
|
||||
<string name="recovery">Recovery</string>
|
||||
<string name="cache">Cache</string>
|
||||
<string name="data">Data</string>
|
||||
<string name="sdcard">SDCard</string>
|
||||
<string name="internal">Internal Storage</string>
|
||||
<string name="microsd">Micro SDCard</string>
|
||||
<string name="usbotg">USB OTG</string>
|
||||
<string name="android_secure">Android Secure</string>
|
||||
<string name="dalvik">Dalvik / ART Cache</string>
|
||||
<!-- This is a rarely used partition on a Micro SD card for a very old app2sd system -->
|
||||
<string name="sdext">SD-EXT</string>
|
||||
<string name="adopted_data">Adopted Data</string>
|
||||
<string name="adopted_storage">Adopted Storage</string>
|
||||
|
||||
<!-- GUI XML strings -->
|
||||
<string name="twrp_header">Team Win Recovery Project</string>
|
||||
<string name="twrp_watch_header">TWRP %tw_version%</string>
|
||||
<string name="cpu_temp">CPU: %tw_cpu_temp% °C</string>
|
||||
<string name="battery_pct">Battery: %tw_battery%</string>
|
||||
<string name="sort_by_name">Sort by Name</string>
|
||||
<string name="sort_by_date">Sort by Date</string>
|
||||
<string name="sort_by_size">Sorty by Size</string>
|
||||
<string name="sort_by_name_only">Name</string>
|
||||
<string name="sort_by_date_only">Date</string>
|
||||
<string name="sort_by_size_only">Size</string>
|
||||
<string name="tab_general">GENERAL</string>
|
||||
<string name="tab_options">OPTIONS</string>
|
||||
<string name="tab_backup">BACKUP</string>
|
||||
<string name="tab_time_zone">TIME ZONE</string>
|
||||
<string name="tab_screen">SCREEN</string>
|
||||
<string name="tab_vibration">VIBRATION</string>
|
||||
<string name="tab_language">LANGUAGE</string>
|
||||
|
||||
<string name="install_btn">Install</string>
|
||||
<string name="wipe_btn">Wipe</string>
|
||||
<string name="backup_btn">Backup</string>
|
||||
<string name="restore_btn">Restore</string>
|
||||
<string name="mount_btn">Mount</string>
|
||||
<string name="settings_btn">Settings</string>
|
||||
<string name="advanced_btn">Advanced</string>
|
||||
<string name="reboot_btn">Reboot</string>
|
||||
<string name="files_btn">Files</string>
|
||||
<string name="copy_log_btn">Copy Log</string>
|
||||
<string name="select_type_hdr">Select Type</string>
|
||||
<string name="install_zip_hdr">Install Zip</string>
|
||||
<string name="install_zip_btn">Install Zip</string>
|
||||
<string name="install_image_hdr">Install Image</string>
|
||||
<string name="install_image_btn">Install Image</string>
|
||||
<string name="install_select_file_hdr">Select File</string>
|
||||
<string name="file_selector_folders_hdr">Folders</string>
|
||||
<string name="select_file_from_storage">Select File from %tw_storage_display_name% (%tw_storage_free_size% MB)</string>
|
||||
<string name="adb_sideload_btn">ADB Sideload</string>
|
||||
<string name="install_hdr">Install</string>
|
||||
<string name="select_storage_hdr">Select Storage</string>
|
||||
<string name="select_storage_btn">Select Storage</string>
|
||||
<string name="queue_hdr">Queue</string>
|
||||
<string name="zip_queue_count">%tw_zip_queue_count% of max of 10 Files queued</string>
|
||||
<string name="zip_queue_count_s">File %tw_zip_queue_count% of 10:</string>
|
||||
<string name="zip_warn1">This operation may install incompatible</string>
|
||||
<string name="zip_warn2">software and render your device unusable.</string>
|
||||
<string name="zip_back_cancel">Press back to cancel adding this zip.</string>
|
||||
<string name="zip_back_clear">Press back button to clear the queue.</string>
|
||||
<string name="folder">Folder:</string>
|
||||
<string name="file">File:</string>
|
||||
<string name="zip_sig_chk">Zip signature verification</string>
|
||||
<string name="inject_twrp_chk">Inject TWRP after install</string>
|
||||
<string name="options_hdr">Options</string>
|
||||
<string name="confirm_flash_hdr">Confirm Flash</string>
|
||||
<string name="zip_queue">Queue:</string>
|
||||
<string name="options">Options:</string>
|
||||
<string name="swipe_confirm"> Confirm</string>
|
||||
<string name="zip_add_btn">Add more Zips</string>
|
||||
<string name="zip_clear_btn">Clear Zip Queue</string>
|
||||
<string name="install_zip_count_hdr">Install Zip %tw_zip_index% of %tw_zip_queue_count%</string>
|
||||
<string name="installing_zip">Installing Zip: %tw_file%</string>
|
||||
<string name="failed">Failed</string>
|
||||
<string name="successful">Successful</string>
|
||||
<string name="install_failed">Installation Failed</string>
|
||||
<string name="install_successful">Installation Successful</string>
|
||||
<string name="wipe_cache_dalvik_btn">Wipe cache/dalvik</string>
|
||||
<string name="reboot_system_btn">Reboot System</string>
|
||||
<string name="install_sel_target">Select Target Partition</string>
|
||||
<string name="flash_image_select">Select Partition to Flash Image:</string>
|
||||
<string name="target_partition">Target Partition:</string>
|
||||
<string name="flashing_image">Flashing Image...</string>
|
||||
<string name="image_flashed">Image Flashed</string>
|
||||
<string name="wipe_cache_dalvik_confirm">Wipe Cache & Dalvik?</string>
|
||||
<string name="wiping_cache_dalvik">Wiping Cache & Dalvik...</string>
|
||||
<string name="wipe_cache_dalvik_complete">Cache & Dalvik Wipe Complete</string>
|
||||
<string name="swipe_wipe">Swipe to Wipe</string>
|
||||
<string name="swipe_wipe_s"> Wipe</string>
|
||||
<string name="no_os1">No OS Installed! Are you</string>
|
||||
<string name="no_osrb">sure you wish to reboot?</string>
|
||||
<string name="no_ospo">sure you wish to power off?</string>
|
||||
<string name="rebooting">Rebooting...</string>
|
||||
<string name="swipe_reboot_s"> Reboot</string>
|
||||
<string name="swipe_flash">Swipe to confirm Flash</string>
|
||||
<string name="confirm_action">Confirm Action</string>
|
||||
<string name="back_cancel">Press back button to cancel.</string>
|
||||
<string name="cancel_btn">Cancel</string>
|
||||
<string name="wipe_hdr">Wipe</string>
|
||||
<string name="factory_reset_hdr">Factory Reset</string>
|
||||
<string name="factory_reset_btn">Factory Reset</string>
|
||||
<string name="factory_reset1">Wipes Data, Cache, and Dalvik</string>
|
||||
<string name="factory_reset2">(not including internal storage)</string>
|
||||
<string name="factory_reset3">Most of the time this is</string>
|
||||
<string name="factory_reset4">the only wipe that you need.</string>
|
||||
<string name="factory_resetting">Factory Reset...</string>
|
||||
<string name="advanced_wipe_hdr">Advanced Wipe</string>
|
||||
<string name="advanced_wipe_btn">Advanced Wipe</string>
|
||||
<string name="wipe_enc_confirm">Wipe Encryption from Data?</string>
|
||||
<string name="formatting_data">Formatting Data...</string>
|
||||
<string name="swipe_format_data">Swipe to Format Data</string>
|
||||
<string name="swipe_format_data_s"> Format Data</string>
|
||||
<string name="factory_reset_complete">Factory Reset Complete</string>
|
||||
<string name="sel_part_hdr">Select Partitions</string>
|
||||
<string name="wipe_sel_confirm">Wipe Selected Partition(s)?</string>
|
||||
<string name="wiping_part">Wiping Partition(s)...</string>
|
||||
<string name="wipe_complete">Wipe Complete</string>
|
||||
<string name="sel_part_wipe">Select Partitions to Wipe:</string>
|
||||
<string name="invalid_part_sel">Invalid partition selection</string>
|
||||
<string name="format_data_hdr">Format Data</string>
|
||||
<string name="format_data_btn">Format Data</string>
|
||||
<string name="format_data_ptr1">Format Data will wipe all of your apps,</string>
|
||||
<string name="format_data_ptr2">backups, pictures, videos, media, and</string>
|
||||
<string name="format_data_ptr3">removes encryption on internal storage.</string>
|
||||
<string name="format_data_lcp1">Format Data will wipe all of your apps, backups, pictures, videos, media, and</string>
|
||||
<string name="format_data_lcp2">removes encryption on internal storage.</string>
|
||||
<string name="format_data_wtc1">Format Data will wipe all of your apps,</string>
|
||||
<string name="format_data_wtc2">backups and media. This cannot be undone.</string>
|
||||
<string name="format_data_undo">This cannot be undone.</string>
|
||||
<string name="format_data_complete">Data Format Complete</string>
|
||||
<string name="yes_continue">Type yes to continue. Press back to cancel.</string>
|
||||
<string name="part_opt_hdr">Partition Options for: %tw_partition_name%</string>
|
||||
<string name="sel_act_hdr">Select Action</string>
|
||||
<string name="file_sys_opt">File System Options</string>
|
||||
<string name="partition">Partition: %tw_partition_name%</string>
|
||||
<string name="part_mount_point">Mount Point: %tw_partition_mount_point%</string>
|
||||
<string name="part_curr_fs">File system: %tw_partition_file_system%</string>
|
||||
<string name="part_present_yes">Present: Yes</string>
|
||||
<string name="part_present_no">Present: No</string>
|
||||
<string name="part_removable_yes">Removable: Yes</string>
|
||||
<string name="part_removable_no">Removable: No</string>
|
||||
<string name="part_size">Size: %tw_partition_size%MB</string>
|
||||
<string name="part_used">Used: %tw_partition_used%MB</string>
|
||||
<string name="part_free">Free: %tw_partition_free%MB</string>
|
||||
<string name="part_backup_size">Backup Size: %tw_partition_backup_size%MB</string>
|
||||
<string name="resize_btn">Resize File System</string>
|
||||
<string name="resize_btn_s">Resize</string>
|
||||
<string name="resize_confirm">Resize %tw_partition_name%?</string>
|
||||
<string name="resizing">Resizing...</string>
|
||||
<string name="resize_complete">Resize Complete</string>
|
||||
<string name="swipe_resize">Swipe to Resize</string>
|
||||
<string name="swipe_resize_s"> Resize</string>
|
||||
<string name="repair_btn">Repair File System</string>
|
||||
<string name="repair_btn_s">Repair</string>
|
||||
<string name="repair_confirm">Repair %tw_partition_name%?</string>
|
||||
<string name="repairing">Repairing...</string>
|
||||
<string name="repair_complete">Repair Complete</string>
|
||||
<string name="swipe_repair">Swipe to Repair</string>
|
||||
<string name="swipe_repair_s"> Repair</string>
|
||||
<string name="change_fs_btn">Change File System</string>
|
||||
<string name="change_fs_btn_s">Change</string>
|
||||
<string name="change_fs_for_hdr">Change File System for: %tw_partition_name%</string>
|
||||
<string name="change_fs_for_hdr_s">Partition: %tw_partition_name% > Select File System</string>
|
||||
<string name="change_fs_warn1">Some ROMs or kernels may not support some</string>
|
||||
<string name="change_fs_warn2">file systems. Proceed with caution!</string>
|
||||
<string name="change_fs_confirm">Change %tw_partition_name%?</string>
|
||||
<string name="formatting">Formatting...</string>
|
||||
<string name="format_complete">Format Complete</string>
|
||||
<string name="swipe_change_fs">Swipe to Change</string>
|
||||
<string name="swipe_change_s"> Change</string>
|
||||
<string name="back_btn">Back</string>
|
||||
<string name="wipe_enc_btn">Wipe Encryption</string>
|
||||
<string name="swipe_factory_reset">Swipe to Factory Reset</string>
|
||||
<string name="repair_change_btn">Repair or Change File System</string>
|
||||
<string name="storage_hdr">Storage: %tw_storage_display_name% (%tw_storage_free_size% MB)</string>
|
||||
<string name="backup_hdr">Backup</string>
|
||||
<string name="backup_confirm_hdr">Confirm Backup</string>
|
||||
<string name="encryption_tab">ENCRYPTION</string>
|
||||
<string name="encryption">Encryption:</string>
|
||||
<string name="name">Name:</string>
|
||||
<string name="sel_part_backup">Select Partitions to Backup:</string>
|
||||
<string name="storage">Storage:</string>
|
||||
<string name="enc_disabled">disabled - set a password to enable</string>
|
||||
<string name="enc_enabled">enabled</string>
|
||||
<string name="enable_backup_comp_chk">Enable compression</string>
|
||||
<string name="skip_md5_backup_chk">Skip MD5 generation during backup</string>
|
||||
<string name="disable_backup_space_chk">Disable Free Space Check</string>
|
||||
<string name="refresh_sizes_btn">Refresh Sizes</string>
|
||||
<string name="swipe_backup">Swipe to Backup</string>
|
||||
<string name="append_date_btn">Append Date</string>
|
||||
<string name="backup_name_exists">A backup with that name already exists!</string>
|
||||
<string name="encrypt_backup">Encrypt your Backup?</string>
|
||||
<string name="enter_pass">Enter Password:</string>
|
||||
<string name="enter_pass2">Enter Password Again:</string>
|
||||
<string name="pass_not_match">Passwords do not match!</string>
|
||||
<string name="partitions">Partitions:</string>
|
||||
<string name="disabled">Disabled</string>
|
||||
<string name="enabled">Enabled</string>
|
||||
<string name="backup_name_hdr">Set Backup Name</string>
|
||||
<string name="progress">Progress:</string>
|
||||
<string name="backup_complete">Backup Complete</string>
|
||||
<string name="backup_cancel">Backup Cancelled</string>
|
||||
<string name="restore_hdr">Restore</string>
|
||||
<string name="sel_backup_hdr">Select Backup</string>
|
||||
<string name="restore_sel_store_hdr">Select Backup from %tw_storage_display_name% (%tw_storage_free_size% MB)</string>
|
||||
<string name="restore_sel_pack_fs">Select Package to Restore:</string>
|
||||
<string name="restore_enc_backup_hdr">Encrypted Backup</string>
|
||||
<string name="restore_dec_fail">Password failed, please try again!</string>
|
||||
<string name="del_backup_btn">Delete Backup</string>
|
||||
<string name="del_backup_confirm">Delete Backup?</string>
|
||||
<string name="del_backup_confirm2">This cannot be undone!</string>
|
||||
<string name="deleting_backup">Deleting Backup...</string>
|
||||
<string name="backup_deleted">Backup Delete Complete</string>
|
||||
<string name="swipe_delete">Swipe to Delete</string>
|
||||
<string name="swipe_delete_s"> Delete</string>
|
||||
<string name="restore_try_decrypt">Encrypted Backup - Trying Decryption</string>
|
||||
<string name="restore_try_decrypt_s">Trying Decryption</string>
|
||||
<string name="restore_backup_date">Backup made on %tw_restore_file_date%</string>
|
||||
<string name="restore_sel_part">Select Partitions to Restore:</string>
|
||||
<string name="retore_enable_md5_chk">Enable MD5 Verification of Backup Files</string>
|
||||
<string name="swipe_restore">Swipe to Restore</string>
|
||||
<string name="swipe_restore_s"> Restore</string>
|
||||
<string name="rename_backup_hdr">Rename Backup</string>
|
||||
<string name="rename_backup_confirm">Rename Backup?</string>
|
||||
<string name="rename_backup_confirm2">This cannot be undone!</string>
|
||||
<string name="renaming_backup">Renaming Backup...</string>
|
||||
<string name="rename_backup_complete">Backup Rename Complete</string>
|
||||
<string name="swipe_to_rename">Swipe to Rename</string>
|
||||
<string name="swipe_rename"> Rename</string>
|
||||
<string name="confirm_hdr">Confirm</string>
|
||||
<string name="mount_hdr">Mount</string>
|
||||
<string name="mount_sel_part"></string>
|
||||
<string name="mount_sel_part">Select Partitions to Mount:</string>
|
||||
<string name="mount_sys_ro_chk">Mount system partition read-only</string>
|
||||
<string name="mount_sys_ro_s_chk">Mount System RO</string>
|
||||
<string name="decrypt_data_btn">Decrypt Data</string>
|
||||
<string name="disable_mtp_btn">Disable MTP</string>
|
||||
<string name="enable_mtp_btn">Enable MTP</string>
|
||||
<string name="mount_usb_storage_btn">Mount USB Storage</string>
|
||||
<string name="usb_storage_hdr">USB Storage</string>
|
||||
<string name="usb_stor_mnt1">USB Storage Mounted</string>
|
||||
<string name="usb_stor_mnt2">Be sure to safely remove your device</string>
|
||||
<string name="usb_stor_mnt3">from your computer before unmounting!</string>
|
||||
<string name="unmount_btn">Unmount</string>
|
||||
<string name="reboot_hdr">Reboot Menu</string>
|
||||
<string name="rb_system_btn">System</string>
|
||||
<string name="rb_poweroff_btn">Power Off</string>
|
||||
<string name="rb_recovery_btn">Recovery</string>
|
||||
<string name="rb_bootloader_btn">Bootloader</string>
|
||||
<string name="rb_download_btn">Download</string>
|
||||
<string name="turning_off">Turning Off...</string>
|
||||
<string name="swipe_power_off">Swipe to Power Off</string>
|
||||
<string name="swipe_power_off_s">Power Off</string>
|
||||
<string name="sys_ro_hdr">Unmodified System Partition</string>
|
||||
<string name="sys_ro_keep">Keep System Read only?</string>
|
||||
<string name="sys_rop1">TWRP can leave your system partition unmodified</string>
|
||||
<string name="sys_rop2">to make it easier for you to take official updates.</string>
|
||||
<string name="sys_rop3">TWRP will be unable to prevent the stock ROM from</string>
|
||||
<string name="sys_rop4">replacing TWRP and will not offer to root your device.</string>
|
||||
<string name="sys_rop5">Installing zips or performing adb operations may still</string>
|
||||
<string name="sys_rop6">modify the system partition.</string>
|
||||
<string name="sys_rol1">TWRP can leave your system partition unmodified to make it easier for you to take official updates.</string>
|
||||
<string name="sys_rol2">TWRP will be unable to prevent the stock ROM from replacing TWRP and will not offer to root your device.</string>
|
||||
<string name="sys_rol3">Installing zips or performing adb operations may still modify the system partition.</string>
|
||||
<string name="sys_ro_never_show_chk">Never show this screen during boot again</string>
|
||||
<string name="sys_ro_keep_ro_btn">Keep Read Only</string>
|
||||
<string name="swipe_allow_mod">Swipe to Allow Modifications</string>
|
||||
<string name="swipe_allow_mod_s">Allow Modifications</string>
|
||||
<string name="settings_hdr">Settings</string>
|
||||
<string name="settings_gen_hdr">General Settings</string>
|
||||
<string name="settings_gen_s_hdr">General</string>
|
||||
<string name="settings_gen_btn">General</string>
|
||||
<string name="use_rmrf_chk">Use rm -rf instead of formatting</string>
|
||||
<string name="use24clock_chk">Use 24-hour clock</string>
|
||||
<string name="rev_navbar_chk">Reversed navbar layout</string>
|
||||
<string name="simact_chk">Simulate actions for theme testing</string>
|
||||
<string name="simfail_chk">Simulate failure for actions</string>
|
||||
<string name="ctr_navbar_rdo">Center navbar buttons</string>
|
||||
<string name="lft_navbar_rdo">Left align navbar buttons</string>
|
||||
<string name="rht_navbar_rdo">Right align navbar buttons</string>
|
||||
<string name="restore_defaults_btn">Restore Defaults</string>
|
||||
<string name="settings_tz_btn">Time Zone</string>
|
||||
<string name="settings_screen_btn">Screen</string>
|
||||
<string name="settings_screen_bright_btn">Screen Brightness</string>
|
||||
<string name="settings_vibration_btn">Vibration</string>
|
||||
<string name="settings_language_btn">Language</string>
|
||||
<string name="time_zone_hdr">Time Zone</string>
|
||||
<string name="sel_tz_list">Select Time Zone:</string>
|
||||
<!-- Translator note: if it does not make sense to translate the locations or if it makes more sense,
|
||||
feel free to change the location listed or drop the location entirely and just call it UTC -6 -->
|
||||
<string name="utcm11">(UTC -11) Samoa, Midway Island</string>
|
||||
<string name="utcm10">(UTC -10) Hawaii</string>
|
||||
<string name="utcm9">(UTC -9) Alaska</string>
|
||||
<string name="utcm8">(UTC -8) Pacific Time</string>
|
||||
<string name="utcm7">(UTC -7) Mountain Time</string>
|
||||
<string name="utcm6">(UTC -6) Central Time</string>
|
||||
<string name="utcm5">(UTC -5) Eastern Time</string>
|
||||
<string name="utcm4">(UTC -4) Atlantic Time</string>
|
||||
<string name="utcm3">(UTC -3) Brazil, Buenos Aires</string>
|
||||
<string name="utcm2">(UTC -2) Mid-Atlantic</string>
|
||||
<string name="utcm1">(UTC -1) Azores, Cape Verde</string>
|
||||
<string name="utc0">(UTC 0) London, Dublin, Lisbon</string>
|
||||
<string name="utcp1">(UTC +1) Berlin, Brussels, Paris</string>
|
||||
<string name="utcp2">(UTC +2) Athens, Istanbul, South Africa</string>
|
||||
<string name="utcp3">(UTC +3) Moscow, Baghdad</string>
|
||||
<string name="utcp4">(UTC +4) Abu Dhabi, Tbilisi, Muscat</string>
|
||||
<string name="utcp5">(UTC +5) Yekaterinburg, Islamabad</string>
|
||||
<string name="utcp6">(UTC +6) Almaty, Dhaka, Colombo</string>
|
||||
<string name="utcp7">(UTC +7) Bangkok, Hanoi, Jakarta</string>
|
||||
<string name="utcp8">(UTC +8) Beijing, Singapore, Hong Kong</string>
|
||||
<string name="utcp9">(UTC +9) Tokyo, Seoul, Yakutsk</string>
|
||||
<string name="utcp10">(UTC +10) Eastern Australia, Guam</string>
|
||||
<string name="utcp11">(UTC +11) Vladivostok, Solomon Islands</string>
|
||||
<string name="utcp12">(UTC +12) Auckland, Wellington, Fiji</string>
|
||||
<string name="sel_tz_offset">Select Offset (usually 0): %tw_time_zone_guioffset%</string>
|
||||
<string name="tz_offset_none">None</string>
|
||||
<string name="tz_offset_0">0</string>
|
||||
<string name="tz_offset_15">15</string>
|
||||
<string name="tz_offset_30">30</string>
|
||||
<string name="tz_offset_45">45</string>
|
||||
<string name="use_dst_chk">Use daylight savings time (DST)</string>
|
||||
<string name="curr_tz">Current Time Zone: %tw_time_zone%</string>
|
||||
<string name="curr_tz_s">Current Time Zone:</string>
|
||||
<string name="set_tz_btn">Set Time Zone</string>
|
||||
<string name="settings_screen_hdr">Screen Settings</string>
|
||||
<string name="settings_screen_timeout_hdr">Screen Timeout</string>
|
||||
<string name="enable_timeout_chk">Enable screen timeout</string>
|
||||
<string name="screen_to_slider">Screen timeout in seconds:</string>
|
||||
<string name="screen_to_slider_s">Screen timeout in seconds (0=disabled): %tw_screen_timeout_secs%</string>
|
||||
<string name="screen_to_na">Screen timeout setting unavailable</string>
|
||||
<string name="screen_bright_slider">Brightness: %tw_brightness_pct%%</string>
|
||||
<string name="screen_bright_na">Brightness setting unavailable</string>
|
||||
<string name="vibration_hdr">Vibration</string>
|
||||
<string name="button_vibration_hdr">Button Vibration</string>
|
||||
<string name="kb_vibration_hdr">Keyboard Vibration</string>
|
||||
<string name="act_vibration_hdr">Action Vibration</string>
|
||||
<string name="button_vibration">Button Vibration:</string>
|
||||
<string name="kb_vibration">Keyboard Vibration:</string>
|
||||
<string name="act_vibration">Action Vibration:</string>
|
||||
<string name="select_language">Select Language:</string>
|
||||
<string name="set_language_btn">Set Language</string>
|
||||
<string name="advanced_hdr">Advanced</string>
|
||||
<string name="copy_log_confirm">Copy Log to SD Card?</string>
|
||||
<string name="copying_log">Copying Log to SD Card...</string>
|
||||
<string name="copy_log_complete">Log Copy Complete</string>
|
||||
<string name="fix_perm_btn">Fix Permissions</string>
|
||||
<string name="fix_perm_s_btn">Fix Perms</string>
|
||||
<string name="part_sd_btn">Partition SD Card</string>
|
||||
<string name="part_sd_s_btn">SD Card</string>
|
||||
<string name="file_manager_btn">File Manager</string>
|
||||
<string name="language_hdr">Language</string>
|
||||
<string name="terminal_btn">Terminal</string>
|
||||
<string name="reload_theme_btn">Reload Theme</string>
|
||||
<string name="dumlock_btn">HTC Dumlock</string>
|
||||
<string name="inject_twrp_btn">Inject TWRP</string>
|
||||
<string name="inject_twrp_confirm">Re-Inject TWRP?</string>
|
||||
<string name="injecting_twrp">Re-Injecting TWRP...</string>
|
||||
<string name="inject_twrp_complete">TWRP Injection Complete</string>
|
||||
<string name="swipe_to_confirm">Swipe to Confirm</string>
|
||||
<string name="part_sd_hdr">Partition SD Card</string>
|
||||
<string name="part_sd_lose">You will lose all files on your SD card!</string>
|
||||
<string name="part_sd_undo">This action cannot be undone!</string>
|
||||
<string name="part_sd_ext_sz">EXT Size:</string>
|
||||
<string name="part_sd_swap_sz">Swap Size:</string>
|
||||
<string name="part_sd_m">-</string>
|
||||
<string name="part_sd_p">+</string>
|
||||
<string name="file_system">File System:</string>
|
||||
<string name="swipe_part_sd">Swipe to Partition</string>
|
||||
<string name="swipe_part_sd_s">Partition</string>
|
||||
<string name="partitioning_sd">Partitioning SD Card...</string>
|
||||
<string name="partitioning_sd2">This will take a few minutes.</string>
|
||||
<string name="part_sd_complete">Partitioning Complete</string>
|
||||
<string name="dumlock_hdr">HTC Dumlock</string>
|
||||
<string name="dumlock_restore_btn">Restore Original Boot</string>
|
||||
<string name="dumlock_restore_confirm">Restore original boot image?</string>
|
||||
<string name="dumlock_restoring">Restoring Original Boot...</string>
|
||||
<string name="dumlock_restore_complete">Restore Original Boot Complete</string>
|
||||
<string name="dumlock_reflash_btn">Reflash Recovery</string>
|
||||
<string name="dumlock_reflash_confirm">Reflash recovery to boot?</string>
|
||||
<string name="dumlock_reflashing">Flashing recovery to boot...</string>
|
||||
<string name="dumlock_reflash_complete">Recovery Flash to Boot Complete</string>
|
||||
<string name="dumlock_install_btn">Install HTC Dumlock</string>
|
||||
<string name="dumlock_install_confirm">Install HTC dumlock files to ROM?</string>
|
||||
<string name="dumlock_installing">Installing HTC Dumlock...</string>
|
||||
<string name="dumlock_install_complete">HTC Dumlock Install Complete</string>
|
||||
<string name="swipe_to_unlock">Swipe to Unlock</string>
|
||||
<string name="swipe_unlock"> Unlock</string>
|
||||
<string name="fm_hdr">File Manager</string>
|
||||
<string name="fm_sel_file">Select a File or Folder</string>
|
||||
<string name="fm_type_folder">Folder</string>
|
||||
<string name="fm_type_file">File</string>
|
||||
<string name="fm_choose_act">Choose Action</string>
|
||||
<string name="fm_selected">%tw_fm_type% selected:</string>
|
||||
<string name="fm_copy_btn">Copy</string>
|
||||
<string name="fm_copy_file_btn">Copy File</string>
|
||||
<string name="fm_copy_folder_btn">Copy Folder</string>
|
||||
<string name="fm_copying">Copying</string>
|
||||
<string name="fm_move_btn">Move</string>
|
||||
<string name="fm_moving">Moving</string>
|
||||
<string name="fm_chmod755_btn">chmod 755</string>
|
||||
<string name="fm_chmod755ing">chmod 755</string>
|
||||
<string name="fm_chmod_btn">chmod</string>
|
||||
<string name="fm_delete_btn">Delete</string>
|
||||
<string name="fm_deleting">Deleting</string>
|
||||
<string name="fm_rename_btn">Rename</string>
|
||||
<string name="fm_rename_file_btn">Rename File</string>
|
||||
<string name="fm_rename_folder_btn">Rename Folder</string>
|
||||
<string name="fm_renaming">Renaming</string>
|
||||
<string name="fm_sel_dest">Select Destination Folder</string>
|
||||
<string name="fm_sel_curr_folder">Select Current Folder</string>
|
||||
<string name="fm_rename_hdr">Rename</string>
|
||||
<string name="fm_set_perms_hdr">Set Permissions</string>
|
||||
<string name="fm_perms">Permissions:</string>
|
||||
<string name="fm_complete">File Operation Complete</string>
|
||||
<string name="decrypt_data_hdr">Decrypt Data</string>
|
||||
<string name="decrypt_data_enter_pass"></string>
|
||||
<string name="decryt_data_failed">Password failed, please try again!</string>
|
||||
<string name="decrypt_data_enter_pattern">Enter Pattern.</string>
|
||||
<string name="decrypt_data_trying">Trying Decryption</string>
|
||||
<string name="term_hdr">Terminal Command</string>
|
||||
<string name="term_s_hdr">Terminal</string>
|
||||
<string name="term_kill_btn">KILL</string>
|
||||
<string name="term_sel_folder_hdr">Browse to Starting Folder</string>
|
||||
<string name="adb_sideload_hdr">ADB Sideload</string>
|
||||
<string name="sideload_wipe_dalvik_chk">Wipe Dalvik Cache</string>
|
||||
<string name="sideload_wipe_cache_chk">Wipe Cache</string>
|
||||
<string name="swipe_to_sideload">Swipe to Start Sideload</string>
|
||||
<string name="swipe_sideload"> Start</string>
|
||||
<string name="sideload_confirm">ADB Sideload</string>
|
||||
<string name="sideload_usage">Usage: adb sideload filename.zip</string>
|
||||
<string name="sideload_complete">ADB Sideload Complete</string>
|
||||
<string name="fix_perms_hdr">Fix Permissions</string>
|
||||
<string name="fix_perms_note">Note: Fixing permissions is rarely needed.</string>
|
||||
<string name="fix_perms_selinux_chk">Also fix SELinux Contexts</string>
|
||||
<string name="fix_perms_sel_note1">Fixing SELinux Contexts may cause</string>
|
||||
<string name="fix_perms_sel_note2">your device to not boot properly.</string>
|
||||
<string name="swipe_to_fix_perms">Swipe to Fix Permissions</string>
|
||||
<string name="swipe_fix_perms"> Fix Perms</string>
|
||||
<string name="fixing_perms">Fixing Permissions...</string>
|
||||
<string name="fix_perms_complete">Fix Permissions Complete</string>
|
||||
<string name="reboot_hdr">Reboot</string>
|
||||
<string name="su_hdr">SuperSU Check</string>
|
||||
<string name="su_note1">Your device does not appear to be rooted.</string>
|
||||
<string name="su_note2">Install SuperSU now?</string>
|
||||
<string name="su_note3">This will root your device.</string>
|
||||
<string name="su_cancel">Do Not Install</string>
|
||||
<string name="swipe_su_to_install">Swipe to Install</string>
|
||||
<string name="swipe_su_install"> Install</string>
|
||||
<string name="su_installing">Installing SuperSU</string>
|
||||
<string name="sel_storage_list">Select Storage</string>
|
||||
<string name="ok_btn">OK</string>
|
||||
|
||||
<!-- Various console messages - these consist of user displayed messages, oftentimes errors -->
|
||||
<string name="no_kernel_selinux">Kernel does not have support for reading SELinux contexts.</string>
|
||||
<string name="full_selinux">Full SELinux support is present.</string>
|
||||
<string name="no_selinux">No SELinux support (no libselinux).</string>
|
||||
<string name="mtp_enabled">MTP Enabled</string>
|
||||
<string name="mtp_crash">MTP Crashed, not starting MTP on boot.</string>
|
||||
<string name="rebooting">Rebooting...</string>
|
||||
<string name="decrypt_success">Successfully decrypted with default password.</string>
|
||||
<string name="unable_to_decrypt">Unable to decrypt with default password. You may need to perform a Format Data.</string>
|
||||
<string name="generating_md51">Generating MD5</string>
|
||||
<!-- Message displayed during a backup if we are generating an MD5, ideally, leave the leading " * " to help align and separate this text from other console text -->
|
||||
<string name="generating_md52"> * Generating md5...</string>
|
||||
<string name="md5_created"> * MD5 Created.</string>
|
||||
<string name="md5_error"> * MD5 Error!</string>
|
||||
<string name="md5_compute_error"> * Error computing MD5.</string>
|
||||
<string name="md5_created"> * MD5 Created.</string>
|
||||
<string name="current_date">(Current Date)</string>
|
||||
<string name="auto_generate">(Auto Generate)</string>
|
||||
<string name="unable_to_locate_partition">Unable to locate '{1}' partition for backup calculations.</string>
|
||||
<string name="no_partition_selected">No partitions selected for backup.</string>
|
||||
<string name="total_partitions_backup"> * Total number of partitions to back up: {1}</string>
|
||||
<string name="total_backup_size"> * Total size of all data: {1}MB</string>
|
||||
<string name="available_space"> * Available space: {1}MB</string>
|
||||
<string name="unable_locate_storage">Unable to locate storage device.</string>
|
||||
<string name="Not enough free space on storage.">Not enough free space on storage.</string>
|
||||
<string name="backup_started">[BACKUP STARTED]</string>
|
||||
<string name="backup_folder"> * Backup Folder: {1}</string>
|
||||
<string name="fail_backup_folder">Failed to make backup folder.</string>
|
||||
<string name="avg_backup_fs">Average backup rate for file systems: {1} MB/sec</string>
|
||||
<string name="avg_backup_img">Average backup rate for imaged drives: {1} MB/sec</string>
|
||||
<string name="total_backed_size">[{1} MB TOTAL BACKED UP]</string>
|
||||
<string name="backup_completed">[BACKUP COMPLETED IN {1} SECONDS]</string>
|
||||
<string name="restore_started">[RESTORE STARTED]</string>
|
||||
<string name="restore_folder">Restore folder: '{1}'</string>
|
||||
<!-- {1} is the partition display name and {2} is the number of seconds -->
|
||||
<string name="restort_part_done">[{1} done ({2} seconds)]</string>
|
||||
<string name="verifying_md5">Verifying MD5</string>
|
||||
<string name="skip_md5">Skipping MD5 check based on user setting.</string>
|
||||
<string name="calc_restore">Calculating restore details...</string>
|
||||
<string name="restore_read_only">Cannot restore {1} -- mounted read only.</string>
|
||||
<string name="restore_unable_locate">Unable to locate '{1}' partition for restoring.</string>
|
||||
<string name="no_part_restore">No partitions selected for restore.</string>
|
||||
<string name="restore_part_count">Restoring {1} partitions...</string>
|
||||
<string name="total_restore_size">Total restore size is {1}MB</string>
|
||||
<string name="updating_system_details">Updating System Details</string>
|
||||
<string name="restore_complete">[RESTORE COMPLETED IN {1} SECONDS]</string>
|
||||
<!-- {1} is the path we could not open, {2} is strerror output -->
|
||||
<string name="error_opening_strerr">Error opening: '{1}' ({2})</string>
|
||||
<string name="unable_locate_part_backup_name">Unable to locate partition by backup name: '{1}'</string>
|
||||
<string name="unable_find_part_path">Unable to find partition for path '{1}'</string>
|
||||
<string name="update_part_details">Updating partition details...</string>
|
||||
<string name="update_part_details_done">...done</string>
|
||||
<string name="wiping_dalvik">Wiping Dalvik Cache Directories...</string>
|
||||
<string name="cleaned">Cleaned: {1}...</string>
|
||||
<string name="dalvik_done">-- Dalvik Cache Directories Wipe Complete!</string>
|
||||
<string name="no_andsec">No android secure partitions found.</string>
|
||||
<string name="unable_to_locate">Unable to locate {1}.</string>
|
||||
<string name="wiping_datamedia">Wiping internal storage -- /data/media...</string>
|
||||
<string name="unable_to_mount">Unable to mount {1}</string>
|
||||
<string name="unable_to_mount_internal">Unable to mount internal_storage</string>
|
||||
<string name="unable_to_mount_storage">Unable to mount storage</string>
|
||||
<string name="fail_decrypt">Failed to decrypt data.</string>
|
||||
<string name="no_crypto_support">No crypto support was compiled into this build.</string>
|
||||
<string name="decrypt_success">Data successfully decrypted, new block device: '{1}'</string>
|
||||
<string name="done">Done.</string>
|
||||
<string name="start_partition_sd">Partitioning SD Card...</string>
|
||||
<string name="partition_sd_locate">Unable to locate device to partition.</string>
|
||||
<string name="ext_swap_size">EXT + Swap size is larger than sdcard size.</string>
|
||||
<string name="remove_part_table">Removing partition table...</string>
|
||||
<string name="unable_rm_part">Unable to remove partition table.</string>
|
||||
<string name="create_part">Creating {1} partition...</string>
|
||||
<string name="unable_to_create_part">Unable to create {1} partition.</string>
|
||||
<string name="format_sdext_as">Formatting sd-ext as {1}...</string>
|
||||
<string name="part_complete">Partitioning complete.</string>
|
||||
<string name="unable_to_open">Unable to open '{1}'.</string>
|
||||
<string name="mtp_already_enabled">MTP already enabled</string>
|
||||
<string name="mtp_fail">Failed to enable MTP</string>
|
||||
<string name="no_mtp">MTP support not included</string>
|
||||
<string name="image_flash_start">[IMAGE FLASH STARTED]</string>
|
||||
<string name="img_to_flash">Image to flash: '{1}'</string>
|
||||
<string name="flash_unable_locate">Unable to locate '{1}' partition for flashing.</string>
|
||||
<string name="no_part_flash">No partitions selected for flashing.</string>
|
||||
<string name="too_many_flash">Too many partitions selected for flashing.</string>
|
||||
<string name="invalid_flash">Invalid flash partition specified.</string>
|
||||
<string name="flash_done">[IMAGE FLASH COMPLETED]</string>
|
||||
<string name="wiping">Wiping {1}</string>
|
||||
<string name="repair_not_exist">{1} does not exist! Cannot repair!</string>
|
||||
<string name="unable_repair">Unable to repair {1}.</string>
|
||||
<string name="mount_data_footer">Could not mount /data and unable to find crypto footer.</string>
|
||||
<!-- {1} is the folder name that we could not create, {2} is strerror output -->
|
||||
<string name="create_folder_strerr">Can not create '{1}' folder ({2}).</string>
|
||||
<!-- {1} is the folder name that we could not mount, {2} is strerror output -->
|
||||
<string name="fail_mount">Failed to mount '{1}' ({2})</string>
|
||||
<!-- {1} is the folder name that we could not unmount, {2} is strerror output -->
|
||||
<string name="fail_mount">Failed to unmount '{1}' ({2})</string>
|
||||
<string name="cannot_resize">Cannot resize {1}.</string>
|
||||
<string name="repair_resize">Repairing {1} before resizing.</string>
|
||||
<string name="unable_resize">Unable to resize {1}.</string>
|
||||
<string name="no_md5_found">No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.</string>
|
||||
<string name="md5_fail_match">MD5 failed to match on '{1}'.</string>
|
||||
<string name="restoring">Restoring</string>
|
||||
<string name="format_data_msg">You may need to reboot recovery to be able to use /data again.</string>
|
||||
<string name="format_data_err">Unable to format to remove encryption.</string>
|
||||
<string name="formating_using">Formatting {1} using {2}...</string>
|
||||
<string name="unable_to_wipe">Unable to wipe {1}.</string>
|
||||
<string name="remove_all">Removing all files under '{1}'</string>
|
||||
<string name="wiping_data">Wiping data without wiping /data/media ...</string>
|
||||
<string name="backing_up">Backing up {1}...</string>
|
||||
<string name="backing">Backing Up</string>
|
||||
<string name="backup_size">Backup file size for '{1}' is 0 bytes.</string>
|
||||
<string name="datamedia_fs_restore">WARNING: This /data backup was made with {1} file system! The backup may not boot unless you change back to {1}.</string>
|
||||
<string name="restoring">Restoring {1}...</string>
|
||||
<string name="restore">Restoring</string>
|
||||
<string name="recreate_folder_err">Unable to recreate {1} folder.</string>
|
||||
<string name="img_size_err">Size of image is larger than target device</string>
|
||||
<string name="flashing">Flashing {1}...</string>
|
||||
<string name="backup_folder">Backup folder set to '{1}'</string>
|
||||
<string name="locate_backup_err">Unable to locate backup '{1}'</string>
|
||||
<string name="set_restore_opt">Setting restore options: '{1}':</string>
|
||||
<string name="md5_check_skip">MD5 check skip is on</string>
|
||||
<string name="ors_encrypt_restore_err">Unable to use OpenRecoveryScript to restore an encrypted backup.</string>
|
||||
<string name="mounting">Mounting</string>
|
||||
<string name="unmounting">Unmounting</string>
|
||||
<string name="mounted">Mounted '{1}'</string>
|
||||
<string name="unmounted">Unmounted '{1}'</string>
|
||||
<string name="setting">Setting '{1}' to '{2}'</string>
|
||||
<string name="setting_empty">Setting '{1}' to empty</string>
|
||||
<string name="making_dir1">Making Directory</string>
|
||||
<string name="making_dir2">Making directory: '{1}'</string>
|
||||
<string name="running_command">Running Command</string>
|
||||
<string name="sideload">ADB Sideload</string>
|
||||
<string name="start_sideload">Starting ADB sideload feature...</string>
|
||||
<string name="need_new_adb">You need adb 1.0.32 or newer to sideload to this device.</string>
|
||||
<string name="no_pwd">No password provided.</string>
|
||||
<string name="done_ors">Done processing script file</string>
|
||||
<string name="injecttwrp">Injecting TWRP into boot image...</string>
|
||||
<string name="zip_err">Error installing zip file '{1}'</string>
|
||||
<string name="installing_zip">Installing zip file '{1}'</string>
|
||||
<string name="select_backup_opt">Setting backup options:</string>
|
||||
<string name="compression_on">Compression is on</string>
|
||||
<string name="md5_off">MD5 Generation is off</string>
|
||||
<string name="backup_fail">Backup Failed</string>
|
||||
<string name="backup_complete">Backup complete!</string>
|
||||
<string name="running_recovery_commands">Running Recovery Commands</string>
|
||||
<string name="recovery_commands_complete">Recovery Commands Complete</string>
|
||||
<string name="running_ors">Running OpenRecoveryScript</string>
|
||||
<string name="ors_complete">OpenRecoveryScript Complete</string>
|
||||
<string name="no_updater_binary">Could not find '{1}' in the zip file.</string>
|
||||
<string name="check_for_md5">Checking for MD5 file...</string>
|
||||
<string name="fail_sysmap">Failed to map file '{1}'</string>
|
||||
<string name="verify_zip_sig">Verifying zip signature...</string>
|
||||
<string name="verify_zip_fail">Zip signature verification failed!</string>
|
||||
<string name="verify_zip_done">Zip signature verified successfully.</string>
|
||||
<string name="zip_corrupt">Zip file is corrupt!</string>
|
||||
<string name="no_md5">Skipping MD5 check: no MD5 file found</string>
|
||||
<string name="md5_fail">MD5 does not match</string>
|
||||
<string name="md5_match">MD5 matched</string>
|
||||
<string name="pid_signal">{1} process ended with signal: {2}</string>
|
||||
<string name="pid_error">{1} process ended with ERROR: {2}</string>
|
||||
<string name="install_dumlock">Installing HTC Dumlock to system...</string>
|
||||
<string name="dumlock_restore">Restoring original boot...</string>
|
||||
<string name="dumlock_reflash">Reflashing recovery to boot...</string>
|
||||
<string name="run_script">Running {1} script...</string>
|
||||
<string name="rename_stock">Renamed stock recovery file in /system to prevent the stock ROM from replacing TWRP.</string>
|
||||
<string name="split_backup">Breaking backup file into multiple archives...</string>
|
||||
<string name="backup_error">Error creating backup.</string>
|
||||
<string name="restore_error">Error during restore process.</string>
|
||||
<string name="split_thread">Splitting thread ID {1} into archive {2}</string>
|
||||
<!-- These 2 items are saved in the data manager instead of resource manager, so %llu, etc is correct instead of {1} -->
|
||||
<string name="file_progress">%llu of %llu files, %i%%</string>
|
||||
<string name="size_progress">%lluMB of %lluMB, %i%%</string>
|
||||
<string name="decrypt_cmd">Attempting to decrypt data partition via command line.</string>
|
||||
<string name="base_pkg_err">Failed to load base packages.</string>
|
||||
<string name="simulating">Simulating actions...</string>
|
||||
<string name="backup_cancel">Backup Canceled.</string>
|
||||
<string name="config_twrp">Configuring TWRP...</string>
|
||||
<string name="config_twrp_err">Unable to configure TWRP with this kernel.</string>
|
||||
<string name="copy_log">Copied recovery log to {1}.</string>
|
||||
<string name="max_queue">Maximum zip queue reached!</string>
|
||||
<string name="min_queue">Minimum zip queue reached!</string>
|
||||
<string name="screenshot_err">Failed to take a screenshot!</string>
|
||||
<string name="zip_wipe_cache">One or more zip requested a cache wipe -- Wiping cache now.</string>
|
||||
<string name="and_sec_wipe_err">Unable to wipe android secure</string>
|
||||
<string name="dalvik_wipe_err">Failed to wipe dalvik</string>
|
||||
<string name="auto_gen">(Auto Generate)</string>
|
||||
<string name="curr_date">(Current Date)</string>
|
||||
<string name="backup_name_len">Backup name is too long.</string>
|
||||
<string name="backup_name_invalid">Backup name '{1}' contains invalid character: '{1}'</string>
|
||||
<string name="backup_name_exists">A backup with this name already exists.</string>
|
||||
<string name="no_real_sdcard">This device does not have a real SD Card! Aborting!</string>
|
||||
<string name="cancel_sideload">Cancelling ADB sideload...</string>
|
||||
<string name="change_fs_err">Error changing file system.</string>
|
||||
</resources>
|
||||
</language>
|
||||
13
gui/theme/common/languages/es.xml
Normal file
13
gui/theme/common/languages/es.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>Español</display>
|
||||
|
||||
<resources>
|
||||
<resource name="font" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="mediumfont" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="filelist" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
<string name="install_btn">Instalar</string>
|
||||
</resources>
|
||||
</language>
|
||||
13
gui/theme/common/languages/fi.xml
Normal file
13
gui/theme/common/languages/fi.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<language>
|
||||
<display>Suomi</display>
|
||||
|
||||
<resources>
|
||||
<resource name="font" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="mediumfont" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="filelist" type="fontoverride" filename="RobotoCondensed-Regular.ttf" scale="100" />
|
||||
<resource name="fixed" type="fontoverride" filename="DroidSansMono.ttf" scale="100" />
|
||||
<string name="install_btn">Asenna</string>
|
||||
</resources>
|
||||
</language>
|
||||
1050
gui/theme/common/portrait.xml
Normal file → Executable file
1050
gui/theme/common/portrait.xml
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
1018
gui/theme/common/watch.xml
Normal file → Executable file
1018
gui/theme/common/watch.xml
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
@@ -94,8 +94,13 @@
|
||||
<variable name="tab_height" value="72" />
|
||||
<variable name="tab_indicator_height" value="4" />
|
||||
<variable name="tab4_width" value="480" />
|
||||
<variable name="tab5_width" value="384" />
|
||||
<variable name="tab4_col2_x" value="480" />
|
||||
<variable name="tab4_col4_x" value="1440" />
|
||||
<variable name="tab5_col2_x" value="384" />
|
||||
<variable name="tab5_col3_x" value="768" />
|
||||
<variable name="tab5_col4_x" value="1152" />
|
||||
<variable name="tab5_col5_x" value="1536" />
|
||||
<variable name="btn4_col2_x_left" value="282" />
|
||||
<variable name="btn4_col3_x_left" value="516" />
|
||||
<variable name="btn4_col4_x_left" value="750" />
|
||||
@@ -255,7 +260,7 @@
|
||||
<condition var1="tw_no_cpu_temp" var2="0" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>CPU: %tw_cpu_temp% °C</text>
|
||||
<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
@@ -272,7 +277,7 @@
|
||||
</conditions>
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent_right%" y="%row1_header_y%" placement="1" />
|
||||
<text>Battery: %tw_battery%</text>
|
||||
<text>{@battery_pct=Battery: %tw_battery%}</text>
|
||||
</object>
|
||||
|
||||
<object type="fill" color="#000000">
|
||||
@@ -456,14 +461,14 @@
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="1" />
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=-1</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-1" />
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
|
||||
@@ -473,21 +478,21 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-1" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="2" />
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=-2</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-2" />
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
|
||||
@@ -497,21 +502,21 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-2" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="3" />
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=-3</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-3" />
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
|
||||
@@ -521,35 +526,41 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-3" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="tabs_settings">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>GENERAL</text>
|
||||
<placement x="0" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_general=GENERAL}</text>
|
||||
<action function="page">settings</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col2_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>TIME ZONE</text>
|
||||
<placement x="%tab5_col2_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_time_zone=TIME ZONE}</text>
|
||||
<action function="page">settings_timezone</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%center_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>SCREEN</text>
|
||||
<placement x="%tab5_col3_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_screen=SCREEN}</text>
|
||||
<action function="page">settings_screen</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col4_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>VIBRATION</text>
|
||||
<placement x="%tab5_col4_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_vibration=VIBRATION}</text>
|
||||
<action function="page">settings_vibration</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab5_col5_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_language=LANGUAGE}</text>
|
||||
<action function="page">settings_language</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="console">
|
||||
|
||||
@@ -94,8 +94,13 @@
|
||||
<variable name="tab_height" value="30" />
|
||||
<variable name="tab_indicator_height" value="2" />
|
||||
<variable name="tab4_width" value="200" />
|
||||
<variable name="tab5_width" value="160" />
|
||||
<variable name="tab4_col2_x" value="200" />
|
||||
<variable name="tab4_col4_x" value="600" />
|
||||
<variable name="tab5_col2_x" value="160" />
|
||||
<variable name="tab5_col3_x" value="320" />
|
||||
<variable name="tab5_col4_x" value="480" />
|
||||
<variable name="tab5_col5_x" value="640" />
|
||||
<variable name="btn4_col2_x_left" value="117" />
|
||||
<variable name="btn4_col3_x_left" value="216" />
|
||||
<variable name="btn4_col4_x_left" value="313" />
|
||||
@@ -255,7 +260,7 @@
|
||||
<condition var1="tw_no_cpu_temp" var2="0" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>CPU: %tw_cpu_temp% °C</text>
|
||||
<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
@@ -272,7 +277,7 @@
|
||||
</conditions>
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent_right%" y="%row1_header_y%" placement="1" />
|
||||
<text>Battery: %tw_battery%</text>
|
||||
<text>{@battery_pct=Battery: %tw_battery%}</text>
|
||||
</object>
|
||||
|
||||
<object type="fill" color="#000000">
|
||||
@@ -456,14 +461,14 @@
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="1" />
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=-1</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-1" />
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
|
||||
@@ -473,21 +478,21 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-1" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row1a_y%" />
|
||||
<text>Sort by Name</text>
|
||||
<text>{@sort_by_name=Sort by Name}</text>
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="2" />
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=-2</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-2" />
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
|
||||
@@ -497,21 +502,21 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-2" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row4a_y%" />
|
||||
<text>Sort by Date</text>
|
||||
<text>{@sort_by_date=Sort by Date}</text>
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_asc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="3" />
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=-3</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="sort_desc">
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-3" />
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
|
||||
@@ -521,35 +526,41 @@
|
||||
<condition var1="tw_gui_sort_order" op="!=" var2="-3" />
|
||||
</conditions>
|
||||
<placement x="%col_button_right%" y="%row7a_y%" />
|
||||
<text>Sort by Size</text>
|
||||
<text>{@sort_by_size=Sort by Size}</text>
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="tabs_settings">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>GENERAL</text>
|
||||
<placement x="0" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_general=GENERAL}</text>
|
||||
<action function="page">settings</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col2_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>TIME ZONE</text>
|
||||
<placement x="%tab5_col2_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_time_zone=TIME ZONE}</text>
|
||||
<action function="page">settings_timezone</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%center_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>SCREEN</text>
|
||||
<placement x="%tab5_col3_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_screen=SCREEN}</text>
|
||||
<action function="page">settings_screen</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col4_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>VIBRATION</text>
|
||||
<placement x="%tab5_col4_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_vibration=VIBRATION}</text>
|
||||
<action function="page">settings_vibration</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab5_col5_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_language=LANGUAGE}</text>
|
||||
<action function="page">settings_language</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="console">
|
||||
|
||||
@@ -82,10 +82,15 @@
|
||||
<variable name="tab_indicator_height" value="6" />
|
||||
<variable name="tab3_width" value="360" />
|
||||
<variable name="tab4_width" value="270" />
|
||||
<variable name="tab5_width" value="216" />
|
||||
<variable name="tab3_col2_x" value="360" />
|
||||
<variable name="tab3_col3_x" value="720" />
|
||||
<variable name="tab4_col2_x" value="270" />
|
||||
<variable name="tab4_col4_x" value="810" />
|
||||
<variable name="tab5_col2_x" value="216" />
|
||||
<variable name="tab5_col3_x" value="432" />
|
||||
<variable name="tab5_col4_x" value="648" />
|
||||
<variable name="tab5_col5_x" value="864" />
|
||||
<variable name="btn3_col2_x" value="384" />
|
||||
<variable name="btn3_col3_x" value="732" />
|
||||
<variable name="btn4_col2_x" value="297" />
|
||||
@@ -247,7 +252,7 @@
|
||||
<condition var1="tw_no_cpu_temp" var2="0" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>CPU: %tw_cpu_temp% °C</text>
|
||||
<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
@@ -264,7 +269,7 @@
|
||||
</conditions>
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent_right%" y="%row1_header_y%" placement="1" />
|
||||
<text>Battery: %tw_battery%</text>
|
||||
<text>{@battery_pct=Battery: %tw_battery%}</text>
|
||||
</object>
|
||||
|
||||
<object type="fill" color="#000000">
|
||||
@@ -357,7 +362,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="1" />
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-1</action>
|
||||
</object>
|
||||
@@ -367,7 +372,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-1" />
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
@@ -380,7 +385,7 @@
|
||||
</conditions>
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
@@ -390,7 +395,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="2" />
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-2</action>
|
||||
</object>
|
||||
@@ -400,7 +405,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-2" />
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
@@ -413,7 +418,7 @@
|
||||
</conditions>
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
@@ -423,7 +428,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="3" />
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-3</action>
|
||||
</object>
|
||||
@@ -433,7 +438,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-3" />
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
@@ -446,7 +451,7 @@
|
||||
</conditions>
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
@@ -455,41 +460,47 @@
|
||||
<template name="tabs_backup">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab3_width%" h="%tab_height%" />
|
||||
<text>BACKUP</text>
|
||||
<text>{@tab_backup=BACKUP}</text>
|
||||
<action function="page">backup</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab3_col2_x%" y="%row1_y%" w="%tab3_width%" h="%tab_height%" />
|
||||
<text>OPTIONS</text>
|
||||
<text>{@tab_options=OPTIONS}</text>
|
||||
<action function="page">backup_options</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="tabs_settings">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>GENERAL</text>
|
||||
<placement x="0" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_general=GENERAL}</text>
|
||||
<action function="page">settings</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col2_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>TIME ZONE</text>
|
||||
<placement x="%tab5_col2_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_time_zone=TIME ZONE}</text>
|
||||
<action function="page">settings_timezone</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%center_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>SCREEN</text>
|
||||
<placement x="%tab5_col3_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_screen=SCREEN}</text>
|
||||
<action function="page">settings_screen</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col4_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>VIBRATION</text>
|
||||
<placement x="%tab5_col4_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_vibration=VIBRATION}</text>
|
||||
<action function="page">settings_vibration</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab5_col5_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_language=LANGUAGE}</text>
|
||||
<action function="page">settings_language</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="console">
|
||||
|
||||
@@ -82,10 +82,15 @@
|
||||
<variable name="tab_indicator_height" value="3" />
|
||||
<variable name="tab3_width" value="160" />
|
||||
<variable name="tab4_width" value="120" />
|
||||
<variable name="tab5_width" value="96" />
|
||||
<variable name="tab3_col2_x" value="160" />
|
||||
<variable name="tab3_col3_x" value="320" />
|
||||
<variable name="tab4_col2_x" value="120" />
|
||||
<variable name="tab4_col4_x" value="360" />
|
||||
<variable name="tab5_col2_x" value="96" />
|
||||
<variable name="tab5_col3_x" value="192" />
|
||||
<variable name="tab5_col4_x" value="288" />
|
||||
<variable name="tab5_col5_x" value="384" />
|
||||
<variable name="btn3_col2_x" value="170" />
|
||||
<variable name="btn3_col3_x" value="325" />
|
||||
<variable name="btn4_col2_x" value="131" />
|
||||
@@ -247,7 +252,7 @@
|
||||
<condition var1="tw_no_cpu_temp" var2="0" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>CPU: %tw_cpu_temp% °C</text>
|
||||
<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
@@ -264,7 +269,7 @@
|
||||
</conditions>
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent_right%" y="%row1_header_y%" placement="1" />
|
||||
<text>Battery: %tw_battery%</text>
|
||||
<text>{@battery_pct=Battery: %tw_battery%}</text>
|
||||
</object>
|
||||
|
||||
<object type="fill" color="#000000">
|
||||
@@ -357,7 +362,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="1" />
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-1</action>
|
||||
</object>
|
||||
@@ -367,7 +372,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-1" />
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
@@ -380,7 +385,7 @@
|
||||
</conditions>
|
||||
<placement x="%indent%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Name</text>
|
||||
<text>{@sort_by_name_only=Name}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=1</action>
|
||||
</object>
|
||||
@@ -390,7 +395,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="2" />
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-2</action>
|
||||
</object>
|
||||
@@ -400,7 +405,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-2" />
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
@@ -413,7 +418,7 @@
|
||||
</conditions>
|
||||
<placement x="%btn3_col2_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Date</text>
|
||||
<text>{@sort_by_date_only=Date}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=2</action>
|
||||
</object>
|
||||
@@ -423,7 +428,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="3" />
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_asc" />
|
||||
<action function="set">tw_gui_sort_order=-3</action>
|
||||
</object>
|
||||
@@ -433,7 +438,7 @@
|
||||
<condition var1="tw_gui_sort_order" op="=" var2="-3" />
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_desc" />
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
@@ -446,7 +451,7 @@
|
||||
</conditions>
|
||||
<placement x="%btn3_col3_x%" y="%row1a_y%" />
|
||||
<font resource="font_s" color="%text_button_color%" />
|
||||
<text>Size</text>
|
||||
<text>{@sort_by_size_only=Size}</text>
|
||||
<image resource="sort_empty" />
|
||||
<action function="set">tw_gui_sort_order=3</action>
|
||||
</object>
|
||||
@@ -455,41 +460,47 @@
|
||||
<template name="tabs_backup">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab3_width%" h="%tab_height%" />
|
||||
<text>BACKUP</text>
|
||||
<text>{@tab_backup=BACKUP}</text>
|
||||
<action function="page">backup</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab3_col2_x%" y="%row1_y%" w="%tab3_width%" h="%tab_height%" />
|
||||
<text>OPTIONS</text>
|
||||
<text>{@tab_options=OPTIONS}</text>
|
||||
<action function="page">backup_options</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="tabs_settings">
|
||||
<object type="button" style="tab">
|
||||
<placement x="0" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>GENERAL</text>
|
||||
<placement x="0" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_general=GENERAL}</text>
|
||||
<action function="page">settings</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col2_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>TIME ZONE</text>
|
||||
<placement x="%tab5_col2_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_time_zone=TIME ZONE}</text>
|
||||
<action function="page">settings_timezone</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%center_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>SCREEN</text>
|
||||
<placement x="%tab5_col3_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_screen=SCREEN}</text>
|
||||
<action function="page">settings_screen</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab4_col4_x%" y="%row1_y%" w="%tab4_width%" h="%tab_height%" />
|
||||
<text>VIBRATION</text>
|
||||
<placement x="%tab5_col4_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_vibration=VIBRATION}</text>
|
||||
<action function="page">settings_vibration</action>
|
||||
</object>
|
||||
|
||||
<object type="button" style="tab">
|
||||
<placement x="%tab5_col5_x%" y="%row1_y%" w="%tab5_width%" h="%tab_height%" />
|
||||
<text>{@tab_language=LANGUAGE}</text>
|
||||
<action function="page">settings_language</action>
|
||||
</object>
|
||||
</template>
|
||||
|
||||
<template name="console">
|
||||
|
||||
@@ -193,14 +193,14 @@
|
||||
<condition var1="tw_no_cpu_temp" var2="1" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>TWRP %tw_version%</text>
|
||||
<text>{@twrp_watch_header=TWRP %tw_version%}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
<condition var1="tw_no_cpu_temp" var2="0" />
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent%" y="%row1_header_y%" />
|
||||
<text>CPU: %tw_cpu_temp% °C</text>
|
||||
<text>{@cpu_temp=CPU: %tw_cpu_temp% °C}</text>
|
||||
</object>
|
||||
|
||||
<object type="text" color="%text_color%">
|
||||
@@ -217,7 +217,7 @@
|
||||
</conditions>
|
||||
<font resource="font_m" />
|
||||
<placement x="%indent_right%" y="%row1_header_y%" placement="1" />
|
||||
<text>Battery: %tw_battery%</text>
|
||||
<text>{@battery_pct=Battery: %tw_battery%}</text>
|
||||
</object>
|
||||
|
||||
<object type="fill" color="#000000">
|
||||
|
||||
129
gui/twmsg.cpp
Normal file
129
gui/twmsg.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
Copyright 2015 _that/TeamWin
|
||||
This file is part of TWRP/TeamWin Recovery Project.
|
||||
|
||||
TWRP is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TWRP is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../data.hpp"
|
||||
#include "pages.hpp"
|
||||
#include "resources.hpp"
|
||||
|
||||
#include "twmsg.h"
|
||||
|
||||
std::string Message::GetFormatString(const std::string& name) const
|
||||
{
|
||||
std::string resname;
|
||||
size_t pos = name.find('=');
|
||||
if (pos == std::string::npos)
|
||||
resname = name;
|
||||
else
|
||||
resname = name.substr(0, pos);
|
||||
|
||||
std::string formatstr = resourceLookup(resname);
|
||||
bool notfound = formatstr.empty() || formatstr[0] == '['; // HACK: TODO: integrate this with resource-not-found logic
|
||||
if (notfound && pos != std::string::npos)
|
||||
// resource not found - use the default format string specified after "="
|
||||
formatstr = name.substr(pos + 1);
|
||||
return formatstr;
|
||||
}
|
||||
|
||||
// Look up in local replacement vars first, if not found then use outer lookup object
|
||||
class LocalLookup : public StringLookup
|
||||
{
|
||||
const std::vector<std::string>& vars;
|
||||
const StringLookup& next;
|
||||
public:
|
||||
LocalLookup(const std::vector<std::string>& vars, const StringLookup& next) : vars(vars), next(next) {}
|
||||
virtual std::string operator()(const std::string& name) const
|
||||
{
|
||||
if (!name.empty() && isdigit(name[0])) { // {1}..{9}
|
||||
int i = atoi(name.c_str());
|
||||
if (i > 0 && i <= (int)vars.size())
|
||||
return vars[i - 1];
|
||||
}
|
||||
return next(name);
|
||||
}
|
||||
};
|
||||
|
||||
// conversion to final string
|
||||
Message::operator std::string() const
|
||||
{
|
||||
// do resource lookup
|
||||
std::string str = GetFormatString(name);
|
||||
|
||||
LocalLookup lookup(variables, varLookup);
|
||||
|
||||
// now insert stuff into curly braces
|
||||
|
||||
size_t pos = 0;
|
||||
while ((pos = str.find('{', pos)) < std::string::npos) {
|
||||
size_t end = str.find('}', pos);
|
||||
if (end == std::string::npos)
|
||||
break;
|
||||
|
||||
std::string varname = str.substr(pos + 1, end - pos - 1);
|
||||
std::string vartext = lookup(varname);
|
||||
|
||||
str.replace(pos, end - pos + 1, vartext);
|
||||
}
|
||||
// TODO: complain about too many or too few numbered replacement variables
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
Resource manager lookup
|
||||
*/
|
||||
class ResourceLookup : public StringLookup
|
||||
{
|
||||
public:
|
||||
virtual std::string operator()(const std::string& name) const
|
||||
{
|
||||
const ResourceManager* res = PageManager::GetResources();
|
||||
if (res)
|
||||
return res->FindString(name);
|
||||
return name;
|
||||
}
|
||||
};
|
||||
ResourceLookup resourceLookup;
|
||||
|
||||
|
||||
/*
|
||||
DataManager lookup
|
||||
*/
|
||||
class DataLookup : public StringLookup
|
||||
{
|
||||
public:
|
||||
virtual std::string operator()(const std::string& name) const
|
||||
{
|
||||
std::string value;
|
||||
if (DataManager::GetValue(name, value) == 0)
|
||||
return value;
|
||||
else
|
||||
return "";
|
||||
}
|
||||
};
|
||||
DataLookup dataLookup;
|
||||
|
||||
|
||||
// Utility functions to create messages. Short names to make usage convenient.
|
||||
Message Msg(const char* name)
|
||||
{
|
||||
return Message(msg::kNormal, name, resourceLookup, dataLookup);
|
||||
}
|
||||
|
||||
Message Msg(msg::Kind kind, const char* name)
|
||||
{
|
||||
return Message(kind, name, resourceLookup, dataLookup);
|
||||
}
|
||||
97
gui/twmsg.h
Normal file
97
gui/twmsg.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
Copyright 2015 _that/TeamWin
|
||||
This file is part of TWRP/TeamWin Recovery Project.
|
||||
|
||||
TWRP is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
TWRP is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with TWRP. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef twmsg_h
|
||||
#define twmsg_h
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
Abstract interface for something that can look up strings by name.
|
||||
*/
|
||||
class StringLookup
|
||||
{
|
||||
public:
|
||||
virtual std::string operator()(const std::string& name) const = 0;
|
||||
virtual ~StringLookup() {};
|
||||
};
|
||||
|
||||
|
||||
namespace msg
|
||||
{
|
||||
// These get translated to colors in the GUI console
|
||||
enum Kind
|
||||
{
|
||||
kNormal,
|
||||
kHighlight,
|
||||
kWarning,
|
||||
kError
|
||||
};
|
||||
|
||||
|
||||
template<typename T> std::string to_string(const T& v)
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << v;
|
||||
return ss.str();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Generic message formatting class.
|
||||
Designed to decouple message generation from actual resource string lookup and variable insertion,
|
||||
so that messages can be re-translated at any later time.
|
||||
*/
|
||||
class Message
|
||||
{
|
||||
msg::Kind kind; // severity or similar message kind
|
||||
std::string name; // the resource string name. may be of format "name=default value".
|
||||
std::vector<std::string> variables; // collected insertion variables to replace {1}, {2}, ...
|
||||
const StringLookup& resourceLookup; // object to resolve resource string name into a final format string
|
||||
const StringLookup& varLookup; // object to resolve any non-numeric insertion strings
|
||||
|
||||
std::string GetFormatString(const std::string& name) const;
|
||||
|
||||
public:
|
||||
Message(msg::Kind kind, const char* name, const StringLookup& resourceLookup, const StringLookup& varLookup)
|
||||
: kind(kind), name(name), resourceLookup(resourceLookup), varLookup(varLookup) {}
|
||||
|
||||
// Variable insertion.
|
||||
template<typename T>
|
||||
Message& operator()(const T& v) { variables.push_back(msg::to_string(v)); return *this; }
|
||||
|
||||
// conversion to final string
|
||||
operator std::string() const;
|
||||
|
||||
// Get Message Kind
|
||||
msg::Kind GetKind() {return kind;};
|
||||
};
|
||||
|
||||
|
||||
// Utility functions to create messages with standard resource and data manager lookups.
|
||||
// Short names to make usage convenient.
|
||||
Message Msg(const char* name);
|
||||
Message Msg(msg::Kind kind, const char* name);
|
||||
|
||||
#endif
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "data.hpp"
|
||||
#include "adb_install.h"
|
||||
#include "fuse_sideload.h"
|
||||
#include "gui/gui.hpp"
|
||||
extern "C" {
|
||||
#include "twinstall.h"
|
||||
#include "gui/gui.h"
|
||||
@@ -51,7 +52,8 @@ extern "C" {
|
||||
|
||||
int OpenRecoveryScript::check_for_script_file(void) {
|
||||
if (!PartitionManager.Mount_By_Path(SCRIPT_FILE_CACHE, false)) {
|
||||
LOGERR("Unable to mount /cache for OpenRecoveryScript support.\n");
|
||||
LOGINFO("Unable to mount /cache for OpenRecoveryScript support.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_mount=Unable to mount {1}")(SCRIPT_FILE_CACHE));
|
||||
return 0;
|
||||
}
|
||||
if (TWFunc::Path_Exists(SCRIPT_FILE_CACHE)) {
|
||||
@@ -134,24 +136,18 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
} else if (strcmp(command, "wipe") == 0) {
|
||||
// Wipe
|
||||
if (strcmp(value, "cache") == 0 || strcmp(value, "/cache") == 0) {
|
||||
gui_print("-- Wiping Cache Partition...\n");
|
||||
PartitionManager.Wipe_By_Path("/cache");
|
||||
gui_print("-- Cache Partition Wipe Complete!\n");
|
||||
} else if (strcmp(value, "dalvik") == 0 || strcmp(value, "dalvick") == 0 || strcmp(value, "dalvikcache") == 0 || strcmp(value, "dalvickcache") == 0) {
|
||||
gui_print("-- Wiping Dalvik Cache...\n");
|
||||
PartitionManager.Wipe_Dalvik_Cache();
|
||||
gui_print("-- Dalvik Cache Wipe Complete!\n");
|
||||
} else if (strcmp(value, "data") == 0 || strcmp(value, "/data") == 0 || strcmp(value, "factory") == 0 || strcmp(value, "factoryreset") == 0) {
|
||||
gui_print("-- Wiping Data Partition...\n");
|
||||
PartitionManager.Factory_Reset();
|
||||
gui_print("-- Data Partition Wipe Complete!\n");
|
||||
} else {
|
||||
LOGERR("Error with wipe command value: '%s'\n", value);
|
||||
ret_val = 1;
|
||||
}
|
||||
} else if (strcmp(command, "backup") == 0) {
|
||||
// Backup
|
||||
DataManager::SetValue("tw_action_text2", "Backing Up");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@backing}"));
|
||||
tok = strtok(value, " ");
|
||||
strcpy(value1, tok);
|
||||
tok = strtok(NULL, " ");
|
||||
@@ -168,7 +164,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
remove_nl = 0;
|
||||
strncpy(value2, tok, line_len - remove_nl);
|
||||
DataManager::SetValue(TW_BACKUP_NAME, value2);
|
||||
gui_print("Backup folder set to '%s'\n", value2);
|
||||
gui_msg(Msg("backup_folder=Backup folder set to '{1}'")(value2));
|
||||
if (PartitionManager.Check_Backup_Name(true) != 0) {
|
||||
ret_val = 1;
|
||||
continue;
|
||||
@@ -181,7 +177,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
ret_val = Backup_Command(value1);
|
||||
} else if (strcmp(command, "restore") == 0) {
|
||||
// Restore
|
||||
DataManager::SetValue("tw_action_text2", "Restoring");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@restore}"));
|
||||
PartitionManager.Mount_All_Storage();
|
||||
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 0);
|
||||
char folder_path[512], partitions[512];
|
||||
@@ -198,7 +194,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
}
|
||||
strcpy(folder_path, restore_folder.c_str());
|
||||
LOGINFO("Restore folder is: '%s' and partitions: '%s'\n", folder_path, partitions);
|
||||
gui_print("Restoring '%s'\n", folder_path);
|
||||
gui_msg(Msg("restoring=Restoring {1}...")(folder_path));
|
||||
|
||||
if (folder_path[0] != '/') {
|
||||
char backup_folder[512];
|
||||
@@ -225,7 +221,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
strcat(folder_path, "/.");
|
||||
}
|
||||
if (!TWFunc::Path_Exists(folder_path)) {
|
||||
gui_print("Unable to locate backup '%s'\n", folder_path);
|
||||
gui_msg(Msg(msg::kError, "locate_backup_err=Unable to locate backup '{1}'")(folder_path));
|
||||
ret_val = 1;
|
||||
continue;
|
||||
}
|
||||
@@ -241,20 +237,21 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
|
||||
memset(value2, 0, sizeof(value2));
|
||||
strcpy(value2, partitions);
|
||||
gui_print("Setting restore options: '%s':\n", value2);
|
||||
gui_msg(Msg("set_restore_opt=Setting restore options: '{1}':")(value2));
|
||||
line_len = strlen(value2);
|
||||
for (i=0; i<line_len; i++) {
|
||||
if ((value2[i] == 'S' || value2[i] == 's') && Partition_List.find("/system;") != string::npos) {
|
||||
Restore_List += "/system;";
|
||||
gui_print("System\n");
|
||||
gui_msg("system=System");
|
||||
} else if ((value2[i] == 'D' || value2[i] == 'd') && Partition_List.find("/data;") != string::npos) {
|
||||
Restore_List += "/data;";
|
||||
gui_print("Data\n");
|
||||
gui_msg("data=Data");
|
||||
} else if ((value2[i] == 'C' || value2[i] == 'c') && Partition_List.find("/cache;") != string::npos) {
|
||||
Restore_List += "/cache;";
|
||||
gui_print("Cache\n");
|
||||
gui_msg("cache=Cache");
|
||||
} else if ((value2[i] == 'R' || value2[i] == 'r') && Partition_List.find("/recovery;") != string::npos) {
|
||||
gui_print("Recovery -- Not allowed to restore recovery\n");
|
||||
Restore_List += "/recovery;";
|
||||
gui_msg("recovery=Recovery");
|
||||
} else if (value2[i] == '1' && DataManager::GetIntValue(TW_RESTORE_SP1_VAR) > 0) {
|
||||
gui_print("%s\n", "Special1 -- No Longer Supported...");
|
||||
} else if (value2[i] == '2' && DataManager::GetIntValue(TW_RESTORE_SP2_VAR) > 0) {
|
||||
@@ -263,16 +260,16 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
gui_print("%s\n", "Special3 -- No Longer Supported...");
|
||||
} else if ((value2[i] == 'B' || value2[i] == 'b') && Partition_List.find("/boot;") != string::npos) {
|
||||
Restore_List += "/boot;";
|
||||
gui_print("Boot\n");
|
||||
gui_msg("boot=Boot");
|
||||
} else if ((value2[i] == 'A' || value2[i] == 'a') && Partition_List.find("/and-sec;") != string::npos) {
|
||||
Restore_List += "/and-sec;";
|
||||
gui_print("Android Secure\n");
|
||||
gui_msg("android_secure=Android Secure");
|
||||
} else if ((value2[i] == 'E' || value2[i] == 'e') && Partition_List.find("/sd-ext;") != string::npos) {
|
||||
Restore_List += "/sd-ext;";
|
||||
gui_print("SD-Ext\n");
|
||||
gui_msg("sdext=SD-EXT");
|
||||
} else if (value2[i] == 'M' || value2[i] == 'm') {
|
||||
DataManager::SetValue(TW_SKIP_MD5_CHECK_VAR, 1);
|
||||
gui_print("MD5 check skip is on\n");
|
||||
gui_msg("md5_check_skip=MD5 check skip is on");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,32 +278,32 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
DataManager::SetValue("tw_restore_selected", Partition_List);
|
||||
}
|
||||
if (is_encrypted) {
|
||||
LOGERR("Unable to use OpenRecoveryScript to restore an encrypted backup.\n");
|
||||
gui_err("ors_encrypt_restore_err=Unable to use OpenRecoveryScript to restore an encrypted backup.");
|
||||
ret_val = 1;
|
||||
} else if (!PartitionManager.Run_Restore(folder_path))
|
||||
ret_val = 1;
|
||||
else
|
||||
gui_print("Restore complete!\n");
|
||||
gui_msg("done=Done.");
|
||||
} else if (strcmp(command, "mount") == 0) {
|
||||
// Mount
|
||||
DataManager::SetValue("tw_action_text2", "Mounting");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@mounting}"));
|
||||
if (value[0] != '/') {
|
||||
strcpy(mount, "/");
|
||||
strcat(mount, value);
|
||||
} else
|
||||
strcpy(mount, value);
|
||||
if (PartitionManager.Mount_By_Path(mount, true))
|
||||
gui_print("Mounted '%s'\n", mount);
|
||||
gui_msg(Msg("mounted=Mounted '{1}'")(mount));
|
||||
} else if (strcmp(command, "unmount") == 0 || strcmp(command, "umount") == 0) {
|
||||
// Unmount
|
||||
DataManager::SetValue("tw_action_text2", "Unmounting");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@unmounting}"));
|
||||
if (value[0] != '/') {
|
||||
strcpy(mount, "/");
|
||||
strcat(mount, value);
|
||||
} else
|
||||
strcpy(mount, value);
|
||||
if (PartitionManager.UnMount_By_Path(mount, true))
|
||||
gui_print("Unmounted '%s'\n", mount);
|
||||
gui_msg(Msg("unmounted=Unounted '{1}'")(mount));
|
||||
} else if (strcmp(command, "set") == 0) {
|
||||
// Set value
|
||||
size_t len = strlen(value);
|
||||
@@ -314,18 +311,18 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
strcpy(value1, tok);
|
||||
if (len > strlen(value1) + 1) {
|
||||
char *val2 = value + strlen(value1) + 1;
|
||||
gui_print("Setting '%s' to '%s'\n", value1, val2);
|
||||
gui_msg(Msg("setting=Setting '{1}' to '{2}'")(value1)(val2));
|
||||
DataManager::SetValue(value1, val2);
|
||||
} else {
|
||||
gui_print("Setting '%s' to empty\n", value1);
|
||||
gui_msg(Msg("setting_empty=Setting '{1}' to empty")(value1));
|
||||
DataManager::SetValue(value1, "");
|
||||
}
|
||||
} else if (strcmp(command, "mkdir") == 0) {
|
||||
// Make directory (recursive)
|
||||
DataManager::SetValue("tw_action_text2", "Making Directory");
|
||||
gui_print("Making directory (recursive): '%s'\n", value);
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@making_dir1}"));
|
||||
gui_msg(Msg("making_dir2=Making directory: '{1}'")(value));
|
||||
if (TWFunc::Recursive_Mkdir(value)) {
|
||||
LOGERR("Unable to create folder: '%s'\n", value);
|
||||
gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2}).")(value)(strerror(errno)));
|
||||
ret_val = 1;
|
||||
}
|
||||
} else if (strcmp(command, "reboot") == 0) {
|
||||
@@ -340,7 +337,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
else
|
||||
TWFunc::tw_reboot(rb_system);
|
||||
} else if (strcmp(command, "cmd") == 0) {
|
||||
DataManager::SetValue("tw_action_text2", "Running Command");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@running_command}"));
|
||||
if (cindex != 0) {
|
||||
TWFunc::Exec_Cmd(value);
|
||||
} else {
|
||||
@@ -350,18 +347,18 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
gui_print("%s\n", value);
|
||||
} else if (strcmp(command, "sideload") == 0) {
|
||||
// ADB Sideload
|
||||
DataManager::SetValue("tw_action_text2", "ADB Sideload");
|
||||
DataManager::SetValue("tw_action_text2", gui_parse_text("{@sideload}"));
|
||||
install_cmd = -1;
|
||||
|
||||
int wipe_cache = 0;
|
||||
string result;
|
||||
pid_t sideload_child_pid;
|
||||
|
||||
gui_print("Starting ADB sideload feature...\n");
|
||||
gui_msg("start_sideload=Starting ADB sideload feature...");
|
||||
ret_val = apply_from_adb("/", &sideload_child_pid);
|
||||
if (ret_val != 0) {
|
||||
if (ret_val == -2)
|
||||
gui_print("You need adb 1.0.32 or newer to sideload to this device.\n");
|
||||
gui_err("need_new_adb=You need adb 1.0.32 or newer to sideload to this device.");
|
||||
ret_val = 1; // failure
|
||||
} else if (TWinstall_zip(FUSE_SIDELOAD_HOST_PATHNAME, &wipe_cache) == 0) {
|
||||
if (wipe_cache)
|
||||
@@ -381,7 +378,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
waitpid(sideload_child_pid, &status, 0);
|
||||
}
|
||||
property_set("ctl.start", "adbd");
|
||||
gui_print("Sideload finished.\n");
|
||||
gui_msg("done=Done.");
|
||||
} else if (strcmp(command, "fixperms") == 0 || strcmp(command, "fixpermissions") == 0) {
|
||||
ret_val = PartitionManager.Fix_Permissions();
|
||||
if (ret_val != 0)
|
||||
@@ -392,7 +389,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
if (ret_val != 0)
|
||||
ret_val = 1; // failure
|
||||
} else {
|
||||
LOGERR("No password provided.\n");
|
||||
gui_err("no_pwd=No password provided.");
|
||||
ret_val = 1; // failure
|
||||
}
|
||||
} else {
|
||||
@@ -401,13 +398,13 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
gui_print("Done processing script file\n");
|
||||
gui_msg("done_ors=Done processing script file");
|
||||
} else {
|
||||
LOGERR("Error opening script file '%s'\n", SCRIPT_FILE_TMP);
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(SCRIPT_FILE_TMP)(strerror(errno)));
|
||||
return 1;
|
||||
}
|
||||
if (install_cmd && DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
|
||||
gui_print("Injecting TWRP into boot image...\n");
|
||||
gui_msg("injecttwrp=Injecting TWRP into boot image...");
|
||||
TWPartition* Boot = PartitionManager.Find_Partition_By_Path("/boot");
|
||||
if (Boot == NULL || Boot->Current_File_System != "emmc")
|
||||
TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash");
|
||||
@@ -415,7 +412,7 @@ int OpenRecoveryScript::run_script_file(void) {
|
||||
string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
|
||||
TWFunc::Exec_Cmd(injectcmd.c_str());
|
||||
}
|
||||
gui_print("TWRP injection complete.\n");
|
||||
gui_msg("done=Done.");
|
||||
}
|
||||
if (sideload)
|
||||
ret_val = 1; // Forces booting to the home page after sideload
|
||||
@@ -447,10 +444,12 @@ int OpenRecoveryScript::Install_Command(string Zip) {
|
||||
// This is a special file that contains a map of blocks on the data partition
|
||||
Full_Path = Zip.substr(1);
|
||||
if (!PartitionManager.Mount_By_Path(Full_Path, true) || !TWFunc::Path_Exists(Full_Path)) {
|
||||
gui_print("Unable to install via mapped zip '%s'\n", Full_Path.c_str());
|
||||
LOGINFO("Unable to install via mapped zip '%s'\n", Full_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "zip_err=Error installing zip file '{1}'")(Zip));
|
||||
return 1;
|
||||
}
|
||||
gui_print("Installing mapped zip file '%s'\n", Full_Path.c_str());
|
||||
LOGINFO("Installing mapped zip file '%s'\n", Full_Path.c_str());
|
||||
gui_msg(Msg("installing_zip=Installing zip file '{1}'")(Zip));
|
||||
} else if (!TWFunc::Path_Exists(Zip)) {
|
||||
PartitionManager.Mount_All_Storage();
|
||||
PartitionManager.Get_Partition_List("storage", &Storage_List);
|
||||
@@ -476,12 +475,12 @@ int OpenRecoveryScript::Install_Command(string Zip) {
|
||||
gui_print("Unable to locate zip file '%s'.\n", Zip.c_str());
|
||||
ret_val = 1;
|
||||
} else
|
||||
gui_print("Installing zip file '%s'\n", Zip.c_str());
|
||||
gui_msg(Msg("installing_zip=Installing zip file '{1}'")(Zip));
|
||||
}
|
||||
|
||||
ret_val = TWinstall_zip(Zip.c_str(), &wipe_cache);
|
||||
if (ret_val != 0) {
|
||||
LOGERR("Error installing zip file '%s'\n", Zip.c_str());
|
||||
gui_msg(Msg(msg::kError, "zip_err=Error installing zip file '{1}'")(Zip));
|
||||
ret_val = 1;
|
||||
} else if (wipe_cache)
|
||||
PartitionManager.Wipe_By_Path("/cache");
|
||||
@@ -523,21 +522,21 @@ int OpenRecoveryScript::Backup_Command(string Options) {
|
||||
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 0);
|
||||
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 0);
|
||||
|
||||
gui_print("Setting backup options:\n");
|
||||
gui_msg("select_backup_opt=Setting backup options:");
|
||||
line_len = Options.size();
|
||||
for (i=0; i<line_len; i++) {
|
||||
if (Options.substr(i, 1) == "S" || Options.substr(i, 1) == "s") {
|
||||
Backup_List += "/system;";
|
||||
gui_print("System\n");
|
||||
gui_msg("system=System");
|
||||
} else if (Options.substr(i, 1) == "D" || Options.substr(i, 1) == "d") {
|
||||
Backup_List += "/data;";
|
||||
gui_print("Data\n");
|
||||
gui_msg("data=Data");
|
||||
} else if (Options.substr(i, 1) == "C" || Options.substr(i, 1) == "c") {
|
||||
Backup_List += "/cache;";
|
||||
gui_print("Cache\n");
|
||||
gui_msg("cache=Cache");
|
||||
} else if (Options.substr(i, 1) == "R" || Options.substr(i, 1) == "r") {
|
||||
Backup_List += "/recovery;";
|
||||
gui_print("Recovery\n");
|
||||
gui_msg("recovery=Recovery");
|
||||
} else if (Options.substr(i, 1) == "1") {
|
||||
gui_print("%s\n", "Special1 -- No Longer Supported...");
|
||||
} else if (Options.substr(i, 1) == "2") {
|
||||
@@ -546,27 +545,27 @@ int OpenRecoveryScript::Backup_Command(string Options) {
|
||||
gui_print("%s\n", "Special3 -- No Longer Supported...");
|
||||
} else if (Options.substr(i, 1) == "B" || Options.substr(i, 1) == "b") {
|
||||
Backup_List += "/boot;";
|
||||
gui_print("Boot\n");
|
||||
gui_msg("boot=Boot");
|
||||
} else if (Options.substr(i, 1) == "A" || Options.substr(i, 1) == "a") {
|
||||
Backup_List += "/and-sec;";
|
||||
gui_print("Android Secure\n");
|
||||
gui_msg("android_secure=Android Secure");
|
||||
} else if (Options.substr(i, 1) == "E" || Options.substr(i, 1) == "e") {
|
||||
Backup_List += "/sd-ext;";
|
||||
gui_print("SD-Ext\n");
|
||||
gui_msg("sdext=SD-EXT");
|
||||
} else if (Options.substr(i, 1) == "O" || Options.substr(i, 1) == "o") {
|
||||
DataManager::SetValue(TW_USE_COMPRESSION_VAR, 1);
|
||||
gui_print("Compression is on\n");
|
||||
gui_msg("compression_on=Compression is on");
|
||||
} else if (Options.substr(i, 1) == "M" || Options.substr(i, 1) == "m") {
|
||||
DataManager::SetValue(TW_SKIP_MD5_GENERATE_VAR, 1);
|
||||
gui_print("MD5 Generation is off\n");
|
||||
gui_msg("md5_off=MD5 Generation is off");
|
||||
}
|
||||
}
|
||||
DataManager::SetValue("tw_backup_list", Backup_List);
|
||||
if (!PartitionManager.Run_Backup()) {
|
||||
LOGERR("Backup failed!\n");
|
||||
gui_err("backup_fail=Backup Failed");
|
||||
return 1;
|
||||
}
|
||||
gui_print("Backup complete!\n");
|
||||
gui_msg("backup_complete=Backup complete!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -577,11 +576,11 @@ void OpenRecoveryScript::Run_OpenRecoveryScript(void) {
|
||||
DataManager::SetValue("tw_action2", "");
|
||||
DataManager::SetValue("tw_action2_param", "");
|
||||
#ifdef TW_OEM_BUILD
|
||||
DataManager::SetValue("tw_action_text1", "Running Recovery Commands");
|
||||
DataManager::SetValue("tw_complete_text1", "Recovery Commands Complete");
|
||||
DataManager::SetValue("tw_action_text1", gui_lookup("running_recovery_commands", "Running Recovery Commands"));
|
||||
DataManager::SetValue("tw_complete_text1", gui_lookup("recovery_commands_complete", "Recovery Commands Complete"));
|
||||
#else
|
||||
DataManager::SetValue("tw_action_text1", "Running OpenRecoveryScript");
|
||||
DataManager::SetValue("tw_complete_text1", "OpenRecoveryScript Complete");
|
||||
DataManager::SetValue("tw_action_text1", gui_lookup("running_ors", "Running OpenRecoveryScript"));
|
||||
DataManager::SetValue("tw_complete_text1", gui_lookup("ors_complete", "OpenRecoveryScript Complete"));
|
||||
#endif
|
||||
DataManager::SetValue("tw_action_text2", "");
|
||||
DataManager::SetValue("tw_has_cancel", 0);
|
||||
|
||||
188
partition.cpp
188
partition.cpp
@@ -43,6 +43,7 @@
|
||||
#include "fixPermissions.hpp"
|
||||
#include "infomanager.hpp"
|
||||
#include "set_metadata.h"
|
||||
#include "gui/gui.hpp"
|
||||
extern "C" {
|
||||
#include "mtdutils/mtdutils.h"
|
||||
#include "mtdutils/mounts.h"
|
||||
@@ -299,7 +300,7 @@ bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
|
||||
DataManager::SetValue(TW_CRYPTO_PASSWORD, "");
|
||||
DataManager::SetValue("tw_crypto_display", "");
|
||||
} else {
|
||||
LOGERR("Could not mount /data and unable to find crypto footer.\n");
|
||||
gui_err("mount_data_footer=Could not mount /data and unable to find crypto footer.");
|
||||
}
|
||||
} else {
|
||||
LOGERR("Primary block device '%s' for mount point '%s' is not present!\n", Primary_Block_Device.c_str(), Mount_Point.c_str());
|
||||
@@ -642,7 +643,7 @@ bool TWPartition::Make_Dir(string Path, bool Display_Error) {
|
||||
if (!TWFunc::Path_Exists(Path)) {
|
||||
if (mkdir(Path.c_str(), 0777) == -1) {
|
||||
if (Display_Error)
|
||||
LOGERR("Can not create '%s' folder.\n", Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "create_folder_strerr=Can not create '{1}' folder ({2}).")(Path)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Can not create '%s' folder.\n", Path.c_str());
|
||||
return false;
|
||||
@@ -1011,7 +1012,7 @@ bool TWPartition::Mount(bool Display_Error) {
|
||||
if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Fstab_File_System.c_str(), flags, NULL) < 0) {
|
||||
if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), Fstab_File_System.c_str(), flags | MS_RDONLY, NULL) < 0) {
|
||||
if (Display_Error)
|
||||
LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_mount=Failed to mount '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
|
||||
return false;
|
||||
@@ -1024,7 +1025,7 @@ bool TWPartition::Mount(bool Display_Error) {
|
||||
string test_path = Mount_Point;
|
||||
if (stat(test_path.c_str(), &st) < 0) {
|
||||
if (Display_Error)
|
||||
LOGERR("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_mount=Failed to mount '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Failed to mount '%s' (MTD)\n", Mount_Point.c_str());
|
||||
return false;
|
||||
@@ -1056,7 +1057,7 @@ bool TWPartition::Mount(bool Display_Error) {
|
||||
LOGINFO("Mounting exfat failed, trying vfat...\n");
|
||||
if (mount(Actual_Block_Device.c_str(), Mount_Point.c_str(), "vfat", 0, NULL) != 0) {
|
||||
if (Display_Error)
|
||||
LOGERR("Unable to mount '%s'\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_mount=Failed to mount '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Unable to mount '%s'\n", Mount_Point.c_str());
|
||||
LOGINFO("Actual block device: '%s', current file system: '%s', flags: 0x%8x, options: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str(), flags, Mount_Options.c_str());
|
||||
@@ -1065,7 +1066,7 @@ bool TWPartition::Mount(bool Display_Error) {
|
||||
} else {
|
||||
#endif
|
||||
if (!Removable && Display_Error)
|
||||
LOGERR("Unable to mount '%s'\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_mount=Failed to mount '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Unable to mount '%s'\n", Mount_Point.c_str());
|
||||
LOGINFO("Actual block device: '%s', current file system: '%s'\n", Actual_Block_Device.c_str(), Current_File_System.c_str());
|
||||
@@ -1102,7 +1103,7 @@ bool TWPartition::UnMount(bool Display_Error) {
|
||||
umount(Mount_Point.c_str());
|
||||
if (Is_Mounted()) {
|
||||
if (Display_Error)
|
||||
LOGERR("Unable to unmount '%s'\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_unmount=Failed to unmount '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
else
|
||||
LOGINFO("Unable to unmount '%s'\n", Mount_Point.c_str());
|
||||
return false;
|
||||
@@ -1120,7 +1121,7 @@ bool TWPartition::Wipe(string New_File_System) {
|
||||
string Layout_Filename = Mount_Point + "/.layout_version";
|
||||
|
||||
if (!Can_Be_Wiped) {
|
||||
LOGERR("Partition '%s' cannot be wiped.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "cannot_wipe=Partition {1} cannot be wiped.\n")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1207,7 +1208,7 @@ bool TWPartition::Wipe_AndSec(void) {
|
||||
if (!Mount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Wiping %s\n", Backup_Display_Name.c_str());
|
||||
gui_msg(Msg("wiping=Wiping {1}")(Backup_Display_Name));
|
||||
TWFunc::removeDir(Mount_Point + "/.android_secure/", true);
|
||||
return true;
|
||||
}
|
||||
@@ -1233,96 +1234,96 @@ bool TWPartition::Repair() {
|
||||
|
||||
if (Current_File_System == "vfat") {
|
||||
if (!TWFunc::Path_Exists("/sbin/fsck.fat")) {
|
||||
gui_print("fsck.fat does not exist! Cannot repair!\n");
|
||||
gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.fat"));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
gui_print("Repairing %s using fsck.fat...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("fsck.fat"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/fsck.fat -y " + Actual_Block_Device;
|
||||
LOGINFO("Repair command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_repair=Unable to repair {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") {
|
||||
if (!TWFunc::Path_Exists("/sbin/e2fsck")) {
|
||||
gui_print("e2fsck does not exist! Cannot repair!\n");
|
||||
gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("e2fsck"));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
gui_print("Repairing %s using e2fsck...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("e2fsck"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/e2fsck -fp " + Actual_Block_Device;
|
||||
LOGINFO("Repair command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_repair=Unable to repair {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Current_File_System == "exfat") {
|
||||
if (!TWFunc::Path_Exists("/sbin/fsck.exfat")) {
|
||||
gui_print("fsck.exfat does not exist! Cannot repair!\n");
|
||||
gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.exfat"));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
gui_print("Repairing %s using fsck.exfat...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("fsck.exfat"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/fsck.exfat " + Actual_Block_Device;
|
||||
LOGINFO("Repair command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_repair=Unable to repair {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Current_File_System == "f2fs") {
|
||||
if (!TWFunc::Path_Exists("/sbin/fsck.f2fs")) {
|
||||
gui_print("fsck.f2fs does not exist! Cannot repair!\n");
|
||||
gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("fsck.f2fs"));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
gui_print("Repairing %s using fsck.f2fs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("fsck.f2fs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/fsck.f2fs " + Actual_Block_Device;
|
||||
LOGINFO("Repair command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_repair=Unable to repair {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Current_File_System == "ntfs") {
|
||||
if (!TWFunc::Path_Exists("/sbin/ntfsfix")) {
|
||||
gui_print("ntfsfix does not exist! Cannot repair!\n");
|
||||
gui_msg(Msg(msg::kError, "repair_not_exist={1} does not exist! Cannot repair!")("ntfsfix"));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
gui_print("Repairing %s using ntfsfix...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("reparing=Repairing {1} using {2}...")(Display_Name)("ntfsfix"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/ntfsfix " + Actual_Block_Device;
|
||||
LOGINFO("Repair command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to repair '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_repair=Unable to repair {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1342,18 +1343,20 @@ bool TWPartition::Resize() {
|
||||
|
||||
if (Current_File_System == "ext2" || Current_File_System == "ext3" || Current_File_System == "ext4") {
|
||||
if (!Can_Repair()) {
|
||||
LOGERR("Cannot resize %s because %s cannot be repaired before resizing.\n", Display_Name.c_str(), Display_Name.c_str());
|
||||
LOGINFO("Cannot resize %s because %s cannot be repaired before resizing.\n", Display_Name.c_str(), Display_Name.c_str());
|
||||
gui_msg(Msg(msg::kError, "cannot_resize=Cannot resize {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
if (!TWFunc::Path_Exists("/sbin/resize2fs")) {
|
||||
gui_print("resize2fs does not exist! Cannot resize!\n");
|
||||
LOGINFO("resize2fs does not exist! Cannot resize!\n");
|
||||
gui_msg(Msg(msg::kError, "cannot_resize=Cannot resize {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
// Repair will unmount so no need to do it twice
|
||||
gui_print("Repairing %s before resizing.\n", Display_Name.c_str());
|
||||
gui_msg(Msg("repair_resize=Repairing {1} before resizing.")( Display_Name));
|
||||
if (!Repair())
|
||||
return false;
|
||||
gui_print("Resizing %s using resize2fs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("resizing=Resizing {1} using {2}...")(Display_Name)("resize2fs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "/sbin/resize2fs " + Actual_Block_Device;
|
||||
if (Length != 0) {
|
||||
@@ -1362,13 +1365,14 @@ bool TWPartition::Resize() {
|
||||
|
||||
fd = open(Actual_Block_Device.c_str(), O_RDONLY);
|
||||
if (fd < 0) {
|
||||
LOGERR("Resize: Failed to open '%s'\n", Actual_Block_Device.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Actual_Block_Device)(strerror(errno)));
|
||||
return false;
|
||||
}
|
||||
ret = ioctl(fd, BLKGETSIZE, &block_device_size);
|
||||
close(fd);
|
||||
if (ret) {
|
||||
LOGERR("Resize: ioctl error\n");
|
||||
gui_msg(Msg(msg::kError, "unable_resize=Unable to resize {1}.")(Display_Name));
|
||||
LOGINFO("Resize: ioctl error\n");
|
||||
return false;
|
||||
}
|
||||
unsigned long long Actual_Size = (unsigned long long)(block_device_size) * 512LLU;
|
||||
@@ -1389,11 +1393,11 @@ bool TWPartition::Resize() {
|
||||
LOGINFO("Resize command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Update_Size(true);
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
Update_Size(true);
|
||||
LOGERR("Unable to resize '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_resize=Unable to resize {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1429,14 +1433,13 @@ bool TWPartition::Check_MD5(string restore_folder) {
|
||||
md5file = split_filename;
|
||||
md5file += ".md5";
|
||||
if (!TWFunc::Path_Exists(md5file)) {
|
||||
LOGERR("No md5 file found for '%s'.\n", split_filename);
|
||||
LOGERR("Please unselect Enable MD5 verification to restore.\n");
|
||||
gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(split_filename));
|
||||
return false;
|
||||
}
|
||||
md5sum.setfn(split_filename);
|
||||
while (index < 1000) {
|
||||
if (TWFunc::Path_Exists(split_filename) && md5sum.verify_md5digest() != 0) {
|
||||
LOGERR("MD5 failed to match on '%s'.\n", split_filename);
|
||||
gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
|
||||
return false;
|
||||
}
|
||||
index++;
|
||||
@@ -1448,13 +1451,12 @@ bool TWPartition::Check_MD5(string restore_folder) {
|
||||
// Single file archive
|
||||
md5file = Full_Filename + ".md5";
|
||||
if (!TWFunc::Path_Exists(md5file)) {
|
||||
LOGERR("No md5 file found for '%s'.\n", Full_Filename.c_str());
|
||||
LOGERR("Please unselect Enable MD5 verification to restore.\n");
|
||||
gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(split_filename));
|
||||
return false;
|
||||
}
|
||||
md5sum.setfn(Full_Filename);
|
||||
if (md5sum.verify_md5digest() != 0) {
|
||||
LOGERR("MD5 failed to match on '%s'.\n", Full_Filename.c_str());
|
||||
gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
@@ -1465,7 +1467,7 @@ bool TWPartition::Check_MD5(string restore_folder) {
|
||||
bool TWPartition::Restore(string restore_folder, const unsigned long long *total_restore_size, unsigned long long *already_restored_size) {
|
||||
string Restore_File_System;
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, "Restoring");
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, gui_parse_text("{@restoring}"));
|
||||
LOGINFO("Restore filename is: %s\n", Backup_FileName.c_str());
|
||||
|
||||
Restore_File_System = Get_Restore_File_System(restore_folder);
|
||||
@@ -1591,12 +1593,12 @@ bool TWPartition::Wipe_Encryption() {
|
||||
}
|
||||
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
|
||||
#ifndef TW_OEM_BUILD
|
||||
gui_print("You may need to reboot recovery to be able to use /data again.\n");
|
||||
gui_msg("format_data_msg=You may need to reboot recovery to be able to use /data again.");
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
Has_Data_Media = Save_Data_Media;
|
||||
LOGERR("Unable to format to remove encryption.\n");
|
||||
gui_err("format_data_err=Unable to format to remove encryption.");
|
||||
if (Has_Data_Media && Mount(false))
|
||||
PartitionManager.Add_MTP_Storage(MTP_Storage_ID);
|
||||
return false;
|
||||
@@ -1639,17 +1641,17 @@ bool TWPartition::Wipe_EXT23(string File_System) {
|
||||
if (TWFunc::Path_Exists("/sbin/mke2fs")) {
|
||||
string command;
|
||||
|
||||
gui_print("Formatting %s using mke2fs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mke2fs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "mke2fs -t " + File_System + " -m 0 " + Actual_Block_Device;
|
||||
LOGINFO("mke2fs command: %s\n", command.c_str());
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Current_File_System = File_System;
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
@@ -1661,7 +1663,8 @@ bool TWPartition::Wipe_EXT23(string File_System) {
|
||||
bool TWPartition::Wipe_EXT4() {
|
||||
Find_Actual_Block_Device();
|
||||
if (!Is_Present) {
|
||||
LOGERR("Block device not present, cannot wipe %s.\n", Display_Name.c_str());
|
||||
LOGINFO("Block device not present, cannot wipe %s.\n", Display_Name.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
if (!UnMount(true))
|
||||
@@ -1671,7 +1674,7 @@ bool TWPartition::Wipe_EXT4() {
|
||||
int ret;
|
||||
char *secontext = NULL;
|
||||
|
||||
gui_print("Formatting %s using make_ext4fs function.\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("make_ext4fs"));
|
||||
|
||||
if (!selinux_handle || selabel_lookup(selinux_handle, &secontext, Mount_Point.c_str(), S_IFDIR) < 0) {
|
||||
LOGINFO("Cannot lookup security context for '%s'\n", Mount_Point.c_str());
|
||||
@@ -1680,7 +1683,7 @@ bool TWPartition::Wipe_EXT4() {
|
||||
ret = make_ext4fs(Actual_Block_Device.c_str(), Length, Mount_Point.c_str(), selinux_handle);
|
||||
}
|
||||
if (ret != 0) {
|
||||
LOGERR("Unable to wipe '%s' using function call.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
} else {
|
||||
string sedir = Mount_Point + "/lost+found";
|
||||
@@ -1693,7 +1696,7 @@ bool TWPartition::Wipe_EXT4() {
|
||||
if (TWFunc::Path_Exists("/sbin/make_ext4fs")) {
|
||||
string Command;
|
||||
|
||||
gui_print("Formatting %s using make_ext4fs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("make_ext4fs"));
|
||||
Find_Actual_Block_Device();
|
||||
Command = "make_ext4fs";
|
||||
if (!Is_Decrypted && Length != 0) {
|
||||
@@ -1711,10 +1714,10 @@ bool TWPartition::Wipe_EXT4() {
|
||||
if (TWFunc::Exec_Cmd(Command) == 0) {
|
||||
Current_File_System = "ext4";
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
} else
|
||||
@@ -1730,16 +1733,16 @@ bool TWPartition::Wipe_FAT() {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Formatting %s using mkfs.fat...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mkfs.fat"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "mkfs.fat " + Actual_Block_Device;
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Current_File_System = "vfat";
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1757,15 +1760,15 @@ bool TWPartition::Wipe_EXFAT() {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Formatting %s using mkexfatfs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mkexfatfs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "mkexfatfs " + Actual_Block_Device;
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1777,7 +1780,7 @@ bool TWPartition::Wipe_MTD() {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
|
||||
gui_print("MTD Formatting \"%s\"\n", MTD_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("MTD"));
|
||||
|
||||
mtd_scan_partitions();
|
||||
const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str());
|
||||
@@ -1802,7 +1805,7 @@ bool TWPartition::Wipe_MTD() {
|
||||
}
|
||||
Current_File_System = "yaffs2";
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1815,7 +1818,7 @@ bool TWPartition::Wipe_RMRF() {
|
||||
if (Is_Storage)
|
||||
PartitionManager.Remove_MTP_Storage(MTP_Storage_ID);
|
||||
|
||||
gui_print("Removing all files under '%s'\n", Mount_Point.c_str());
|
||||
gui_msg(Msg("remove_all=Removing all files under '{1}'")(Mount_Point));
|
||||
TWFunc::removeDir(Mount_Point, true);
|
||||
Recreate_AndSec_Folder();
|
||||
return true;
|
||||
@@ -1828,7 +1831,7 @@ bool TWPartition::Wipe_F2FS() {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Formatting %s using mkfs.f2fs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mkfs.f2fs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "mkfs.f2fs -t 1";
|
||||
if (!Is_Decrypted && Length != 0) {
|
||||
@@ -1844,15 +1847,15 @@ bool TWPartition::Wipe_F2FS() {
|
||||
command += " " + Actual_Block_Device;
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
gui_print("mkfs.f2fs binary not found, using rm -rf to wipe.\n");
|
||||
LOGINFO("mkfs.f2fs binary not found, using rm -rf to wipe.\n");
|
||||
return Wipe_RMRF();
|
||||
}
|
||||
return false;
|
||||
@@ -1865,15 +1868,15 @@ bool TWPartition::Wipe_NTFS() {
|
||||
if (!UnMount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Formatting %s using mkntfs...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("formating_using=Formatting {1} using {2}...")(Display_Name)("mkntfs"));
|
||||
Find_Actual_Block_Device();
|
||||
command = "mkntfs " + Actual_Block_Device;
|
||||
if (TWFunc::Exec_Cmd(command) == 0) {
|
||||
Recreate_AndSec_Folder();
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to wipe '%s'.\n", Mount_Point.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_wipe=Unable to wipe {1}.")(Display_Name));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1892,7 +1895,7 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() {
|
||||
if (!Mount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Wiping data without wiping /data/media ...\n");
|
||||
gui_msg("wiping_data=Wiping data without wiping /data/media ...");
|
||||
|
||||
DIR* d;
|
||||
d = opendir("/data");
|
||||
@@ -1917,10 +1920,10 @@ bool TWPartition::Wipe_Data_Without_Wiping_Media() {
|
||||
}
|
||||
closedir(d);
|
||||
|
||||
gui_print("Done.\n");
|
||||
gui_msg("done=Done.");
|
||||
return true;
|
||||
}
|
||||
gui_print("Dirent failed to open /data, error!\n");
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Mount_Point)(strerror(errno)));
|
||||
return false;
|
||||
#endif // ifdef TW_OEM_BUILD
|
||||
}
|
||||
@@ -1938,7 +1941,7 @@ bool TWPartition::Backup_Tar(string backup_folder, const unsigned long long *ove
|
||||
return false;
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Backup_Display_Name, "Backing Up");
|
||||
gui_print("Backing up %s...\n", Backup_Display_Name.c_str());
|
||||
gui_msg(Msg("backing_up=Backing up {1}...")(Backup_Display_Name));
|
||||
|
||||
DataManager::GetValue(TW_USE_COMPRESSION_VAR, use_compression);
|
||||
tar.use_compression = use_compression;
|
||||
@@ -1989,8 +1992,8 @@ bool TWPartition::Backup_DD(string backup_folder) {
|
||||
sprintf(block_size, "%llu", DD_Block_Size);
|
||||
DD_BS = block_size;
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, "Backing Up");
|
||||
gui_print("Backing up %s...\n", Display_Name.c_str());
|
||||
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, gui_parse_text("{@backing}"));
|
||||
gui_msg(Msg("backing_up=Backing up {1}...")(Backup_Display_Name));
|
||||
|
||||
sprintf(back_name, "%s.%s.win", Backup_Name.c_str(), Current_File_System.c_str());
|
||||
Backup_FileName = back_name;
|
||||
@@ -2002,7 +2005,7 @@ bool TWPartition::Backup_DD(string backup_folder) {
|
||||
TWFunc::Exec_Cmd(Command);
|
||||
tw_set_default_metadata(Full_FileName.c_str());
|
||||
if (TWFunc::Get_File_Size(Full_FileName) == 0) {
|
||||
LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
|
||||
gui_msg(Msg(msg::kError, "backup_size=Backup file size for '{1}' is 0 bytes.")(Full_FileName));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2013,8 +2016,8 @@ bool TWPartition::Backup_Dump_Image(string backup_folder) {
|
||||
string Full_FileName, Command;
|
||||
int use_compression;
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, "Backing Up");
|
||||
gui_print("Backing up %s...\n", Display_Name.c_str());
|
||||
TWFunc::GUI_Operation_Text(TW_BACKUP_TEXT, Display_Name, gui_parse_text("{@backing}"));
|
||||
gui_msg(Msg("backing_up=Backing up {1}...")(Backup_Display_Name));
|
||||
|
||||
sprintf(back_name, "%s.%s.win", Backup_Name.c_str(), Current_File_System.c_str());
|
||||
Backup_FileName = back_name;
|
||||
@@ -2027,7 +2030,7 @@ bool TWPartition::Backup_Dump_Image(string backup_folder) {
|
||||
tw_set_default_metadata(Full_FileName.c_str());
|
||||
if (TWFunc::Get_File_Size(Full_FileName) == 0) {
|
||||
// Actual size may not match backup size due to bad blocks on MTD devices so just check for 0 bytes
|
||||
LOGERR("Backup file size for '%s' is 0 bytes.\n", Full_FileName.c_str());
|
||||
gui_msg(Msg(msg::kError, "backup_size=Backup file size for '%s' is 0 bytes.")(Full_FileName));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -2076,10 +2079,9 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System,
|
||||
if (!Wipe_AndSec())
|
||||
return false;
|
||||
} else {
|
||||
gui_print("Wiping %s...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("wiping=Wiping {1}")(Backup_Display_Name));
|
||||
if (Has_Data_Media && Mount_Point == "/data" && Restore_File_System != Current_File_System) {
|
||||
gui_print("WARNING: This /data backup was made with %s file system!\n", Restore_File_System.c_str());
|
||||
gui_print("The backup may not boot unless you change back to %s.\n", Restore_File_System.c_str());
|
||||
gui_msg(Msg(msg::kWarning, "datamedia_fs_restore=WARNING: This /data backup was made with {1} file system! The backup may not boot unless you change back to {1}.")(Restore_File_System));
|
||||
if (!Wipe_Data_Without_Wiping_Media())
|
||||
return false;
|
||||
} else {
|
||||
@@ -2087,8 +2089,8 @@ bool TWPartition::Restore_Tar(string restore_folder, string Restore_File_System,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, "Restoring");
|
||||
gui_print("Restoring %s...\n", Backup_Display_Name.c_str());
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, gui_parse_text("{@restore}"));
|
||||
gui_msg(Msg("restoring=Restoring {1}...")(Backup_Display_Name));
|
||||
|
||||
if (!Mount(true))
|
||||
return false;
|
||||
@@ -2135,7 +2137,8 @@ bool TWPartition::Restore_Image(string restore_folder, const unsigned long long
|
||||
double display_percent, progress_percent;
|
||||
char size_progress[1024];
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, "Restoring");
|
||||
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, gui_parse_text("{@restore}"));
|
||||
gui_msg(Msg("restoring=Restoring {1}...")(Backup_Display_Name));
|
||||
Full_FileName = restore_folder + "/" + Backup_FileName;
|
||||
|
||||
if (Restore_File_System == "emmc") {
|
||||
@@ -2226,7 +2229,7 @@ void TWPartition::Recreate_Media_Folder(void) {
|
||||
string Command;
|
||||
|
||||
if (!Mount(true)) {
|
||||
LOGERR("Unable to recreate /data/media folder.\n");
|
||||
gui_msg(Msg(msg::kError, "recreate_folder_err=Unable to recreate {1} folder.")("/data/media"));
|
||||
} else if (!TWFunc::Path_Exists("/data/media")) {
|
||||
PartitionManager.Mount_By_Path(Symlink_Mount_Point, true);
|
||||
LOGINFO("Recreating /data/media folder.\n");
|
||||
@@ -2258,7 +2261,7 @@ void TWPartition::Recreate_AndSec_Folder(void) {
|
||||
return;
|
||||
LOGINFO("Creating %s: %s\n", Backup_Display_Name.c_str(), Symlink_Path.c_str());
|
||||
if (!Mount(true)) {
|
||||
LOGERR("Unable to recreate %s folder.\n", Backup_Name.c_str());
|
||||
gui_msg(Msg(msg::kError, "recreate_folder_err=Unable to recreate {1} folder.")(Backup_Name));
|
||||
} else if (!TWFunc::Path_Exists(Symlink_Path)) {
|
||||
LOGINFO("Recreating %s folder.\n", Backup_Name.c_str());
|
||||
PartitionManager.Mount_By_Path(Symlink_Mount_Point, true);
|
||||
@@ -2308,8 +2311,9 @@ bool TWPartition::Flash_Image(string Filename) {
|
||||
}
|
||||
unsigned long long image_size = TWFunc::Get_File_Size(Filename);
|
||||
if (image_size > Size) {
|
||||
LOGERR("Size (%llu bytes) of image '%s' is larger than target device '%s' (%llu bytes)\n",
|
||||
LOGINFO("Size (%llu bytes) of image '%s' is larger than target device '%s' (%llu bytes)\n",
|
||||
image_size, Filename.c_str(), Actual_Block_Device.c_str(), Size);
|
||||
gui_err("img_size_err=Size of image is larger than target device");
|
||||
return false;
|
||||
}
|
||||
if (Backup_Method == DD)
|
||||
@@ -2325,7 +2329,7 @@ bool TWPartition::Flash_Image(string Filename) {
|
||||
bool TWPartition::Flash_Image_DD(string Filename) {
|
||||
string Command;
|
||||
|
||||
gui_print("Flashing %s...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("flashing=Flashing {1}...")(Display_Name));
|
||||
Command = "dd bs=8388608 if='" + Filename + "' of=" + Actual_Block_Device;
|
||||
LOGINFO("Flash command: '%s'\n", Command.c_str());
|
||||
TWFunc::Exec_Cmd(Command);
|
||||
@@ -2335,7 +2339,7 @@ bool TWPartition::Flash_Image_DD(string Filename) {
|
||||
bool TWPartition::Flash_Image_FI(string Filename) {
|
||||
string Command;
|
||||
|
||||
gui_print("Flashing %s...\n", Display_Name.c_str());
|
||||
gui_msg(Msg("flashing=Flashing {1}...")(Display_Name));
|
||||
// Sometimes flash image doesn't like to flash due to the first 2KB matching, so we erase first to ensure that it flashes
|
||||
Command = "erase_image " + MTD_Name;
|
||||
LOGINFO("Erase command: '%s'\n", Command.c_str());
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "twrpDU.hpp"
|
||||
#include "set_metadata.h"
|
||||
#include "tw_atomic.hpp"
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
#ifdef TW_HAS_MTP
|
||||
#include "mtp/mtp_MtpServer.hpp"
|
||||
@@ -49,6 +50,7 @@
|
||||
|
||||
extern "C" {
|
||||
#include "cutils/properties.h"
|
||||
#include "gui/gui.h"
|
||||
}
|
||||
|
||||
#ifdef TW_INCLUDE_CRYPTO
|
||||
@@ -154,11 +156,10 @@ int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error)
|
||||
if (password_type == CRYPT_TYPE_DEFAULT) {
|
||||
LOGINFO("Device is encrypted with the default password, attempting to decrypt.\n");
|
||||
if (Decrypt_Device("default_password") == 0) {
|
||||
gui_print("Successfully decrypted with default password.\n");
|
||||
gui_msg("decrypt_success=Successfully decrypted with default password.");
|
||||
DataManager::SetValue(TW_IS_ENCRYPTED, 0);
|
||||
} else {
|
||||
LOGERR("Unable to decrypt with default password.");
|
||||
LOGERR("You may need to perform a Format Data.\n");
|
||||
gui_err("unable_to_decrypt=Unable to decrypt with default password.");
|
||||
}
|
||||
} else {
|
||||
DataManager::SetValue("TW_CRYPTO_TYPE", password_type);
|
||||
@@ -342,7 +343,7 @@ int TWPartitionManager::Mount_By_Path(string Path, bool Display_Error) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else if (Display_Error) {
|
||||
LOGERR("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
} else {
|
||||
LOGINFO("Mount: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
}
|
||||
@@ -367,7 +368,7 @@ int TWPartitionManager::UnMount_By_Path(string Path, bool Display_Error) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else if (Display_Error) {
|
||||
LOGERR("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
} else {
|
||||
LOGINFO("UnMount: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
}
|
||||
@@ -425,7 +426,7 @@ int TWPartitionManager::Check_Backup_Name(bool Display_Error) {
|
||||
// Check size
|
||||
if (copy_size > MAX_BACKUP_NAME_LEN) {
|
||||
if (Display_Error)
|
||||
LOGERR("Backup name is too long.\n");
|
||||
gui_err("backup_name_len=Backup name is too long.");
|
||||
return -2;
|
||||
}
|
||||
|
||||
@@ -444,7 +445,7 @@ int TWPartitionManager::Check_Backup_Name(bool Display_Error) {
|
||||
// and -_.{}[]
|
||||
} else {
|
||||
if (Display_Error)
|
||||
LOGERR("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char);
|
||||
gui_msg(Msg(msg::kError, "backup_name_invalid=Backup name '{1}' contains invalid character: '{1}'")(backup_name)((char)cur_char));
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
@@ -455,7 +456,7 @@ int TWPartitionManager::Check_Backup_Name(bool Display_Error) {
|
||||
sprintf(tw_image_dir,"%s/%s", backup_loc, Backup_Name.c_str());
|
||||
if (TWFunc::Path_Exists(tw_image_dir)) {
|
||||
if (Display_Error)
|
||||
LOGERR("A backup with this name already exists.\n");
|
||||
gui_err("backup_name_exists=A backup with this name already exists.");
|
||||
return -4;
|
||||
}
|
||||
// No problems found, return 0
|
||||
@@ -472,18 +473,18 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin
|
||||
if (!generate_md5)
|
||||
return true;
|
||||
|
||||
TWFunc::GUI_Operation_Text(TW_GENERATE_MD5_TEXT, "Generating MD5");
|
||||
gui_print(" * Generating md5...\n");
|
||||
TWFunc::GUI_Operation_Text(TW_GENERATE_MD5_TEXT, gui_parse_text("{@generating_md51}"));
|
||||
gui_msg("generating_md52= * Generating md5...");
|
||||
|
||||
if (TWFunc::Path_Exists(Full_File)) {
|
||||
md5sum.setfn(Backup_Folder + Backup_Filename);
|
||||
if (md5sum.computeMD5() == 0)
|
||||
if (md5sum.write_md5digest() == 0)
|
||||
gui_print(" * MD5 Created.\n");
|
||||
gui_msg("md5_created= * MD5 Created.");
|
||||
else
|
||||
return -1;
|
||||
else
|
||||
gui_print(" * MD5 Error!\n");
|
||||
gui_err("md5_error= * MD5 Error!");
|
||||
} else {
|
||||
char filename[512];
|
||||
int index = 0;
|
||||
@@ -496,11 +497,11 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin
|
||||
if (md5sum.computeMD5() == 0) {
|
||||
if (md5sum.write_md5digest() != 0)
|
||||
{
|
||||
gui_print(" * MD5 Error.\n");
|
||||
gui_err("md5_error= * MD5 Error!");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
gui_print(" * Error computing MD5.\n");
|
||||
gui_err("md5_compute_error= * Error computing MD5.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +513,7 @@ bool TWPartitionManager::Make_MD5(bool generate_md5, string Backup_Folder, strin
|
||||
LOGERR("Backup file: '%s' not found!\n", filename);
|
||||
return false;
|
||||
}
|
||||
gui_print(" * MD5 Created.\n");
|
||||
gui_msg("md5_created= * MD5 Created.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -602,10 +603,10 @@ void TWPartitionManager::Clean_Backup_Folder(string Backup_Folder) {
|
||||
struct dirent *p;
|
||||
int r;
|
||||
|
||||
gui_print("Backup Failed.\nCleaning Backup Folder\n");
|
||||
gui_msg("backup_clean=Backup Failed. Cleaning Backup Folder.");
|
||||
|
||||
if (d == NULL) {
|
||||
LOGERR("Error opening dir: '%s'\n", Backup_Folder.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Backup_Folder)(strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -679,9 +680,9 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
|
||||
DataManager::GetValue(TW_BACKUPS_FOLDER_VAR, Backup_Folder);
|
||||
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
|
||||
if (Backup_Name == "(Current Date)") {
|
||||
if (Backup_Name == gui_parse_text("{@current_date}")) {
|
||||
Backup_Name = TWFunc::Get_Current_Date();
|
||||
} else if (Backup_Name == "(Auto Generate)" || Backup_Name == "0" || Backup_Name.empty()) {
|
||||
} else if (Backup_Name == gui_parse_text("{@auto_generate}") || Backup_Name == "0" || Backup_Name.empty()) {
|
||||
TWFunc::Auto_Generate_Backup_Name();
|
||||
DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
|
||||
}
|
||||
@@ -716,7 +717,7 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for backup calculations.\n", backup_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_locate_partition=Unable to locate '{1}' partition for backup calculations.")(backup_path));
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
end_pos = Backup_List.find(";", start_pos);
|
||||
@@ -724,18 +725,18 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
}
|
||||
|
||||
if (partition_count == 0) {
|
||||
gui_print("No partitions selected for backup.\n");
|
||||
gui_msg("no_partition_selected=No partitions selected for backup.");
|
||||
return false;
|
||||
}
|
||||
total_bytes = file_bytes + img_bytes;
|
||||
gui_print(" * Total number of partitions to back up: %d\n", partition_count);
|
||||
gui_print(" * Total size of all data: %lluMB\n", total_bytes / 1024 / 1024);
|
||||
gui_msg(Msg("total_partitions_backup= * Total number of partitions to back up: {1}")(partition_count));
|
||||
gui_msg(Msg("total_backup_size= * Total size of all data: {1}MB")(total_bytes / 1024 / 1024));
|
||||
storage = Find_Partition_By_Path(DataManager::GetCurrentStoragePath());
|
||||
if (storage != NULL) {
|
||||
free_space = storage->Free;
|
||||
gui_print(" * Available space: %lluMB\n", free_space / 1024 / 1024);
|
||||
gui_msg(Msg("available_space= * Available space: {1}MB")(free_space / 1024 / 1024));
|
||||
} else {
|
||||
LOGERR("Unable to locate storage device.\n");
|
||||
gui_err("unable_locate_storage=Unable to locate storage device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -743,17 +744,17 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
if (!disable_free_space_check) {
|
||||
if (free_space - (32 * 1024 * 1024) < total_bytes) {
|
||||
// We require an extra 32MB just in case
|
||||
LOGERR("Not enough free space on storage.\n");
|
||||
gui_err("no_space=Not enough free space on storage.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
img_bytes_remaining = img_bytes;
|
||||
file_bytes_remaining = file_bytes;
|
||||
|
||||
gui_print("\n[BACKUP STARTED]\n");
|
||||
gui_print(" * Backup Folder: %s\n", Full_Backup_Path.c_str());
|
||||
gui_msg("backup_started=[BACKUP STARTED]");
|
||||
gui_msg(Msg("backup_folder= * Backup Folder: {1}")(Full_Backup_Path));
|
||||
if (!TWFunc::Recursive_Mkdir(Full_Backup_Path)) {
|
||||
LOGERR("Failed to make backup folder.\n");
|
||||
gui_err("fail_backup_folder=Failed to make backup folder.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -770,7 +771,7 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
if (!Backup_Partition(backup_part, Full_Backup_Path, do_md5, &img_bytes_remaining, &file_bytes_remaining, &img_time, &file_time, &img_bytes, &file_bytes))
|
||||
return false;
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for backup process.\n", backup_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_to_locate_partition=Unable to locate '{1}' partition for backup calculations.")(backup_path));
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
end_pos = Backup_List.find(";", start_pos);
|
||||
@@ -784,8 +785,8 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
int img_bps = (int)img_bytes / (int)img_time;
|
||||
unsigned long long file_bps = file_bytes / (int)file_time;
|
||||
|
||||
gui_print("Average backup rate for file systems: %llu MB/sec\n", (file_bps / (1024 * 1024)));
|
||||
gui_print("Average backup rate for imaged drives: %lu MB/sec\n", (img_bps / (1024 * 1024)));
|
||||
gui_msg(Msg("avg_backup_fs=Average backup rate for file systems: {1} MB/sec")(file_bps / (1024 * 1024)));
|
||||
gui_msg(Msg("avg_backup_img=Average backup rate for imaged drives: {1} MB/sec")(img_bps / (1024 * 1024)));
|
||||
|
||||
time(&total_stop);
|
||||
int total_time = (int) difftime(total_stop, total_start);
|
||||
@@ -812,10 +813,10 @@ int TWPartitionManager::Run_Backup(void) {
|
||||
else
|
||||
DataManager::SetValue(TW_BACKUP_AVG_FILE_RATE, file_bps);
|
||||
|
||||
gui_print("[%llu MB TOTAL BACKED UP]\n", actual_backup_size);
|
||||
gui_msg(Msg("total_backed_size=[{1} MB TOTAL BACKED UP]")(actual_backup_size));
|
||||
Update_System_Details();
|
||||
UnMount_Main_Partitions();
|
||||
gui_print_color("highlight", "[BACKUP COMPLETED IN %d SECONDS]\n\n", total_time); // the end
|
||||
gui_msg(Msg(msg::kHighlight, "backup_completed=[BACKUP COMPLETED IN %s SECONDS]")(total_time)); // the end
|
||||
string backup_log = Full_Backup_Path + "recovery.log";
|
||||
TWFunc::copy_file("/tmp/recovery.log", backup_log, 0644);
|
||||
tw_set_default_metadata(backup_log.c_str());
|
||||
@@ -845,7 +846,7 @@ bool TWPartitionManager::Restore_Partition(TWPartition* Part, string Restore_Nam
|
||||
}
|
||||
time(&Stop);
|
||||
TWFunc::SetPerformanceMode(false);
|
||||
gui_print("[%s done (%d seconds)]\n\n", Part->Backup_Display_Name.c_str(), (int)difftime(Stop, Start));
|
||||
gui_msg(Msg("restort_part_done=[{1} done ({2} seconds)]")(Part->Backup_Display_Name)((int)difftime(Stop, Start)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -858,8 +859,8 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
size_t start_pos = 0, end_pos;
|
||||
unsigned long long total_restore_size = 0, already_restored_size = 0;
|
||||
|
||||
gui_print("\n[RESTORE STARTED]\n\n");
|
||||
gui_print("Restore folder: '%s'\n", Restore_Name.c_str());
|
||||
gui_msg("restore_started=[RESTORE STARTED]");
|
||||
gui_msg(Msg("restore_folder=Restore folder: '{1}'")(Restore_Name));
|
||||
|
||||
if (!Mount_Current_Storage(true))
|
||||
return false;
|
||||
@@ -867,12 +868,12 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
DataManager::GetValue(TW_SKIP_MD5_CHECK_VAR, check_md5);
|
||||
if (check_md5 > 0) {
|
||||
// Check MD5 files first before restoring to ensure that all of them match before starting a restore
|
||||
TWFunc::GUI_Operation_Text(TW_VERIFY_MD5_TEXT, "Verifying MD5");
|
||||
gui_print("Verifying MD5...\n");
|
||||
TWFunc::GUI_Operation_Text(TW_VERIFY_MD5_TEXT, gui_parse_text("{@verifying_md5}"));
|
||||
gui_msg("verifying_md5=Verifying MD5");
|
||||
} else {
|
||||
gui_print("Skipping MD5 check based on user setting.\n");
|
||||
gui_msg("skip_md5=Skipping MD5 check based on user setting.");
|
||||
}
|
||||
gui_print("Calculating restore details...\n");
|
||||
gui_msg("calc_restore=Calculating restore details...");
|
||||
DataManager::GetValue("tw_restore_selected", Restore_List);
|
||||
if (!Restore_List.empty()) {
|
||||
end_pos = Restore_List.find(";", start_pos);
|
||||
@@ -881,7 +882,7 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
restore_part = Find_Partition_By_Path(restore_path);
|
||||
if (restore_part != NULL) {
|
||||
if (restore_part->Mount_Read_Only) {
|
||||
LOGERR("Cannot restore %s -- mounted read only.\n", restore_part->Backup_Display_Name.c_str());
|
||||
gui_msg(Msg(msg::kError, "restore_read_only=Cannot restore {1} -- mounted read only.")(restore_part->Backup_Display_Name));
|
||||
return false;
|
||||
}
|
||||
if (check_md5 > 0 && !restore_part->Check_MD5(Restore_Name))
|
||||
@@ -900,7 +901,7 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for restoring (restore list).\n", restore_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "restore_unable_locate=Unable to locate '{1}' partition for restoring.")(restore_path));
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
end_pos = Restore_List.find(";", start_pos);
|
||||
@@ -908,12 +909,12 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
}
|
||||
|
||||
if (partition_count == 0) {
|
||||
LOGERR("No partitions selected for restore.\n");
|
||||
gui_err("no_part_restore=No partitions selected for restore.");
|
||||
return false;
|
||||
}
|
||||
|
||||
gui_print("Restoring %i partitions...\n", partition_count);
|
||||
gui_print("Total restore size is %lluMB\n", total_restore_size / 1048576);
|
||||
gui_msg(Msg("restore_part_count=Restoring {1} partitions...")(partition_count));
|
||||
gui_msg(Msg("total_restore_size=Total restore size is {1}MB")(total_restore_size / 1048576));
|
||||
DataManager::SetProgress(0.0);
|
||||
|
||||
start_pos = 0;
|
||||
@@ -927,17 +928,17 @@ int TWPartitionManager::Run_Restore(string Restore_Name) {
|
||||
if (!Restore_Partition(restore_part, Restore_Name, partition_count, &total_restore_size, &already_restored_size))
|
||||
return false;
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for restoring.\n", restore_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "restore_unable_locate=Unable to locate '{1}' partition for restoring.")(restore_path));
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
end_pos = Restore_List.find(";", start_pos);
|
||||
}
|
||||
}
|
||||
TWFunc::GUI_Operation_Text(TW_UPDATE_SYSTEM_DETAILS_TEXT, "Updating System Details");
|
||||
TWFunc::GUI_Operation_Text(TW_UPDATE_SYSTEM_DETAILS_TEXT, gui_parse_text("{@updating_system_details}"));
|
||||
Update_System_Details();
|
||||
UnMount_Main_Partitions();
|
||||
time(&rStop);
|
||||
gui_print_color("highlight", "[RESTORE COMPLETED IN %d SECONDS]\n\n",(int)difftime(rStop,rStart));
|
||||
gui_msg(Msg(msg::kHighlight, "restore_complete=[RESTORE COMPLETED IN {1} SECONDS]")((int)difftime(rStop,rStart)));
|
||||
DataManager::SetValue("tw_file_progress", "");
|
||||
return true;
|
||||
}
|
||||
@@ -953,7 +954,7 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
|
||||
d = opendir(Restore_Name.c_str());
|
||||
if (d == NULL)
|
||||
{
|
||||
LOGERR("Error opening %s\n", Restore_Name.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Restore_Name)(strerror(errno)));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1020,7 +1021,7 @@ void TWPartitionManager::Set_Restore_Files(string Restore_Name) {
|
||||
TWPartition* Part = Find_Partition_By_Path(label);
|
||||
if (Part == NULL)
|
||||
{
|
||||
LOGERR(" Unable to locate partition by backup name: '%s'\n", label);
|
||||
gui_msg(Msg(msg::kError, "unable_locate_part_backup_name=Unable to locate partition by backup name: '{1}'")(label));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1060,7 +1061,7 @@ int TWPartitionManager::Wipe_By_Path(string Path) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else
|
||||
LOGERR("Wipe: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1085,7 +1086,7 @@ int TWPartitionManager::Wipe_By_Path(string Path, string New_File_System) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else
|
||||
LOGERR("Wipe: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1127,11 +1128,11 @@ int TWPartitionManager::Wipe_Dalvik_Cache(void) {
|
||||
dir.push_back("/data/dalvik-cache");
|
||||
dir.push_back("/cache/dalvik-cache");
|
||||
dir.push_back("/cache/dc");
|
||||
gui_print("\nWiping Dalvik Cache Directories...\n");
|
||||
gui_msg("wiping_dalvik=Wiping Dalvik Cache Directories...");
|
||||
for (unsigned i = 0; i < dir.size(); ++i) {
|
||||
if (stat(dir.at(i).c_str(), &st) == 0) {
|
||||
TWFunc::removeDir(dir.at(i), false);
|
||||
gui_print("Cleaned: %s...\n", dir.at(i).c_str());
|
||||
gui_msg(Msg("cleaned=Cleaned: {1}...")(dir.at(i)));
|
||||
}
|
||||
}
|
||||
TWPartition* sdext = Find_Partition_By_Path("/sd-ext");
|
||||
@@ -1140,10 +1141,10 @@ int TWPartitionManager::Wipe_Dalvik_Cache(void) {
|
||||
if (stat("/sd-ext/dalvik-cache", &st) == 0)
|
||||
{
|
||||
TWFunc::removeDir("/sd-ext/dalvik-cache", false);
|
||||
gui_print("Cleaned: /sd-ext/dalvik-cache...\n");
|
||||
gui_msg(Msg("cleaned=Cleaned: {1}...")("/sd-ext/dalvik-cache"));
|
||||
}
|
||||
}
|
||||
gui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
|
||||
gui_msg("dalvik_done=-- Dalvik Cache Directories Wipe Complete!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1187,7 +1188,7 @@ int TWPartitionManager::Wipe_Android_Secure(void) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else {
|
||||
LOGERR("No android secure partitions found.\n");
|
||||
gui_err("no_andsec=No android secure partitions found.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1201,7 +1202,7 @@ int TWPartitionManager::Format_Data(void) {
|
||||
|
||||
return dat->Wipe_Encryption();
|
||||
} else {
|
||||
LOGERR("Unable to locate /data.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1].")("/data"));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -1218,14 +1219,14 @@ int TWPartitionManager::Wipe_Media_From_Data(void) {
|
||||
if (!dat->Mount(true))
|
||||
return false;
|
||||
|
||||
gui_print("Wiping internal storage -- /data/media...\n");
|
||||
gui_msg("wiping_datamedia=Wiping internal storage -- /data/media...");
|
||||
Remove_MTP_Storage(dat->MTP_Storage_ID);
|
||||
TWFunc::removeDir("/data/media", false);
|
||||
dat->Recreate_Media_Folder();
|
||||
Add_MTP_Storage(dat->MTP_Storage_ID);
|
||||
return true;
|
||||
} else {
|
||||
LOGERR("Unable to locate /data.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1].")("/data"));
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
@@ -1252,7 +1253,7 @@ int TWPartitionManager::Repair_By_Path(string Path, bool Display_Error) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else if (Display_Error) {
|
||||
LOGERR("Repair: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
} else {
|
||||
LOGINFO("Repair: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
}
|
||||
@@ -1280,7 +1281,7 @@ int TWPartitionManager::Resize_By_Path(string Path, bool Display_Error) {
|
||||
if (found) {
|
||||
return ret;
|
||||
} else if (Display_Error) {
|
||||
LOGERR("Resize: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Local_Path));
|
||||
} else {
|
||||
LOGINFO("Resize: Unable to find partition for path '%s'\n", Local_Path.c_str());
|
||||
}
|
||||
@@ -1291,7 +1292,7 @@ void TWPartitionManager::Update_System_Details(void) {
|
||||
std::vector<TWPartition*>::iterator iter;
|
||||
int data_size = 0;
|
||||
|
||||
gui_print("Updating partition details...\n");
|
||||
gui_msg("update_part_details=Updating partition details...");
|
||||
for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
|
||||
if ((*iter)->Can_Be_Mounted) {
|
||||
(*iter)->Update_Size(true);
|
||||
@@ -1387,7 +1388,7 @@ void TWPartitionManager::Update_System_Details(void) {
|
||||
#endif
|
||||
}
|
||||
}
|
||||
gui_print("...done\n");
|
||||
gui_msg("update_part_details_done=...done");
|
||||
DataManager::SetValue(TW_BACKUP_DATA_SIZE, data_size);
|
||||
string current_storage_path = DataManager::GetCurrentStoragePath();
|
||||
TWPartition* FreeStorage = Find_Partition_By_Path(current_storage_path);
|
||||
@@ -1402,7 +1403,7 @@ void TWPartitionManager::Update_System_Details(void) {
|
||||
if (current_storage_path == DataManager::GetSettingsStoragePath()) {
|
||||
if (!FreeStorage->Is_Encrypted) {
|
||||
// Not able to use internal, so error!
|
||||
LOGERR("Unable to mount internal storage.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_mount_internal=Unable to mount internal_storage"));
|
||||
}
|
||||
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
|
||||
} else {
|
||||
@@ -1413,13 +1414,13 @@ void TWPartitionManager::Update_System_Details(void) {
|
||||
if (FreeStorage != NULL) {
|
||||
DataManager::SetValue(TW_STORAGE_FREE_SIZE, (int)(FreeStorage->Free / 1048576LLU));
|
||||
} else {
|
||||
LOGERR("Unable to locate internal storage partition.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_locate=Unable to locate {1}")("internal storage partition"));
|
||||
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No dual storage and unable to mount storage, error!
|
||||
LOGERR("Unable to mount storage.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_mount_storage=Unable to mount storage"));
|
||||
DataManager::SetValue(TW_STORAGE_FREE_SIZE, 0);
|
||||
}
|
||||
} else {
|
||||
@@ -1465,7 +1466,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
|
||||
}
|
||||
|
||||
if (pwret != 0) {
|
||||
LOGERR("Failed to decrypt data.\n");
|
||||
gui_err("fail_decrypt=Failed to decrypt data.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1481,7 +1482,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
|
||||
dat->Decrypted_Block_Device = crypto_blkdev;
|
||||
dat->Setup_File_System(false);
|
||||
dat->Current_File_System = dat->Fstab_File_System; // Needed if we're ignoring blkid because encrypted devices start out as emmc
|
||||
gui_print("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
|
||||
gui_msg(Msg("decrypt_success=Data successfully decrypted, new block device: '{1}'")(crypto_blkdev));
|
||||
|
||||
// Sleep for a bit so that the device will be ready
|
||||
sleep(1);
|
||||
@@ -1500,7 +1501,7 @@ int TWPartitionManager::Decrypt_Device(string Password) {
|
||||
}
|
||||
return 0;
|
||||
#else
|
||||
LOGERR("No crypto support was compiled into this build.\n");
|
||||
gui_err("no_crypto_support=No crypto support was compiled into this build.");
|
||||
return -1;
|
||||
#endif
|
||||
return 1;
|
||||
@@ -1523,7 +1524,7 @@ int TWPartitionManager::Fix_Permissions(void) {
|
||||
result = perms.fixContexts();
|
||||
#endif
|
||||
UnMount_Main_Partitions();
|
||||
gui_print("Done.\n\n");
|
||||
gui_msg("done=Done.");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1553,7 +1554,8 @@ int TWPartitionManager::Open_Lun_File(string Partition_Path, string Lun_File) {
|
||||
TWPartition* Part = Find_Partition_By_Path(Partition_Path);
|
||||
|
||||
if (Part == NULL) {
|
||||
LOGERR("Unable to locate '%s' for USB storage mode.", Partition_Path.c_str());
|
||||
LOGINFO("Unable to locate '%s' for USB storage mode.", Partition_Path.c_str());
|
||||
gui_msg(Msg(msg::kError, "unable_find_part_path=Unable to find partition for path '{1}'")(Partition_Path));
|
||||
return false;
|
||||
}
|
||||
LOGINFO("USB mount '%s', '%s' > '%s'\n", Partition_Path.c_str(), Part->Actual_Block_Device.c_str(), Lun_File.c_str());
|
||||
@@ -1591,7 +1593,7 @@ int TWPartitionManager::usb_storage_enable(void) {
|
||||
goto error_handle;
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to find storage partition to mount to USB\n");
|
||||
gui_err("unable_locate_storage=Unable to locate storage device.");
|
||||
goto error_handle;
|
||||
}
|
||||
} else if (!Open_Lun_File(DataManager::GetCurrentStoragePath(), lun_file)) {
|
||||
@@ -1613,7 +1615,7 @@ int TWPartitionManager::usb_storage_enable(void) {
|
||||
Open_Lun_File(Mount2->Mount_Point, lun_file);
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to find storage partition to mount to USB\n");
|
||||
gui_err("unable_locate_storage=Unable to locate storage device.");
|
||||
goto error_handle;
|
||||
}
|
||||
}
|
||||
@@ -1686,14 +1688,14 @@ int TWPartitionManager::Partition_SDCard(void) {
|
||||
int ext, swap, total_size = 0, fat_size;
|
||||
FILE* fp;
|
||||
|
||||
gui_print("Partitioning SD Card...\n");
|
||||
gui_msg("start_partition_sd=Partitioning SD Card...");
|
||||
#ifdef TW_EXTERNAL_STORAGE_PATH
|
||||
TWPartition* SDCard = Find_Partition_By_Path(EXPAND(TW_EXTERNAL_STORAGE_PATH));
|
||||
#else
|
||||
TWPartition* SDCard = Find_Partition_By_Path("/sdcard");
|
||||
#endif
|
||||
if (SDCard == NULL || !SDCard->Removable || SDCard->Has_Data_Media) {
|
||||
LOGERR("Unable to locate device to partition.\n");
|
||||
gui_err("partition_sd_locate=Unable to locate device to partition.");
|
||||
return false;
|
||||
}
|
||||
if (!SDCard->UnMount(true))
|
||||
@@ -1712,7 +1714,7 @@ int TWPartitionManager::Partition_SDCard(void) {
|
||||
// Find the size of the block device:
|
||||
fp = fopen("/proc/partitions", "rt");
|
||||
if (fp == NULL) {
|
||||
LOGERR("Unable to open /proc/partitions\n");
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")("/proc/partitions")(strerror(errno)));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1750,40 +1752,40 @@ int TWPartitionManager::Partition_SDCard(void) {
|
||||
sprintf(temp, "%i", fat_size + ext + swap);
|
||||
swap_str = temp;
|
||||
if (ext + swap > total_size) {
|
||||
LOGERR("EXT + Swap size is larger than sdcard size.\n");
|
||||
gui_err("ext_swap_size=EXT + Swap size is larger than sdcard size.");
|
||||
return false;
|
||||
}
|
||||
gui_print("Removing partition table...\n");
|
||||
gui_msg("remove_part_table=Removing partition table...");
|
||||
Command = "parted -s " + Device + " mklabel msdos";
|
||||
LOGINFO("Command is: '%s'\n", Command.c_str());
|
||||
if (TWFunc::Exec_Cmd(Command) != 0) {
|
||||
LOGERR("Unable to remove partition table.\n");
|
||||
gui_err("unable_rm_part=Unable to remove partition table.");
|
||||
Update_System_Details();
|
||||
return false;
|
||||
}
|
||||
gui_print("Creating FAT32 partition...\n");
|
||||
gui_msg(Msg("create_part=Creating {1} partition...")("FAT32"));
|
||||
Command = "parted " + Device + " mkpartfs primary fat32 0 " + fat_str + "MB";
|
||||
LOGINFO("Command is: '%s'\n", Command.c_str());
|
||||
if (TWFunc::Exec_Cmd(Command) != 0) {
|
||||
LOGERR("Unable to create FAT32 partition.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_create_part=Unable to create {1} partition.")("FAT32"));
|
||||
return false;
|
||||
}
|
||||
if (ext > 0) {
|
||||
gui_print("Creating EXT partition...\n");
|
||||
gui_msg(Msg("create_part=Creating {1} partition...")("EXT"));
|
||||
Command = "parted " + Device + " mkpartfs primary ext2 " + fat_str + "MB " + ext_str + "MB";
|
||||
LOGINFO("Command is: '%s'\n", Command.c_str());
|
||||
if (TWFunc::Exec_Cmd(Command) != 0) {
|
||||
LOGERR("Unable to create EXT partition.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_create_part=Unable to create {1} partition.")("EXT"));
|
||||
Update_System_Details();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (swap > 0) {
|
||||
gui_print("Creating swap partition...\n");
|
||||
gui_msg(Msg("create_part=Creating {1} partition...")("swap"));
|
||||
Command = "parted " + Device + " mkpartfs primary linux-swap " + ext_str + "MB " + swap_str + "MB";
|
||||
LOGINFO("Command is: '%s'\n", Command.c_str());
|
||||
if (TWFunc::Exec_Cmd(Command) != 0) {
|
||||
LOGERR("Unable to create swap partition.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_create_part=Unable to create {1} partition.")("swap"));
|
||||
Update_System_Details();
|
||||
return false;
|
||||
}
|
||||
@@ -1815,13 +1817,13 @@ int TWPartitionManager::Partition_SDCard(void) {
|
||||
return false;
|
||||
}
|
||||
Command = "mke2fs -t " + ext_format + " -m 0 " + SDext->Actual_Block_Device;
|
||||
gui_print("Formatting sd-ext as %s...\n", ext_format.c_str());
|
||||
gui_msg(Msg("format_sdext_as=Formatting sd-ext as {1}...")(ext_format));
|
||||
LOGINFO("Formatting sd-ext after partitioning, command: '%s'\n", Command.c_str());
|
||||
TWFunc::Exec_Cmd(Command);
|
||||
}
|
||||
|
||||
Update_System_Details();
|
||||
gui_print("Partitioning complete.\n");
|
||||
gui_msg("part_complete=Partitioning complete.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1900,7 +1902,7 @@ void TWPartitionManager::Get_Partition_List(string ListType, std::vector<Partiti
|
||||
Partition_List->push_back(part);
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for restore.\n", restore_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "restore_unable_locate=Unable to locate '{1}' partition for restoring.")(restore_path));
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
end_pos = Restore_List.find(";", start_pos);
|
||||
@@ -1908,7 +1910,7 @@ void TWPartitionManager::Get_Partition_List(string ListType, std::vector<Partiti
|
||||
}
|
||||
} else if (ListType == "wipe") {
|
||||
struct PartitionList dalvik;
|
||||
dalvik.Display_Name = "Dalvik Cache";
|
||||
dalvik.Display_Name = gui_parse_text("{@dalvik}");
|
||||
dalvik.Mount_Point = "DALVIK";
|
||||
dalvik.selected = 0;
|
||||
Partition_List->push_back(dalvik);
|
||||
@@ -1961,7 +1963,7 @@ void TWPartitionManager::Output_Storage_Fstab(void) {
|
||||
FILE *fp = fopen("/cache/recovery/storage.fstab", "w");
|
||||
|
||||
if (fp == NULL) {
|
||||
LOGERR("Unable to open '/cache/recovery/storage.fstab'.\n");
|
||||
gui_msg(Msg(msg::kError, "unable_to_open=Unable to open '{1}'.")("/cache/recovery/storage.fstab"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1995,7 +1997,7 @@ TWPartition *TWPartitionManager::Get_Default_Storage_Partition()
|
||||
bool TWPartitionManager::Enable_MTP(void) {
|
||||
#ifdef TW_HAS_MTP
|
||||
if (mtppid) {
|
||||
LOGERR("MTP already enabled\n");
|
||||
gui_err("mtp_already_enabled=MTP already enabled");
|
||||
return true;
|
||||
}
|
||||
//Launch MTP Responder
|
||||
@@ -2036,11 +2038,11 @@ bool TWPartitionManager::Enable_MTP(void) {
|
||||
} else {
|
||||
close(mtppipe[0]);
|
||||
close(mtppipe[1]);
|
||||
LOGERR("Failed to enable MTP\n");
|
||||
gui_err("mtp_fail=Failed to enable MTP");
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
LOGERR("MTP support not included\n");
|
||||
gui_err("no_mtp=MTP support not included");
|
||||
#endif
|
||||
DataManager::SetValue("tw_mtp_enabled", 0);
|
||||
return false;
|
||||
@@ -2157,7 +2159,7 @@ bool TWPartitionManager::Add_Remove_MTP_Storage(TWPartition* Part, int message_t
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
LOGERR("MTP support not included\n");
|
||||
gui_err("no_mtp=MTP support not included");
|
||||
DataManager::SetValue("tw_mtp_enabled", 0);
|
||||
return false;
|
||||
#endif
|
||||
@@ -2217,13 +2219,13 @@ bool TWPartitionManager::Flash_Image(string Filename) {
|
||||
string Flash_List, flash_path;
|
||||
size_t start_pos = 0, end_pos = 0;
|
||||
|
||||
gui_print("\n[IMAGE FLASH STARTED]\n\n");
|
||||
gui_print("Image to flash: '%s'\n", Filename.c_str());
|
||||
gui_msg("image_flash_start=[IMAGE FLASH STARTED]");
|
||||
gui_msg(Msg("img_to_flash=Image to flash: '{1}'")(Filename));
|
||||
|
||||
if (!Mount_Current_Storage(true))
|
||||
return false;
|
||||
|
||||
gui_print("Calculating restore details...\n");
|
||||
gui_msg("calc_restore=Calculating restore details...");
|
||||
DataManager::GetValue("tw_flash_partition", Flash_List);
|
||||
if (!Flash_List.empty()) {
|
||||
end_pos = Flash_List.find(";", start_pos);
|
||||
@@ -2233,11 +2235,11 @@ bool TWPartitionManager::Flash_Image(string Filename) {
|
||||
if (flash_part != NULL) {
|
||||
partition_count++;
|
||||
if (partition_count > 1) {
|
||||
LOGERR("Too many partitions selected for flashing.\n");
|
||||
gui_err("too_many_flash=Too many partitions selected for flashing.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LOGERR("Unable to locate '%s' partition for flashing (flash list).\n", flash_path.c_str());
|
||||
gui_msg(Msg(msg::kError, "flash_unable_locate=Unable to locate '{1}' partition for flashing.")(flash_path));
|
||||
return false;
|
||||
}
|
||||
start_pos = end_pos + 1;
|
||||
@@ -2246,7 +2248,7 @@ bool TWPartitionManager::Flash_Image(string Filename) {
|
||||
}
|
||||
|
||||
if (partition_count == 0) {
|
||||
LOGERR("No partitions selected for flashing.\n");
|
||||
gui_err("no_part_flash=No partitions selected for flashing.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2255,9 +2257,56 @@ bool TWPartitionManager::Flash_Image(string Filename) {
|
||||
if (!flash_part->Flash_Image(Filename))
|
||||
return false;
|
||||
} else {
|
||||
LOGERR("Invalid flash partition specified.\n");
|
||||
gui_err("invalid_flash=Invalid flash partition specified.");
|
||||
return false;
|
||||
}
|
||||
gui_print_color("highlight", "[IMAGE FLASH COMPLETED]\n\n");
|
||||
gui_highlight("flash_done=IMAGE FLASH COMPLETED]");
|
||||
return true;
|
||||
}
|
||||
|
||||
void TWPartitionManager::Translate_Partition(const char* path, const char* resource_name, const char* default_value) {
|
||||
TWPartition* part = PartitionManager.Find_Partition_By_Path(path);
|
||||
if (part) {
|
||||
part->Display_Name = gui_lookup(resource_name, default_value);
|
||||
part->Backup_Display_Name = part->Display_Name;
|
||||
}
|
||||
}
|
||||
|
||||
void TWPartitionManager::Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value) {
|
||||
TWPartition* part = PartitionManager.Find_Partition_By_Path(path);
|
||||
if (part) {
|
||||
part->Display_Name = gui_lookup(resource_name, default_value);
|
||||
part->Backup_Display_Name = part->Display_Name;
|
||||
if (part->Is_Storage)
|
||||
part->Storage_Name = gui_lookup(storage_resource_name, storage_default_value);
|
||||
}
|
||||
}
|
||||
|
||||
void TWPartitionManager::Translate_Partition_Display_Names() {
|
||||
Translate_Partition("/system", "system", "System");
|
||||
Translate_Partition("/system_image", "system_image", "System Image");
|
||||
Translate_Partition("/vendor", "vendor", "Vendor");
|
||||
Translate_Partition("/vendor_image", "vendor_image", "Vendor Image");
|
||||
Translate_Partition("/cache", "cache", "Cache");
|
||||
Translate_Partition("/data", "data", "Data", "internal", "Internal Storage");
|
||||
Translate_Partition("/boot", "boot", "Boot");
|
||||
Translate_Partition("/recovery", "recovery", "Recovery");
|
||||
if (!datamedia) {
|
||||
Translate_Partition("/sdcard", "sdcard", "SDCard", "sdcard", "SDCard");
|
||||
Translate_Partition("/internal_sd", "sdcard", "SDCard", "sdcard", "SDCard");
|
||||
Translate_Partition("/internal_sdcard", "sdcard", "SDCard", "sdcard", "SDCard");
|
||||
Translate_Partition("/emmc", "sdcard", "SDCard", "sdcard", "SDCard");
|
||||
}
|
||||
Translate_Partition("/external_sd", "microsd", "Micro SDCard", "microsd", "Micro SDCard");
|
||||
Translate_Partition("/external_sdcard", "microsd", "Micro SDCard", "microsd", "Micro SDCard");
|
||||
Translate_Partition("/usb-otg", "usbotg", "USB OTG", "usbotg", "USB OTG");
|
||||
Translate_Partition("/sd-ext", "sdext", "SD-EXT");
|
||||
|
||||
// Android secure is a special case
|
||||
TWPartition* part = PartitionManager.Find_Partition_By_Path("/and-sec");
|
||||
if (part)
|
||||
part->Backup_Display_Name = gui_lookup("android_secure", "Android Secure");
|
||||
|
||||
// This updates the text on all of the storage selection buttons in the GUI
|
||||
DataManager::SetBackupFolder();
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ friend class TWPartitionManager;
|
||||
friend class DataManager;
|
||||
friend class GUIPartitionList;
|
||||
friend class GUIAction;
|
||||
friend class PageManager;
|
||||
};
|
||||
|
||||
class TWPartitionManager
|
||||
@@ -233,6 +234,9 @@ public:
|
||||
bool Remove_MTP_Storage(string Mount_Point); // Adds or removes an MTP Storage partition
|
||||
bool Remove_MTP_Storage(unsigned int Storage_ID); // Adds or removes an MTP Storage partition
|
||||
bool Flash_Image(string Filename); // Flashes an image to a selected partition from the partition list
|
||||
void Translate_Partition(const char* path, const char* resource_name, const char* default_value);
|
||||
void Translate_Partition(const char* path, const char* resource_name, const char* default_value, const char* storage_resource_name, const char* storage_default_value);
|
||||
void Translate_Partition_Display_Names(); // Updates display names based on translations
|
||||
|
||||
TWAtomicInt stop_backup;
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "partitions.hpp"
|
||||
#include "twrpDigest.hpp"
|
||||
#include "twrp-functions.hpp"
|
||||
#include "gui/gui.hpp"
|
||||
extern "C" {
|
||||
#include "gui/gui.h"
|
||||
#include "legacy_property_service.h"
|
||||
@@ -102,7 +103,7 @@ static int Run_Update_Binary(const char *path, ZipArchive *Zip, int* wipe_cache)
|
||||
|
||||
if (binary_location == NULL) {
|
||||
mzCloseZipArchive(Zip);
|
||||
LOGERR("Could not find '" ASSUMED_UPDATE_BINARY_NAME "' in the zip file.\n");
|
||||
gui_msg(Msg(msg::kError, "no_updater_binary=Could not find '{1}' in the zip file.")(ASSUMED_UPDATE_BINARY_NAME));
|
||||
return INSTALL_CORRUPT;
|
||||
}
|
||||
|
||||
@@ -257,9 +258,9 @@ extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
|
||||
return INSTALL_CORRUPT;
|
||||
}
|
||||
|
||||
gui_print("Installing '%s'...\n", path);
|
||||
gui_msg(Msg("installing_zip=Installing zip file '{1}'")(path));
|
||||
if (strlen(path) < 9 || strncmp(path, "/sideload", 9) != 0) {
|
||||
gui_print("Checking for MD5 file...\n");
|
||||
gui_msg("check_for_md5=Checking for MD5 file...");
|
||||
twrpDigest md5sum;
|
||||
md5sum.setfn(path);
|
||||
int md5_return = md5sum.verify_md5digest();
|
||||
@@ -276,24 +277,25 @@ extern "C" int TWinstall_zip(const char* path, int* wipe_cache) {
|
||||
|
||||
MemMapping map;
|
||||
if (sysMapFile(path, &map) != 0) {
|
||||
LOGERR("Failed to sysMapFile '%s'\n", path);
|
||||
gui_msg(Msg(msg::kError, "fail_sysmap=Failed to map file '{1}'")(path));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (zip_verify) {
|
||||
gui_print("Verifying zip signature...\n");
|
||||
gui_msg("verify_zip_sig=Verifying zip signature...");
|
||||
ret_val = verify_file(map.addr, map.length);
|
||||
if (ret_val != VERIFY_SUCCESS) {
|
||||
LOGERR("Zip signature verification failed: %i\n", ret_val);
|
||||
LOGINFO("Zip signature verification failed: %i\n", ret_val);
|
||||
gui_err("verify_zip_fail=Zip signature verification failed!");
|
||||
sysReleaseMap(&map);
|
||||
return -1;
|
||||
} else {
|
||||
gui_print("Zip signature verified successfully.\n");
|
||||
gui_msg("verify_zip_done=Zip signature verified successfully.");
|
||||
}
|
||||
}
|
||||
ret_val = mzOpenZipArchive(map.addr, map.length, &Zip);
|
||||
if (ret_val != 0) {
|
||||
LOGERR("Zip file is corrupt!\n", path);
|
||||
gui_err("zip_corrupt=Zip file is corrupt!");
|
||||
sysReleaseMap(&map);
|
||||
return INSTALL_CORRUPT;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
21
twrp.cpp
21
twrp.cpp
@@ -15,12 +15,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include "gui/twmsg.h"
|
||||
|
||||
#include "cutils/properties.h"
|
||||
extern "C" {
|
||||
@@ -37,6 +38,9 @@ extern "C" {
|
||||
#include "gui/gui.h"
|
||||
#include "set_metadata.h"
|
||||
}
|
||||
#include "gui/gui.hpp"
|
||||
#include "gui/pages.hpp"
|
||||
#include "gui/objects.hpp"
|
||||
#include "twcommon.h"
|
||||
#include "twrp-functions.hpp"
|
||||
#include "data.hpp"
|
||||
@@ -162,14 +166,14 @@ int main(int argc, char **argv) {
|
||||
lgetfilecon("/sbin/teamwin", &contexts);
|
||||
}
|
||||
if (!contexts) {
|
||||
gui_print_color("warning", "Kernel does not have support for reading SELinux contexts.\n");
|
||||
gui_warn("no_kernel_selinux=Kernel does not have support for reading SELinux contexts.");
|
||||
} else {
|
||||
free(contexts);
|
||||
gui_print("Full SELinux support is present.\n");
|
||||
gui_msg("full_selinux=Full SELinux support is present.");
|
||||
}
|
||||
}
|
||||
#else
|
||||
gui_print_color("warning", "No SELinux support (no libselinux).\n");
|
||||
gui_warn("no_selinux=No SELinux support (no libselinux).");
|
||||
#endif
|
||||
|
||||
PartitionManager.Mount_By_Path("/cache", true);
|
||||
@@ -307,6 +311,8 @@ int main(int argc, char **argv) {
|
||||
DataManager::SetValue("tw_mtp_enabled", 1);
|
||||
#endif
|
||||
DataManager::ReadSettingsFile();
|
||||
PageManager::LoadLanguage(DataManager::GetStrValue("tw_language"));
|
||||
GUIConsole::Translate_Now();
|
||||
|
||||
// Fixup the RTC clock on devices which require it
|
||||
if(crash_counter == 0)
|
||||
@@ -328,13 +334,13 @@ int main(int argc, char **argv) {
|
||||
if (!PartitionManager.Enable_MTP())
|
||||
PartitionManager.Disable_MTP();
|
||||
else
|
||||
gui_print("MTP Enabled\n");
|
||||
gui_msg("mtp_enabled=MTP Enabled");
|
||||
} else {
|
||||
PartitionManager.Disable_MTP();
|
||||
}
|
||||
property_set("mtp.crash_check", "0");
|
||||
} else {
|
||||
gui_print_color("warning", "MTP Crashed, not starting MTP on boot.\n");
|
||||
gui_warn("mtp_crash=MTP Crashed, not starting MTP on boot.");
|
||||
DataManager::SetValue("tw_mtp_enabled", 0);
|
||||
PartitionManager.Disable_MTP();
|
||||
}
|
||||
@@ -367,7 +373,6 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Launch the main GUI
|
||||
gui_start();
|
||||
|
||||
@@ -391,7 +396,7 @@ int main(int argc, char **argv) {
|
||||
// Reboot
|
||||
TWFunc::Update_Intent_File(Reboot_Value);
|
||||
TWFunc::Update_Log_File();
|
||||
gui_print("Rebooting...\n");
|
||||
gui_msg(Msg("rebooting=Rebooting..."));
|
||||
string Reboot_Arg;
|
||||
DataManager::GetValue("tw_reboot_arg", Reboot_Arg);
|
||||
if (Reboot_Arg == "recovery")
|
||||
|
||||
@@ -30,6 +30,7 @@ extern "C" {
|
||||
#include <algorithm>
|
||||
#include "twrpDU.hpp"
|
||||
#include "twrp-functions.hpp"
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -73,8 +74,7 @@ uint64_t twrpDU::Get_Folder_Size(const string& Path) {
|
||||
|
||||
d = opendir(Path.c_str());
|
||||
if (d == NULL) {
|
||||
LOGERR("error opening '%s'\n", Path.c_str());
|
||||
LOGERR("error: %s\n", strerror(errno));
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,8 @@ uint64_t twrpDU::Get_Folder_Size(const string& Path) {
|
||||
FullPath = Path + "/";
|
||||
FullPath += de->d_name;
|
||||
if (lstat(FullPath.c_str(), &st)) {
|
||||
LOGERR("Unable to stat '%s'\n", FullPath.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(FullPath)(strerror(errno)));
|
||||
LOGINFO("Real error: Unable to stat '%s'\n", FullPath.c_str());
|
||||
continue;
|
||||
}
|
||||
if ((st.st_mode & S_IFDIR) && !check_skip_dirs(FullPath) && de->d_type != DT_SOCK) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
extern "C"
|
||||
{
|
||||
#include "digest/md5.h"
|
||||
#include "gui/gui.h"
|
||||
#include "libcrecovery/common.h"
|
||||
}
|
||||
|
||||
@@ -41,6 +40,7 @@ extern "C"
|
||||
#include "twrp-functions.hpp"
|
||||
#include "twrpDigest.hpp"
|
||||
#include "set_metadata.h"
|
||||
#include "gui/gui.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -103,10 +103,10 @@ int twrpDigest::read_md5digest(void) {
|
||||
}
|
||||
|
||||
if (!foundMd5File) {
|
||||
gui_print("Skipping MD5 check: no MD5 file found\n");
|
||||
gui_msg("no_md5=Skipping MD5 check: no MD5 file found");
|
||||
return -1;
|
||||
} else if (TWFunc::read_file(md5file, line) != 0) {
|
||||
gui_print("Skipping MD5 check: MD5 file unreadable\n");
|
||||
LOGERR("Skipping MD5 check: MD5 file unreadable %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -139,10 +139,10 @@ int twrpDigest::verify_md5digest(void) {
|
||||
md5string += hex;
|
||||
}
|
||||
if (tokens.at(0) != md5string) {
|
||||
LOGERR("MD5 does not match\n");
|
||||
gui_err("md5_fail=MD5 does not match");
|
||||
return -2;
|
||||
}
|
||||
|
||||
gui_print("MD5 matched\n");
|
||||
gui_msg("md5_match=MD5 matched");
|
||||
return 0;
|
||||
}
|
||||
|
||||
241
twrpTar.cpp
241
twrpTar.cpp
@@ -45,6 +45,7 @@ extern "C" {
|
||||
#ifndef BUILD_TWRPTAR_MAIN
|
||||
#include "data.hpp"
|
||||
#include "infomanager.hpp"
|
||||
#include "gui/gui.hpp"
|
||||
extern "C" {
|
||||
#include "set_metadata.h"
|
||||
}
|
||||
@@ -97,11 +98,13 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
file_count = 0;
|
||||
|
||||
if (pipe(progress_pipe) < 0) {
|
||||
LOGERR("Error creating progress tracking pipe\n");
|
||||
LOGINFO("Error creating progress tracking pipe\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
if ((tar_fork_pid = fork()) == -1) {
|
||||
LOGINFO("create tar failed to fork.\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[0]);
|
||||
close(progress_pipe[1]);
|
||||
return -1;
|
||||
@@ -139,7 +142,7 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
|
||||
d = opendir(tardir.c_str());
|
||||
if (d == NULL) {
|
||||
LOGERR("error opening '%s'\n", tardir.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tardir)(strerror(errno)));
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -154,7 +157,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
if (userdata_encryption && ((item_len >= 3 && strncmp(de->d_name, "app", 3) == 0) || (item_len >= 6 && strncmp(de->d_name, "dalvik", 6) == 0))) {
|
||||
ret = Generate_TarList(FileName, &RegularList, &target_size, ®ular_thread_id);
|
||||
if (ret < 0) {
|
||||
LOGERR("Error in Generate_TarList with regular list!\n");
|
||||
LOGINFO("Error in Generate_TarList with regular list!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
closedir(d);
|
||||
close(progress_pipe_fd);
|
||||
close(progress_pipe[1]);
|
||||
@@ -186,7 +190,7 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
|
||||
d = opendir(tardir.c_str());
|
||||
if (d == NULL) {
|
||||
LOGERR("error opening '%s'\n", tardir.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tardir)(strerror(errno)));
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -204,7 +208,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
FileName = tardir + "/" + de->d_name;
|
||||
ret = Generate_TarList(FileName, &EncryptList, &target_size, &enc_thread_id);
|
||||
if (ret < 0) {
|
||||
LOGERR("Error in Generate_TarList with encrypted list!\n");
|
||||
LOGINFO("Error in Generate_TarList with encrypted list!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
closedir(d);
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
@@ -223,12 +228,13 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
}
|
||||
closedir(d);
|
||||
if (enc_thread_id != core_count) {
|
||||
LOGERR("Error dividing up threads for encryption, %u threads for %u cores!\n", enc_thread_id, core_count);
|
||||
LOGINFO("Error dividing up threads for encryption, %u threads for %u cores!\n", enc_thread_id, core_count);
|
||||
if (enc_thread_id > core_count) {
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
} else {
|
||||
LOGERR("Continuining anyway.");
|
||||
LOGINFO("Continuining anyway.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,24 +255,28 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
reg.progress_pipe_fd = progress_pipe_fd;
|
||||
LOGINFO("Creating unencrypted backup...\n");
|
||||
if (createList((void*)®) != 0) {
|
||||
LOGERR("Error creating unencrypted backup.\n");
|
||||
LOGINFO("Error creating unencrypted backup.\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (pthread_attr_init(&tattr)) {
|
||||
LOGERR("Unable to pthread_attr_init\n");
|
||||
LOGINFO("Unable to pthread_attr_init\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE)) {
|
||||
LOGERR("Error setting pthread_attr_setdetachstate\n");
|
||||
LOGINFO("Error setting pthread_attr_setdetachstate\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
if (pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM)) {
|
||||
LOGERR("Error setting pthread_attr_setscope\n");
|
||||
LOGINFO("Error setting pthread_attr_setscope\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -291,7 +301,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
if (ret) {
|
||||
LOGINFO("Unable to create %i thread for encryption! %i\nContinuing in same thread (backup will be slower).\n", i, ret);
|
||||
if (createList((void*)&enc[i]) != 0) {
|
||||
LOGERR("Error creating encrypted backup %i.\n", i);
|
||||
LOGINFO("Error creating encrypted backup %i.\n", i);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
} else {
|
||||
@@ -301,12 +312,13 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
usleep(100000); // Need a short delay before starting the next thread or the threads will never finish for some reason.
|
||||
}
|
||||
if (pthread_attr_destroy(&tattr)) {
|
||||
LOGERR("Failed to pthread_attr_destroy\n");
|
||||
LOGINFO("Failed to pthread_attr_destroy\n");
|
||||
}
|
||||
for (i = start_thread_id; i <= core_count; i++) {
|
||||
if (enc[i].thread_id == i) {
|
||||
if (pthread_join(enc_thread[i], &thread_return)) {
|
||||
LOGERR("Error joining thread %i\n", i);
|
||||
LOGINFO("Error joining thread %i\n", i);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
} else {
|
||||
@@ -314,7 +326,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
ret = (int)(intptr_t)thread_return;
|
||||
if (ret != 0) {
|
||||
thread_error = 1;
|
||||
LOGERR("Thread %i returned an error %i.\n", i, ret);
|
||||
LOGINFO("Thread %i returned an error %i.\n", i, ret);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -324,7 +337,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
}
|
||||
}
|
||||
if (thread_error) {
|
||||
LOGERR("Error returned by one or more threads.\n");
|
||||
LOGINFO("Error returned by one or more threads.\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -342,7 +356,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
// Generate list of files to back up
|
||||
ret = Generate_TarList(tardir, &FileList, &target_size, &thread_id);
|
||||
if (ret < 0) {
|
||||
LOGERR("Error in Generate_TarList!\n");
|
||||
LOGINFO("Error in Generate_TarList!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -356,7 +371,7 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
reg.setsize(Total_Backup_Size);
|
||||
reg.progress_pipe_fd = progress_pipe_fd;
|
||||
if (Total_Backup_Size > MAX_ARCHIVE_SIZE) {
|
||||
gui_print("Breaking backup file into multiple archives...\n");
|
||||
gui_msg("split_backup=Breaking backup file into multiple archives...");
|
||||
reg.split_archives = 1;
|
||||
} else {
|
||||
reg.split_archives = 0;
|
||||
@@ -365,7 +380,7 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
write(progress_pipe_fd, &file_count, sizeof(file_count));
|
||||
write(progress_pipe_fd, &Total_Backup_Size, sizeof(Total_Backup_Size));
|
||||
if (createList((void*)®) != 0) {
|
||||
LOGERR("Error creating backup.\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(progress_pipe[1]);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -381,6 +396,8 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
char size_progress[1024];
|
||||
files_backup = 0;
|
||||
size_backup = 0;
|
||||
string file_prog = gui_lookup("file_progress", "%llu of %llu files, %i%%");
|
||||
string size_prog = gui_lookup("size_progress", "%lluMB of %lluMB, %i%%");
|
||||
|
||||
fork_pid = tar_fork_pid;
|
||||
|
||||
@@ -402,11 +419,11 @@ int twrpTar::createTarFork(const unsigned long long *overall_size, const unsigne
|
||||
files_backup++;
|
||||
size_backup += fs;
|
||||
display_percent = (double)(files_backup) / (double)(file_count) * 100;
|
||||
sprintf(file_progress, "%llu of %llu files, %i%%", files_backup, file_count, (int)(display_percent));
|
||||
sprintf(file_progress, file_prog.c_str(), files_backup, file_count, (int)(display_percent));
|
||||
#ifndef BUILD_TWRPTAR_MAIN
|
||||
DataManager::SetValue("tw_file_progress", file_progress);
|
||||
display_percent = (double)(size_backup + *other_backups_size) / (double)(*overall_size) * 100;
|
||||
sprintf(size_progress, "%lluMB of %lluMB, %i%%", (size_backup + *other_backups_size) / 1048576, *overall_size / 1048576, (int)(display_percent));
|
||||
sprintf(size_progress, size_prog.c_str(), (size_backup + *other_backups_size) / 1048576, *overall_size / 1048576, (int)(display_percent));
|
||||
DataManager::SetValue("tw_size_progress", size_progress);
|
||||
progress_percent = (display_percent / 100);
|
||||
DataManager::SetProgress((float)(progress_percent));
|
||||
@@ -443,7 +460,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
int progress_pipe[2], ret;
|
||||
|
||||
if (pipe(progress_pipe) < 0) {
|
||||
LOGERR("Error creating progress tracking pipe\n");
|
||||
LOGINFO("Error creating progress tracking pipe\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -475,7 +493,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
temp = basefn + "%i%02i";
|
||||
tarfn += "000";
|
||||
if (!TWFunc::Path_Exists(tarfn)) {
|
||||
LOGERR("Unable to locate '%s' or '%s'\n", basefn.c_str(), tarfn.c_str());
|
||||
LOGINFO("Unable to locate '%s' or '%s'\n", basefn.c_str(), tarfn.c_str());
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -485,7 +504,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
tars[0].thread_id = 0;
|
||||
tars[0].progress_pipe_fd = progress_pipe_fd;
|
||||
if (extractMulti((void*)&tars[0]) != 0) {
|
||||
LOGERR("Error extracting split archive.\n");
|
||||
LOGINFO("Error extracting split archive.\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -494,17 +514,20 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
}
|
||||
// Start threading encrypted restores
|
||||
if (pthread_attr_init(&tattr)) {
|
||||
LOGERR("Unable to pthread_attr_init\n");
|
||||
LOGINFO("Unable to pthread_attr_init\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE)) {
|
||||
LOGERR("Error setting pthread_attr_setdetachstate\n");
|
||||
LOGINFO("Error setting pthread_attr_setdetachstate\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
if (pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM)) {
|
||||
LOGERR("Error setting pthread_attr_setscope\n");
|
||||
LOGINFO("Error setting pthread_attr_setscope\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -526,7 +549,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
if (ret) {
|
||||
LOGINFO("Unable to create %i thread for extraction! %i\nContinuing in same thread (restore will be slower).\n", i, ret);
|
||||
if (extractMulti((void*)&tars[i]) != 0) {
|
||||
LOGERR("Error extracting backup in thread %i.\n", i);
|
||||
LOGINFO("Error extracting backup in thread %i.\n", i);
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
} else {
|
||||
@@ -541,7 +565,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
for (i = start_thread_id; i < thread_count + start_thread_id; i++) {
|
||||
if (tars[i].thread_id == i) {
|
||||
if (pthread_join(tar_thread[i], &thread_return)) {
|
||||
LOGERR("Error joining thread %i\n", i);
|
||||
LOGINFO("Error joining thread %i\n", i);
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
} else {
|
||||
@@ -549,7 +574,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
ret = (int)(intptr_t)thread_return;
|
||||
if (ret != 0) {
|
||||
thread_error = 1;
|
||||
LOGERR("Thread %i returned an error %i.\n", i, ret);
|
||||
LOGINFO("Thread %i returned an error %i.\n", i, ret);
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -559,7 +585,8 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
}
|
||||
}
|
||||
if (thread_error) {
|
||||
LOGERR("Error returned by one or more threads.\n");
|
||||
LOGINFO("Error returned by one or more threads.\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(progress_pipe_fd);
|
||||
_exit(-1);
|
||||
}
|
||||
@@ -574,6 +601,7 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
double display_percent, progress_percent;
|
||||
char size_progress[1024];
|
||||
size_backup = 0;
|
||||
string size_prog = gui_lookup("size_progress", "%lluMB of %lluMB, %i%%");
|
||||
|
||||
// Parent closes output side
|
||||
close(progress_pipe[1]);
|
||||
@@ -582,7 +610,7 @@ int twrpTar::extractTarFork(const unsigned long long *overall_size, unsigned lon
|
||||
while (read(progress_pipe[0], &fs, sizeof(fs)) > 0) {
|
||||
size_backup += fs;
|
||||
display_percent = (double)(size_backup + *other_backups_size) / (double)(*overall_size) * 100;
|
||||
sprintf(size_progress, "%lluMB of %lluMB, %i%%", (size_backup + *other_backups_size) / 1048576, *overall_size / 1048576, (int)(display_percent));
|
||||
sprintf(size_progress, size_prog.c_str(), (size_backup + *other_backups_size) / 1048576, *overall_size / 1048576, (int)(display_percent));
|
||||
progress_percent = (display_percent / 100);
|
||||
#ifndef BUILD_TWRPTAR_MAIN
|
||||
DataManager::SetValue("tw_size_progress", size_progress);
|
||||
@@ -621,7 +649,7 @@ int twrpTar::Generate_TarList(string Path, std::vector<TarListStruct> *TarList,
|
||||
|
||||
d = opendir(Path.c_str());
|
||||
if (d == NULL) {
|
||||
LOGERR("Error opening '%s' -- error: %s\n", Path.c_str(), strerror(errno));
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(Path)(strerror(errno)));
|
||||
closedir(d);
|
||||
return -1;
|
||||
}
|
||||
@@ -660,11 +688,13 @@ int twrpTar::extractTar() {
|
||||
if (openTar() == -1)
|
||||
return -1;
|
||||
if (tar_extract_all(t, charRootDir, &progress_pipe_fd) != 0) {
|
||||
LOGERR("Unable to extract tar archive '%s'\n", tarfn.c_str());
|
||||
LOGINFO("Unable to extract tar archive '%s'\n", tarfn.c_str());
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
if (tar_close(t) != 0) {
|
||||
LOGERR("Unable to close tar file\n");
|
||||
LOGINFO("Unable to close tar file\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -681,11 +711,12 @@ int twrpTar::extract() {
|
||||
} else if (Archive_Current_Type == 2) {
|
||||
int ret = TWFunc::Try_Decrypting_File(tarfn, password);
|
||||
if (ret < 1) {
|
||||
LOGERR("Failed to decrypt tar file '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_decrypt_tar=Failed to decrypt tar file '{1}'")(tarfn));
|
||||
return -1;
|
||||
}
|
||||
if (ret == 1) {
|
||||
LOGERR("Decrypted file is not in tar format.\n");
|
||||
LOGINFO("Decrypted file is not in tar format.\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
if (ret == 3) {
|
||||
@@ -720,7 +751,8 @@ int twrpTar::tarList(std::vector<TarListStruct> *TarList, unsigned thread_id) {
|
||||
}
|
||||
LOGINFO("Creating tar file '%s'\n", tarfn.c_str());
|
||||
if (createTar() != 0) {
|
||||
LOGERR("Error creating tar '%s' for thread %i\n", tarfn.c_str(), thread_id);
|
||||
LOGINFO("Error creating tar '%s' for thread %i\n", tarfn.c_str(), thread_id);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -2;
|
||||
}
|
||||
Archive_Current_Size = 0;
|
||||
@@ -733,19 +765,22 @@ int twrpTar::tarList(std::vector<TarListStruct> *TarList, unsigned thread_id) {
|
||||
fs = (unsigned long long)(st.st_size);
|
||||
if (split_archives && Archive_Current_Size + fs > MAX_ARCHIVE_SIZE) {
|
||||
if (closeTar() != 0) {
|
||||
LOGERR("Error closing '%s' on thread %i\n", tarfn.c_str(), thread_id);
|
||||
LOGINFO("Error closing '%s' on thread %i\n", tarfn.c_str(), thread_id);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -3;
|
||||
}
|
||||
archive_count++;
|
||||
gui_print("Splitting thread ID %i into archive %i\n", thread_id, archive_count + 1);
|
||||
gui_msg(Msg("split_thread=Splitting thread ID {1} into archive {2}")(thread_id)(archive_count + 1));
|
||||
if (archive_count > 99) {
|
||||
LOGERR("Too many archives for thread %i\n", thread_id);
|
||||
LOGINFO("Too many archives for thread %i\n", thread_id);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -4;
|
||||
}
|
||||
sprintf(actual_filename, temp.c_str(), thread_id, archive_count);
|
||||
tarfn = actual_filename;
|
||||
if (createTar() != 0) {
|
||||
LOGERR("Error creating tar '%s' for thread %i\n", tarfn.c_str(), thread_id);
|
||||
LOGINFO("Error creating tar '%s' for thread %i\n", tarfn.c_str(), thread_id);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -2;
|
||||
}
|
||||
Archive_Current_Size = 0;
|
||||
@@ -755,14 +790,16 @@ int twrpTar::tarList(std::vector<TarListStruct> *TarList, unsigned thread_id) {
|
||||
}
|
||||
LOGINFO("addFile '%s' including root: %i\n", buf, include_root_dir);
|
||||
if (addFile(buf, include_root_dir) != 0) {
|
||||
LOGERR("Error adding file '%s' to '%s'\n", buf, tarfn.c_str());
|
||||
LOGINFO("Error adding file '%s' to '%s'\n", buf, tarfn.c_str());
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (closeTar() != 0) {
|
||||
LOGERR("Error closing '%s' on thread %i\n", tarfn.c_str(), thread_id);
|
||||
LOGINFO("Error closing '%s' on thread %i\n", tarfn.c_str(), thread_id);
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -3;
|
||||
}
|
||||
LOGINFO("Thread id %i tarList done, %i archives.\n", thread_id, archive_count);
|
||||
@@ -834,16 +871,18 @@ int twrpTar::createTar() {
|
||||
int i, pipes[4];
|
||||
|
||||
if (pipe(pipes) < 0) {
|
||||
LOGERR("Error creating first pipe\n");
|
||||
LOGINFO("Error creating first pipe\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
if (pipe(pipes + 2) < 0) {
|
||||
LOGERR("Error creating second pipe\n");
|
||||
LOGINFO("Error creating second pipe\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (output_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
for (i = 0; i < 4; i++)
|
||||
close(pipes[i]); // close all
|
||||
return -1;
|
||||
@@ -851,7 +890,8 @@ int twrpTar::createTar() {
|
||||
pigz_pid = fork();
|
||||
|
||||
if (pigz_pid < 0) {
|
||||
LOGERR("pigz fork() failed\n");
|
||||
LOGINFO("pigz fork() failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
for (i = 0; i < 4; i++)
|
||||
close(pipes[i]); // close all
|
||||
@@ -865,7 +905,8 @@ int twrpTar::createTar() {
|
||||
close(1);
|
||||
dup2(pipes[3], 1);
|
||||
if (execlp("pigz", "pigz", "-", NULL) < 0) {
|
||||
LOGERR("execlp pigz ERROR!\n");
|
||||
LOGINFO("execlp pigz ERROR!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
close(pipes[0]);
|
||||
close(pipes[3]);
|
||||
@@ -876,7 +917,8 @@ int twrpTar::createTar() {
|
||||
oaes_pid = fork();
|
||||
|
||||
if (oaes_pid < 0) {
|
||||
LOGERR("openaes fork() failed\n");
|
||||
LOGINFO("openaes fork() failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
for (i = 0; i < 4; i++)
|
||||
close(pipes[i]); // close all
|
||||
@@ -891,7 +933,8 @@ int twrpTar::createTar() {
|
||||
close(1);
|
||||
dup2(output_fd, 1);
|
||||
if (execlp("openaes", "openaes", "enc", "--key", password.c_str(), NULL) < 0) {
|
||||
LOGERR("execlp openaes ERROR!\n");
|
||||
LOGINFO("execlp openaes ERROR!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(pipes[2]);
|
||||
close(output_fd);
|
||||
_exit(-1);
|
||||
@@ -904,7 +947,8 @@ int twrpTar::createTar() {
|
||||
fd = pipes[1];
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -917,20 +961,22 @@ int twrpTar::createTar() {
|
||||
int pigzfd[2];
|
||||
int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (output_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
close(pigzfd[0]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pipe(pigzfd) < 0) {
|
||||
LOGERR("Error creating pipe\n");
|
||||
LOGINFO("Error creating pipe\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
return -1;
|
||||
}
|
||||
pigz_pid = fork();
|
||||
|
||||
if (pigz_pid < 0) {
|
||||
LOGERR("fork() failed\n");
|
||||
LOGINFO("fork() failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
close(pigzfd[0]);
|
||||
close(pigzfd[1]);
|
||||
@@ -941,7 +987,8 @@ int twrpTar::createTar() {
|
||||
dup2(pigzfd[0], 0); // remap stdin
|
||||
dup2(output_fd, 1); // remap stdout to output file
|
||||
if (execlp("pigz", "pigz", "-", NULL) < 0) {
|
||||
LOGERR("execlp pigz ERROR!\n");
|
||||
LOGINFO("execlp pigz ERROR!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
close(pigzfd[0]);
|
||||
_exit(-1);
|
||||
@@ -952,7 +999,8 @@ int twrpTar::createTar() {
|
||||
fd = pigzfd[1]; // copy parent output
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -963,18 +1011,20 @@ int twrpTar::createTar() {
|
||||
int oaesfd[2];
|
||||
int output_fd = open(tarfn.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
|
||||
if (output_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
if (pipe(oaesfd) < 0) {
|
||||
LOGERR("Error creating pipe\n");
|
||||
LOGINFO("Error creating pipe\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
return -1;
|
||||
}
|
||||
oaes_pid = fork();
|
||||
|
||||
if (oaes_pid < 0) {
|
||||
LOGERR("fork() failed\n");
|
||||
LOGINFO("fork() failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
close(oaesfd[0]);
|
||||
close(oaesfd[1]);
|
||||
@@ -985,7 +1035,8 @@ int twrpTar::createTar() {
|
||||
dup2(oaesfd[0], 0); // remap stdin
|
||||
dup2(output_fd, 1); // remap stdout to output file
|
||||
if (execlp("openaes", "openaes", "enc", "--key", password.c_str(), NULL) < 0) {
|
||||
LOGERR("execlp openaes ERROR!\n");
|
||||
LOGINFO("execlp openaes ERROR!\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
close(output_fd);
|
||||
close(oaesfd[0]);
|
||||
_exit(-1);
|
||||
@@ -996,7 +1047,8 @@ int twrpTar::createTar() {
|
||||
fd = oaesfd[1]; // copy parent output
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1005,7 +1057,8 @@ int twrpTar::createTar() {
|
||||
// Not compressed or encrypted
|
||||
init_libtar_buffer(0);
|
||||
if (tar_open(&t, charTarFile, &type, O_WRONLY | O_CREAT | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) == -1) {
|
||||
LOGERR("tar_open error opening '%s'\n", tarfn.c_str());
|
||||
LOGINFO("tar_open error opening '%s'\n", tarfn.c_str());
|
||||
gui_err("backup_error=Error creating backup.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1022,17 +1075,19 @@ int twrpTar::openTar() {
|
||||
int i, pipes[4];
|
||||
int input_fd = open(tarfn.c_str(), O_RDONLY | O_LARGEFILE);
|
||||
if (input_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pipe(pipes) < 0) {
|
||||
LOGERR("Error creating first pipe\n");
|
||||
LOGINFO("Error creating first pipe\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
return -1;
|
||||
}
|
||||
if (pipe(pipes + 2) < 0) {
|
||||
LOGERR("Error creating second pipe\n");
|
||||
LOGINFO("Error creating second pipe\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(pipes[0]);
|
||||
close(pipes[1]);
|
||||
close(input_fd);
|
||||
@@ -1041,7 +1096,8 @@ int twrpTar::openTar() {
|
||||
oaes_pid = fork();
|
||||
|
||||
if (oaes_pid < 0) {
|
||||
LOGERR("pigz fork() failed\n");
|
||||
LOGINFO("pigz fork() failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
for (i = 0; i < 4; i++)
|
||||
close(pipes[i]); // close all
|
||||
@@ -1056,7 +1112,8 @@ int twrpTar::openTar() {
|
||||
close(1);
|
||||
dup2(pipes[1], 1);
|
||||
if (execlp("openaes", "openaes", "dec", "--key", password.c_str(), NULL) < 0) {
|
||||
LOGERR("execlp openaes ERROR!\n");
|
||||
LOGINFO("execlp openaes ERROR!\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
close(pipes[1]);
|
||||
_exit(-1);
|
||||
@@ -1066,7 +1123,8 @@ int twrpTar::openTar() {
|
||||
pigz_pid = fork();
|
||||
|
||||
if (pigz_pid < 0) {
|
||||
LOGERR("openaes fork() failed\n");
|
||||
LOGINFO("openaes fork() failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
for (i = 0; i < 4; i++)
|
||||
close(pipes[i]); // close all
|
||||
@@ -1080,7 +1138,8 @@ int twrpTar::openTar() {
|
||||
close(1);
|
||||
dup2(pipes[3], 1);
|
||||
if (execlp("pigz", "pigz", "-d", "-c", NULL) < 0) {
|
||||
LOGERR("execlp pigz ERROR!\n");
|
||||
LOGINFO("execlp pigz ERROR!\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
close(pipes[0]);
|
||||
close(pipes[3]);
|
||||
@@ -1094,7 +1153,8 @@ int twrpTar::openTar() {
|
||||
fd = pipes[2];
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1104,19 +1164,21 @@ int twrpTar::openTar() {
|
||||
int oaesfd[2];
|
||||
int input_fd = open(tarfn.c_str(), O_RDONLY | O_LARGEFILE);
|
||||
if (input_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pipe(oaesfd) < 0) {
|
||||
LOGERR("Error creating pipe\n");
|
||||
LOGINFO("Error creating pipe\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
oaes_pid = fork();
|
||||
if (oaes_pid < 0) {
|
||||
LOGERR("fork() failed\n");
|
||||
LOGINFO("fork() failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
close(oaesfd[0]);
|
||||
close(oaesfd[1]);
|
||||
@@ -1128,7 +1190,8 @@ int twrpTar::openTar() {
|
||||
dup2(oaesfd[1], 1); // remap stdout
|
||||
dup2(input_fd, 0); // remap input fd to stdin
|
||||
if (execlp("openaes", "openaes", "dec", "--key", password.c_str(), NULL) < 0) {
|
||||
LOGERR("execlp openaes ERROR!\n");
|
||||
LOGINFO("execlp openaes ERROR!\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
close(oaesfd[1]);
|
||||
_exit(-1);
|
||||
@@ -1139,7 +1202,8 @@ int twrpTar::openTar() {
|
||||
fd = oaesfd[0]; // copy parent input
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1148,18 +1212,20 @@ int twrpTar::openTar() {
|
||||
int pigzfd[2];
|
||||
int input_fd = open(tarfn.c_str(), O_RDONLY | O_LARGEFILE);
|
||||
if (input_fd < 0) {
|
||||
LOGERR("Failed to open '%s'\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "error_opening_strerr=Error opening: '{1}' ({2})")(tarfn)(strerror(errno)));
|
||||
return -1;
|
||||
}
|
||||
if (pipe(pigzfd) < 0) {
|
||||
LOGERR("Error creating pipe\n");
|
||||
LOGINFO("Error creating pipe\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pigz_pid = fork();
|
||||
if (pigz_pid < 0) {
|
||||
LOGERR("fork() failed\n");
|
||||
LOGINFO("fork() failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
close(input_fd);
|
||||
close(pigzfd[0]);
|
||||
close(pigzfd[1]);
|
||||
@@ -1172,7 +1238,8 @@ int twrpTar::openTar() {
|
||||
if (execlp("pigz", "pigz", "-d", "-c", NULL) < 0) {
|
||||
close(pigzfd[1]);
|
||||
close(input_fd);
|
||||
LOGERR("execlp openaes ERROR!\n");
|
||||
LOGINFO("execlp openaes ERROR!\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
_exit(-1);
|
||||
}
|
||||
} else {
|
||||
@@ -1181,12 +1248,14 @@ int twrpTar::openTar() {
|
||||
fd = pigzfd[0]; // copy parent input
|
||||
if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
close(fd);
|
||||
LOGERR("tar_fdopen failed\n");
|
||||
LOGINFO("tar_fdopen failed\n");
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} else if (tar_open(&t, charTarFile, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TAR_GNU | TAR_STORE_SELINUX) != 0) {
|
||||
LOGERR("Unable to open tar archive '%s'\n", charTarFile);
|
||||
LOGINFO("Unable to open tar archive '%s'\n", charTarFile);
|
||||
gui_err("restore_error=Error during restore process.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -1229,12 +1298,12 @@ int twrpTar::addFile(string fn, bool include_root) {
|
||||
int twrpTar::closeTar() {
|
||||
flush_libtar_buffer(t->fd);
|
||||
if (tar_append_eof(t) != 0) {
|
||||
LOGERR("tar_append_eof(): %s\n", strerror(errno));
|
||||
LOGINFO("tar_append_eof(): %s\n", strerror(errno));
|
||||
tar_close(t);
|
||||
return -1;
|
||||
}
|
||||
if (tar_close(t) != 0) {
|
||||
LOGERR("Unable to close tar archive: '%s'\n", tarfn.c_str());
|
||||
LOGINFO("Unable to close tar archive: '%s'\n", tarfn.c_str());
|
||||
return -1;
|
||||
}
|
||||
if (Archive_Current_Type > 0) {
|
||||
@@ -1253,7 +1322,7 @@ int twrpTar::closeTar() {
|
||||
}
|
||||
}
|
||||
if (TWFunc::Get_File_Size(tarfn) == 0) {
|
||||
LOGERR("Backup file size for '%s' is 0 bytes.\n", tarfn.c_str());
|
||||
gui_msg(Msg(msg::kError, "backup_size=Backup file size for '%s' is 0 bytes.")(tarfn));
|
||||
return -1;
|
||||
}
|
||||
#ifndef BUILD_TWRPTAR_MAIN
|
||||
@@ -1373,7 +1442,7 @@ unsigned long long twrpTar::uncompressedSize(string filename, int *archive_type)
|
||||
int ret = TWFunc::Try_Decrypting_File(filename, password);
|
||||
*archive_type = 2;
|
||||
if (ret < 1) {
|
||||
LOGERR("Failed to decrypt tar file '%s'\n", filename.c_str());
|
||||
gui_msg(Msg(msg::kError, "fail_decrypt_tar=Failed to decrypt tar file '{1}'")(tarfn));
|
||||
total_size = TWFunc::Get_File_Size(filename);
|
||||
} else if (ret == 1) {
|
||||
LOGERR("Decrypted file is not in tar format.\n");
|
||||
|
||||
Reference in New Issue
Block a user