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 7.0 #178

Open
wants to merge 4 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1737,18 +1737,11 @@ int GUIAction::flashimage(std::string arg __unused)
{
int op_status = 0;

PartitionSettings part_settings;
operation_start("Flash Image");
string path, filename;
DataManager::GetValue("tw_zip_location", path);
DataManager::GetValue("tw_file", filename);
part_settings.Backup_Folder = path + "/" + filename;
unsigned long long total_bytes = TWFunc::Get_File_Size(part_settings.Backup_Folder);
ProgressTracking progress(total_bytes);
part_settings.progress = &progress;
part_settings.adbbackup = false;
part_settings.PM_Method = PM_RESTORE;
if (PartitionManager.Flash_Image(&part_settings))
if (PartitionManager.Flash_Image(path, filename))
op_status = 0; // success
else
op_status = 1; // fail
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/cz.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<string name="unable_resize">Nelze natáhnout {1}.</string>
<string name="no_md5_found">Soubor MD5 se nenašel pro \'{1}\'. Prosím zvolte Vypnout kontrolu MD5 během obnovy.</string>
<string name="md5_fail_match">MD5 neodpovídá souboru \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nelze dešifrovat soubor tar \'{1}\'</string>
<string name="format_data_msg">Měli by jste restartovat recovery aby jste mohli znova používat /data.</string>
<string name="format_data_err">Nelze formátovat pro zrušení šifrování.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/de.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<string name="unable_resize">Größe von {1} kann nicht geändert werden.</string>
<string name="no_md5_found">Keine MD5-Datei für '{1}' gefunden. Bitte MD5-Prüfung für Wiederherstellung deaktivieren.</string>
<string name="md5_fail_match">MD5-Prüfung für '{1}' fehlgeschlagen.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">TAR-Datei '{1}' konnte nicht entschlüsselt werden.</string>
<string name="format_data_msg">Ein Neustart von TWRP kann notwendig sein, damit /data wieder verwendet werden kann.</string>
<string name="format_data_err">Formatierung zum Entfernen der Verschlüsselung kann nicht durchgeführt werden.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/el.xml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@
<string name="unable_resize">Δεν είναι δυνατή η αλλαγή μεγέθους {1}.</string>
<string name="no_md5_found">Δεν βρέθηκε MD5 αρχείο για το '{1}'. Παρακαλώ απεπηλέξτε την επαλήθευση MD5 για επαναφορά.</string>
<string name="md5_fail_match">Το MD5 απέτυχε να ταυτίσει με το '{1}'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Αποτυχία αποκρυπτογράφησης του αρχείου tar '{1}'</string>
<string name="format_data_msg">Ίσως χρειαστεί να επανεκκινήσετε στο recovery για να ξαναχρησιμοποιήσετε το /data.</string>
<string name="format_data_err">Αδύνατη η διαμόρφωση για να καταργήσετε την κρυπτογράφηση.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/en.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<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="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Failed to decrypt tar file '{1}'</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>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/es.xml
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@
<string name="unable_resize">Incapaz de cambiar el tamaño de archivo de {1}.</string>
<string name="no_md5_found">No se encuentra archivo md5 para \'{1}\'. Por favor, deselecciona Activar verificación de MD5 para restaurar.</string>
<string name="md5_fail_match">MD5 no coincide en \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Fallo al desencriptar el archivo tar '{1}'</string>
<string name="format_data_msg">Quizás necesites reiniciar el recovery para ser capaz de usar /data de nuevo.</string>
<string name="format_data_err">Incapaz de formatear para remover encriptación.</string>
Expand Down
3 changes: 2 additions & 1 deletion gui/theme/common/languages/fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@
<string name="repair_resize">Réparation de {1} avant de redimensionner.</string>
<string name="unable_resize">Incapable de redimensionner {1}.</string>
<string name="no_md5_found">Pas de fichier md5 trouvé pour '{1}'. Veuillez désactiver la vérification MD5 pour effectuer la restauration.</string>
<string name="md5_fail_match">Le MD5 ne corresponds pas pour '{1}'.</string>
<string name="md5_fail_match">Le MD5 ne correspond pas pour '{1}'.</string>
<string name="md5_matched">Le MD5 correspond pour '{1}'.</string>
<string name="restoring">Restauration en cours</string>
<string name="format_data_msg">Vous aurez peut-être à redémarrer pour pouvoir utiliser /data à nouveau.</string>
<string name="format_data_err">Incapable de formater pour enlever l'encryption.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/hu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<string name="unable_resize">Nem lehet átméretezni: {1}.</string>
<string name="no_md5_found">Nem található MD5 fájl ehhez: \'{1}\'. Kérjük, a visszaállításhoz szüntesse meg a kijelölést: \"MD5 ellenőrzés engedélyezése\".</string>
<string name="md5_fail_match">MD5 nem egyezik ezzel: \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nem sikerült visszafejteni a(z) \'{1}\' tar fájlt</string>
<string name="format_data_msg">Lehet, hogy a recovery-be kell újraindítania ahhoz, hogy képes legyen használni az /adat partíciót.</string>
<string name="format_data_err">Nem sikerült formázni a titkosítás eltávolításához.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<string name="unable_resize">Impossibile ridimensionare {1}.</string>
<string name="no_md5_found">Nessun MD5 trovato per '{1}'. Deseleziona "Abilita verifica MD5" per procedere con il ripristino.</string>
<string name="md5_fail_match">Il valore MD5 non corrisponde per '{1}'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Decriptazione fallita per il file Tar '{1}'</string>
<string name="format_data_msg">Potresti dover riavviare la Recovery per accedere nuovamente a Data.</string>
<string name="format_data_err">Impossibile formattare al fine di rimuovere la crittografia.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/nl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<string name="unable_resize">Kan de grootte van {1} niet wijzigen.</string>
<string name="no_md5_found">Geen md5 bestand gevonden voor \'{1}\'. Gelieve MD5 controle inschakelen uitzetten om te herstellen.</string>
<string name="md5_fail_match">MD5 vergelijken mislukt op \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Het decoderen van tar bestand \'{1}\' is mislukt</string>
<string name="format_data_msg">U zou in recovery moeten herstarten om /data opnieuw te kunnen gebruiken.</string>
<string name="format_data_err">Kan niet formatteren om encryptie te verwijderen.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@
<string name="unable_resize">Nie można zmienić rozmiaru {1}.</string>
<string name="no_md5_found">Nie znaleziono pliku MD5 '{1}'. Proszę wyłączyć weryfikację MD5, aby przywrócić.</string>
<string name="md5_fail_match">MD5 nie pasuje do '{1}'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nie udało się odszyfrować pliku tar '{1}'</string>
<string name="format_data_msg">Może być konieczne ponowne uruchomienie recovery, aby móc ponownie użyć /date.</string>
<string name="format_data_err">Nie można sformatować, aby usunąć szyfrowanie.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/pt_BR.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<string name="unable_resize">Não é possível redimensionar {1}.</string>
<string name="no_md5_found">Nenhum arquivo md5 foi encontrado para \'{1}\'. Por favor, cancelar a seleção de verificação MD5 habilitar para restaurar.</string>
<string name="md5_fail_match">MD5 não conseguiram corresponder na \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Falha ao descriptografar arquivo tar \'{1}\'</string>
<string name="format_data_msg">Você pode precisar reiniciar recuperação para ser capaz de usar /data novamente.</string>
<string name="format_data_err">Não é possível formatar para remover a criptografia.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/ru.xml
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@
<string name="unable_resize">Не удается изменить размер {1}.</string>
<string name="no_md5_found">Отсутствует файл md5 для '{1}'. Пожалуйста отмените выбор проверки MD5 при восстановлении.</string>
<string name="md5_fail_match">MD5 не соответствует для '{1}'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Не удается расшифровать tar-файл '{1}'</string>
<string name="format_data_msg">Вам, возможно, потребуется перезагрузись рекавери, чтобы иметь возможность использовать /data снова.</string>
<string name="format_data_err">Невозможно отформатировать и удалить шифрование.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<string name="unable_resize">Nemožno natiahnuť {1}.</string>
<string name="no_md5_found">Súbor MD5 sa nenašiel pre \'{1}\'. Prosím zvoľte Vypnúť kontrolu MD5 počas obnovy.</string>
<string name="md5_fail_match">MD5 nezodpovedá súboru \'{1}\'.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Nemožno dešifrovať súbor tar \'{1}\'</string>
<string name="format_data_msg">Mali by ste reštartovať recovery aby ste mohli znova používať /data.</string>
<string name="format_data_err">Nemožno formátovať pre zrušenie šifrovania.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/common/languages/sl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@
<string name="unable_resize">Velikosti {1} ni mogoče spremeniti.</string>
<string name="no_md5_found">Za \'{1}\' ni bilo najdene datoteke MD5. Odstranite izbiro \'Omogoči preverjanje razpršila MD5\' za obnovitev.</string>
<string name="md5_fail_match">Ujemanje razpršila MD5 na \'{1}\' je spodletelo.</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">Odšifriranje datoteke TAR \'{1}\' je spodletelo</string>
<string name="format_data_msg">Za ponovno uporabo /data boste morda morali ponovno zagnati obnovitev.</string>
<string name="format_data_err">Formatiranje za odstranitev šifriranja ni mogoče.</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/extra-languages/languages/ja.xml
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@
<string name="unable_resize">{1} をリサイズできません。</string>
<string name="no_md5_found">\'{1}\' の MD5 ファイルが見つかりません。リストアするには MD5 の検証を無効化してください。</string>
<string name="md5_fail_match">\'{1}\' で MD5 が一致しません。</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">tar ファイル '{1}' を復号できませんでした</string>
<string name="format_data_msg">/data を再度使用するにはリカバリを再起動してください。</string>
<string name="format_data_err">暗号化を解除するための初期化ができません。</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/extra-languages/languages/zh_CN.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
<string name="unable_resize">无法修改 {1} 大小。</string>
<string name="no_md5_found">无法为 '{1}' 找到 MD5 校验文件。请取消允许 MD5 校验选项。</string>
<string name="md5_fail_match">MD5 校验失败 '{1}'。</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">解密 tar 文件 '{1}' 失败</string>
<string name="format_data_msg">你可能需要重启 recovery 才能使用/data。</string>
<string name="format_data_err">无法格式化并删除加密。</string>
Expand Down
1 change: 1 addition & 0 deletions gui/theme/extra-languages/languages/zh_TW.xml
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@
<string name="unable_resize">無法調整{1}大小。</string>
<string name="no_md5_found">未找到'{1}'MD5校驗檔案,請取消“啟用MD5校驗備份檔案”選項。</string>
<string name="md5_fail_match">'{1}' MD5校驗失敗。</string>
<string name="md5_matched">MD5 matched for '{1}'.</string>
<string name="fail_decrypt_tar">無法解密tar檔案:'{1}'</string>
<string name="format_data_msg">您可能需要重啟recovery才能使用/data。</string>
<string name="format_data_err">無法格式化並刪除加密。</string>
Expand Down
71 changes: 32 additions & 39 deletions partition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1612,57 +1612,53 @@ bool TWPartition::Backup(PartitionSettings *part_settings, pid_t *tar_fork_pid)
return false;
}

