1. 程式人生 > >在MTK6572當中如何增加一個新按鍵,而且此按鍵值在虛擬按鍵當中可以使用

在MTK6572當中如何增加一個新按鍵,而且此按鍵值在虛擬按鍵當中可以使用

7.修改XML檔案描述符framework/base/core/res/res/values/attr.xml
<enum name="KEYCODE_SMS" value="220" />
 
8.增加測試驗證log在android
framework\base\policy\src\com\android\internal\polidy\impl\phoneWindowManager.java
在interceptKeyBeforeDispatching()增加
if(keycode== KeyEvent.KEYCODE_SMS){
        log.d(TAG, "interceptKeyTi KEYCODE_SMS keyCode="+ keyCode + " down=" + down + " repeatCount=" + repeatCount + “ keyguardOn=” + keyguardOn + “ mHomePressed=” + mHomePressed + “ cancled=” + canceled)
 
9.可以抓log確認,或者增加測試APK檢測
 
Kernal log:
<4>[253.828234]kpd: register = fffe ffff ffff ffff ff
<4>[253.828825]kpd: (pressed) HW keycode = 0
<4>[253.829348]kpd: report Linux keycode = 252
<4>[253.829857]kpd: save new keymap state
<4>[254.030814]kpd: register = ffff ffff ffff ffff ff
<4>[254.031405]kpd: (released) HW keycode = 0
<4>[254.031936]kpd: report Linux keycode = 252
<4>[254.032445]kpd: save new keymap state


Android log:
WindowManager: interceptKeyTq keycode=220 screenIsOn=true keyguardActive=false policyFlags = #2000000 down =false canceled = false
D WindowManager: interceptKeyTi keyCode=220 down=false repeatCount=0 keyguardOn=false mHomePressed=false canceled=false
D WindowManager: interceptKeyTi KEYCODE_SMS keyCode=220 down=false repeatCount=0 keyguardOn=false mHomePressed=false canceled=false