Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 6.0 #192

Open
wants to merge 6 commits into
base: android-7.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 4 additions & 9 deletions gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,16 +1737,11 @@ int GUIAction::flashimage(std::string arg __unused)
{
int op_status = 0;

PartitionSettings part_settings;
operation_start("Flash Image");
DataManager::GetValue("tw_zip_location", part_settings.Restore_Name);
DataManager::GetValue("tw_file", part_settings.Backup_FileName);
unsigned long long total_bytes = TWFunc::Get_File_Size(part_settings.Restore_Name + "/" + part_settings.Backup_FileName);
ProgressTracking progress(total_bytes);
part_settings.progress = &progress;
part_settings.adbbackup = false;
part_settings.PM_Method = PM_RESTORE;
if (PartitionManager.Flash_Image(&part_settings))
string path, filename;
DataManager::GetValue("tw_zip_location", path);
DataManager::GetValue("tw_file", filename);
if (PartitionManager.Flash_Image(path, filename))
op_status = 0; // success
else
op_status = 1; // fail
Expand Down
5 changes: 1 addition & 4 deletions openrecoveryscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -840,11 +840,10 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) {
pos = Restore_Name.find_last_of("/");
Backup_FileName = Restore_Name.substr(pos + 1, Restore_Name.size());
part_settings.Part = PartitionManager.Find_Partition_By_Path(path);
part_settings.Restore_Name = path;
part_settings.Backup_Folder = path;
part_settings.partition_count = partition_count;
part_settings.adbbackup = true;
part_settings.adb_compression = twimghdr.compressed;
part_settings.Backup_FileName = Backup_FileName;
part_settings.PM_Method = PM_RESTORE;
ProgressTracking progress(part_settings.total_restore_size);
part_settings.progress = &progress;
Expand All @@ -871,7 +870,6 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) {
pos = Restore_Name.find_last_of("/");
Backup_FileName = Restore_Name.substr(pos + 1, Restore_Name.size());
pos = Restore_Name.find_last_of("/");
part_settings.Restore_Name = Restore_Name.substr(0, pos);
part_settings.Part = PartitionManager.Find_Partition_By_Path(path);

if (path.compare("/system") == 0) {
Expand All @@ -893,7 +891,6 @@ int OpenRecoveryScript::Restore_ADB_Backup(void) {
part_settings.partition_count = partition_count;
part_settings.adbbackup = true;
part_settings.adb_compression = twimghdr.compressed;
part_settings.Backup_FileName = Backup_FileName;
part_settings.total_restore_size += part_settings.Part->Get_Restore_Size(&part_settings);
part_settings.PM_Method = PM_RESTORE;
ProgressTracking progress(part_settings.total_restore_size);
Expand Down
42 changes: 21 additions & 21 deletions partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,7 @@ bool TWPartition::Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid)
return false;
}

bool TWPartition::Check_MD5(string restore_folder) {
bool TWPartition::Check_MD5(PartitionSettings *part_settings) {
string Full_Filename, md5file;
char split_filename[512];
int index = 0;
Expand All @@ -1621,7 +1621,7 @@ bool TWPartition::Check_MD5(string restore_folder) {
sync();

memset(split_filename, 0, sizeof(split_filename));
Full_Filename = restore_folder + "/" + Backup_FileName;
Full_Filename = part_settings->Backup_Folder + "/" + Backup_FileName;
if (!TWFunc::Path_Exists(Full_Filename)) {
// This is a split archive, we presume
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
Expand All @@ -1647,7 +1647,7 @@ bool TWPartition::Check_MD5(string restore_folder) {
// Single file archive
md5file = Full_Filename + ".md5";
if (!TWFunc::Path_Exists(md5file)) {
gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(split_filename));
gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(md5file));
return false;
}
md5sum.setfn(Full_Filename);
Expand All @@ -1662,7 +1662,7 @@ bool TWPartition::Check_MD5(string restore_folder) {

bool TWPartition::Restore(PartitionSettings *part_settings) {
TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Display_Name, gui_parse_text("{@restoring_hdr}"));
LOGINFO("Restore filename is: %s/%s\n", part_settings->Restore_Name.c_str(), part_settings->Backup_FileName.c_str());
LOGINFO("Restore filename is: %s/%s\n", part_settings->Backup_Folder.c_str(), Backup_FileName.c_str());

string Restore_File_System = Get_Restore_File_System(part_settings);

Expand All @@ -1680,12 +1680,12 @@ string TWPartition::Get_Restore_File_System(PartitionSettings *part_settings) {
string Restore_File_System;

// Parse backup filename to extract the file system before wiping
first_period = part_settings->Backup_FileName.find(".");
first_period = Backup_FileName.find(".");
if (first_period == string::npos) {
LOGERR("Unable to find file system (first period).\n");
return string();
}
Restore_File_System = part_settings->Backup_FileName.substr(first_period + 1, part_settings->Backup_FileName.size() - first_period - 1);
Restore_File_System = Backup_FileName.substr(first_period + 1, Backup_FileName.size() - first_period - 1);
second_period = Restore_File_System.find(".");
if (second_period == string::npos) {
LOGERR("Unable to find file system (second period).\n");
Expand Down Expand Up @@ -2167,14 +2167,14 @@ bool TWPartition::Backup_Tar(PartitionSettings *part_settings, pid_t *tar_fork_p
#endif

Backup_FileName = Backup_Name + "." + Current_File_System + ".win";
Full_FileName = part_settings->Full_Backup_Path + Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;
tar.has_data_media = Has_Data_Media;
tar.part_settings = part_settings;
tar.setdir(Backup_Path);
tar.setfn(Full_FileName);
tar.setsize(Backup_Size);
tar.partition_name = Backup_Name;
tar.backup_folder = part_settings->Full_Backup_Path;
tar.backup_folder = part_settings->Backup_Folder;
if (tar.createTarFork(tar_fork_pid) != 0)
return false;
return true;
Expand All @@ -2191,10 +2191,10 @@ bool TWPartition::Backup_Image(PartitionSettings *part_settings) {

if (part_settings->adbbackup) {
Full_FileName = TW_ADB_BACKUP;
adb_file_name = part_settings->Full_Backup_Path + "/" + Backup_FileName;
adb_file_name = part_settings->Backup_Folder + "/" + Backup_FileName;
}
else
Full_FileName = part_settings->Full_Backup_Path + "/" + Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;

part_settings->total_restore_size = Backup_Size;

Expand Down Expand Up @@ -2227,14 +2227,14 @@ bool TWPartition::Raw_Read_Write(PartitionSettings *part_settings) {
if (part_settings->adbbackup)
destfn = TW_ADB_BACKUP;
else
destfn = part_settings->Full_Backup_Path + part_settings->Backup_FileName;
destfn = part_settings->Backup_Folder + "/" + Backup_FileName;
}
else {
destfn = Actual_Block_Device;
if (part_settings->adbbackup) {
srcfn = TW_ADB_RESTORE;
} else {
srcfn = part_settings->Restore_Name + "/" + part_settings->Backup_FileName;
srcfn = part_settings->Backup_Folder + "/" + Backup_FileName;
Remain = TWFunc::Get_File_Size(srcfn);
}
}
Expand Down Expand Up @@ -2315,7 +2315,7 @@ bool TWPartition::Backup_Dump_Image(PartitionSettings *part_settings) {
part_settings->progress->SetPartitionSize(Backup_Size);

Backup_FileName = Backup_Name + "." + Current_File_System + ".win";
Full_FileName = part_settings->Full_Backup_Path + "/" + Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;

Command = "dump_image " + MTD_Name + " '" + Full_FileName + "'";

Expand All @@ -2335,7 +2335,7 @@ bool TWPartition::Backup_Dump_Image(PartitionSettings *part_settings) {

unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_settings) {
if (!part_settings->adbbackup) {
InfoManager restore_info(part_settings->Restore_Name + "/" + Backup_Name + ".info");
InfoManager restore_info(part_settings->Backup_Folder + "/" + Backup_Name + ".info");
if (restore_info.LoadValues() == 0) {
if (restore_info.GetValue("backup_size", Restore_Size) == 0) {
LOGINFO("Read info file, restore size is %llu\n", Restore_Size);
Expand All @@ -2346,7 +2346,7 @@ unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_setting

string Full_FileName, Restore_File_System = Get_Restore_File_System(part_settings);

Full_FileName = part_settings->Restore_Name + "/" + Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;
if (Is_Image(Restore_File_System)) {
Restore_Size = TWFunc::Get_File_Size(Full_FileName);
return Restore_Size;
Expand All @@ -2363,7 +2363,7 @@ unsigned long long TWPartition::Get_Restore_Size(PartitionSettings *part_setting
tar.setpassword(Password);
#endif
tar.partition_name = Backup_Name;
tar.backup_folder = part_settings->Restore_Name;
tar.backup_folder = part_settings->Backup_Folder;
tar.part_settings = part_settings;
Restore_Size = tar.get_size();
return Restore_Size;
Expand Down Expand Up @@ -2395,7 +2395,7 @@ bool TWPartition::Restore_Tar(PartitionSettings *part_settings) {
if (!ReMount_RW(true))
return false;

Full_FileName = part_settings->Restore_Name + "/" + part_settings->Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;
twrpTar tar;
tar.part_settings = part_settings;
tar.setdir(Backup_Path);
Expand Down Expand Up @@ -2448,7 +2448,7 @@ bool TWPartition::Restore_Image(PartitionSettings *part_settings) {
if (part_settings->adbbackup)
Full_FileName = TW_ADB_RESTORE;
else
Full_FileName = part_settings->Full_Backup_Path + part_settings->Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;

if (Restore_File_System == "emmc") {
if (!part_settings->adbbackup)
Expand Down Expand Up @@ -2607,9 +2607,9 @@ uint64_t TWPartition::Get_Max_FileSize() {
bool TWPartition::Flash_Image(PartitionSettings *part_settings) {
string Restore_File_System, full_filename;

full_filename = part_settings->Restore_Name + "/" + part_settings->Backup_FileName;
full_filename = part_settings->Backup_Folder + "/" + Backup_FileName;

LOGINFO("Image filename is: %s\n", part_settings->Backup_FileName.c_str());
LOGINFO("Image filename is: %s\n", Backup_FileName.c_str());

if (Backup_Method == BM_FILES) {
LOGERR("Cannot flash images to file systems\n");
Expand All @@ -2625,7 +2625,7 @@ bool TWPartition::Flash_Image(PartitionSettings *part_settings) {
unsigned long long image_size = TWFunc::Get_File_Size(full_filename);
if (image_size > Size) {
LOGINFO("Size (%llu bytes) of image '%s' is larger than target device '%s' (%llu bytes)\n",
image_size, part_settings->Backup_FileName.c_str(), Actual_Block_Device.c_str(), Size);
image_size, Backup_FileName.c_str(), Actual_Block_Device.c_str(), Size);
gui_err("img_size_err=Size of image is larger than target device");
return false;
}
Expand Down