2013年8月19日 星期一

[Code trace] Android Irda Input key handling

The purpose is to find out where some globally functioned keys are handled, like power key, which is specially handled within handleInterceptActions() after interceptKeyBeforeQueueing() is called, and a key works to change the TV display format wherever you are. The goal however, is to add a set of 4 hot keys each of which is a shortcut to a certain APP.

remote control key : UP
------------------------------------------------------------------------------------------------
D/InputReader( 1417): BatchSize: 2 Count: 2
D/InputReader( 1417): Input event: device=1 type=0x0001 scancode=0x0067 keycode=0x0013 value=0x00000001 flags=0x00000000
D/InputReader( 1417): Input event: device=1 type=0x0000 scancode=0x0000 keycode=0x0000 value=0x00000000 flags=0x00000000

D/WindowManager( 1417): UP key is pressed/released
D/KeyEvent-JNI( 1417): android_view_KeyEvent_recycle...
D/InputManager-JNI( 1417): NativeInputManager::handleInterceptActions
D/KeyEvent-JNI( 1417): android_view_KeyEvent_recycle...
D/KeyEvent-JNI( 1417): android_view_KeyEvent_recycle...

------------------------------------------------------------------------------------------------
                                 (1)                   (2)
remote control key <-> scancode <-> keycode
        0xca                        0x67              0x13

remote control key :  device/hisilicon/godbox/driver/sdk/msp/ecs/drv/ir/ir_s2/hiir_ir2.h
keycode :  frameworks/base/native/include/android/keycodes.h
scancode : device/hisilicon/godbox/prebuilt/Vendor_0001_Product_0001.kl

Mappings:
(1) device/hisilicon/godbox/driver/sdk/msp/ecs/drv/ir/ir_s2/hiir_ir2.h
(2) frameworks/base/include/ui/KeycodeLabels.h

The following code handles a universal key event - KEYCODE_MORE(0x498)
[Window Manager]
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
interceptKeyBeforeQueueing()

After finding out the place, the idea is then to handle these 4 hot keys here in interceptKeyBeforeQueseing() and jump to the corresponding APP designated.

Reference links
http://www.hovercool.com/en/Special:History?topicVersionId=767&topic=Input%E4%BA%8B%E4%BB%B6%E6%B5%81%E7%A8%8B
http://blog.csdn.net/eastmoon502136/article/details/7697434

沒有留言:

張貼留言