ap日志查看Android启动流程
event日志查看:adb logcat -b “events” > events.txt
看了 Android系统启动、init进程 – 干了啥事、init进程——从kernel Log查看,越来越云里雾里,知道大致情况就行:Loader->Kernel->init->Zygote->SystemServer
event日志关键字boot_progress
一般搜索“boot_progress”直观的查看时间:
- boot_progress_start
- boot_progress_preload_start
- boot_progress_preload_end
- boot_progress_system_run
- boot_progress_pms_start
- boot_progress_pms_system_scan_start
- boot_progress_pms_data_scan_start
- boot_progress_pms_scan_end
- boot_progress_pms_ready
- boot_progress_ams_ready
- boot_progress_enable_screen
查看EventLogTags.logtags
启动SystemServer开始
boot_progress_start、boot_progress_preload_start、boot_progress_preload_end
对照上面Events日志缺少boot_progress_start、boot_progress_preload_start、boot_progress_preload_end,其实此时是在Zygote进程启动SystemServer。
frameworks/base/core/java/com/android/internal/os/ZygoteInit.java
boot_progress_system_run
frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
frameworks/base/services/java/com/android/server/SystemServer.java
boot_progress_pms_start
frameworks/base/services/core/java/com/android/server/EventLogTags.logtags
SystemServer添加PackageManagerService.main
:
boot_progress_pms_start、boot_progress_pms_system_scan_start、boot_progress_pms_data_scan_start、boot_progress_pms_scan_end、boot_progress_pms_ready
public main(Injector injector, boolean onlyCore, boolean factoryTest) {
// 。。。。。。。。。。。。
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START,
SystemClock.uptimeMillis());
if (mSdkVersion <= 0) {
Slog.w(TAG, "**** ro.build.version.sdk not set!");
}
// 。。。。。。。。。。。。
long startTime = SystemClock.uptimeMillis();
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SYSTEM_SCAN_START,
startTime);
// 。。。。。。。。。。。。
File frameworkDir = new File(Environment.getRootDirectory(), "framework");
// 。。。。。。。。。。。。
// Collect vendor/product/system_ext overlay packages. (Do this before scanning
// any apps.)
// 。。。。。。。。。。。。
if (!mOnlyCore) {
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_DATA_SCAN_START,
SystemClock.uptimeMillis());
scanDirTracedLI(sAppInstallDir, 0, scanFlags | SCAN_REQUIRE_KNOWN, 0,
packageParser, executorService);
}
// 。。。。。。。。。。。。
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_SCAN_END,
SystemClock.uptimeMillis());
Slog.i(TAG, "Time to scan packages: "
+ ((SystemClock.uptimeMillis()-startTime)/1000f)
+ " seconds");
// 。。。。。。。。。。。。
// can downgrade to reader
t.traceBegin("write settings");
mSettings.writeLPr();
t.traceEnd();
EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_READY,
SystemClock.uptimeMillis());
boot_progress_ams_ready
frameworks/base/services/core/java/com/android/server/am/EventLogTags.logtags
frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
Slog.i(TAG, "System now ready");
EventLogTags.writeBootProgressAmsReady(SystemClock.uptimeMillis());
frameworks/base/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
writeBootProgressEnableScreen(SystemClock.uptimeMillis());
这里注意 ActivityManagerService.systemReady
与 ActivityManagerService.Lifecycle.startService
是不同的
OK,到此结束。