Android 传入呼叫在系统级会发生什么?

Android 传入呼叫在系统级会发生什么?,android,telephony,Android,Telephony,我已经从下载了主分支的全部源代码 ,我正试图破译来电中的一连串事件 我假设动作已经开始,但除此之外,我不知道之前或之后会发生什么 有人能帮忙吗?看看这个InCallScreen.java else if (action.equals(Intent.ACTION_ANSWER)) { internalAnswerCall(); app.setRestoreMuteOnInCallResume(false); return InCallInitS

我已经从下载了主分支的全部源代码 ,我正试图破译来电中的一连串事件

我假设动作已经开始,但除此之外,我不知道之前或之后会发生什么

有人能帮忙吗?

看看这个InCallScreen.java

   else if (action.equals(Intent.ACTION_ANSWER)) {
        internalAnswerCall();
        app.setRestoreMuteOnInCallResume(false);
        return InCallInitStatus.SUCCESS;

希望下面的代码能帮助你

    @Override
    public void onCallStateChanged(int state, String incomingNumber) {
         super.onCallStateChanged(state, incomingNumber);
         switch(state){
         case TelephonyManager.CALL_STATE_IDLE:
             //Not in call: Play music

             break;
         case TelephonyManager.CALL_STATE_OFFHOOK:
             //A call is dialing, active or on hold

             break;
         case TelephonyManager.CALL_STATE_RINGING:
             //Incoming call: Pause music

             break;

         }            
    }
谷歌参考是
让我们从以下内容开始:

/***手机应用程序模块,用于监听手机状态更改和 来自电话层的各种其他*事件,并触发任何 产生的UI行为*(如启动振铃器和来电 用户界面,播放通话铃声,*更新通知,编写通话日志 参赛作品等)*/

此处理程序响应的消息之一是:
CallStateMonitor.PHONE\u NEW\u RINGING\u CONNECTION

case CallStateMonitor.PHONE_NEW_RINGING_CONNECTION:
    log("RINGING... (new)");
    onNewRingingConnection((AsyncResult) msg.obj);
    mSilentRingerRequested = false;
    break;
onneWritingConnection(AsyncResult)
最终(通常情况下)调用
ringandnotifyOfComingCall(连接c)

CallModeler.onWritingConnection(连接)
()通知连接的侦听器:

for (int i = 0; i < mListeners.size(); ++i) {
    mListeners.get(i).onIncoming(call);
}
定义
ICallHandlerService.Stub
成员及其
onIncoming(调用、列表)
方法如下所示:

@Override
public void onIncoming(Call call, List<String> textResponses) {
    ....
    mMainHandler.sendMessage(mMainHandler.obtainMessage(
                   ON_UPDATE_CALL_WITH_TEXT_RESPONSES, incomingCall));
    ....
}
保留实现
CallList.Listener的侦听器的列表,并从其
CallList.onIncoming(Call,list)
方法触发其
onIncomingCall(Call)
事件

现在,让我们看看:

/***从呼叫列表中获取更新并通知InCallActivity (UI)*更改内容。*负责启动一个项目的活动 新建呼叫,并在所有呼叫*都已完成时完成活动 断开连接。*创建和管理in-call状态,并提供 要在上收听的演示者*的侦听器模式 呼叫状态更改。*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! ] */

我希望这能回答你的问题,或者至少能告诉你去哪里找。请随时更正我忽略/误解的任何内容。

在哪个系统级别?这涉及到一系列的事情:是的,我对RIL很熟悉。主要关注ApplicationFramework层及以上,因为这都是Java,易于修改。谢谢。这是Android的一个旧版本。基特卡特呢?似乎InCall屏幕已更改
@Override
public void onIncoming(Call call, List<String> textResponses) {
    ....
    mMainHandler.sendMessage(mMainHandler.obtainMessage(
                   ON_UPDATE_CALL_WITH_TEXT_RESPONSES, incomingCall));
    ....
}
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;
/* 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! ] */