From 42c12306c90e9ac467262f838dba30a5ff81957e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 9 Apr 2015 11:50:56 -0700 Subject: Remove some commented-out code. Change-Id: Ifb466ee2a89da88832c04086fa43da2b8409c232 --- device.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'device.h') diff --git a/device.h b/device.h index 8ff4ec031..02f956489 100644 --- a/device.h +++ b/device.h @@ -34,16 +34,6 @@ class Device { // before anything else). virtual void StartRecovery() { }; - // enum KeyAction { NONE, TOGGLE, REBOOT }; - - // // Called in the input thread when a new key (key_code) is - // // pressed. *key_pressed is an array of KEY_MAX+1 bytes - // // indicating which other keys are already pressed. Return a - // // KeyAction to indicate action should be taken immediately. - // // These actions happen when recovery is not waiting for input - // // (eg, in the midst of installing a package). - // virtual KeyAction CheckImmediateKeyAction(volatile char* key_pressed, int key_code) = 0; - // Called from the main thread when recovery is at the main menu // and waiting for input, and a key is pressed. (Note that "at" // the main menu does not necessarily mean the menu is visible; -- 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 --- device.h | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'device.h') diff --git a/device.h b/device.h index 8ff4ec031..a24540066 100644 --- a/device.h +++ b/device.h @@ -21,13 +21,14 @@ class Device { public: + Device(RecoveryUI* ui) : ui_(ui) { } virtual ~Device() { } // Called to obtain the UI object that should be used to display // the recovery user interface for this device. You should not // have called Init() on the UI object already, the caller will do // that after this method returns. - virtual RecoveryUI* GetUI() = 0; + virtual RecoveryUI* GetUI() { return ui_; } // Called when recovery starts up (after the UI has been obtained // and initialized and after the arguments have been parsed, but @@ -70,6 +71,17 @@ class Device { APPLY_ADB_SIDELOAD, WIPE_DATA, WIPE_CACHE, REBOOT_BOOTLOADER, SHUTDOWN, READ_RECOVERY_LASTLOG }; + // Return the headers (an array of strings, one per line, + // NULL-terminated) for the main menu. Typically these tell users + // what to push to move the selection and invoke the selected + // item. + virtual const char* const* GetMenuHeaders(); + + // Return the list of menu items (an array of strings, + // NULL-terminated). The menu_position passed to InvokeMenuItem + // will correspond to the indexes into this array. + virtual const char* const* GetMenuItems(); + // Perform a recovery action selected from the menu. // 'menu_position' will be the item number of the selected menu // item, or a non-negative number returned from @@ -79,7 +91,7 @@ class Device { // builtin actions, you can just return the corresponding enum // value. If it is an action specific to your device, you // actually perform it here and return NO_ACTION. - virtual BuiltinAction InvokeMenuItem(int menu_position) = 0; + virtual BuiltinAction InvokeMenuItem(int menu_position); static const int kNoAction = -1; static const int kHighlightUp = -2; @@ -94,16 +106,8 @@ class Device { // are erased AFTER this returns (whether it returns success or not). virtual int WipeData() { return 0; } - // Return the headers (an array of strings, one per line, - // NULL-terminated) for the main menu. Typically these tell users - // what to push to move the selection and invoke the selected - // item. - virtual const char* const* GetMenuHeaders() = 0; - - // Return the list of menu items (an array of strings, - // NULL-terminated). The menu_position passed to InvokeMenuItem - // will correspond to the indexes into this array. - virtual const char* const* GetMenuItems() = 0; + private: + RecoveryUI* ui_; }; // The device-specific library must define this function (or the -- cgit v1.2.3 From ec28340cf3af1029a00db1c83d78d14e8798e245 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 10 Apr 2015 10:01:53 -0700 Subject: Move "Mount /system" to the main menu. Everyone's adding secret key combinations for this anyway, and it's very useful when debugging. Change-Id: Iad549452b872a7af963dd649f283ebcd3ea24234 --- device.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'device.h') diff --git a/device.h b/device.h index 97ec2fb41..3d9101bf4 100644 --- a/device.h +++ b/device.h @@ -56,10 +56,19 @@ class Device { // - invoke a specific action (a menu position: any non-negative number) virtual int HandleMenuKey(int key, int visible) = 0; - enum BuiltinAction { NO_ACTION, REBOOT, APPLY_EXT, - APPLY_CACHE, // APPLY_CACHE is deprecated; has no effect - APPLY_ADB_SIDELOAD, WIPE_DATA, WIPE_CACHE, - REBOOT_BOOTLOADER, SHUTDOWN, READ_RECOVERY_LASTLOG }; + enum BuiltinAction { + NO_ACTION = 0, + REBOOT = 1, + APPLY_SDCARD = 2, + // APPLY_CACHE was 3. + APPLY_ADB_SIDELOAD = 4, + WIPE_DATA = 5, + WIPE_CACHE = 6, + REBOOT_BOOTLOADER = 7, + SHUTDOWN = 8, + VIEW_RECOVERY_LOGS = 9, + MOUNT_SYSTEM = 10, + }; // Return the headers (an array of strings, one per line, // NULL-terminated) for the main menu. Typically these tell users -- 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 --- device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'device.h') diff --git a/device.h b/device.h index 3d9101bf4..150718359 100644 --- a/device.h +++ b/device.h @@ -54,7 +54,7 @@ class Device { // - invoke the highlighted item (kInvokeItem) // - do nothing (kNoAction) // - invoke a specific action (a menu position: any non-negative number) - virtual int HandleMenuKey(int key, int visible) = 0; + virtual int HandleMenuKey(int key, int visible); enum BuiltinAction { NO_ACTION = 0, -- cgit v1.2.3 From 8fd86d77f1a2f15c6fa95bc390bcbe646374873a Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 13 Apr 2015 14:36:02 -0700 Subject: Move the menu header out of the menu. This makes it easier for us to deal with arbitrary information at the top, and means that headers added by specific commands don't overwrite the default ones. Add the fingerprint back, but broken up so it fits even on sprout's display. Change-Id: Id71da79ab1aa455a611d72756a3100a97ceb4c1c --- device.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'device.h') diff --git a/device.h b/device.h index 150718359..dad8ccd56 100644 --- a/device.h +++ b/device.h @@ -70,12 +70,6 @@ class Device { MOUNT_SYSTEM = 10, }; - // Return the headers (an array of strings, one per line, - // NULL-terminated) for the main menu. Typically these tell users - // what to push to move the selection and invoke the selected - // item. - virtual const char* const* GetMenuHeaders(); - // Return the list of menu items (an array of strings, // NULL-terminated). The menu_position passed to InvokeMenuItem // will correspond to the indexes into this array. -- cgit v1.2.3 From 0005f89c31dfc2ca9053512900571620a0eba842 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 5 Jun 2015 17:59:56 -0700 Subject: Split WipeData into PreWipeData and PostWipeData. Bug: http://b/21760064 Change-Id: Idde268fe4d7e27586ca4469de16783f1ffdc5069 (cherry picked from commit 945548ef7b3eee5dbfb46f6291465d4b0b6d02e1) --- device.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'device.h') diff --git a/device.h b/device.h index dad8ccd56..f74b6b047 100644 --- a/device.h +++ b/device.h @@ -91,13 +91,16 @@ class Device { static const int kHighlightDown = -3; static const int kInvokeItem = -4; - // Called when we do a wipe data/factory reset operation (either via a - // reboot from the main system with the --wipe_data flag, or when the - // user boots into recovery manually and selects the option from the - // menu.) Can perform whatever device-specific wiping actions are - // needed. Return 0 on success. The userdata and cache partitions - // are erased AFTER this returns (whether it returns success or not). - virtual int WipeData() { return 0; } + // Called before and after we do a wipe data/factory reset operation, + // either via a reboot from the main system with the --wipe_data flag, + // or when the user boots into recovery image manually and selects the + // option from the menu, to perform whatever device-specific wiping + // actions are needed. + // Return true on success; returning false from PreWipeData will prevent + // the regular wipe, and returning false from PostWipeData will cause + // the wipe to be considered a failure. + virtual bool PreWipeData() { return true; } + virtual bool PostWipeData() { return true; } private: RecoveryUI* ui_; -- cgit v1.2.3