From 19fb79c722622ac4a068e258501ab4b161420cda Mon Sep 17 00:00:00 2001 From: bigbiff bigbiff Date: Mon, 5 Sep 2016 21:04:51 -0400 Subject: ADB Backup: add ability for TWRP GUI to restore Restore adb backup files that TWRP made to your PC. Put files in your backup directory to see them. e.g. /sdcard/TWRP/BACKUPS/ Change-Id: I2c57970d77b64c39a302159041456e761c185259 --- twrp-functions.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'twrp-functions.cpp') diff --git a/twrp-functions.cpp b/twrp-functions.cpp index eabcc53e1..d7c9c2cab 100644 --- a/twrp-functions.cpp +++ b/twrp-functions.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "twrp-functions.hpp" #include "twcommon.h" @@ -857,6 +858,10 @@ void TWFunc::Auto_Generate_Backup_Name() { DataManager::SetValue(TW_BACKUP_NAME, Get_Current_Date()); return; } + else { + //remove periods from build display so it doesn't confuse the extension code + propvalue.erase(remove(propvalue.begin(), propvalue.end(), '.'), propvalue.end()); + } string Backup_Name = Get_Current_Date(); Backup_Name += "_" + propvalue; if (Backup_Name.size() > MAX_BACKUP_NAME_LEN) @@ -1122,4 +1127,23 @@ void TWFunc::copy_kernel_log(string curr_storage) { gui_msg(Msg("copy_kernel_log=Copied kernel log to {1}")(dmesgDst)); tw_set_default_metadata(dmesgDst.c_str()); } + +bool TWFunc::isNumber(string strtocheck) { + int num = 0; + std::istringstream iss(strtocheck); + + if (!(iss >> num).fail()) + return true; + else + return false; +} + +int TWFunc::stream_adb_backup(string &Restore_Name) { + string cmd = "/sbin/bu --twrp stream " + Restore_Name; + LOGINFO("stream_adb_backup: %s\n", cmd.c_str()); + int ret = TWFunc::Exec_Cmd(cmd); + if (ret != 0) + return -1; + return ret; +} #endif // ndef BUILD_TWRPTAR_MAIN -- cgit v1.2.3