aboutsummaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-06-05 17:59:56 -0700
committerElliott Hughes <enh@google.com>2015-06-10 14:11:08 -0700
commit0005f89c31dfc2ca9053512900571620a0eba842 (patch)
treee0749788a43dc1411d34a5d1cb788a23a9b0054d /recovery.cpp
parent6abd52f62be24981398a99ebefc8717eb2294f97 (diff)
downloadbootable_recovery-0005f89c31dfc2ca9053512900571620a0eba842.zip
bootable_recovery-0005f89c31dfc2ca9053512900571620a0eba842.tar.gz
bootable_recovery-0005f89c31dfc2ca9053512900571620a0eba842.tar.bz2
Split WipeData into PreWipeData and PostWipeData.
Bug: http://b/21760064 Change-Id: Idde268fe4d7e27586ca4469de16783f1ffdc5069 (cherry picked from commit 945548ef7b3eee5dbfb46f6291465d4b0b6d02e1)
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp29
1 files changed, 12 insertions, 17 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 80a8c7b..b7a5458 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -417,8 +417,7 @@ typedef struct _saved_log_file {
struct _saved_log_file* next;
} saved_log_file;
-static int
-erase_volume(const char *volume) {
+static bool erase_volume(const char* volume) {
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
ui->SetBackground(RecoveryUI::ERASING);
@@ -499,7 +498,7 @@ erase_volume(const char *volume) {
copy_logs();
}
- return result;
+ return (result == 0);
}
static int
@@ -673,13 +672,13 @@ static bool wipe_data(int should_confirm, Device* device) {
modified_flash = true;
ui->Print("\n-- Wiping data...\n");
- if (device->WipeData() == 0 && erase_volume("/data") == 0 && erase_volume("/cache") == 0) {
- ui->Print("Data wipe complete.\n");
- return true;
- } else {
- ui->Print("Data wipe failed.\n");
- return false;
- }
+ bool success =
+ device->PreWipeData() &&
+ erase_volume("/data") &&
+ erase_volume("/cache") &&
+ device->PostWipeData();
+ ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
+ return success;
}
// Return true on success.
@@ -691,13 +690,9 @@ static bool wipe_cache(bool should_confirm, Device* device) {
modified_flash = true;
ui->Print("\n-- Wiping cache...\n");
- if (erase_volume("/cache") == 0) {
- ui->Print("Cache wipe complete.\n");
- return true;
- } else {
- ui->Print("Cache wipe failed.\n");
- return false;
- }
+ bool success = erase_volume("/cache");
+ ui->Print("Cache wipe %s.\n", success ? "complete" : "failed");
+ return success;
}
static void choose_recovery_file(Device* device) {