diff --git a/install/include/install/wipe_data.h b/install/include/install/wipe_data.h index 42cad871..255d9b17 100644 --- a/install/include/install/wipe_data.h +++ b/install/include/install/wipe_data.h @@ -27,4 +27,4 @@ struct selabel_handle; bool WipeCache(RecoveryUI* ui, const std::function& confirm); // Returns true on success. -bool WipeData(Device* device); +bool WipeData(Device* device, bool keep_memtag_mode = false); diff --git a/install/wipe_data.cpp b/install/wipe_data.cpp index c65e6f48..7aff6226 100644 --- a/install/wipe_data.cpp +++ b/install/wipe_data.cpp @@ -79,7 +79,7 @@ bool WipeCache(RecoveryUI* ui, const std::function& confirm_func) { return success; } -bool WipeData(Device* device) { +bool WipeData(Device* device, bool keep_memtag_mode) { RecoveryUI* ui = device->GetUI(); ui->Print("\n-- Wiping data...\n"); ui->SetBackground(RecoveryUI::ERASING); @@ -101,11 +101,15 @@ bool WipeData(Device* device) { success &= EraseVolume(METADATA_ROOT, ui); } } - ui->Print("Resetting memtag message...\n"); - std::string err; - if (!WriteMiscMemtagMessage({}, &err)) { - ui->Print("Failed to reset memtag message: %s\n", err.c_str()); - success = false; + if (keep_memtag_mode) { + ui->Print("NOT resetting memtag message as per request...\n"); + } else { + ui->Print("Resetting memtag message...\n"); + std::string err; + if (!WriteMiscMemtagMessage({}, &err)) { + ui->Print("Failed to reset memtag message: %s\n", err.c_str()); + success = false; + } } if (success) { success &= device->PostWipeData(); diff --git a/recovery.cpp b/recovery.cpp index 4d390195..1a6a7d6c 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -608,6 +608,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vectorGetReason().has_value()); - if (!WipeData(device)) { + if (!WipeData(device, should_keep_memtag_mode)) { status = INSTALL_ERROR; } } else if (should_prompt_and_wipe_data) {