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
diff --git a/Android.mk b/Android.mk
index a567aa5..a34c265 100644
--- a/Android.mk
+++ b/Android.mk
@@ -107,7 +107,6 @@
 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 20a763f..af92b15 100644
--- a/device.cpp
+++ b/device.cpp
@@ -31,6 +31,7 @@
     "Apply update from SD card",
     "Wipe data/factory reset",
     "Wipe cache partition",
+    "Mount /system",
     "View recovery logs",
     "Power off",
     NULL
@@ -44,11 +45,12 @@
     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 97ec2fb..3d9101b 100644
--- a/device.h
+++ b/device.h
@@ -56,10 +56,19 @@
     //   - 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 bbfeda4..cdbb598 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -840,7 +840,7 @@
                 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 @@
                 }
                 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 c8f08cd..8716245 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 @@
 }
 
 
-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 @@
           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 @@
 
 
 // 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 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 @@
     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 @@
         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 3b21774..bc728b0 100644
--- a/ui.h
+++ b/ui.h
@@ -81,7 +81,7 @@
     // 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 @@
     int rel_sum;
 
     int consecutive_power_keys;
-    int consecutive_alternate_keys;
     int last_key;
 
     typedef struct {