Android 12 S SystemServer启动过程中的服务分析
SystemServer是由zygote启动的启动后会先走main方法看注释也可以看到此方法是The main entry point from zygote.接着往下走就到了run方法frameworks/base/services/java/com/android/server/SystemServer.javapublic static void main(String[] args) { new SystemServer().run(); } private void run() { ... Looper.prepareMainLooper(); Looper.getMainLooper().setSlowLogThresholdMs( SLOW_DISPATCH_THRESHOLD_MS, SLOW_DELIVERY_THRESHOLD_MS); // Start services. try { t.traceBegin(StartServices); startBootstrapServices(t); startCoreServices(t); startOtherServices(t); } catch (Throwable ex) { Slog.e(System, ******************************************); Slog.e(System, ************ Failure starting system services, ex); throw ex; } finally { t.traceEnd(); // StartServices } ... // Loop forever. Looper.loop(); throw new RuntimeException(Main thread loop unexpectedly exited); }然后走startBootstrapServices这里主要是启动一些系统的关键服务这些服务具有复杂的相互依赖关系。/** * Starts the small tangle of critical services that are needed to get the system off the * ground. These services have complex mutual dependencies which is why we initialize them all * in one place here. Unless your service is also entwined in these dependencies, it should be * initialized in one of the other functions. */ private void startBootstrapServices(NonNull TimingsTraceAndSlog t) { t.traceBegin(startBootstrapServices); ... // Activity manager runs the show. t.traceBegin(StartActivityManager); // TODO: Might need to move after migration to WM. ActivityTaskManagerService atm mSystemServiceManager.startService( ActivityTaskManagerService.Lifecycle.class).getService(); mActivityManagerService ActivityManagerService.Lifecycle.startService( mSystemServiceManager, atm); mActivityManagerService.setSystemServiceManager(mSystemServiceManager); mActivityManagerService.setInstaller(installer); mWindowManagerGlobalLock atm.getGlobalLock(); t.traceEnd(); ... // Set up the Application instance for the system process and get started. t.traceBegin(SetSystemProcess); mActivityManagerService.setSystemProcess(); t.traceEnd(); ... t.traceBegin(StartPackageManagerService); try { Watchdog.getInstance().pauseWatchingCurrentThread(packagemanagermain); mPackageManagerService PackageManagerService.main(mSystemContext, installer, domainVerificationService, mFactoryTestMode ! FactoryTest.FACTORY_TEST_OFF, mOnlyCore); } finally { Watchdog.getInstance().resumeWatchingCurrentThread(packagemanagermain); } }然后走startCoreServices方法这个方法主要是启动一些在开机过程中没有互相依赖的基本服务。/** * Starts some essential services that are not tangled up in the bootstrap process. */ private void startCoreServices(NonNull TimingsTraceAndSlog t) { t.traceBegin(startCoreServices); // Service for system config t.traceBegin(StartSystemConfigService); mSystemServiceManager.startService(SystemConfigService.class); t.traceEnd(); t.traceBegin(StartBatteryService); // Tracks the battery level. Requires LightService. mSystemServiceManager.startService(BatteryService.class); t.traceEnd(); ... // Service for GPU and GPU driver. t.traceBegin(GpuService); mSystemServiceManager.startService(GpuService.class); t.traceEnd(); // Handles system process requests for remotely provisioned keys data. t.traceBegin(StartRemoteProvisioningService); mSystemServiceManager.startService(RemoteProvisioningService.class); t.traceEnd(); // TODO(b/277600174): Start CpuMonitorService on all builds and not just on debuggable // builds once the Android JobScheduler starts using this service. if (Build.IS_DEBUGGABLE || Build.IS_ENG) { // Service for CPU monitor. t.traceBegin(CpuMonitorService); mSystemServiceManager.startService(CpuMonitorService.class); t.traceEnd(); } t.traceEnd(); // startCoreServices }然后走startOtherServices方法此方法中主要是启动一些系统中其他的服务/** * Starts a miscellaneous grab bag of stuff that has yet to be refactored and organized. */ private void startOtherServices(NonNull TimingsTraceAndSlog t) { t.traceBegin(startOtherServices); final Context context mSystemContext; DynamicSystemService dynamicSystem null; IStorageManager storageManager null; NetworkManagementService networkManagement null; IpSecService ipSecService null; VpnManagerService vpnManager null; VcnManagementService vcnManagement null; NetworkStatsService networkStats null; NetworkPolicyManagerService networkPolicy null; NsdService serviceDiscovery null; WindowManagerService wm null; SerialService serial null; NetworkTimeUpdateService networkTimeUpdater null; InputManagerService inputManager null; TelephonyRegistry telephonyRegistry null; ConsumerIrService consumerIr null; MmsServiceBroker mmsService null; HardwarePropertiesManagerService hardwarePropertiesService null; PacProxyService pacProxyService null; ... t.traceBegin(StartVibratorManagerService); mSystemServiceManager.startService(VibratorManagerService.Lifecycle.class); t.traceEnd(); t.traceBegin(StartDynamicSystemService); dynamicSystem new DynamicSystemService(context); ServiceManager.addService(dynamic_system, dynamicSystem); t.traceEnd(); if (!isWatch) { t.traceBegin(StartConsumerIrService); consumerIr new ConsumerIrService(context); ServiceManager.addService(Context.CONSUMER_IR_SERVICE, consumerIr); t.traceEnd(); } t.traceBegin(StartAlarmManagerService); mSystemServiceManager.startService(ALARM_MANAGER_SERVICE_CLASS); t.traceEnd(); t.traceBegin(StartInputManagerService); inputManager new InputManagerService(context); t.traceEnd(); ... }以下是一个在systemserver中启动AMS的流程且WindowManagerService以及ActivityManagerService等的服务的进程号都是SystemServer但是是跑在不同的线程上

相关新闻

CPQ软件推荐有实力品牌 核心技术与知识产权核验指南

CPQ软件推荐有实力品牌 核心技术与知识产权核验指南

本文速览当前制造业数字化转型进程中,65%的国企优先选择自主可控工业软件,CPQ作为销售端核心数字化工具,其技术实力与知识产权储备直接决定系统的稳定性、适配性与长期迭代能力。本文梳理CPQ品牌技术实力的核心评判标准、知识产权核验方法&am…

2026/11/13 19:53:58 阅读更多 →
告别Steam客户端,WorkshopDL免费解锁742款游戏创意工坊模组

告别Steam客户端,WorkshopDL免费解锁742款游戏创意工坊模组

告别Steam客户端,WorkshopDL免费解锁742款游戏创意工坊模组 【免费下载链接】WorkshopDL WorkshopDL - The Best Steam Workshop Downloader 项目地址: https://gitcode.com/gh_mirrors/wo/WorkshopDL 如果你在 Epic、GOG 或微软商店买过游戏,多半…

2026/11/13 19:53:58 阅读更多 →
Steam创意工坊下载器终极指南:用WorkshopDL跨平台畅享海量模组

Steam创意工坊下载器终极指南:用WorkshopDL跨平台畅享海量模组

Steam创意工坊下载器终极指南:用WorkshopDL跨平台畅享海量模组 【免费下载链接】WorkshopDL WorkshopDL - The Best Steam Workshop Downloader 项目地址: https://gitcode.com/gh_mirrors/wo/WorkshopDL 半年前,我在 Epic 平台入手了《Garrys Mo…

2026/11/11 2:13:45 阅读更多 →

最新新闻

Electron桌面应用开发实战:从环境搭建到打包发布全流程

Electron桌面应用开发实战:从环境搭建到打包发布全流程

做前端这些年,我大部分时间都在跟浏览器标签页打交道,直到第一次把桌面应用跑起来,才发现原来自己一直被限制在地址栏和刷新按钮围起来的框框里。Electron这个词,最开始是在某段时间频繁出现在同事的讨论里,一个用HTML…

2026/11/13 5:13:25 阅读更多 →
滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

滑盖智能锁T109深度解析:结构原理、安装调试与故障排查

简介:亚太天能T109滑盖智能锁产品说明书是一份PDF格式的官方技术文档,主要面向智能锁安装人员、终端用户及售后维护者,帮助快速掌握产品安装、配置与常见故障处理。全包仅1个PDF文件,大小4.37MB,内容结构清晰&#xff…

2026/11/13 5:13:25 阅读更多 →
PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

PMSM弱磁控制原理与Simulink建模:高速AGV驱动系统设计指南

上个月我在调试一台高速AGV的驱动系统,整车要求空载跑到8m/s,电机转速已经拉到额定点,驱动器的输出电压也顶到了母线电压极限附近。再往上踩速度指令,转速纹丝不动,三相电流反而开始震荡。那会儿我的第一反应就是&…

2026/11/13 5:13:25 阅读更多 →
C++核心知识点:从内存管理到STL的实战指南

C++核心知识点:从内存管理到STL的实战指南

C 这门语言我前前后后折腾了十几年,用它写过嵌入式驱动、做过游戏服务端,也搭过基础组件库。每次看到新人一头扎进"C 核心知识点"这个搜索词,我其实挺感慨的——这门语言的难点从来不是语法多,而是知识点之间的耦合太深…

2026/11/12 18:22:26 阅读更多 →
T109滑盖智能锁怎么装?安装调试与故障排查全攻略

T109滑盖智能锁怎么装?安装调试与故障排查全攻略

简介:亚太天能T109滑盖智能锁产品说明书以PDF格式发布,适合智能锁用户、安装人员与售后维修人员阅读。内容围绕T109系列指纹密码刷卡锁展开,先介绍前面板、后面板、锁体、机械钥匙、电池盒盖等部件名称与功能,再给出完整安装步骤&…

2026/11/12 18:22:25 阅读更多 →
LLM知识降熵:从信息垄断到理解权下放

LLM知识降熵:从信息垄断到理解权下放

你有没有过这种经历:翻开源码注释、论文摘要或者一份专业报告,每个字都认识,连在一起却像天书。想找人聊聊,身边要么没人懂,要么懂的懒得跟你解释。后来我试着把同一段内容丢给一个大语言模型,几秒钟之后&a…

2026/11/13 5:13:25 阅读更多 →

日新闻

周新闻

月新闻