diff options
author | Tao Bao <tbao@google.com> | 2018-05-04 01:13:09 +0200 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-05-04 01:13:09 +0200 |
commit | fb86bb2a074cdec6d82e1df7304f1c41309ec220 (patch) | |
tree | e4a6d12bc2aca2b7b5cffbe213780ca894e31306 /device.cpp | |
parent | Merge "updater_sample: update tests" (diff) | |
parent | Move menu headers/items to std::vector<std::string>. (diff) | |
download | android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar.gz android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar.bz2 android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar.lz android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar.xz android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.tar.zst android_bootable_recovery-fb86bb2a074cdec6d82e1df7304f1c41309ec220.zip |
Diffstat (limited to 'device.cpp')
-rw-r--r-- | device.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/device.cpp b/device.cpp index 3b0942c49..5cf9cc242 100644 --- a/device.cpp +++ b/device.cpp @@ -16,9 +16,13 @@ #include "device.h" +#include <android-base/logging.h> +#include <android-base/macros.h> + #include "ui.h" -static const char* MENU_ITEMS[] = { +// clang-format off +static constexpr const char* kItems[]{ "Reboot system now", "Reboot to bootloader", "Apply update from ADB", @@ -32,10 +36,11 @@ static const char* MENU_ITEMS[] = { "Run graphics test", "Run locale test", "Power off", - nullptr, }; +// clang-format on -static const Device::BuiltinAction MENU_ACTIONS[] = { +// clang-format off +static constexpr Device::BuiltinAction kMenuActions[] { Device::REBOOT, Device::REBOOT_BOOTLOADER, Device::APPLY_ADB_SIDELOAD, @@ -50,18 +55,20 @@ static const Device::BuiltinAction MENU_ACTIONS[] = { Device::RUN_LOCALE_TEST, Device::SHUTDOWN, }; +// clang-format on + +static_assert(arraysize(kItems) == arraysize(kMenuActions), + "kItems and kMenuActions should have the same length."); -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."); +static const std::vector<std::string> kMenuItems(kItems, kItems + arraysize(kItems)); -const char* const* Device::GetMenuItems() { - return MENU_ITEMS; +const std::vector<std::string>& Device::GetMenuItems() { + return kMenuItems; } -Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { - return menu_position < 0 ? NO_ACTION : MENU_ACTIONS[menu_position]; +Device::BuiltinAction Device::InvokeMenuItem(size_t menu_position) { + // CHECK_LT(menu_position, ); + return kMenuActions[menu_position]; } int Device::HandleMenuKey(int key, bool visible) { |