am a1009c34: Merge "Split WipeData into PreWipeData and PostWipeData."
* commit 'a1009c346827c89f35d4feb011d01dd18de1b134': Split WipeData into PreWipeData and PostWipeData.
This commit is contained in:
17
device.h
17
device.h
@@ -91,13 +91,16 @@ class Device {
|
|||||||
static const int kHighlightDown = -3;
|
static const int kHighlightDown = -3;
|
||||||
static const int kInvokeItem = -4;
|
static const int kInvokeItem = -4;
|
||||||
|
|
||||||
// Called when we do a wipe data/factory reset operation (either via a
|
// Called before and after we do a wipe data/factory reset operation,
|
||||||
// reboot from the main system with the --wipe_data flag, or when the
|
// either via a reboot from the main system with the --wipe_data flag,
|
||||||
// user boots into recovery manually and selects the option from the
|
// or when the user boots into recovery image manually and selects the
|
||||||
// menu.) Can perform whatever device-specific wiping actions are
|
// option from the menu, to perform whatever device-specific wiping
|
||||||
// needed. Return 0 on success. The userdata and cache partitions
|
// actions are needed.
|
||||||
// are erased AFTER this returns (whether it returns success or not).
|
// Return true on success; returning false from PreWipeData will prevent
|
||||||
virtual int WipeData() { return 0; }
|
// 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:
|
private:
|
||||||
RecoveryUI* ui_;
|
RecoveryUI* ui_;
|
||||||
|
|||||||
29
recovery.cpp
29
recovery.cpp
@@ -421,8 +421,7 @@ typedef struct _saved_log_file {
|
|||||||
struct _saved_log_file* next;
|
struct _saved_log_file* next;
|
||||||
} saved_log_file;
|
} saved_log_file;
|
||||||
|
|
||||||
static int
|
static bool erase_volume(const char* volume) {
|
||||||
erase_volume(const char *volume) {
|
|
||||||
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
|
bool is_cache = (strcmp(volume, CACHE_ROOT) == 0);
|
||||||
|
|
||||||
ui->SetBackground(RecoveryUI::ERASING);
|
ui->SetBackground(RecoveryUI::ERASING);
|
||||||
@@ -503,7 +502,7 @@ erase_volume(const char *volume) {
|
|||||||
copy_logs();
|
copy_logs();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return (result == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -677,13 +676,13 @@ static bool wipe_data(int should_confirm, Device* device) {
|
|||||||
modified_flash = true;
|
modified_flash = true;
|
||||||
|
|
||||||
ui->Print("\n-- Wiping data...\n");
|
ui->Print("\n-- Wiping data...\n");
|
||||||
if (device->WipeData() == 0 && erase_volume("/data") == 0 && erase_volume("/cache") == 0) {
|
bool success =
|
||||||
ui->Print("Data wipe complete.\n");
|
device->PreWipeData() &&
|
||||||
return true;
|
erase_volume("/data") &&
|
||||||
} else {
|
erase_volume("/cache") &&
|
||||||
ui->Print("Data wipe failed.\n");
|
device->PostWipeData();
|
||||||
return false;
|
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
|
||||||
}
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return true on success.
|
// Return true on success.
|
||||||
@@ -695,13 +694,9 @@ static bool wipe_cache(bool should_confirm, Device* device) {
|
|||||||
modified_flash = true;
|
modified_flash = true;
|
||||||
|
|
||||||
ui->Print("\n-- Wiping cache...\n");
|
ui->Print("\n-- Wiping cache...\n");
|
||||||
if (erase_volume("/cache") == 0) {
|
bool success = erase_volume("/cache");
|
||||||
ui->Print("Cache wipe complete.\n");
|
ui->Print("Cache wipe %s.\n", success ? "complete" : "failed");
|
||||||
return true;
|
return success;
|
||||||
} else {
|
|
||||||
ui->Print("Cache wipe failed.\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void choose_recovery_file(Device* device) {
|
static void choose_recovery_file(Device* device) {
|
||||||
|
|||||||
Reference in New Issue
Block a user