aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--device.h17
-rw-r--r--recovery.cpp29
2 files changed, 22 insertions, 24 deletions
diff --git a/device.h b/device.h
index dad8ccd5..f74b6b04 100644
--- a/device.h
+++ b/device.h
@@ -91,13 +91,16 @@ class Device {
91 static const int kHighlightDown = -3; 91 static const int kHighlightDown = -3;
92 static const int kInvokeItem = -4; 92 static const int kInvokeItem = -4;
93 93
94 // Called when we do a wipe data/factory reset operation (either via a 94 // Called before and after we do a wipe data/factory reset operation,
95 // reboot from the main system with the --wipe_data flag, or when the 95 // either via a reboot from the main system with the --wipe_data flag,
96 // user boots into recovery manually and selects the option from the 96 // or when the user boots into recovery image manually and selects the
97 // menu.) Can perform whatever device-specific wiping actions are 97 // option from the menu, to perform whatever device-specific wiping
98 // needed. Return 0 on success. The userdata and cache partitions 98 // actions are needed.
99 // are erased AFTER this returns (whether it returns success or not). 99 // Return true on success; returning false from PreWipeData will prevent
100 virtual int WipeData() { return 0; } 100 // the regular wipe, and returning false from PostWipeData will cause
101 // the wipe to be considered a failure.
102 virtual bool PreWipeData() { return true; }
103 virtual bool PostWipeData() { return true; }
101 104
102 private: 105 private:
103 RecoveryUI* ui_; 106 RecoveryUI* ui_;
diff --git a/recovery.cpp b/recovery.cpp
index 76149cd9..6cda10c2 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -421,8 +421,7 @@ typedef struct _saved_log_file {
421 struct _saved_log_file* next; 421 struct _saved_log_file* next;
422} saved_log_file; 422} saved_log_file;
423 423
424static int 424static bool erase_volume(const char* volume) {
425erase_volume(const char *volume) {
426 bool is_cache = (strcmp(volume, CACHE_ROOT) == 0); 425 bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
427 426
428 ui->SetBackground(RecoveryUI::ERASING); 427 ui->SetBackground(RecoveryUI::ERASING);
@@ -503,7 +502,7 @@ erase_volume(const char *volume) {
503 copy_logs(); 502 copy_logs();
504 } 503 }
505 504
506 return result; 505 return (result == 0);
507} 506}
508 507
509static int 508static int
@@ -677,13 +676,13 @@ static bool wipe_data(int should_confirm, Device* device) {
677 modified_flash = true; 676 modified_flash = true;
678 677
679 ui->Print("\n-- Wiping data...\n"); 678 ui->Print("\n-- Wiping data...\n");
680 if (device->WipeData() == 0 && erase_volume("/data") == 0 && erase_volume("/cache") == 0) { 679 bool success =
681 ui->Print("Data wipe complete.\n"); 680 device->PreWipeData() &&
682 return true; 681 erase_volume("/data") &&
683 } else { 682 erase_volume("/cache") &&
684 ui->Print("Data wipe failed.\n"); 683 device->PostWipeData();
685 return false; 684 ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
686 } 685 return success;
687} 686}
688 687
689// Return true on success. 688// Return true on success.
@@ -695,13 +694,9 @@ static bool wipe_cache(bool should_confirm, Device* device) {
695 modified_flash = true; 694 modified_flash = true;
696 695
697 ui->Print("\n-- Wiping cache...\n"); 696 ui->Print("\n-- Wiping cache...\n");
698 if (erase_volume("/cache") == 0) { 697 bool success = erase_volume("/cache");
699 ui->Print("Cache wipe complete.\n"); 698 ui->Print("Cache wipe %s.\n", success ? "complete" : "failed");
700 return true; 699 return success;
701 } else {
702 ui->Print("Cache wipe failed.\n");
703 return false;
704 }
705} 700}
706 701
707static void choose_recovery_file(Device* device) { 702static void choose_recovery_file(Device* device) {