From c51ac89f0ee5d4a0dd8edebc134a924f83738140 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 20 Mar 2015 18:22:15 -0700 Subject: Add "Apply update from sdcard" to default recovery image. At the moment, this is the only difference in the sprout recovery image. That's silly. Let's just improve the error handling slightly and always have this option present. Also make the obscure "<3e>" less unclear. Also use "power button" as the default text rather than "enter button", because it's been years since anyone had one of those. (Longer term we should let subclassers tell us the keycode and we translate it to the correct string.) Also move the two "Reboot" options together, put "Power off" at the bottom (and use that terminology, like the real UI, rather than "Power down"), and use capitals throughout. Finally, add a README.md with some useful instructions. Change-Id: I94fb19f73d79c54fed2dda30cefb884426641b5c --- default_device.cpp | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'default_device.cpp') diff --git a/default_device.cpp b/default_device.cpp index 97806ac58..ed601f6c6 100644 --- a/default_device.cpp +++ b/default_device.cpp @@ -20,19 +20,24 @@ #include "device.h" #include "screen_ui.h" -static const char* HEADERS[] = { "Volume up/down to move highlight;", - "enter button to select.", - "", - NULL }; +static const char* HEADERS[] = { + "Volume up/down to move highlight.", + "Power button to select.", + "", + NULL +}; -static const char* ITEMS[] = {"reboot system now", - "apply update from ADB", - "wipe data/factory reset", - "wipe cache partition", - "reboot to bootloader", - "power down", - "view recovery logs", - NULL }; +static const char* ITEMS[] = { + "Reboot system now", + "Reboot to bootloader", + "Apply update from ADB", + "Apply update from SD card", + "Wipe data/factory reset", + "Wipe cache partition", + "View recovery logs", + "Power off", + NULL +}; class DefaultDevice : public Device { public: @@ -65,12 +70,13 @@ class DefaultDevice : public Device { BuiltinAction InvokeMenuItem(int menu_position) { switch (menu_position) { case 0: return REBOOT; - case 1: return APPLY_ADB_SIDELOAD; - case 2: return WIPE_DATA; - case 3: return WIPE_CACHE; - case 4: return REBOOT_BOOTLOADER; - case 5: return SHUTDOWN; + case 1: return REBOOT_BOOTLOADER; + case 2: return APPLY_ADB_SIDELOAD; + case 3: return APPLY_EXT; + case 4: return WIPE_DATA; + case 5: return WIPE_CACHE; case 6: return READ_RECOVERY_LASTLOG; + case 7: return SHUTDOWN; default: return NO_ACTION; } } -- cgit v1.2.3 From 9e7ae8a62652258f3ecbf147b578b73286f6d4d8 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 9 Apr 2015 13:40:31 -0700 Subject: Move default implementations into Device. The current abstract class was a nice idea but has led to a lot of copy & paste in practice. Right now, no one we know of has any extra menu items, so let's make the default menu available to everyone. (If we assume that someone somewhere really does need custom device-specific menu options, a better API would let them add to our menu rather than replacing it.) Change-Id: I59f6a92f3ecd830c2ce78ce9da19eaaf472c5dfa --- default_device.cpp | 90 ++++++++++++++---------------------------------------- 1 file changed, 23 insertions(+), 67 deletions(-) (limited to 'default_device.cpp') diff --git a/default_device.cpp b/default_device.cpp index ed601f6c6..d7dd45283 100644 --- a/default_device.cpp +++ b/default_device.cpp @@ -14,80 +14,36 @@ * limitations under the License. */ -#include - -#include "common.h" #include "device.h" #include "screen_ui.h" -static const char* HEADERS[] = { - "Volume up/down to move highlight.", - "Power button to select.", - "", - NULL -}; - -static const char* ITEMS[] = { - "Reboot system now", - "Reboot to bootloader", - "Apply update from ADB", - "Apply update from SD card", - "Wipe data/factory reset", - "Wipe cache partition", - "View recovery logs", - "Power off", - NULL -}; - class DefaultDevice : public Device { - public: - DefaultDevice() : - ui(new ScreenRecoveryUI) { - } - - RecoveryUI* GetUI() { return ui; } - - int HandleMenuKey(int key, int visible) { - if (visible) { - switch (key) { - case KEY_DOWN: - case KEY_VOLUMEDOWN: - return kHighlightDown; - - case KEY_UP: - case KEY_VOLUMEUP: - return kHighlightUp; - - case KEY_ENTER: - case KEY_POWER: - return kInvokeItem; - } - } - - return kNoAction; + public: + DefaultDevice() : Device(new ScreenRecoveryUI) { + } + + // TODO: make this handle more cases, and move the default implementation into Device too. + int HandleMenuKey(int key, int visible) { + if (visible) { + switch (key) { + case KEY_DOWN: + case KEY_VOLUMEDOWN: + return kHighlightDown; + + case KEY_UP: + case KEY_VOLUMEUP: + return kHighlightUp; + + case KEY_ENTER: + case KEY_POWER: + return kInvokeItem; + } } - BuiltinAction 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_EXT; - case 4: return WIPE_DATA; - case 5: return WIPE_CACHE; - case 6: return READ_RECOVERY_LASTLOG; - case 7: return SHUTDOWN; - default: return NO_ACTION; - } - } - - const char* const* GetMenuHeaders() { return HEADERS; } - const char* const* GetMenuItems() { return ITEMS; } - - private: - RecoveryUI* ui; + return kNoAction; + } }; Device* make_device() { - return new DefaultDevice(); + return new DefaultDevice; } -- cgit v1.2.3 From 4af215b2c35b41e983753256ad6dbebbf879c982 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Apr 2015 15:00:34 -0700 Subject: Auto-detect whether to use the long-press UI. Change-Id: Ie77a5584e301467c6a5e164d2c62d6f036b2c0c0 --- default_device.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'default_device.cpp') diff --git a/default_device.cpp b/default_device.cpp index d7dd45283..a9718668d 100644 --- a/default_device.cpp +++ b/default_device.cpp @@ -17,33 +17,6 @@ #include "device.h" #include "screen_ui.h" -class DefaultDevice : public Device { - public: - DefaultDevice() : Device(new ScreenRecoveryUI) { - } - - // TODO: make this handle more cases, and move the default implementation into Device too. - int HandleMenuKey(int key, int visible) { - if (visible) { - switch (key) { - case KEY_DOWN: - case KEY_VOLUMEDOWN: - return kHighlightDown; - - case KEY_UP: - case KEY_VOLUMEUP: - return kHighlightUp; - - case KEY_ENTER: - case KEY_POWER: - return kInvokeItem; - } - } - - return kNoAction; - } -}; - Device* make_device() { - return new DefaultDevice; + return new Device(new ScreenRecoveryUI); } -- cgit v1.2.3