summaryrefslogtreecommitdiffstats
path: root/device.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-05-02 00:56:05 +0200
committerTao Bao <tbao@google.com>2018-05-03 21:31:18 +0200
commit1fe1afe863fde957051774cf2d9936c314d342a2 (patch)
tree40ece1d1f510c39df717316764c23c1c88b0630c /device.cpp
parentMerge "updater_sample: update ui and README, clean-up" (diff)
downloadandroid_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar.gz
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar.bz2
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar.lz
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar.xz
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.tar.zst
android_bootable_recovery-1fe1afe863fde957051774cf2d9936c314d342a2.zip
Diffstat (limited to 'device.cpp')
-rw-r--r--device.cpp29
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) {