Android 来电静音键拦截流程
现在在做双卡双待的项目!作为主要核心Phone遇到的问题也是千奇百怪!
今天就被一个问题困扰了一下午--来电后按声音按键需要静音!因为是双Phone对象所以对应的RINGER也有两个!
分析一下解BUG流程!
最开始以为按键处理会在InCallScreen.java里面的
后来发现了这行注释
// Note there's no KeyEvent.KEYCODE_ENDCALL case here.
// The standard system-wide handling of the ENDCALL key
// (see PhoneWindowManager's handling of KEYCODE_ENDCALL)
// already implements exactly what the UI spec wants,
// namely (1) "hang up" if there's a current active call,
// or (2) "don't answer" if there's a current ringing call.
原来在WindowManagerService会有一个 int actions = mPolicy.interceptKeyTq(event, !screenIsOff);
对应的PhoneWindowManager里会有一个
phoneServ.silenceRinger();
这样做是为了区别某哥界面的状态对应的按键事件!比如Incallscreen接了电话和没接电话几个按键的事件就不同!