【私人备忘录】Android P 去电代码流程

一、Dialer:
DialpadFragment.handleDialButtonPressed(PreCall.start()) → DialerUtils.startActivityWithErrorToast(placeCallOrMakeToast(context, intent)) → TelecomUtil.placeCall(getTelecomManager(context).placeCall()) → TelecomManager.placeCall()

二、Telecom Frameworks:
TelecomManager.placeCall() → ITelecomService.placeCall() → TelecomServiceImpl.placeCall(private final ITelecomService.Stub mBinderImpl = new ITelecomService.Stub())

三、Telecom Services:
TelecomServiceImpl.placeCall(mUserCallIntentProcessorFactory.create(mContext, userHandle).processIntent) → UserCallIntentProcessor.processIntent(processOutgoingCallIntent(sendIntentToDestination())) → PrimaryCallReceiver.onReceive() → CallIntentProcessor.processIntent(processOutgoingCallIntent(sendNewOutgoingCallIntent())) → NewOutgoingCallIntentBroadcaster.processIntent(broadcastIntent(Intent.ACTION_NEW_OUTGOING_CALL)) → this.NewOutgoingCallBroadcastIntentReceiver.onReceive(placeOutgoingCallImmediately()) → CallsManager.placeOutgoingCall(call.startCreateConnection) → Call.startCreateConnection(mCreateConnectionProcessor.process()) → CreateConnectionProcessor.process(attemptNextPhoneAccount(mService.createConnection(mCall, CreateConnectionProcessor.this))) → ConnectionServiceWrapper.createConnection(mBinder.bind(callback, call)) → ServiceBinder.Binder2.bind(ServiceConnection connection = new ServiceBinderConnection(call)) → ServiceBinderConnection.onServiceConnected() 
1、onServiceConnected(setBinder(binder).setServiceInterface(binder)) → ConnectionServiceWrapper.setServiceInterface() → mServiceInterface = IConnectionService.Stub.asInterface(binder) 获取远程IConnectionService服务的aidl接口
2、onServiceConnected(handleSuccessfulConnection(callback.onSuccess())) → ConnectionServiceWrapper.createConnection(onSuccess(mServiceInterface.createConnection())) → ConnectionService.createConnection
备注:
1、NewOutgoingCallIntentBroadcaster.processIntent中主要对三种类型call的一些检查:普通call Intent.ACTION_CALL,系统call Intent.ACTION_CALL_PRIVILEGED,紧急呼叫call Intent.ACTION_CALL_EMERGENCY。最后调用broadcastIntent(intent, number, !callImmediately, targetUser);
2、从Call.startCreateConnection开始和来电的五是一样的流程

四、Telecom Frameworks:
ConnectionService.createConnection(mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget()) → mHandler(case MSG_CREATE_CONNECTION(createConnection())) → onCreateOutgoingConnection(空实现,找子类) → TelephonyConnectionService.onCreateOutgoingConnection
备注:
1、ConnectionService.createConnection是protected IBinder mBinder = new IConnectionService.Stub()中实现的方法,之前mServiceInterface调用AIDL过来的。

五、Telephony Services:
TelephonyConnectionService.onCreateOutgoingConnection(placeOutgoingConnection(originalConnection = phone.dial())) → GsmCdmaPhone.dial()
备注:
1、onCreateOutgoingConnection里主要跟进getTelephonyConnection和placeOutgoingConnection,getTelephonyConnection很长,关键代码:final TelephonyConnection connection = createConnectionFor()通过getTelephonyConnection方法根据对于的pnone类型进行创建连接,并添加监听,获取到connection对象。

六、Telephony Frameworks:
GsmCdmaPhone.dial(dialInternal(mCT.dial(newDialString))) → GsmCdmaCallTracker.dial(mCi.dial(mPendingMO.getAddress(), clirMode, uusInfo, obtainCompleteMessage())) → RIL.dial(radioProxy.dial(rr.mSerial, dialInfo))
备注:
1、obtainCompleteMessage方法中调用到operationComplete(),mCi.getCurrentCalls(mLastRelevantPoll);什么的,用来查询当前call情况

七、RILD层:
IRadio.dial() → ril_service.cpp(dial)

八、Telecom Frameworks:
createConnection(handleCreateConnectionComplete) → IConnectionServiceAdapter.handleCreateConnectionComplete → ConnectionServiceWrapper.this.handleCreateConnectionComplete()
备注:
1、ConnectionServiceWrapper中实现了private final class Adapter extends IConnectionServiceAdapter.Stub
备注:
1、如同来电第七/八点,从去电第五点返回connection对象

九、Telecom Services:
ConnectionServiceWrapper.this.handleCreateConnectionComplete() → CreateConnectionProcessor.hanleCreateConnectionSuccess(mCallResponse.handleCreateConnectionSuccess(idMapper, connection)) → Call.onSuccessfulOutgoingCall(l.onSuccessfulOutgoingCall(this)) → CallsManager.onSuccessfulOutgoingCall() → setCallState() → listener.onCallStateChanged(call, oldState, newState) → IncallController.onCallStateChanged(updateCall(inCallService.updateCall(parcelableCall))) → IncallService.updateCall()
备注:
1、CallsManager.onSuccessfulOutgoingCall中setCallState()后markCallAsDialing(call)

十、Telecom Frameworks:
IncallService.updateCall() → Phone.internalUpdateCall() → Call.internalUpdate() → DialerCall(更新上层)

发布了15 篇原创文章 · 获赞 107 · 访问量 19万+

猜你喜欢

转载自blog.csdn.net/llleahdizon/article/details/89640767
今日推荐