启动流程的更改阅读
API 26
Launcher->AMS
Launcher_AMS.png
AMS->ApplicationThread
AMS_AlicationThread.pngAppLicationThread->Activity
Application_Activity.png--------------------------------Launcher-----------------------------------
Launcher#startActivity--->Activty#startActivityForResult(三个参数) --> Activity#Instrumentation#execStartActivity
-->Instrumentation#startActivity
---> IActivityManager#startActivity
--->AMS(ActivityManagerService)#mActivityStarter#startActivityMayWait
--------------------------------AMS------------------------------------
-->ActivityStarter#startActivityLocked-->ActivityStarter#startActivity-->ActivityStarter#startActivity-->ActivityStarter#startActivityUnchecked--> ActivityStarter#mSupervisor# resumeFocusedStackTopActivityLocked
---> ActiviltyStack#resumeTopActivityUncheckedLocked--> ActiviltyStack#resumeTopActivityInnerLocked--> ActiviltyStack#mStackSupervisor# startSpecificActivityLocked
---> ActivityStackSupervisor#realStartActivityLocked-->ActivityStackSupervisor#app.thread.scheduleLaunchActivity
--> ApplicationThread
--------------------------------ApplicationThread------------------------
ApplicationThread#scheduleLaunchActivity-->ApplicationThread#sendMessage
--->ActivityThread#handlerMessage
--->H#handleLaunchActivity
--->ActivityThread#performLaunchActivity--> ActivityThread#callActivityOrCreate
--->Instrumentation#PerformCreate
--->Activity#onCreate
API26-----API28-------以上
ActivityThread 的兼容变化
API23---API26----API28----以上
Instrumentation/ActivityManger/ActivityMangerNative 发生很大的变化,兼容难度增加
Instrumentation_ActivityManger.pngAPI 28 启动流程发生的变化
ActivityStackSupervisor#realStartActivityLocked --> ActivityStackSupervisor#mService.getLifecycleManager().scheduleTransaction
---> ClientLifecycleManager#schedule
---> ClientTransaction#scheduleTransaction (IApplicationThread mClient)
---> ActivityThread#ApplicationThread#scheduleTransaction
(实际上是ActivityThread 内部创建,这里容易找不到)
final ApplicationThread mAppThread = new ApplicationThread();
ActivityThread extends ClientTransactionHandler
---> ActivityThread extends ClientTransactionHandler#scheduleTransaction
---> ClientTransactionHandler#sendMessage ActivityThread.H.EXECUTE_TRANSACTION 159
---> H#handleMessage
---> TransactionExecutor#execute --> TransactionExecutor#executeCallbacks -->TransactionExecutor#List<ClientTransactionItem> #execute
这里面我们只能知道callback 得到的ClientTransactionItem ,一脸懵逼
我们看get,那么一定有add 方法。是谁加进来的。
回到入口看这句话
// Schedule transaction.
mService.getLifecycleManager().scheduleTransaction(clientTransaction);
继续向上翻
找到了addCallback,里面的LaunchActivityItem -----------想骂娘了。。。。。。
--->LaunchActivityItem#execute
--->ClientTransactionHandler#handleLaunchActivity
看到ActivityClientRecord 整个流程通过Intent传递信息
实际就找到Handler的msg.obj
消息状态模式,找类找的懵逼。
还没完
ClientTransactionHandler#handleLaunchActivity 怎么有找不到。记得ActivityThread 改版了extends于ClientTransactionHandler 破案了
--->ActivityThread#handleLaunchActivity-->ActivityThread#performLaunchActivity-->ActivityThread#mInstrumentation #callActivityOnCreate
---> Instrumentation#activity #performCreate
---> Activity#onCreate
api28 启动流程.png
只能说改的太乱了,不过这么庞大的系统升级也是没办法。知识体系越来越大
网友评论