bool TWPartition::Check_Restore_File_MD5(const string& Filename) {
twrpDigest md5sum;

md5sum.setfn(Filename);
switch (md5sum.verify_md5digest()) {
case MD5_OK:
gui_msg(Msg("md5_matched=MD5 matched for '{1}'.")(Filename));
return true;
case MD5_FILE_UNREADABLE:
case MD5_NOT_FOUND:
gui_msg(Msg(msg::kError, "no_md5_found=No md5 file found for '{1}'. Please unselect Enable MD5 verification to restore.")(Filename));
break;
case MD5_MATCH_FAIL:
gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(Filename));
break;
}
return false;
}

bool TWPartition::Check_MD5(PartitionSettings *part_settings) {
string Full_Filename, md5file;
string Full_Filename;
char split_filename[512];
int index = 0;
twrpDigest md5sum;

sync();

memset(split_filename, 0, sizeof(split_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);
LOGINFO("split_filename: %s\n", split_filename);
md5file = split_filename;
md5file += ".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));
return false;
}
md5sum.setfn(split_filename);
memset(split_filename, 0, sizeof(split_filename));
while (index < 1000) {
if (TWFunc::Path_Exists(split_filename) && md5sum.verify_md5digest() != 0) {
gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
if (!TWFunc::Path_Exists(split_filename))
break;
LOGINFO("split_filename: %s\n", split_filename);
if (!Check_Restore_File_MD5(split_filename))
return false;
}
index++;
sprintf(split_filename, "%s%03i", Full_Filename.c_str(), index);
md5sum.setfn(split_filename);
}
return true;
} else {
// 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.")(md5file));
return false;
}
md5sum.setfn(Full_Filename);
if (md5sum.verify_md5digest() != 0) {
gui_msg(Msg(msg::kError, "md5_fail_match=MD5 failed to match on '{1}'.")(split_filename));
return false;
} else
return true;
}
return false;
return Check_Restore_File_MD5(Full_Filename); // Single file archive
}

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->Backup_Folder.c_str(), 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 Down Expand Up @@ -2167,7 +2163,7 @@ 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->Backup_Folder + 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);
Expand Down Expand Up @@ -2227,7 +2223,7 @@ bool TWPartition::Raw_Read_Write(PartitionSettings *part_settings) {
if (part_settings->adbbackup)
destfn = TW_ADB_BACKUP;
else
destfn = part_settings->Backup_Folder + Backup_FileName;
destfn = part_settings->Backup_Folder + "/" + Backup_FileName;
}
else {
destfn = Actual_Block_Device;
Expand Down Expand Up @@ -2448,7 +2444,7 @@ bool TWPartition::Restore_Image(PartitionSettings *part_settings) {
if (part_settings->adbbackup)
Full_FileName = TW_ADB_RESTORE;
else
Full_FileName = part_settings->Backup_Folder + Backup_FileName;
Full_FileName = part_settings->Backup_Folder + "/" + Backup_FileName;

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

if (part_settings->Part != NULL)
full_filename = part_settings->Backup_Folder + "/" + Backup_FileName;
else
full_filename = part_settings->Backup_Folder; // Flash image action from GUI
full_filename = part_settings->Backup_Folder + "/" + Backup_FileName;

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

Expand Down
Loading