summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-06-06 02:59:56 +0200
committerElliott Hughes <enh@google.com>2015-06-10 23:09:31 +0200
commit945548ef7b3eee5dbfb46f6291465d4b0b6d02e1 (patch)
treef047505165fdb3587dccc6e9f38017efa714b8ee
parentMerge "recovery: Switch to clang" (diff)
downloadandroid_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar.gz
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar.bz2
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar.lz
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar.xz
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.tar.zst
android_bootable_recovery-945548ef7b3eee5dbfb46f6291465d4b0b6d02e1.zip
Diffstat (limited to '')
-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 dad8ccd56..f74b6b047 100644
--- a/device.h
+++ b/device.h
@@ -91,13 +91,16 @@ class Device {
static const int kHighlightDown = -3;
static const int kInvokeItem = -4;
- // Called when we do a wipe data/factory reset operation (either via a
- // reboot from the main system with the --wipe_data flag, or when the
- // user boots into recovery manually and selects the option from the
- // menu.) Can perform whatever device-specific wiping actions are
- // needed. Return 0 on success. The userdata and cache partitions
- // are erased AFTER this returns (whether it returns success or not).
- virtual int WipeData() { return 0; }
+ // Called before and after we do a wipe data/factory reset operation,
+ // either via a reboot from the main system with the --wipe_data flag,
+ // or when the user boots into recovery image manually and selects the
+ // option from the menu, to perform whatever device-specific wiping
+ // actions are needed.
+ // Return true on success; returning false from PreWipeData will prevent
+ // the regular wipe, and returning false from PostWipeData will cause
+ // the wipe to be considered a failure.
+ virtual bool PreWipeData() { return true; }
+ virtual bool PostWipeData() { return true; }
private:
RecoveryUI* ui_;
diff --git a/recovery.cpp b/recovery.cpp
index 76149cd98..6cda10c21 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -421,8 +421,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);
@@ -503,7 +502,7 @@ erase_volume(const char *volume) {
copy_logs();
}
- return result;
+ return (result == 0);
}
static int
@@ -677,13 +676,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.
@@ -695,13 +694,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) {