summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk4
-rw-r--r--device.cpp54
-rw-r--r--recovery.cpp24
3 files changed, 56 insertions, 26 deletions
diff --git a/Android.mk b/Android.mk
index dcc11c596..2034d604f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -101,6 +101,10 @@ LOCAL_HAL_STATIC_LIBRARIES := libhealthd
LOCAL_C_INCLUDES += system/extras/ext4_utils
LOCAL_STATIC_LIBRARIES += libext4_utils_static libz
+ifeq ($(AB_OTA_UPDATER),true)
+ LOCAL_CFLAGS += -DAB_OTA_UPDATER=1
+endif
+
LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin
ifeq ($(TARGET_RECOVERY_UI_LIB),)
diff --git a/device.cpp b/device.cpp
index 2465b0778..f8fbb8a49 100644
--- a/device.cpp
+++ b/device.cpp
@@ -16,6 +16,29 @@
#include "device.h"
+#if defined(AB_OTA_UPDATER)
+
+static const char* MENU_ITEMS[] = {
+ "Reboot system now",
+ "Reboot to bootloader",
+ "Wipe data/factory reset",
+ "Mount /system",
+ "Run graphics test",
+ "Power off",
+ NULL,
+};
+
+static const Device::BuiltinAction MENU_ACTIONS[] = {
+ Device::REBOOT,
+ Device::REBOOT_BOOTLOADER,
+ Device::WIPE_DATA,
+ Device::MOUNT_SYSTEM,
+ Device::RUN_GRAPHICS_TEST,
+ Device::SHUTDOWN,
+};
+
+#else
+
static const char* MENU_ITEMS[] = {
"Reboot system now",
"Reboot to bootloader",
@@ -27,27 +50,30 @@ static const char* MENU_ITEMS[] = {
"View recovery logs",
"Run graphics test",
"Power off",
- NULL
+ NULL,
};
+static const Device::BuiltinAction MENU_ACTIONS[] = {
+ Device::REBOOT,
+ Device::REBOOT_BOOTLOADER,
+ Device::APPLY_ADB_SIDELOAD,
+ Device::APPLY_SDCARD,
+ Device::WIPE_DATA,
+ Device::WIPE_CACHE,
+ Device::MOUNT_SYSTEM,
+ Device::VIEW_RECOVERY_LOGS,
+ Device::RUN_GRAPHICS_TEST,
+ Device::SHUTDOWN,
+};
+
+#endif
+
const char* const* Device::GetMenuItems() {
return MENU_ITEMS;
}
Device::BuiltinAction Device::InvokeMenuItem(int menu_position) {
- switch (menu_position) {
- case 0: return REBOOT;
- case 1: return REBOOT_BOOTLOADER;
- case 2: return APPLY_ADB_SIDELOAD;
- case 3: return APPLY_SDCARD;
- case 4: return WIPE_DATA;
- case 5: return WIPE_CACHE;
- case 6: return MOUNT_SYSTEM;
- case 7: return VIEW_RECOVERY_LOGS;
- case 8: return RUN_GRAPHICS_TEST;
- case 9: return SHUTDOWN;
- default: return NO_ACTION;
- }
+ return menu_position < 0 ? NO_ACTION : MENU_ACTIONS[menu_position];
}
int Device::HandleMenuKey(int key, int visible) {
diff --git a/recovery.cpp b/recovery.cpp
index 79b99b176..d611369ed 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -83,7 +83,7 @@ static const struct option OPTIONS[] = {
{ "shutdown_after", no_argument, NULL, 'p' },
{ "reason", required_argument, NULL, 'r' },
{ "security", no_argument, NULL, 'e'},
- { "brick", no_argument, NULL, 0 },
+ { "wipe_ab", no_argument, NULL, 0 },
{ NULL, 0, NULL, 0 },
};
@@ -109,7 +109,7 @@ static const int BATTERY_READ_TIMEOUT_IN_SEC = 10;
// So we should check battery with a slightly lower limitation.
static const int BATTERY_OK_PERCENTAGE = 20;
static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15;
-constexpr const char* RECOVERY_BRICK = "/etc/recovery.brick";
+constexpr const char* RECOVERY_WIPE = "/etc/recovery.wipe";
RecoveryUI* ui = NULL;
static const char* locale = "en_US";
@@ -889,15 +889,15 @@ static bool secure_wipe_partition(const std::string& partition) {
return true;
}
-// Brick the current device, with a secure wipe of all the partitions in
-// RECOVERY_BRICK.
-static bool brick_device() {
+// Wipe the current A/B device, with a secure wipe of all the partitions in
+// RECOVERY_WIPE.
+static bool wipe_ab_device() {
ui->SetBackground(RecoveryUI::ERASING);
ui->SetProgressType(RecoveryUI::INDETERMINATE);
std::string partition_list;
- if (!android::base::ReadFileToString(RECOVERY_BRICK, &partition_list)) {
- LOGE("failed to read \"%s\".\n", RECOVERY_BRICK);
+ if (!android::base::ReadFileToString(RECOVERY_WIPE, &partition_list)) {
+ LOGE("failed to read \"%s\".\n", RECOVERY_WIPE);
return false;
}
@@ -1401,7 +1401,7 @@ int main(int argc, char **argv) {
const char *update_package = NULL;
bool should_wipe_data = false;
bool should_wipe_cache = false;
- bool should_brick = false;
+ bool should_wipe_ab = false;
bool show_text = false;
bool sideload = false;
bool sideload_auto_reboot = false;
@@ -1435,8 +1435,8 @@ int main(int argc, char **argv) {
case 'r': reason = optarg; break;
case 'e': security_update = true; break;
case 0: {
- if (strcmp(OPTIONS[option_index].name, "brick") == 0) {
- should_brick = true;
+ if (strcmp(OPTIONS[option_index].name, "wipe_ab") == 0) {
+ should_wipe_ab = true;
break;
}
break;
@@ -1579,8 +1579,8 @@ int main(int argc, char **argv) {
if (!wipe_cache(false, device)) {
status = INSTALL_ERROR;
}
- } else if (should_brick) {
- if (!brick_device()) {
+ } else if (should_wipe_ab) {
+ if (!wipe_ab_device()) {
status = INSTALL_ERROR;
}
} else if (sideload) {