allow toggling of software back menu item. add recovery checkpoint file. mount auto now uses busybox mount.

This commit is contained in:
Koushik Dutta 2010-07-14 18:37:33 -07:00
parent 37186b19bc
commit 1bf4f695d4
8 changed files with 78 additions and 25 deletions

View File

@ -26,7 +26,7 @@ LOCAL_MODULE := recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true
RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.2
RECOVERY_VERSION := ClockworkMod Recovery v2.0.2.4
LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)

View File

@ -47,6 +47,9 @@ int ui_menu_select(int sel);
// statements will be displayed.
void ui_end_menu();
int ui_get_showing_back_button();
void ui_set_showing_back_button(int showBackButton);
// Set the icon (normally the only thing visible besides the progress bar).
enum {
BACKGROUND_ICON_NONE,

View File

@ -37,11 +37,10 @@ int device_toggle_display(volatile char* key_pressed, int key_code) {
if (alt && key_code == KEY_L)
return 1;
// allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
#ifdef KEY_POWER_IS_SELECT_ITEM
return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
#else
if (ui_get_showing_back_button()) {
return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
}
return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
#endif
}
int device_reboot_now(volatile char* key_pressed, int key_code) {
@ -59,9 +58,13 @@ int device_handle_key(int key_code, int visible) {
case KEY_VOLUMEUP:
return HIGHLIGHT_UP;
#ifdef KEY_POWER_IS_SELECT_ITEM
case KEY_POWER:
#endif
if (ui_get_showing_back_button()) {
return SELECT_ITEM;
}
if (!get_allow_toggle_display())
return GO_BACK;
break;
case KEY_ENTER:
case BTN_MOUSE:
case KEY_CENTER:
@ -70,9 +73,6 @@ int device_handle_key(int key_code, int visible) {
case KEY_SEND:
return SELECT_ITEM;
#ifndef KEY_POWER_IS_SELECT_ITEM
case KEY_POWER:
#endif
case KEY_END:
case KEY_BACKSPACE:
case KEY_BACK:

View File

@ -627,6 +627,7 @@ int run_and_remove_extendedcommand()
char tmp[PATH_MAX];
sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT));
__system(tmp);
__system("rm /sdcard/clockworkmod/.recoverycheckpoint");
remove(EXTENDEDCOMMAND_SCRIPT);
int i = 0;
for (i = 20; i > 0; i--) {

View File

@ -317,12 +317,19 @@ get_menu_selection(char** headers, char** items, int menu_only) {
int selected = 0;
int chosen_item = -1;
// Some users with dead enter keys need a way to turn on power to select.
// Jiggering across the wrapping menu is one "secret" way to enable it.
// We can't rely on /cache or /sdcard since they may not be available.
int wrap_count = 0;
while (chosen_item < 0 && chosen_item != GO_BACK) {
int key = ui_wait_key();
int visible = ui_text_visible();
int action = device_handle_key(key, visible);
int old_selected = selected;
if (action < 0) {
switch (action) {
case HIGHLIGHT_UP:
@ -335,11 +342,11 @@ get_menu_selection(char** headers, char** items, int menu_only) {
break;
case SELECT_ITEM:
chosen_item = selected;
#ifdef KEY_POWER_IS_SELECT_ITEM
if (chosen_item == item_count) {
chosen_item = GO_BACK;
if (ui_get_showing_back_button()) {
if (chosen_item == item_count) {
chosen_item = GO_BACK;
}
}
#endif
break;
case NO_ACTION:
break;
@ -350,6 +357,21 @@ get_menu_selection(char** headers, char** items, int menu_only) {
} else if (!menu_only) {
chosen_item = action;
}
if (abs(selected - old_selected) > 1) {
wrap_count++;
if (wrap_count == 3) {
wrap_count = 0;
if (ui_get_showing_back_button()) {
ui_print("Back button disabled.\n");
ui_set_showing_back_button(0);
}
else {
ui_print("Back button enabled.\n");
ui_set_showing_back_button(1);
}
}
}
}
ui_end_menu();

17
roots.c
View File

@ -21,6 +21,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <limits.h>
#include "mtdutils/mtdutils.h"
#include "mtdutils/mounts.h"
#include "minzip/Zip.h"
@ -205,6 +207,18 @@ is_root_path_mounted(const char *root_path)
return internal_root_mounted(info) >= 0;
}
static int mount_internal(const char* device, const char* mount_point, const char* filesystem)
{
if (strcmp(filesystem, "auto") != 0) {
return mount(device, mount_point, filesystem, MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
}
else {
char mount_cmd[PATH_MAX];
sprintf(mount_cmd, "mount -onoatime,nodiratime,nodev %s %s", device, mount_point);
return __system(mount_cmd);
}
}
int
ensure_root_path_mounted(const char *root_path)
{
@ -245,8 +259,7 @@ ensure_root_path_mounted(const char *root_path)
}
mkdir(info->mount_point, 0755); // in case it doesn't already exist
if (mount(info->device, info->mount_point, info->filesystem,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "")) {
if (mount_internal(info->device, info->mount_point, info->filesystem)) {
if (info->device2 == NULL) {
LOGE("Can't mount %s\n(%s)\n", info->device, strerror(errno));
return -1;

View File

@ -33,7 +33,7 @@
#endif
#ifndef SDEXT_FILESYSTEM
#define SDEXT_FILESYSTEM "ext4"
#define SDEXT_FILESYSTEM "auto"
#endif
#ifndef DATA_DEVICE

30
ui.c
View File

@ -29,6 +29,12 @@
#include "minui/minui.h"
#include "recovery_ui.h"
#ifdef KEY_POWER_IS_SELECT_ITEM
static int gShowBackButton = 1;
#else
static int gShowBackButton = 0;
#endif
#define MAX_COLS 64
#define MAX_ROWS 32
@ -511,10 +517,11 @@ int ui_start_menu(char** headers, char** items) {
strncpy(menu[i] + MENU_ITEM_HEADER_LENGTH, items[i-menu_top], text_cols-1 - MENU_ITEM_HEADER_LENGTH);
menu[i][text_cols-1] = '\0';
}
#ifdef KEY_POWER_IS_SELECT_ITEM
strcpy(menu[i], " - +++++Go Back+++++");
++i;
#endif
if (gShowBackButton) {
strcpy(menu[i], " - +++++Go Back+++++");
++i;
}
menu_items = i - menu_top;
show_menu = 1;
@ -522,11 +529,10 @@ int ui_start_menu(char** headers, char** items) {
update_screen_locked();
}
pthread_mutex_unlock(&gUpdateMutex);
#ifdef KEY_POWER_IS_SELECT_ITEM
return menu_items - 1;
#else
if (gShowBackButton) {
return menu_items - 1;
}
return menu_items;
#endif
}
int ui_menu_select(int sel) {
@ -602,3 +608,11 @@ void ui_clear_key_queue() {
void ui_set_show_text(int value) {
show_text = value;
}
void ui_set_showing_back_button(int showBackButton) {
gShowBackButton = showBackButton;
}
int ui_get_showing_back_button() {
return gShowBackButton;
}