diff options
Diffstat (limited to 'default_device.cpp')
-rw-r--r-- | default_device.cpp | 90 |
1 files changed, 23 insertions, 67 deletions
diff --git a/default_device.cpp b/default_device.cpp index ed601f6c..d7dd4528 100644 --- a/default_device.cpp +++ b/default_device.cpp | |||
@@ -14,80 +14,36 @@ | |||
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/input.h> | ||
18 | |||
19 | #include "common.h" | ||
20 | #include "device.h" | 17 | #include "device.h" |
21 | #include "screen_ui.h" | 18 | #include "screen_ui.h" |
22 | 19 | ||
23 | static const char* HEADERS[] = { | ||
24 | "Volume up/down to move highlight.", | ||
25 | "Power button to select.", | ||
26 | "", | ||
27 | NULL | ||
28 | }; | ||
29 | |||
30 | static const char* ITEMS[] = { | ||
31 | "Reboot system now", | ||
32 | "Reboot to bootloader", | ||
33 | "Apply update from ADB", | ||
34 | "Apply update from SD card", | ||
35 | "Wipe data/factory reset", | ||
36 | "Wipe cache partition", | ||
37 | "View recovery logs", | ||
38 | "Power off", | ||
39 | NULL | ||
40 | }; | ||
41 | |||
42 | class DefaultDevice : public Device { | 20 | class DefaultDevice : public Device { |
43 | public: | 21 | public: |
44 | DefaultDevice() : | 22 | DefaultDevice() : Device(new ScreenRecoveryUI) { |
45 | ui(new ScreenRecoveryUI) { | 23 | } |
46 | } | 24 | |
47 | 25 | // TODO: make this handle more cases, and move the default implementation into Device too. | |
48 | RecoveryUI* GetUI() { return ui; } | 26 | int HandleMenuKey(int key, int visible) { |
49 | 27 | if (visible) { | |
50 | int HandleMenuKey(int key, int visible) { | 28 | switch (key) { |
51 | if (visible) { | 29 | case KEY_DOWN: |
52 | switch (key) { | 30 | case KEY_VOLUMEDOWN: |
53 | case KEY_DOWN: | 31 | return kHighlightDown; |
54 | case KEY_VOLUMEDOWN: | 32 | |
55 | return kHighlightDown; | 33 | case KEY_UP: |
56 | 34 | case KEY_VOLUMEUP: | |
57 | case KEY_UP: | 35 | return kHighlightUp; |
58 | case KEY_VOLUMEUP: | 36 | |
59 | return kHighlightUp; | 37 | case KEY_ENTER: |
60 | 38 | case KEY_POWER: | |
61 | case KEY_ENTER: | 39 | return kInvokeItem; |
62 | case KEY_POWER: | 40 | } |
63 | return kInvokeItem; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | return kNoAction; | ||
68 | } | 41 | } |
69 | 42 | ||
70 | BuiltinAction InvokeMenuItem(int menu_position) { | 43 | return kNoAction; |
71 | switch (menu_position) { | 44 | } |
72 | case 0: return REBOOT; | ||
73 | case 1: return REBOOT_BOOTLOADER; | ||
74 | case 2: return APPLY_ADB_SIDELOAD; | ||
75 | case 3: return APPLY_EXT; | ||
76 | case 4: return WIPE_DATA; | ||
77 | case 5: return WIPE_CACHE; | ||
78 | case 6: return READ_RECOVERY_LASTLOG; | ||
79 | case 7: return SHUTDOWN; | ||
80 | default: return NO_ACTION; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | const char* const* GetMenuHeaders() { return HEADERS; } | ||
85 | const char* const* GetMenuItems() { return ITEMS; } | ||
86 | |||
87 | private: | ||
88 | RecoveryUI* ui; | ||
89 | }; | 45 | }; |
90 | 46 | ||
91 | Device* make_device() { | 47 | Device* make_device() { |
92 | return new DefaultDevice(); | 48 | return new DefaultDevice; |
93 | } | 49 | } |