• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps use "home" to select instead of "power" button in CWM Recovery

stayboogy

Android Expert
Jun 15, 2012
867
285
i have successfully ported CWM Recovery to my ZTE Merit/Avail/Roamer using the CyanogenMod gingerbread source

(i did not use the unofficial port that was built from the ZTE Blade because the screen is upside down)

everything works just like it is supposed to--absolutely flawless. build went through without a hitch.

decided that i instead wanted to use the "home" key to select menu options in the CWM Recovery instead of the "power" button that is default (had to uncomment BOARD_HAS_NO_SELECT_BUTTON in the BoardConfig.mk because there is no camera button on this phone)

so i copied the recovery_ui.c from the working Blade source (which uses the "home" key instead of the "power" key), placed it into my ZTE Roamer (Merit/Avail) source and added BOARD_CUSTOM_RECOVERY_KEYMAPPING := /device/zte/roamer/recovery_ui.c to my BoardConfig.mk

**there is no problem reading the location of the file so don't suggest to change it**

but when i compile i get these errors and it is not built

Code:
prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function get_menu_selection:bootable/recovery/recovery.c:470: error: undefined reference to 'device_handle_key'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function wipe_data:bootable/recovery/recovery.c:681: error: undefined reference to 'device_wipe_data'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function prompt_and_wait:bootable/recovery/recovery.c:707: error: undefined reference to 'device_perform_action'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function prompt_and_wait:bootable/recovery/recovery.c:761: error: undefined reference to 'MENU_HEADERS'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function prompt_and_wait:bootable/recovery/recovery.c:761: error: undefined reference to 'MENU_ITEMS'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function main:bootable/recovery/recovery.c:851: error: undefined reference to 'device_recovery_start'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/recovery.o: in function main:bootable/recovery/recovery.c:920: error: undefined reference to 'device_wipe_data'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/ui.o: in function input_thread:bootable/recovery/ui.c:339: error: undefined reference to 'device_toggle_display'


./arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/ui.o: in function input_thread:bootable/recovery/ui.c:346: error: undefined reference to 'device_reboot_now'

prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/../lib/gcc/arm-eabi/4.4.3/../../../../arm-eabi/bin/ld: out/target/product/roamer/obj/EXECUTABLES/recovery_intermediates/extendedcommands.o: in function show_advanced_menu:bootable/recovery/extendedcommands.c:961: error: undefined reference to 'device_handle_key'

the recovery_ui.c has not been edited at all and it works without a flaw on the Blade, and it doesn't use any other sources from /bootable/recovery/ than what any other one uses, but i get these errors when i try to build.

neither have recovery.o, recovery.c, extendedcommands.o, or ui.c been edited in any way and they are the standard ones included in the CyanogenMod source. and these errors are not present when the Blade is built using the same recovery_ui.c

here's my BoardConfig.mk

Code:
# inherit from the proprietary version
-include vendor/zte/roamer/BoardConfigVendor.mk

TARGET_NO_BOOTLOADER := true
TARGET_BOARD_PLATFORM := unknown
TARGET_CPU_ABI := armeabi
TARGET_BOOTLOADER_BOARD_NAME := roamer
BOARD_KERNEL_CMDLINE :=
BOARD_KERNEL_BASE := 0x02600000
BOARD_KERNEL_PAGESIZE := 2048

# fix this up by examining /proc/mtd on a running device
BOARD_BOOTIMAGE_PARTITION_SIZE := 0x00380000
BOARD_RECOVERYIMAGE_PARTITION_SIZE := 0x00480000
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 0x08c60000
BOARD_USERDATAIMAGE_PARTITION_SIZE := 0x105c0000
BOARD_FLASH_BLOCK_SIZE := 131072
TARGET_PREBUILT_KERNEL := device/zte/roamer/kernel

TARGET_RECOVER_INITRC := device/zte/roamer/recovery.rc
BOARD_CUSTOM_RECOVERY_KEYMAPPING:= device/zte/roamer/recovery_u.ic

#BOARD_HAS_NO_SELECT_BUTTON := true
# Use this flag if the board has a ext4 partition larger than 2gb
#BOARD_HAS_LARGE_FILESYSTEM := true

here's the recovery_ui.c

Code:
#include <linux/input.h>

#include "recovery_ui.h"
#include "common.h"
#include "extendedcommands.h"
char* MENU_HEADERS[] = { "Use vol keys to highlight and home to select.",
                         "",
                         NULL };

char* MENU_ITEMS[] = { "reboot system now",
                       "apply update from sdcard",
                       "wipe data/factory reset",
                       "wipe cache partition",
                       "install zip from sdcard",
                       "backup and restore",
                       "mounts and storage",
                       "advanced",
                       "power off",
                       NULL };
int device_recovery_start() {
    return 0;
}

int device_toggle_display(volatile char* key_pressed, int key_code) {
    int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT];
    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
    if (ui_get_showing_back_button()) {
        return get_allow_toggle_display() && (key_code == KEY_MENU || key_code == KEY_END);
    }
    return get_allow_toggle_display() && (key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
}
int device_reboot_now(volatile char* key_pressed, int key_code) {
    return 0;
}

int device_handle_key(int key_code, int visible) {
    if (visible) {
        switch (key_code) {
            case KEY_CAPSLOCK:
            case KEY_DOWN:
            case KEY_VOLUMEUP:
                return HIGHLIGHT_UP;
            case KEY_LEFTSHIFT:
            case KEY_UP:
            case KEY_VOLUMEDOWN:
                return HIGHLIGHT_DOWN;

            case 62:
  return SELECT_ITEM;
            case KEY_POWER:
                if (ui_get_showing_back_button()) {
                    return SELECT_ITEM;
                }
                if (!get_allow_toggle_display())
                    return GO_BACK;
                break;
            case KEY_LEFTBRACE:
            case KEY_ENTER:
            case BTN_MOUSE:
            case KEY_CENTER:
            case KEY_CAMERA:
            case KEY_F21:
            case KEY_SEND:
     case KEY_HOME:
                return SELECT_ITEM;
           
            case KEY_END:
            case KEY_BACKSPACE:
            case KEY_BACK:
                if (!get_allow_toggle_display())
                    return GO_BACK;
        }
    }

    return NO_ACTION;
}
int device_perform_action(int which) {
    return which;
}

int device_wipe_data() {
    return 0;
}

someone who is familiar with this, who is not some novice that knows nothing about building a recovery.img from CyanogenMod source, please help me figure this out so that i can use the home button instead of the power button.

is there any easier way to change this than by using a custom recovery_ui.c???
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones