基于 Android 13.0 相关源码:
frameworks/base/services/core/java/com/android/server/wm/ ActivityTaskManagerService.java ActivityStarter.java RootWindowContainer.java Task.java TaskFragment.java ActivityTaskSupervisor.java frameworks/base/core/java/android/app/ Activity.java Instrumentation.java IActivityTaskManager.java IActivityTaskManager.aidl IApplicationThread.aidl ApplicationThread.java ClientTransactionHandler.java ActivityThread.java UiTranslationController.java
activity启动流程调用流向:
Activity.java
startActivity -> startActivityForResult
Instrumentation.java
-> execStartActivity
IActivityTaskManager.java IActivityTaskManager.aidl
-> IActivityTaskManager.Stub.asInterface( ServiceManager.getService(Context.ACTIVITY_TASK_SERVICE)) . startActivity
.
.
. (old_app_process通过AIDL-> binder跨进程调用到system_process)
.
.
ActivityTaskManagerService.java (extends IActivityTaskManager.Stub)
startActivity -> startActivityAsUser -> getActivityStartController().obtainStarter(intent, "startActivityAsUser").execute();
【此处obtainStarter是从ActivityStarter的成员变量异步池中获取activitystater,此池子容量为3(刚刚,现在,即将),获取后为其赋值此次启动的关键参数,都放在成员变量mRequest中,Request是静态内部类】
ActivityStarter.java
execute
【如果 mRequest.activityInfo == null 那么 mRequest.resolveActivity(mSupervisor)进行解析;;如果action是关机或者重启,则通过ShutdownCheckPoints记录是谁干的】
【此处的 resolveActivity 函数内会创建新的intent以避免对客户端传来的intent对象修改,
并通过 supervisor.resolveIntent(intent... 对成员变量resolveInfo赋值(这里可以为特殊应用添加独特的resolve方法赋值resolveInfo,来跳转到特定应用如weixin、chooseActivity等)
通过 supervisor.resolveActivity(intent... 对成员变量activityInfo赋值】
-> executeRequest -> startActivityUnchecked -> startActivityInner -> resumeFocusedTasksTopActivities
RootWindowContainer.java
-> resumeFocusedTasksTopActivities -> resumeTopActivityUncheckedLocked
Task.java
-> resumeTopActivityUncheckedLocked
TaskFragment.java
-> resumeTopActivity
ActivityTaskSupervisor.java
-> startSpecificActivity -> realStartActivityLocked
IApplicationThread.aidl
-> scheduleTransaction
.
.
. (system_process通过AIDL-> binder跨进程调用到new_app_process)
.
.
private class ApplicationThread (extends IApplicationThread.Stub) in ActivityThread.java
-> scheduleTransaction
(ActivityThread extends) ClientTransactionHandler.java
-> scheduleTransaction
ActivityThread.java
sendMessage(H.UPDATE_UI_TRANSLATION_STATE, args)
H (in ActivityThread)
匹配case处理 :
Activity.java
updateUiTranslationState
UiTranslationController.java
updateUiTranslationState ( 这里做具体的Update the Ui translation state. 并打印log onAutoTranslationStateChange(): unknown state:)
☝
package android.app; ---frameworks/base/core/java/android/app/
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
package com.android.server.wm; ---frameworks/base/services/core/java/com/android/server/wm/标签:...,java,IActivityTaskManager,流程,intent,activity,android,Android13.0,app From: https://www.cnblogs.com/1118zjg/p/16890178.html