[Nexus One Android Development] chota_shivaji:
Hi,

- I downloaded the source code of this kernel to see if I can contribute for trackball wake support.

- As some of you might be aware, Android provides a toolbox which has useful utilities. This toolbox is inside /system/bin on the device.

- One of the toolbox utility is getevent. This lists all the possible input devices registered with the kernel. Then it lists the keyevents send by kernel per device. Following is the sample output of this utility on my Nexus One (running runnymede):

add device 1: /dev/input/event9

name: "dummy_keypad"

add device 2: /dev/input/event8

name: "mahimahi-nav"

add device 3: /dev/input/event7

name: "mahimahi-keypad"

add device 4: /dev/input/event6

name: "proximity"

add device 5: /dev/input/event5

name: "synaptics-rmi-touchscreen"

add device 6: /dev/input/event4

name: "projector-Keypad"

add device 7: /dev/input/event3

name: "projector_input"

add device 8: /dev/input/event2

name: "compass"

add device 9: /dev/input/event1

name: "h2w headset"

add device 10: /dev/input/event0

name: "lightsensor-level"

- Then, when I press trackball when screen is off, it spits out the output as below:

/dev/input/event8: 0001 0110 00000001

/dev/input/event8: 0001 0110 00000000

(format - event.type, event.code, event.value in HEX; see ~/mydroid/system/core/toolbox/getevent.c)

This means that "/dev/input/event8" device send an key event 0x0110 twice (press and release). As per the list above "/dev/input/event8" is "mahimahi-nav" device of kernel. I cross checked that indeed the trackball is registered with this name.

- So this means that kernel is sending the trackball press and release events to Android user space and it is simply ignoring these events. Good news here is no kernel modifications are necessary to support trackball wake.

- Since Android system is dropping these events (0x0110 = BTN_MOUSE), change has to made to Android framework which handles these events. Here comes the bad news, we do not have source code of Android framework used in Sense ROMs (AFAIK). So we cannot use the commits from CM for trackball wake and apply to rebuild a new system image.

- There is a curcial-oj.kl file that lists which kernel event (0x0110) corresponds to which Android keycode (BTN_MOUSE) and weather this key is capable of waking Android or not. The current file in my ROM has following entry (272 = 0x0110):

key 272 BTN_MOUSE WAKE_DROPPED

- I tried changing this to KEY_POWER (replace BTN_MOUSE with KEY_POWER) but it did not helped. The idea here is with KEY_POWER, Android already wakes up (thats how power button works).

Anyone who has more knowledge of Android's key event framework and knows which key events are capable to wake Android (other than KEY_POWER) can modify curcial-oj.kl and see it works. The valid key events can be found out in - ~/mydroid/bionic/libc/kernel/common/linux/input.h (if you have Android forest synced on our Linux box at /home/<user>/mydroid).

Remeber to have correct permissions to curcial-oj.kl on device after modifications.

Lastly I am not responsible for any damage to your phone trying above experiments. Be cautious and try to understand what you are doing before any change. You have been warned :-D.