From 4344d636d4f8687054593f88ddd7509ff8581419 Mon Sep 17 00:00:00 2001 From: Alex Deymo Date: Wed, 3 Aug 2016 21:03:53 -0700 Subject: Call update_engine_sideload from recovery. This patch enables sideloading an OTA on A/B devices while running from recovery. Recovery accepts the same OTA package format as recent versions of GMS, which consists of .zip file with the payload in it. Bug: 27178350 TEST=`adb sideload` successfully a full OTA (*) TEST=Failed to take several invalid payloads (wrong product, fingerprint, update type, serial, etc). (*) with no postinstall script. Change-Id: I951869340100feb5a37e41fac0ee59c10095659e --- device.cpp | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'device.cpp') diff --git a/device.cpp b/device.cpp index f8fbb8a49..e717dddf7 100644 --- a/device.cpp +++ b/device.cpp @@ -16,36 +16,15 @@ #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", "Apply update from ADB", "Apply update from SD card", "Wipe data/factory reset", +#ifndef AB_OTA_UPDATER "Wipe cache partition", +#endif // !AB_OTA_UPDATER "Mount /system", "View recovery logs", "Run graphics test", @@ -59,14 +38,19 @@ static const Device::BuiltinAction MENU_ACTIONS[] = { Device::APPLY_ADB_SIDELOAD, Device::APPLY_SDCARD, Device::WIPE_DATA, +#ifndef AB_OTA_UPDATER Device::WIPE_CACHE, +#endif // !AB_OTA_UPDATER Device::MOUNT_SYSTEM, Device::VIEW_RECOVERY_LOGS, Device::RUN_GRAPHICS_TEST, Device::SHUTDOWN, }; -#endif +static_assert(sizeof(MENU_ITEMS) / sizeof(MENU_ITEMS[0]) == + sizeof(MENU_ACTIONS) / sizeof(MENU_ACTIONS[0]) + 1, + "MENU_ITEMS and MENU_ACTIONS should have the same length, " + "except for the extra NULL entry in MENU_ITEMS."); const char* const* Device::GetMenuItems() { return MENU_ITEMS; -- cgit v1.2.3