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 --- Android.mk | 1 - device.cpp | 8 +++++--- device.h | 17 +++++++++++++---- recovery.cpp | 12 +++++++----- ui.cpp | 56 ++++++++++++++++---------------------------------------- ui.h | 3 +-- 6 files changed, 42 insertions(+), 55 deletions(-) diff --git a/Android.mk b/Android.mk index a567aa5a2..a34c2659d 100644 --- a/Android.mk +++ b/Android.mk @@ -107,7 +107,6 @@ include $(CLEAR_VARS) LOCAL_MODULE := verifier_test LOCAL_FORCE_STATIC_EXECUTABLE := true LOCAL_MODULE_TAGS := tests -LOCAL_CFLAGS += -DNO_RECOVERY_MOUNT LOCAL_CFLAGS += -Wno-unused-parameter LOCAL_SRC_FILES := \ verifier_test.cpp \ diff --git a/device.cpp b/device.cpp index 20a763f2b..af92b15bd 100644 --- a/device.cpp +++ b/device.cpp @@ -31,6 +31,7 @@ static const char* ITEMS[] = { "Apply update from SD card", "Wipe data/factory reset", "Wipe cache partition", + "Mount /system", "View recovery logs", "Power off", NULL @@ -44,11 +45,12 @@ Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { case 0: return REBOOT; case 1: return REBOOT_BOOTLOADER; case 2: return APPLY_ADB_SIDELOAD; - case 3: return APPLY_EXT; + case 3: return APPLY_SDCARD; case 4: return WIPE_DATA; case 5: return WIPE_CACHE; - case 6: return READ_RECOVERY_LASTLOG; - case 7: return SHUTDOWN; + case 6: return MOUNT_SYSTEM; + case 7: return VIEW_RECOVERY_LOGS; + case 8: return SHUTDOWN; default: return NO_ACTION; } } 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 diff --git a/recovery.cpp b/recovery.cpp index bbfeda4a6..cdbb598e3 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -840,7 +840,7 @@ prompt_and_wait(Device* device, int status) { break; case Device::APPLY_ADB_SIDELOAD: - case Device::APPLY_EXT: + case Device::APPLY_SDCARD: { bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD); if (adb) { @@ -867,12 +867,14 @@ prompt_and_wait(Device* device, int status) { } break; - case Device::APPLY_CACHE: - ui->Print("\nAPPLY_CACHE is deprecated.\n"); + case Device::VIEW_RECOVERY_LOGS: + choose_recovery_file(device); break; - case Device::READ_RECOVERY_LASTLOG: - choose_recovery_file(device); + case Device::MOUNT_SYSTEM: + if (ensure_path_mounted("/system") != -1) { + ui->Print("Mounted /system."); + } break; } } diff --git a/ui.cpp b/ui.cpp index c8f08cdd1..871624520 100644 --- a/ui.cpp +++ b/ui.cpp @@ -44,15 +44,14 @@ // so use a global variable. static RecoveryUI* self = NULL; -RecoveryUI::RecoveryUI() : - key_queue_len(0), - key_last_down(-1), - key_long_press(false), - key_down_count(0), - enable_reboot(true), - consecutive_power_keys(0), - consecutive_alternate_keys(0), - last_key(-1) { +RecoveryUI::RecoveryUI() + : key_queue_len(0), + key_last_down(-1), + key_long_press(false), + key_down_count(0), + enable_reboot(true), + consecutive_power_keys(0), + last_key(-1) { pthread_mutex_init(&key_queue_mutex, NULL); pthread_cond_init(&key_queue_cond, NULL); self = this; @@ -65,8 +64,7 @@ void RecoveryUI::Init() { } -int RecoveryUI::input_callback(int fd, uint32_t epevents, void* data) -{ +int RecoveryUI::input_callback(int fd, uint32_t epevents, void* data) { struct input_event ev; int ret; @@ -162,13 +160,6 @@ void RecoveryUI::process_key(int key_code, int updown) { case RecoveryUI::ENQUEUE: EnqueueKey(key_code); break; - - case RecoveryUI::MOUNT_SYSTEM: -#ifndef NO_RECOVERY_MOUNT - ensure_path_mounted("/system"); - Print("Mounted /system."); -#endif - break; } } } @@ -203,17 +194,16 @@ void RecoveryUI::EnqueueKey(int key_code) { // Reads input events, handles special hot keys, and adds to the key queue. -void* RecoveryUI::input_thread(void *cookie) -{ - for (;;) { - if (!ev_wait(-1)) +void* RecoveryUI::input_thread(void* cookie) { + while (true) { + if (!ev_wait(-1)) { ev_dispatch(); + } } return NULL; } -int RecoveryUI::WaitKey() -{ +int RecoveryUI::WaitKey() { pthread_mutex_lock(&key_queue_mutex); // Time out after UI_WAIT_KEY_TIMEOUT_SEC, unless a USB cable is @@ -228,8 +218,7 @@ int RecoveryUI::WaitKey() int rc = 0; while (key_queue_len == 0 && rc != ETIMEDOUT) { - rc = pthread_cond_timedwait(&key_queue_cond, &key_queue_mutex, - &timeout); + rc = pthread_cond_timedwait(&key_queue_cond, &key_queue_mutex, &timeout); } } while (usb_connected() && key_queue_len == 0); @@ -261,8 +250,7 @@ bool RecoveryUI::usb_connected() { return connected; } -bool RecoveryUI::IsKeyPressed(int key) -{ +bool RecoveryUI::IsKeyPressed(int key) { pthread_mutex_lock(&key_queue_mutex); int pressed = key_pressed[key]; pthread_mutex_unlock(&key_queue_mutex); @@ -301,18 +289,6 @@ RecoveryUI::KeyAction RecoveryUI::CheckKey(int key) { consecutive_power_keys = 0; } - if ((key == KEY_VOLUMEUP && - (last_key == KEY_VOLUMEDOWN || last_key == -1)) || - (key == KEY_VOLUMEDOWN && - (last_key == KEY_VOLUMEUP || last_key == -1))) { - ++consecutive_alternate_keys; - if (consecutive_alternate_keys >= 7) { - consecutive_alternate_keys = 0; - return MOUNT_SYSTEM; - } - } else { - consecutive_alternate_keys = 0; - } last_key = key; return ENQUEUE; diff --git a/ui.h b/ui.h index 3b217745f..bc728b05a 100644 --- a/ui.h +++ b/ui.h @@ -81,7 +81,7 @@ class RecoveryUI { // Return value indicates whether an immediate operation should be // triggered (toggling the display, rebooting the device), or if // the key should be enqueued for use by the main thread. - enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE, MOUNT_SYSTEM }; + enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE }; virtual KeyAction CheckKey(int key); // Called immediately before each call to CheckKey(), tell you if @@ -134,7 +134,6 @@ private: int rel_sum; int consecutive_power_keys; - int consecutive_alternate_keys; int last_key; typedef struct { -- cgit v1.2.3