This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Power button on beagleboard with Android 2.3.4

Hi,

I would like to generate a keyboard event on Android 2.3.4 and Beagleboard, especialy the power button. I have tried to emulate this with adb, with this command:

adb shell input keyevent 26

Here it is the list of the different events:

http://www.kandroid.org/online-pdk/guide/keymaps_keyboard_input.html

It does not work for me, I have this log:

D/AndroidRuntime( 1951):
D/AndroidRuntime( 1951): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
D/AndroidRuntime( 1951): CheckJNI is ON
D/dalvikvm( 1951): creating instr width table
D/AndroidRuntime( 1951): Calling main entry com.android.commands.input.Input
I/SendKeyEvent( 1951): 26
D/AndroidRuntime( 1951): Shutting down VM
D/dalvikvm( 1951): GC_CONCURRENT freed 98K, 72% free 289K/1024K, external 0K/0K, paused 0ms+1ms
I/AndroidRuntime( 1951): NOTE: attach of thread 'Binder Thread #2' failed
D/jdwp ( 1951): adbd disconnected
However, I have the event enabled in the file android_rootfs/system/usr/keylayout/qwerty.kl:
key 115   VOLUME_UP         WAKE
key 114 VOLUME_DOWN WAKE
key 116 POWER WAKE
Nevertheless, events like VOLUME_UP or VOLUME_DOWN  works well.
I have tested this command with an Android emulator and it works.
Do someone have already done this before and could help me how can I do this? 
BR,
Steve.
  • Hi,

    I've followed instructions from here:

    http://e2e.ti.com/support/embedded/android/f/509/t/171383.aspx

     

    I've modified the struct  gpio_buttons in the file kernel/arch/arm/mach-omap2/board-omap3beagle.c to add the right code event (116=KEY_POWER), also change the gpio because there is an error into this struct, on beagleboard xm the user button is wired to gpio_4 and not gpio_7.

    So now when I do a "long press", about 2/3 seconds, a menu appears with different items, like silent mode, airplane mode and power off. 

    If I launch a getevent on the shell, I have it:

    # getevent
    getevent
    add device 1: /dev/input/event3
    name: "DELL Dell USB Entry Keyboard"
    add device 2: /dev/input/event2
    name: "Logitech USB Optical Mouse"
    could not get driver version for /dev/input/mouse0, Not a typewriter
    could not get driver version for /dev/input/mice, Not a typewriter
    add device 3: /dev/input/event0
    name: "gpio-keys"
    add device 4: /dev/input/event1
    name: "twl4030_pwrbutton"
    /dev/input/event0: 0001 0074 00000001
    /dev/input/event0: 0000 0000 00000000
    /dev/input/event0: 0001 0074 00000000
    /dev/input/event0: 0000 0000 00000000

    Ok so the event is well send by the kernel, with 0074 = 116 = KEY_POWER.

    But on the Android side I have this log:

    W/KeyCharacterMap( 1088): Can't open keycharmap file
    W/KeyCharacterMap( 1088): Error loading keycharmap file '/system/usr/keychars/gpio-keys.kcm.bin'. hw
    .keyboards.65538.devname='gpio-keys'
    W/KeyCharacterMap( 1088): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
    
    

    This file is not present, but the default qwerty works for this event.

    Ok, so it works, but it miss something!

    In deed, my concern is not this behaviour but more putting the screen off. If I do a short push on this button, the screen should go off, but there is nothing that happend...

    The event is however well sent by the kernel but it seems that the Android layer drop this event. I don't know the Android framework, there's should be somewhere a method that count the time between the press button event and release button event.

    Someone could help me to find how to put the screen off when I press this button?

    BR,

    Steve.


  • Hi Steve,

    We are also facing the same issue.

    Long press is powering off the system.We need short press to dim LCD.

    Any help?

    Regards,

    RajeeSankar

  • Hi Steve/RajeeSankar,

    Now you have your gpio key sending KEY_POWER and android recognizes the event from qwerty.kl, so it works well.

    Now to enable suspend-resume we need to enable power management via

    1. Replace the line "setprop hw.nopm true" with "setprop hw.nopm false" init.rc.
    2. Uncheck  Settings-> Applications-> Development-> Stay awake

    There are some more steps to be done from kernel to support suspend-resume for Beagleboard. Please pick the relevant patches from http://groups.google.com/group/rowboat/browse_thread/thread/1a950d7ae3b1f339#

    We will push these patches to gitorious.org/rowboat soon.