AMS:startActivity桌面启动应用
Posted xhBruce
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AMS:startActivity桌面启动应用相关的知识,希望对你有一定的参考价值。
startActivity桌面启动应用
android11-release
Launcher点击应用图标
packages/apps/Launcher3/src/com/android/launcher3/touch/ItemClickHandler.java
packages/apps/Launcher3/src/com/android/launcher3/Launcher.java
onClickAppShortcut -> startAppShortcutOrInfoActivity -> launcher.startActivitySafely -> startActivity()
最后调用到Activity.java中
Activity.java
frameworks/base/core/java/android/app/Activity.java
frameworks/base/core/java/android/app/Instrumentation.java
startActivity() -> startActivityForResult -> mInstrumentation.execStartActivity -> ActivityTaskManager.getService().startActivity
mMainThread.getApplicationThread()
获取ApplicationThread成员变量,是一个Binder对象ActivityTaskManager.getService()
获取的是Context.ACTIVITY_TASK_SERVICE
即是 ActivityTaskManagerServiceInstrumentation.java
用来监控应用程序和系统的交互
ActivityTaskManagerService
frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
frameworks/base/services/core/java/com/android/server/wm/ActivityStartController.java
frameworks/base/services/core/java/com/android/server/wm/ActivityStarter.java
ActivityTaskManager.getService().startActivity -> startActivityAsUser() -> getActivityStartController()........execute() -> executeRequest(mRequest) -> startActivityUnchecked() -> startActivityInner()
executeRequest(mRequest)
这里输出START u
日志,一般定制都会加上pid
打印
ActivityRecord r,sourceRecord
信息startActivityInner()
该方法有许多参数处理,如setInitialState
\\computeLaunchingTaskFlags
\\computeSourceStack
\\mIntent.setFlags(mLaunchFlags)
\\computeLaunchParams
startActivityInner()
这里wm_create_task
、wm_create_activity
ActivityStack.java
frameworks/base/services/core/java/com/android/server/wm/RootWindowContainer.java
frameworks/base/services/core/java/com/android/server/wm/ActivityStack.java
frameworks/base/services/core/java/com/android/server/wm/ActivityStackSupervisor.java
frameworks/base/services/core/java/com/android/server/wm/ActivityRecord.java
frameworks/base/services/core/java/com/android/server/wm/Task.java
-
mResumedActivity != null
时先startPausingLocked()
执行Pausing过程 -
next.setState(RESUMED, "resumeTopActivityInnerLocked");
设置ActivityRecord的RESUMED状态,最终通过Task调用到ATMS中setResumedActivityUncheckLocked
,并输出wm_set_resumed_activity
-
resumeTopActivityInnerLocked()
这里输出wm_resume_activity
-
已经启动,执行
realStartActivityLocked()
;没有启动执行mService.startProcessAsync()
startProcess
frameworks/base/services/core/java/com/android/server/am/ProcessList.java
frameworks/base/core/java/android/os/Process.java
frameworks/base/core/java/android/app/ActivityThread.java
Process.start
为应用创建进程,最后执行到ActivityThread.main()
方法
待续~~~ 后面还有很长一段路程
Log关键字:
ActivityTaskManager: START u|ActivityTaskManager: Displayed
wm_create_activity|wm_set_resumed_activity|wm_resume_activity|wm_on_resume_called|wm_activity_launch_time
相关文章:
Android应用程序启动过程源代码分析
Android应用程序内部启动Activity过程(startActivity)的源代码分析
startActivity启动过程分析
【 Android 10 四大组件 】系列 – Activity 的“启动流程”
Android之Activity启动流程详解(基于api28)
以上是关于AMS:startActivity桌面启动应用的主要内容,如果未能解决你的问题,请参考以下文章