aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-02-23 21:06:53 -0600
committerTao Bao2017-03-07 17:35:12 -0600
commitfc5499f22bd9b30affca08e584411012f71b6e9c (patch)
tree80131d47bb390fe5d54587e7e2257ada9725d6e8 /device.h
parentb7f56f9b914c9c1fa9065e9ddfc72f2c930123e1 (diff)
downloadplatform-bootable-recovery-fc5499f22bd9b30affca08e584411012f71b6e9c.tar.gz
platform-bootable-recovery-fc5499f22bd9b30affca08e584411012f71b6e9c.tar.xz
platform-bootable-recovery-fc5499f22bd9b30affca08e584411012f71b6e9c.zip
recovery: Move a few int to bool.
Most of the changes are trivial. Also update a dead reference to device_handle_key() in device.h comment, and add some comments to get_menu_selection() function. Test: `mmma bootable/recovery` Change-Id: I59ef9213ec88ab35c0e7b8a7813ccf9c56dbd5c5
Diffstat (limited to 'device.h')
-rw-r--r--device.h152
1 files changed, 73 insertions, 79 deletions
diff --git a/device.h b/device.h
index 08dfcdff..639e2bf5 100644
--- a/device.h
+++ b/device.h
@@ -20,96 +20,90 @@
20#include "ui.h" 20#include "ui.h"
21 21
22class Device { 22class Device {
23 public: 23 public:
24 explicit Device(RecoveryUI* ui) : ui_(ui) { } 24 explicit Device(RecoveryUI* ui) : ui_(ui) {}
25 virtual ~Device() { } 25 virtual ~Device() {}
26 26
27 // Called to obtain the UI object that should be used to display 27 // Called to obtain the UI object that should be used to display the recovery user interface for
28 // the recovery user interface for this device. You should not 28 // this device. You should not have called Init() on the UI object already, the caller will do
29 // have called Init() on the UI object already, the caller will do 29 // that after this method returns.
30 // that after this method returns. 30 virtual RecoveryUI* GetUI() {
31 virtual RecoveryUI* GetUI() { return ui_; } 31 return ui_;
32 }
32 33
33 // Called when recovery starts up (after the UI has been obtained 34 // Called when recovery starts up (after the UI has been obtained and initialized and after the
34 // and initialized and after the arguments have been parsed, but 35 // arguments have been parsed, but before anything else).
35 // before anything else). 36 virtual void StartRecovery() {};
36 virtual void StartRecovery() { };
37 37
38 // Called from the main thread when recovery is at the main menu 38 // Called from the main thread when recovery is at the main menu and waiting for input, and a key
39 // and waiting for input, and a key is pressed. (Note that "at" 39 // is pressed. (Note that "at" the main menu does not necessarily mean the menu is visible;
40 // the main menu does not necessarily mean the menu is visible; 40 // recovery will be at the main menu with it invisible after an unsuccessful operation [ie OTA
41 // recovery will be at the main menu with it invisible after an 41 // package failure], or if recovery is started with no command.)
42 // unsuccessful operation [ie OTA package failure], or if recovery 42 //
43 // is started with no command.) 43 // 'key' is the code of the key just pressed. (You can call IsKeyPressed() on the RecoveryUI
44 // 44 // object you returned from GetUI if you want to find out if other keys are held down.)
45 // key is the code of the key just pressed. (You can call 45 //
46 // IsKeyPressed() on the RecoveryUI object you returned from GetUI 46 // 'visible' is true if the menu is visible.
47 // if you want to find out if other keys are held down.) 47 //
48 // 48 // Returns one of the defined constants below in order to:
49 // visible is true if the menu is visible. 49 //
50 // 50 // - move the menu highlight (kHighlight{Up,Down})
51 // Return one of the defined constants below in order to: 51 // - invoke the highlighted item (kInvokeItem)
52 // 52 // - do nothing (kNoAction)
53 // - move the menu highlight (kHighlight{Up,Down}) 53 // - invoke a specific action (a menu position: any non-negative number)
54 // - invoke the highlighted item (kInvokeItem) 54 virtual int HandleMenuKey(int key, bool visible);
55 // - do nothing (kNoAction)
56 // - invoke a specific action (a menu position: any non-negative number)
57 virtual int HandleMenuKey(int key, int visible);
58 55
59 enum BuiltinAction { 56 enum BuiltinAction {
60 NO_ACTION = 0, 57 NO_ACTION = 0,
61 REBOOT = 1, 58 REBOOT = 1,
62 APPLY_SDCARD = 2, 59 APPLY_SDCARD = 2,
63 // APPLY_CACHE was 3. 60 // APPLY_CACHE was 3.
64 APPLY_ADB_SIDELOAD = 4, 61 APPLY_ADB_SIDELOAD = 4,
65 WIPE_DATA = 5, 62 WIPE_DATA = 5,
66 WIPE_CACHE = 6, 63 WIPE_CACHE = 6,
67 REBOOT_BOOTLOADER = 7, 64 REBOOT_BOOTLOADER = 7,
68 SHUTDOWN = 8, 65 SHUTDOWN = 8,
69 VIEW_RECOVERY_LOGS = 9, 66 VIEW_RECOVERY_LOGS = 9,
70 MOUNT_SYSTEM = 10, 67 MOUNT_SYSTEM = 10,
71 RUN_GRAPHICS_TEST = 11, 68 RUN_GRAPHICS_TEST = 11,
72 }; 69 };
73 70
74 // Return the list of menu items (an array of strings, 71 // Return the list of menu items (an array of strings, NULL-terminated). The menu_position passed
75 // NULL-terminated). The menu_position passed to InvokeMenuItem 72 // to InvokeMenuItem will correspond to the indexes into this array.
76 // will correspond to the indexes into this array. 73 virtual const char* const* GetMenuItems();
77 virtual const char* const* GetMenuItems();
78 74
79 // Perform a recovery action selected from the menu. 75 // Perform a recovery action selected from the menu. 'menu_position' will be the item number of
80 // 'menu_position' will be the item number of the selected menu 76 // the selected menu item, or a non-negative number returned from HandleMenuKey(). The menu will
81 // item, or a non-negative number returned from 77 // be hidden when this is called; implementations can call ui_print() to print information to the
82 // device_handle_key(). The menu will be hidden when this is 78 // screen. If the menu position is one of the builtin actions, you can just return the
83 // called; implementations can call ui_print() to print 79 // corresponding enum value. If it is an action specific to your device, you actually perform it
84 // information to the screen. If the menu position is one of the 80 // here and return NO_ACTION.
85 // builtin actions, you can just return the corresponding enum 81 virtual BuiltinAction InvokeMenuItem(int menu_position);
86 // value. If it is an action specific to your device, you
87 // actually perform it here and return NO_ACTION.
88 virtual BuiltinAction InvokeMenuItem(int menu_position);
89 82
90 static const int kNoAction = -1; 83 static const int kNoAction = -1;
91 static const int kHighlightUp = -2; 84 static const int kHighlightUp = -2;
92 static const int kHighlightDown = -3; 85 static const int kHighlightDown = -3;
93 static const int kInvokeItem = -4; 86 static const int kInvokeItem = -4;
94 87
95 // Called before and after we do a wipe data/factory reset operation, 88 // Called before and after we do a wipe data/factory reset operation, either via a reboot from the
96 // either via a reboot from the main system with the --wipe_data flag, 89 // main system with the --wipe_data flag, or when the user boots into recovery image manually and
97 // or when the user boots into recovery image manually and selects the 90 // selects the option from the menu, to perform whatever device-specific wiping actions as needed.
98 // option from the menu, to perform whatever device-specific wiping 91 // Returns true on success; returning false from PreWipeData will prevent the regular wipe, and
99 // actions are needed. 92 // returning false from PostWipeData will cause the wipe to be considered a failure.
100 // Return true on success; returning false from PreWipeData will prevent 93 virtual bool PreWipeData() {
101 // the regular wipe, and returning false from PostWipeData will cause 94 return true;
102 // the wipe to be considered a failure. 95 }
103 virtual bool PreWipeData() { return true; }
104 virtual bool PostWipeData() { return true; }
105 96
106 private: 97 virtual bool PostWipeData() {
107 RecoveryUI* ui_; 98 return true;
99 }
100
101 private:
102 RecoveryUI* ui_;
108}; 103};
109 104
110// The device-specific library must define this function (or the 105// The device-specific library must define this function (or the default one will be used, if there
111// default one will be used, if there is no device-specific library). 106// is no device-specific library). It returns the Device object that recovery should use.
112// It returns the Device object that recovery should use.
113Device* make_device(); 107Device* make_device();
114 108
115#endif // _DEVICE_H 109#endif // _DEVICE_H