diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-10-31 11:54:32 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-10-31 11:54:32 +0000 |
commit | c6aabd4c5b3f5e3d61869d3464a9d6a147506945 (patch) | |
tree | 6d5c47eabbebd219844aa37eaecbbccaf42c2ad8 | |
parent | 7b5068bb5ebd036d669f69891adc7c409b71c5f6 (diff) | |
parent | 362b11461d10154a1cdf1de0f9ed5e40e1783e58 (diff) | |
download | recovery-c6aabd4c5b3f5e3d61869d3464a9d6a147506945.tar.gz |
Merge "Add --keep_memtag_mode for --wipe_data" into main am: 0d4e8c333c am: f8d48e1846 am: 362b11461d
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/2810434
Change-Id: I4806d95550ae9998af5958e623eee65b2a0edc95
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r-- | install/include/install/wipe_data.h | 2 | ||||
-rw-r--r-- | install/wipe_data.cpp | 16 | ||||
-rw-r--r-- | recovery.cpp | 6 |
3 files changed, 16 insertions, 8 deletions
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<bool()>& 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<bool()>& 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::vector<std::stri { "wipe_ab", no_argument, nullptr, 0 }, { "wipe_cache", no_argument, nullptr, 0 }, { "wipe_data", no_argument, nullptr, 0 }, + { "keep_memtag_mode", no_argument, nullptr, 0 }, { "wipe_package_size", required_argument, nullptr, 0 }, { nullptr, 0, nullptr, 0 }, }; @@ -616,6 +617,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri bool install_with_fuse = false; // memory map the update package by default. bool should_wipe_data = false; bool should_prompt_and_wipe_data = false; + bool should_keep_memtag_mode = false; bool should_wipe_cache = false; bool should_wipe_ab = false; size_t wipe_package_size = 0; @@ -675,6 +677,8 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri should_wipe_data = true; } else if (option == "wipe_package_size") { android::base::ParseUint(optarg, &wipe_package_size); + } else if (option == "keep_memtag_mode") { + should_keep_memtag_mode = true; } break; } @@ -793,7 +797,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri } else if (should_wipe_data) { save_current_log = true; CHECK(device->GetReason().has_value()); - if (!WipeData(device)) { + if (!WipeData(device, should_keep_memtag_mode)) { status = INSTALL_ERROR; } } else if (should_prompt_and_wipe_data) { |