summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Marshall <tdm@cyngn.com>2016-01-29 15:39:49 -0800
committerTom Marshall <tdm@cyngn.com>2016-02-04 13:22:55 -0800
commit864493c7697818028869ea457e649649af54656b (patch)
tree11fd252d6700b2c24c21f74669034e8eb6485cb2
parentda584a2e6df7045c080aceca9d3a8a3fee0081db (diff)
downloadbootable_recovery-864493c7697818028869ea457e649649af54656b.zip
bootable_recovery-864493c7697818028869ea457e649649af54656b.tar.gz
bootable_recovery-864493c7697818028869ea457e649649af54656b.tar.bz2
recovery: Offer to format if data wipe fails
Change-Id: I76587c4fa234c5aab52882492da295e70029f522
-rw-r--r--recovery.cpp13
-rw-r--r--roots.cpp5
2 files changed, 16 insertions, 2 deletions
diff --git a/recovery.cpp b/recovery.cpp
index 3ecd5db..72ce09e 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -635,6 +635,9 @@ static bool erase_volume(const char* volume, bool force = false) {
copy_logs();
}
+ ui->SetBackground(RecoveryUI::NONE);
+ ui->SetProgressType(RecoveryUI::EMPTY);
+
return (result == 0);
}
@@ -837,11 +840,19 @@ static bool wipe_data(int should_confirm, Device* device, bool force = false) {
modified_flash = true;
ui->Print("\n-- Wiping data...\n");
- bool success =
+ bool success;
+retry:
+ success =
device->PreWipeData() &&
erase_volume("/data", force) &&
erase_volume("/cache") &&
device->PostWipeData();
+ if (!success && !force) {
+ if (!should_confirm || yes_no(device, "Wipe failed, format instead?", " THIS CAN NOT BE UNDONE!")) {
+ force = true;
+ goto retry;
+ }
+ }
ui->Print("Data wipe %s.\n", success ? "complete" : "failed");
return success;
}
diff --git a/roots.cpp b/roots.cpp
index 4bdf192..64c12a3 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -458,7 +458,10 @@ int format_volume(const char* volume, bool force) {
return rc;
}
- LOGE("format_volume failed to mount /data, formatting instead\n");
+ else {
+ LOGE("format_volume failed to mount /data\n");
+ return -1;
+ }
}
if (ensure_path_unmounted(volume) != 0) {