我已经从https://android.googlesource.com/platform/frameworks/base/+/master下载了主分支的完整源代码 ,并试图破解来电的事件链.
我假设ACTION_ANSWER意图已经启动但超出此范围,不知道之前或之后发生了什么.
有人可以帮忙吗?
让我们从查看CallNotifier开始:
/***手机应用程序模块,用于侦听电话状态更改以及来自电话层的各种其他*事件,并触发任何生成的UI行为*(例如启动Ringer和Incoming Call UI,播放通话音,*更新通知,写呼叫日志条目等)*/
此Handler响应的消息之一是CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
log("RINGING... (new)");
onNewRingingConnection((AsyncResult) msg.obj);
mSilentRingerRequested = false;
break;
Run Code Online (Sandbox Code Playgroud)
onNewRingingConnection(AsyncResult)最终(通常情况下)调用ringAndNotifyOfIncomingCall(Connection c):
private void ringAndNotifyOfIncomingCall(Connection c) {
if (PhoneUtils.isRealIncomingCall(c.getState())) {
mRinger.ring();
} else {
if (VDBG) log("- starting call waiting tone...");
if (mCallWaitingTonePlayer == null) {
mCallWaitingTonePlayer = new InCallTonePlayer(
InCallTonePlayer.TONE_CALL_WAITING);
mCallWaitingTonePlayer.start();
}
}
// CallModeler.onNewRingingConnection(Connection)
mCallModeler.onNewRingingConnection(c);
}
Run Code Online (Sandbox Code Playgroud)
CallModeler.onNewRingingConnection(Connection)(链接)通知附加的听众:
for (int i = 0; i < mListeners.size(); ++i) {
mListeners.get(i).onIncoming(call);
}
Run Code Online (Sandbox Code Playgroud)
这些监听器实现CallModeler.Listener接口.CallHandlerServiceProxy是一个这样的监听器,它的onIncoming(Call)回调触发CallHandlerServiceProxy.processIncoming(Call):
private void processIncoming(Call call) {
....
// ICallHandlerService
mCallHandlerServiceGuarded.onIncoming(call,
RejectWithTextMessageManager.loadCannedResponses());
....
}
Run Code Online (Sandbox Code Playgroud)
CallHandlerService定义一个ICallHandlerService.Stub成员,其onIncoming(Call, List<String>)方法如下:
@Override
public void onIncoming(Call call, List<String> textResponses) {
....
mMainHandler.sendMessage(mMainHandler.obtainMessage(
ON_UPDATE_CALL_WITH_TEXT_RESPONSES, incomingCall));
....
}
Run Code Online (Sandbox Code Playgroud)
这是mMainHandler处理案例的方式ON_UPDATE_CALL_WITH_TEXT_RESPONSES:
case ON_UPDATE_CALL_WITH_TEXT_RESPONSES:
AbstractMap.SimpleEntry<Call, List<String>> entry
= (AbstractMap.SimpleEntry<Call, List<String>>) msg.obj;
Log.i(TAG, "ON_INCOMING_CALL: " + entry.getKey());
// CallList
mCallList.onIncoming(entry.getKey(), entry.getValue());
break;
Run Code Online (Sandbox Code Playgroud)
CallList保留一个实现的侦听器列表CallList.Listener,并onIncomingCall(Call)从其CallList.onIncoming(Call, List<String>)方法触发它们的事件.
现在,让我们看看InCallPresenter:
/***从CallList获取更新并通知InCallActivity(UI)*更改.*负责启动新呼叫的活动,并在所有呼叫*断开连接时完成活动.*创建和管理通话中状态,并为希望收听通话中状态更改的演示者*提供监听器模式.*TODO:此类已成为更多的状态机.考虑重命名.*/
InCallPresenter实现CallList.Listener接口,并负责启动InCallActivity,为所有与电话相关的操作提供UI.以下评论(摘自InCallPresenter.startOrFinishUi(InCallState))将上述事件链结合在一起:
/* A new Incoming call means that the user needs to be notified of the
the call (since it wasn't them who initiated it). We do this
through full screen notifications and happens indirectly through {@link
StatusBarListener}. The process for incoming calls is as follows:
1) CallList - Announces existence of new INCOMING call
2) InCallPresenter - Gets announcement and calculates that the new
InCallState should be set to INCOMING.
3) InCallPresenter - This method is called to see if we need to
start or finish the app given the new state.
4) StatusBarNotifier - Listens to InCallState changes. InCallPresenter
calls StatusBarNotifier explicitly to issue a
FullScreen Notification that will either start the
InCallActivity or show the user a top-level
notification dialog if the user is in
an immersive app. That notification can also start
the InCallActivity.
5) InCallActivity - Main activity starts up and at the end of its
onCreate will call InCallPresenter::setActivity()
to let the presenter know that start-up is complete.
[ AND NOW YOU'RE IN THE CALL. voila! ] */
Run Code Online (Sandbox Code Playgroud)
我希望这能回答你的问题,或者至少会告诉你在哪里看.随意纠正我忽略/误解的任何事情.
| 归档时间: |
|
| 查看次数: |
1403 次 |
| 最近记录: |