activity启动过程
2019-12-23 10:05:39 1 举报
Android9.0 Activity启动流程(包括根Activity和非根Activity)
作者其他创作
大纲/内容
TransactionExecutor#execute()
Instrumentation#callActivityOnCreate()
executeCallbacks(transaction);
LaunchActivityItem#excute()
mClient.scheduleTransaction(this);
ActivityManagerService#attachApplication()
Launcher#startActivitySafely()
AMS---->ActivityThread
ActivityStackSupervisor#startSpecificActivityLocked()
Activity#performCreate();
普通Activity
ActivityManagerService#getLifecycleManager().scheduleTransaction();
Activity启动源码分析(Android28_9.0)普通Activity启动过程:1.应用进程IPC调用AMS2.AMS使用IPC调用ActivityThread3.ActivityThread启动Activity
Launcher启动根Activity
startActivityForResult
1.这里IApplicationThread是一个IPC接口,它调用scheduleTransaction(this)是一次IPC调用。2.IApplicationThread的实现类是ApplicationThread,它继承了IApplicationThread.Stub.3.ApplicationThread是ActivityThread的内部类
ActivityStackSuperVisor#attachApplicationLocked()
onCreate()
ActivityThread#main()
mStackSupervisor.attachApplicationLocked(app)
mService.getLifecycleManager().scheduleTransaction(clientTransaction);
ClientTransactionHandler#scheduleTransaction(transaction)
Activity启动源码分析(Android28_9.0)根Activity启动过程:1.Launcher进程启动AMS2.AMS启动应用进程3.AMS使用IPC调用ActivityThread4.ActivityThread启动Activity
transaction.schedule();
ClientTransaction#schedule();
根Activity
用户点击桌面图标触发Launcher#startActivitySafely()
Activity#startActivity
Instrumentation#execStartActivity()
IApplicationThread#scheduleTransaction(this)
IActivityManager#startActivity()
Activity#startActivity()
ClientLifecycleManager#scheduleTransaction();
ClientTransactionItem#excute()
这里是AMS请求启动应用进程,之后系统ZYGOTE会孵化出应用进程,应用进程启动后,会先进入Activity#main()方法中
ActivityThread#handleLaunchActivity()
ActivityStackSupervisor#resumeFocusedStackTopActivityLocked()
H#handleMessage:case H.EXECUTE_TRANSACTION:
ActivityStartController#obtainStarter()
Activity---->AMS
ApplicationThread#scheduleTransaction(transaction)
ActivityThread.this.scheduleTransaction(transaction);
ActivityThread启动Activity
ActivityStack#resumeTopActivityUncheckedLocked()
startActivity(...)
ClientTransactionHandler#handleLaunchActivity()
resumeTopActivityInnerLocked()
ActivityManageService#startActivity()
BaseDraggingActivity#startActivitySafely()
1.这里IActivityManager是通过IActivityManagerSingleton.get()得到的,其内部是final IActivityManager am = IActivityManager.Stub.asInterface(b);初始化的,可以得知,IActivityManager是IPC接口,它执行startActivity是一次IPC调用。2.这个IPC的另一端是ActivityManageService,它实现了IActivityManager.Stub
startActivityMayWait(...)
ActivityStarter#excute()
ActivityThread#scheduleTransaction(transaction)
mTransactionExecutor.execute(transaction);
收藏
0 条评论
下一页