当前位置: 首页 > news >正文

安卓 SystemServer 启动流程

目录

引言

Android系统服务启动顺序 

zygote fork SystemServer 进程

SystemServer启动流程

1、SystemServer.main()

2、SystemServer.run()

3、初始化系统上下文

4、创建系统服务管理

5、启动系统各种服务

总结


引言

开机启动时 PowerManagerService 调用 AudioService 音频接口可能会导致 JE 崩溃,进而 system_server 崩溃。

分析:应该和系统服务SystemServer启动的顺序有关

Android系统服务启动顺序 

Android整体启动流程概括为:启动BootLoader->加载系统内核->启动Init进程->启动Zygote进程->启动Runtime进程->启动本地服务->启动Home Launcher

SystemServer 服务进程是 Android 系统 Java 层框架的核心,它维护着 Android 系统的 核心服务,比如:ActivityManagerService、WindowManagerService、PackageManagerService 等,是 Android 系统中一个非常重要的进程。在 Android 系统中,应用程序出现问题,对系统影响不大,而 Init、Zygote、SystemServer 三大进程对系统的影响则非常大,因为其中任何一个 crash,都会造成系统崩溃,出现重启现象。

zygote fork SystemServer 进程

SystemServer 是由 Zygote 孵化而来的一个进程,通过 ps 命令,我们发现其进程名为:system_server。在分析 zygote 进程时,我们知道当 zygote 进程进入到 java 世界后,在 ZygoteInit.java 中,将调用 forkSystemServer 方法启动 SystemServer 进程。

// frameworks/base/core/java/com/android/internal/os/ZygoteInit.javapublic class ZygoteInit {public static void main(String argv[]) {try {if (startSystemServer) {// fork 出 system_serverRunnable r = forkSystemServer(abiList, zygoteSocketName, zygoteServer);if (r != null) {r.run();return;}}}}private static Runnable forkSystemServer(String abiList, String socketName,ZygoteServer zygoteServer) {try {... .../* Request to fork the system server process */pid = Zygote.forkSystemServer(parsedArgs.mUid, parsedArgs.mGid,parsedArgs.mGids,parsedArgs.mRuntimeFlags,null,parsedArgs.mPermittedCapabilities,parsedArgs.mEffectiveCapabilities);} catch (IllegalArgumentException ex) {throw new RuntimeException(ex);}}}

......

SystemServer启动流程

1、SystemServer.main()

接下来就进到了 SystemServer.java 的 main() 函数处理流程:

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {/*** The main entry point from zygote.*/public static void main(String[] args) {new SystemServer().run();        // 创建并运行,简单粗暴!}}

这里直接 new 出一个 SystemServer 对象 并执行其 run() 方法。

2、SystemServer.run()

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {private void run() {try {traceBeginAndSlog("InitBeforeStartServices");... ...// 如果系统时钟早于1970年,则设置系统始终从1970年开始if (System.currentTimeMillis() < EARLIEST_SUPPORTED_TIME) {Slog.w(TAG, "System clock is before 1970; setting to 1970.");SystemClock.setCurrentTimeMillis(EARLIEST_SUPPORTED_TIME);}... ...    if (!SystemProperties.get("persist.sys.language").isEmpty()) {// 设置区域,语言等选项    final String languageTag = Locale.getDefault().toLanguageTag();SystemProperties.set("persist.sys.locale", languageTag);SystemProperties.set("persist.sys.language", "");SystemProperties.set("persist.sys.country", "");SystemProperties.set("persist.sys.localevar", "");}... ...// 清除 vm 内存增长上限,由于启动过程需要较多的虚拟机内存空间VMRuntime.getRuntime().clearGrowthLimit();                                     // 设置堆栈利用率,GC 后会重新计算堆栈空间大小VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);                         // 针对部分设备依赖于运行时就产生指纹信息,因此需要在开机完成前已经定义Build.ensureFingerprintProperty();                                             // 访问环境变量前,需要明确地指定用户Environment.setUserRequired(true);                                             ... ...// 加载动态库 libandroid_services.soSystem.loadLibrary("android_servers");                                         // 检测上次关机过程是否失败,该方法可能不会返回performPendingShutdown();                                                        // 在 SystemServer 进程中也需要创建 Context 对象,初始化系统上下文createSystemContext();                                                         // 创建 SystemServiceManager 对象mSystemServiceManager = new SystemServiceManager(mSystemContext);  // SystemServer 进程主要是用来构建系统各种 service 服务,// 而 SystemServiceManager 就是这些服务的管理对象            mSystemServiceManager.setStartInfo(mRuntimeRestart,mRuntimeStartElapsedTime, mRuntimeStartUptime);        // 将 SystemServiceManager 对象保存到 SystemServer 进程中的一个数据结构中            LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);   // Prepare the thread pool for init tasks that can be parallelizedSystemServerInitThreadPool.get();} finally {traceEnd();    // InitBeforeStartServices}// Start services.try {traceBeginAndSlog("StartServices");startBootstrapServices();    // 主要用于启动系统 Boot 级服务        startCoreServices();         // 主要用于启动系统核心的服务       startOtherServices();        // 主要用于启动一些非紧要或者非需要及时启动的服务    } catch (Throwable ex) {Slog.e("System", "******************************************");Slog.e("System", "************ Failure starting system services", ex);throw ex;} finally {traceEnd();}... ...// 启动looper,以处理到来的消息,一直循环执行Looper.loop();                                                                       throw new RuntimeException("Main thread loop unexpectedly exited");}}

以上就是 SystemServer.run() 方法的整个流程,简化如下

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {private void run() {try {// Initialize the system context.createSystemContext();    // 01. 初始化系统上下文// 02. 创建系统服务管理                                       mSystemServiceManager = new SystemServiceManager(mSystemContext);mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart);                  LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);   } finally {traceEnd();  // InitBeforeStartServices}// 03.启动系统各种服务try {startBootstrapServices();    // 启动引导服务startCoreServices();         // 启动核心服务startOtherServices();        // 启动其他服务}// Loop forever.Looper.loop();    // 一直循环执行  throw new RuntimeException("Main thread loop unexpectedly exited");}}

接下来我们针对 SystemServer 所做的 三部分工作 单独分析!

3、初始化系统上下文

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {private void createSystemContext() {ActivityThread activityThread = ActivityThread.systemMain();mSystemContext = activityThread.getSystemContext();mSystemContext.setTheme(DEFAULT_SYSTEM_THEME);final Context systemUiContext = activityThread.getSystemUiContext();systemUiContext.setTheme(DEFAULT_SYSTEM_THEME);}}

跟踪 systemMain() 方法

// frameworks/base/core/java/android/app/ActivityThread.javapublic final class ActivityThread extends ClientTransactionHandler {public static ActivityThread systemMain() {// The system process on low-memory devices do not get to use hardware// accelerated drawing, since this can add too much overhead to the// process.if (!ActivityManager.isHighEndGfx()) {ThreadedRenderer.disable(true);    // 对于低内存的设备,禁用硬件加速} else {ThreadedRenderer.enableForegroundTrimming();}ActivityThread thread = new ActivityThread();thread.attach(true, 0);    // 调用 attach() 方法return thread;}}

跟踪 attach() 方法

// frameworks/base/core/java/android/app/ActivityThread.javapublic final class ActivityThread extends ClientTransactionHandler {private void attach(boolean system, long startSeq) {sCurrentActivityThread = this;mSystemThread = system;if (!system) {... ...} else {// Don't set application object here -- if the system crashes,// we can't display an alert, we just want to die die die.// 设置 SystemServer 进程在 DDMS 中显示的名字为 "system_process"android.ddm.DdmHandleAppName.setAppName("system_process",UserHandle.myUserId());    // 如不设置,则显示"?",无法调试该进程try {mInstrumentation = new Instrumentation();mInstrumentation.basicInit(this);// 首先通过 getSystemContext() 创建系统上下文,然后创建应用上下文ContextImpl context = ContextImpl.createAppContext(this, getSystemContext().mPackageInfo);// 创建 ApplicationmInitialApplication = context.mPackageInfo.makeApplication(true, null);// 调用 Application的 onCreate()mInitialApplication.onCreate();} catch (Exception e) {throw new RuntimeException("Unable to instantiate Application():" + e.toString(), e);}        }... ...ViewRootImpl.ConfigChangedCallback configChangedCallback= (Configuration globalConfig) -> {synchronized (mResourcesManager) {// We need to apply this change to the resources immediately, because upon returning// the view hierarchy will be informed about it.if (mResourcesManager.applyConfigurationToResourcesLocked(globalConfig,null /* compat */)) {updateLocaleListFromAppContext(mInitialApplication.getApplicationContext(),mResourcesManager.getConfiguration().getLocales());// This actually changed the resources! Tell everyone about it.if (mPendingConfiguration == null|| mPendingConfiguration.isOtherSeqNewer(globalConfig)) {mPendingConfiguration = globalConfig;sendMessage(H.CONFIGURATION_CHANGED, globalConfig);}}}};// 添加回调ViewRootImpl.addConfigCallback(configChangedCallback);                             }}

我们发现 attach() 方法主要做了四件事:
       (1)创建系统上下文:getSystemContext();
       (2)创建应用上下文:createAppContext();
       (3)创建 Application:makeApplication();
       (4)添加回调 configChangedCallback 到 ViewRootImpl。
(1)创建系统上下文

// frameworks/base/core/java/android/app/ActivityThread.javapublic final class ActivityThread extends ClientTransactionHandler {public ContextImpl getSystemContext() {synchronized (this) {if (mSystemContext == null) {mSystemContext = ContextImpl.createSystemContext(this);}return mSystemContext;}}}
// frameworks/base/core/java/android/app/ContextImpl.javaclass ContextImpl extends Context {static ContextImpl createSystemContext(ActivityThread mainThread) {// 这边 new 出来的 LoadedApk 将作为创建应用上下文的参数 packageInfoLoadedApk packageInfo = new LoadedApk(mainThread);// ContextImpl() 创建系统上下文 ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,null, null);context.setResources(packageInfo.getResources());context.mResources.updateConfiguration(context.mResourcesManager.getConfiguration(),context.mResourcesManager.getDisplayMetrics());return context;}}

(2)创建应用上下文

// frameworks/base/core/java/android/app/ContextImpl.javaclass ContextImpl extends Context {static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo) {return createAppContext(mainThread, packageInfo, null);}static ContextImpl createAppContext(ActivityThread mainThread, LoadedApk packageInfo,String opPackageName) {if (packageInfo == null) throw new IllegalArgumentException("packageInfo");// ContextImpl()创建应用上下文ContextImpl context = new ContextImpl(null, mainThread, packageInfo, null, null, null, 0,null, opPackageName);context.setResources(packageInfo.getResources());return context;}}

我们可以看出:new ContextImpl() 时,系统上下文和应用上下文的参数是一样的,createAppContext() 中的参数 packageInfo,就是 createSystemContext() 中 new 的 LoadedApk。
创建完成之后,系统上下文赋值给了 ActivityThread 的成员变量 mSystemContext,而应用上下文只是作为函数中的局部变量临时使用。
(3)创建 Application

// frameworks/base/core/java/android/app/LoadedApk.javapublic final class LoadedApk {public Application makeApplication(boolean forceDefaultAppClass,Instrumentation instrumentation) {if (mApplication != null) {return mApplication;}Trace.traceBegin(Trace.TRACE_TAG_ACTIVITY_MANAGER, "makeApplication");Application app = null;String appClass = mApplicationInfo.className;if (forceDefaultAppClass || (appClass == null)) {    // forceDefaultAppClass 为 true                               appClass = "android.app.Application";}try {java.lang.ClassLoader cl = getClassLoader();// 此 LoadedApk 对象是 createSystemContext 时 new 的,mPackageName = "android"if (!mPackageName.equals("android")) {                                         initializeJavaContextClassLoader();}// 又创建了一个局部应用上下文ContextImpl appContext = ContextImpl.createAppContext(mActivityThread, this);  // 创建 Application app = mActivityThread.mInstrumentation.newApplication(cl, appClass, appContext);appContext.setOuterContext(app);} catch (Exception e) {if (!mActivityThread.mInstrumentation.onException(app, e)) {Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);throw new RuntimeException("Unable to instantiate application " + appClass+ ": " + e.toString(), e);}}// 将前面创建的 app 添加到应用列表mActivityThread.mAllApplications.add(app);mApplication = app;... ...Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);return app;}}

4、创建系统服务管理

回顾下创建系统服务管理相关代码:

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {private void run() {try {// Initialize the system context.createSystemContext();    // 01. 初始化系统上下文// 02. 创建系统服务管理                                       mSystemServiceManager = new SystemServiceManager(mSystemContext);mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart);                  LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);   } finally {traceEnd();  // InitBeforeStartServices}... ...}

这一步只是 new 了一个 SystemServiceManager,并将其添加到本地服务列表中。mSystemContext 为第一步中创建的系统上下文。本地服务列表是以类为 key 保存的一个列表,即列表中某种类型的对象最多只能有一个。
new SystemServiceManager()

// frameworks/base/services/core/java/com/android/server/SystemServiceManager.javapublic class SystemServiceManager {... ...// 系统服务列表,系统服务必须继承 SystemServiceprivate final ArrayList<SystemService> mServices = new ArrayList<SystemService>();// 当前处于开机过程的哪个阶段private int mCurrentPhase = -1;SystemServiceManager(Context context) {mContext = context;}@SuppressWarnings("unchecked")// 通过类名启动系统服务,可能会找不到类而抛异常public SystemService startService(String className) {final Class<SystemService> serviceClass;try {serviceClass = (Class<SystemService>)Class.forName(className);} catch (ClassNotFoundException ex) {Slog.i(TAG, "Starting " + className);throw new RuntimeException("Failed to create service " + className+ ": service class not found, usually indicates that the caller should "+ "have called PackageManager.hasSystemFeature() to check whether the "+ "feature is available on this device before trying to start the "+ "services that implement it", ex);}return startService(serviceClass);}@SuppressWarnings("unchecked")// 创建并启动系统服务,系统服务类必须继承 SystemServicepublic <T extends SystemService> T startService(Class<T> serviceClass) {try {final String name = serviceClass.getName();Slog.i(TAG, "Starting " + name);Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "StartService " + name);// Create the service.if (!SystemService.class.isAssignableFrom(serviceClass)) {throw new RuntimeException("Failed to create " + name+ ": service must extend " + SystemService.class.getName());}final T service;try {Constructor<T> constructor = serviceClass.getConstructor(Context.class);service = constructor.newInstance(mContext);} catch (InstantiationException ex) {... ...}startService(service);return service;} finally {Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);}}public void startService(@NonNull final SystemService service) {// Register it.mServices.add(service);// Start it.long time = SystemClock.elapsedRealtime();try {service.onStart();} catch (RuntimeException ex) {throw new RuntimeException("Failed to start service " + service.getClass().getName()+ ": onStart threw an exception", ex);}warnIfTooLong(SystemClock.elapsedRealtime() - time, service, "onStart");}// 通知系统服务到了开机的哪个阶段,会遍历调用所有系统服务的 onBootPhase() 函数public void startBootPhase(final int phase) {... ...try {Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, "OnBootPhase " + phase);final int serviceLen = mServices.size();for (int i = 0; i < serviceLen; i++) {final SystemService service = mServices.get(i);long time = SystemClock.elapsedRealtime();Trace.traceBegin(Trace.TRACE_TAG_SYSTEM_SERVER, service.getClass().getName());try {service.onBootPhase(mCurrentPhase);} catch (Exception ex) {throw new RuntimeException("Failed to boot service "+ service.getClass().getName()+ ": onBootPhase threw an exception during phase "+ mCurrentPhase, ex);}warnIfTooLong(SystemClock.elapsedRealtime() - time, service, "onBootPhase");Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);}} finally {Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);}}}

5、启动系统各种服务

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {private void run() {// 01. 初始化系统上下文// 02. 创建系统服务管理                                       // 03.启动系统各种服务try {startBootstrapServices();    // 启动引导服务startCoreServices();         // 启动核心服务startOtherServices();        // 启动其他服务}// Loop forever.Looper.loop();    // 一直循环执行  throw new RuntimeException("Main thread loop unexpectedly exited");}}

(1)启动引导服务startBootstrapServices()

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {/*** 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() {... ...// 启动 Installer 服务,阻塞等待与 installd 建立 socket 通道Installer installer = mSystemServiceManager.startService(Installer.class);mSystemServiceManager.startService(DeviceIdentifiersPolicyService.class);mSystemServiceManager.startService(UriGrantsManagerService.Lifecycle.class);// 启动 ActivityManagerServiceActivityTaskManagerService atm = mSystemServiceManager.startService(ActivityTaskManagerService.Lifecycle.class).getService();mActivityManagerService.setSystemServiceManager(mSystemServiceManager);mActivityManagerService.setInstaller(installer);mWindowManagerGlobalLock = atm.getGlobalLock();// 启动 PowerManagerServicemPowerManagerService = mSystemServiceManager.startService(PowerManagerService.class);mSystemServiceManager.startService(ThermalManagerService.class);// PowerManagerService 就绪,AMS 初始化电源管理mActivityManagerService.initPowerManagement();mActivityManagerService.initPowerManagement();mSystemServiceManager.startService(RecoverySystemService.class);RescueParty.noteBoot(mSystemContext);// 启动 LightsServicemSystemServiceManager.startService(LightsService.class);// 启动 DisplayManagerServicemDisplayManagerService = mSystemServiceManager.startService(DisplayManagerService.class);// We need the default display before we can initialize the package manager.mSystemServiceManager.startBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);// 当设备正在加密时,仅运行核心应用String cryptState = SystemProperties.get("vold.decrypt");if (ENCRYPTING_STATE.equals(cryptState)) {Slog.w(TAG, "Detected encryption in progress - only parsing core apps");mOnlyCore = true;} else if (ENCRYPTED_STATE.equals(cryptState)) {Slog.w(TAG, "Device encrypted - only parsing core apps");mOnlyCore = true;}// Start the package manager.if (!mRuntimeRestart) {MetricsLogger.histogram(null, "boot_package_manager_init_start",(int) SystemClock.elapsedRealtime());}// 启动 PackageManagerServicetry {Watchdog.getInstance().pauseWatchingCurrentThread("packagemanagermain");mPackageManagerService = PackageManagerService.main(mSystemContext, installer,mFactoryTestMode != FactoryTest.FACTORY_TEST_OFF, mOnlyCore);} finally {Watchdog.getInstance().resumeWatchingCurrentThread("packagemanagermain");}mFirstBoot = mPackageManagerService.isFirstBoot();mPackageManager = mSystemContext.getPackageManager();... ...// 将 UserManagerService 添加到服务列表,该服务是在 PackageManagerService 中初始化的        mSystemServiceManager.startService(UserManagerService.LifeCycle.class);// 初始化用来缓存包资源的属性缓存AttributeCache.init(mSystemContext);// Set up the Application instance for the system process and get started.mActivityManagerService.setSystemProcess();... ...mSensorServiceStart = SystemServerInitThreadPool.get().submit(() -> {TimingsTraceLog traceLog = new TimingsTraceLog(SYSTEM_SERVER_TIMING_ASYNC_TAG, Trace.TRACE_TAG_SYSTEM_SERVER);traceLog.traceBegin(START_SENSOR_SERVICE);startSensorService();    // 启动传感器服务traceLog.traceEnd();}, START_SENSOR_SERVICE);}}

首先等待 installd 启动完成,然后启动一些相互依赖的关键服务。

(2)启动核心服务startCoreServices()

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {/*** Starts some essential services that are not tangled up in the bootstrap process.*/private void startCoreServices() {// 启动 BatteryService,用于统计电池电量,需要 LightServicemSystemServiceManager.startService(BatteryService.class);// 启动 UsageStatsService,用于统计应用使用情况mSystemServiceManager.startService(UsageStatsService.class);mActivityManagerService.setUsageStatsManager(LocalServices.getService(UsageStatsManagerInternal.class));// 启动 WebViewUpdateServiceif (mPackageManager.hasSystemFeature(PackageManager.FEATURE_WEBVIEW)) {mWebViewUpdateService = mSystemServiceManager.startService(WebViewUpdateService.class);}.... ...}}

(3)启动其他服务startOtherServices()

代码很长(1200多行...),但是逻辑简单,主要是启动各种服务。

// frameworks/base/services/java/com/android/server/SystemServer.javapublic final class SystemServer {/*** Starts a miscellaneous grab bag of stuff that has yet to be refactored and organized.*/private void startOtherServices() {... ...try {... ...// 调度策略ServiceManager.addService("scheduling_policy", new SchedulingPolicyService());mSystemServiceManager.startService(TelecomLoaderService.class);// 提供电话注册、管理服务,可以获取电话的链接状态、信号强度等telephonyRegistry = new TelephonyRegistry(context);ServiceManager.addService("telephony.registry", telephonyRegistry);mEntropyMixer = new EntropyMixer(context);mContentResolver = context.getContentResolver();// 提供所有账号、密码、认证管理等等的服务mSystemServiceManager.startService(ACCOUNT_SERVICE_CLASS);... ...// 振动器服务vibrator = new VibratorService(context);ServiceManager.addService("vibrator", vibrator);... ...inputManager = new InputManagerService(context);// WMS needs sensor service readyConcurrentUtils.waitForFutureNoInterrupt(mSensorServiceStart, START_SENSOR_SERVICE);mSensorServiceStart = null;wm = WindowManagerService.main(context, inputManager, !mFirstBoot, mOnlyCore,new PhoneWindowManager(), mActivityManagerService.mActivityTaskManager);ServiceManager.addService(Context.WINDOW_SERVICE, wm, /* allowIsolated= */ false,DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PROTO);ServiceManager.addService(Context.INPUT_SERVICE, inputManager,/* allowIsolated= */ false, DUMP_FLAG_PRIORITY_CRITICAL);... ...} catch (RuntimeException e) {Slog.e("System", "******************************************");Slog.e("System", "************ Failure starting core service", e);}... ...LockSettingsService               // 屏幕锁定服务,管理每个用户的相关锁屏信息DeviceIdleController              // Doze模式的主要驱动DevicePolicyManagerService        // 提供一些系统级别的设置及属性StatusBarManagerService           // 状态栏管理服务ClipboardService                  // 系统剪切板服务NetworkManagementService          // 网络管理服务TextServicesManagerService        // 文本服务,例如文本检查等NetworkScoreService               // 网络评分服务NetworkStatsService               // 网络状态服务NetworkPolicyManagerService       // 网络策略服务WifiP2pService                    // Wifi Direct服务WifiService                       // Wifi服务WifiScanningService               // Wifi扫描服务RttService                        // Wifi相关EthernetService                   // 以太网服务ConnectivityService               // 网络连接管理服务NsdService                        // 网络发现服务NotificationManagerService        // 通知栏管理服务DeviceStorageMonitorService       // 磁盘空间状态检测服务LocationManagerService            // 位置服务,GPS、定位等CountryDetectorService            // 检测用户国家SearchManagerService              // 搜索管理服务DropBoxManagerService             // 用于系统运行时日志的存储于管理WallpaperManagerService           // 壁纸管理服务AudioService                      // AudioFlinger的上层管理封装,主要是音量、音效、声道及铃声等的管理DockObserver                      // 如果系统有个座子,当手机装上或拔出这个座子的话,就得靠他来管理了WiredAccessoryManager             // 监视手机和底座上的耳机UsbService                        // USB服务SerialService                     // 串口服务TwilightService                   // 指出用户当前所在位置是否为晚上,被 UiModeManager 等用来调整夜间模式BackupManagerService              // 备份服务AppWidgetService                  // 提供Widget的管理和相关服务VoiceInteractionManagerService    // 语音交互管理服务DiskStatsService                  // 磁盘统计服务,供dumpsys使用SamplingProfilerService           // 用于耗时统计等NetworkTimeUpdateService          // 监视网络时间,当网络时间变化时更新本地时间。CertBlacklister                   // 提供一种机制更新SSL certificate blacklistDreamManagerService               // 屏幕保护PrintManagerService               // 打印服务HdmiControlService                // HDMI控制服务FingerprintService                // 指纹服务... ...}}

总结

可以看到PowerManagerService先于AudioService启动,此时如果在PowerManagerService启动后立刻调用AudioService中的接口就会引发 JE 崩溃,进而导致system_server崩溃。

相关文章:

安卓 SystemServer 启动流程

目录 引言 Android系统服务启动顺序 zygote fork SystemServer 进程 SystemServer启动流程 1、SystemServer.main() 2、SystemServer.run() 3、初始化系统上下文 4、创建系统服务管理 5、启动系统各种服务 总结 引言 开机启动时 PowerManagerService 调用 AudioSer…...

深度分析 es multi_match 中most_fields、best_fields、cross_fields区别

文章目录 1. multi_match 查询的类型1.1 best_fields&#xff08;默认&#xff09;1.2 most_fields1.3 cross_fields 2. 不同类型的示例查询示例数据&#xff1a; 3. 示例 1: 使用 best_fields查询&#xff1a;说明&#xff1a; 4. 示例 2: 使用 most_fields查询&#xff1a;说…...

中职计算机网络技术理实一体化实训室建设方案

构建理实一体化教学模式对于改善中等职业学校计算机网络技术课程的教学现状、提升教学质量和效率具有重要意义。在中职教育不断深化改革的背景下&#xff0c;积极推进理实一体化教学模式的发展&#xff0c;不仅能够提高计算机网络技术课程的教学水平&#xff0c;满足教育改革的…...

Java技术专家视角解读:SQL优化与批处理在大数据处理中的应用及原理

引言 在大厂架构中&#xff0c;提升系统性能和稳定性是技术团队的首要任务。SQL优化与批处理作为两大关键技术手段&#xff0c;对于处理大规模数据和高并发请求具有重要意义。本文将从Java技术专家的视角出发&#xff0c;深入探讨SQL优化与批处理在大数据处理中的应用及原理&a…...

数据结构(Java版)第六期:LinkedList与链表(一)

目录 一、链表 1.1. 链表的概念及结构 1.2. 链表的实现 专栏&#xff1a;数据结构(Java版) 个人主页&#xff1a;手握风云 一、链表 1.1. 链表的概念及结构 链表是⼀种物理存储结构上⾮连续存储结构&#xff0c;数据元素的逻辑顺序是通过链表中的引⽤链接次序实现的。与火车…...

云边端一体化架构

云边端一体化架构是一种将云计算、边缘计算和终端设备相结合的分布式计算模型。该架构旨在通过优化资源分配和数据处理流程&#xff0c;提供更高效、更低延迟的服务体验。 下面是对这个架构的简要说明&#xff1a; 01云计算&#xff08;Cloud Computing&#xff09; — 作为中心…...

人工智能之基于阿里云进行人脸特征检测部署

人工智能之基于阿里云进行人脸特征检测部署 需求描述 基于阿里云搭建真人人脸68个关键点检测模型&#xff0c;模型名称&#xff1a;Damo_XR_Lab/cv_human_68-facial-landmark-detection使用上述模型进行人脸关键点识别&#xff0c;模型地址 业务实现 阿里云配置 阿里云配置…...

基于高云GW5AT-15 FPGA的SLVS-EC桥MIPI设计方案分享

作者&#xff1a;Hello,Panda 一、设计需求 设计一个4Lanes SLVS-EC桥接到2组4lanes MIPI DPHY接口的电路模块&#xff1a; &#xff08;1&#xff09;CMOS芯片&#xff1a;IMX537-AAMJ-C&#xff0c;输出4lanes SLVS-EC 4.752Gbps Lane速率&#xff1b; &#xff08;2&…...

MPLS小实验:利用LDP动态建立LSP

正文共&#xff1a;1234 字 19 图&#xff0c;预估阅读时间&#xff1a;2 分钟 通过上个实验&#xff08;MPLS小实验&#xff1a;静态建立LSP&#xff09;&#xff0c;我们了解到静态LSP不依靠标签分发协议&#xff0c;而是在报文经过的每一跳设备上&#xff08;包括Ingress、T…...

C++ 面向对象编程

面向对象编程&#xff08;Object-Oriented Programming, OOP&#xff09;是C语言的一个重要特性&#xff0c;它允许开发者以更直观和模块化的方式来设计和构建程序。OOP的四个主要原则是&#xff1a;封装&#xff08;Encapsulation&#xff09;、继承&#xff08;Inheritance&a…...

我的Serverless实战——引领云计算的下一个十年,附答案

&#xff08;Serverless模式下&#xff0c;按照实际消耗资源及使用存储进行计费&#xff09; 4.更少的代码&#xff0c;更快的交付速度。 &#xff08;Serverless提供成熟的代码构建发布、版本切换等特性&#xff0c;交付速度更快&#xff09; Serverless由开发者实现的服务端逻…...

有哪些其他方法可以实现数据一致性验证?

数据库约束 主键约束&#xff1a; 主键是表中用于唯一标识每条记录的一列或一组列。例如&#xff0c;在一个“用户表”中&#xff0c;用户ID可以作为主键。当插入或更新数据时&#xff0c;数据库会自动检查主键值是否唯一。如果试图插入一个已存在主键值的记录&#xff0c;数据…...

vue 基础学习

一、ref 和reactive 区别 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>Title</title> </head> <body><div id"app"><h1>{{Web.title}}</h1><h1&…...

HarmonyOS NEXT 实战之元服务:静态案例效果---查看国际航班服务

背景&#xff1a; 前几篇学习了元服务&#xff0c;后面几期就让我们开发简单的元服务吧&#xff0c;里面丰富的内容大家自己加&#xff0c;本期案例 仅供参考 先上本期效果图 &#xff0c;里面图片自行替换 效果图1完整代码案例如下&#xff1a; Index代码 import { authen…...

PetaLinux 内核输出信息的获取方式

串口终端: 默认输出方式。 曾尝试过将串口终端的输出重映射到伪终端&#xff0c;失败了。 伪终端: dmesg命令 dmesg是Linux系统重查看内核日志的使用工具&#xff0c;允许查看系统内核的输出消息&#xff0c;包括引导信息&#xff0c;硬件检测&#xff0c;设备驱动和系统错…...

Android使用辅助服务AccessibilityService实现自动化任务

Android 辅助服务&#xff08;AccessibilityService&#xff09;旨在帮助具有视觉、身体或年龄相关限制的用户更轻松地使用 Android 设备和应用。通过辅助服务&#xff0c;可以将一些人工操作自动化&#xff0c;从而解放用户的双手。 因此我们可以使用它来实现一些自动化任务&a…...

工业大数据分析算法实战-day15

文章目录 day15特定数据类型的算法工业分析中的数据预处理工况划分数据缺失时间数据不连续强噪声大惯性系统趋势项消除 day15 今天是第15天&#xff0c;昨日是针对最优化算法、规则推理算法、系统辨识算法进行了阐述&#xff0c;今日主要是针对其他算法中的特定数据类型的算法…...

C语言实现顺序表详解

文章目录 [TOC] 1.前言&#x1f64b;&#x1f3fc;‍♂️2.顺序表&#x1f9e3;2.1 顺序表概念&#x1f9e3;2.2 顺序表特点&#x1f9e3;2.2 顺序表作用&#x1f9e3; 3.顺序表基操&#x1f9e4;3.1 结构体初始化&#x1f389;3.2 顺序表初始化&#x1f389;3.3 顺序表创建&am…...

【ES6复习笔记】对象方法扩展(17)

对象方法扩展 在 JavaScript 中&#xff0c;对象是属性和方法的集合。除了内置的方法&#xff0c;我们还可以通过扩展对象的原型来添加新的方法。本教程将介绍如何使用 Object.is、Object.assign 和 Object.setPrototypeOf 方法来扩展对象。 1. Object.is 判断两个值是否完全…...

【视觉惯性SLAM:相机成像模型】

相机成像模型介绍 相机成像模型是计算机视觉和图像处理中的核心内容&#xff0c;它描述了真实三维世界如何通过相机映射到二维图像平面。相机成像模型通常包括针孔相机的基本成像原理、数学模型&#xff0c;以及在实际应用中如何处理相机的各种畸变现象。 一、针孔相机成像原…...

Win10/Win11远程桌面报错‘函数不受支持’?5分钟搞定CredSSP加密Oracle修正

Win10/Win11远程桌面报错‘函数不受支持’&#xff1f;5分钟急救指南 刚准备远程处理工作文件&#xff0c;突然跳出"发生身份验证错误&#xff0c;要求的函数不受支持"的红色警告框——这个场景对需要频繁使用远程桌面的职场人来说简直噩梦。上周我就遇到了同样问题&…...

10、Ansible 生产级故障排查与运维最佳实践

Ansible 生产级故障排查与运维最佳实践 一、Ansible 生产常见故障类型&#xff08;高频&#xff09; SSH 连接类故障&#xff08;占 60%&#xff09;sudo/权限类故障网络、端口、防火墙Python 环境缺失/版本不兼容Fact 采集慢、超时、卡死文件权限、临时目录权限变量、模板、加…...

2026最权威的降AI率神器横评

Ai论文网站排名&#xff08;开题报告、文献综述、降aigc率、降重综合对比&#xff09; TOP1. 千笔AI TOP2. aipasspaper TOP3. 清北论文 TOP4. 豆包 TOP5. kimi TOP6. deepseek 使AIGC率降低的关键重心是去削减文本所具有的那种机械规整感&#xff0c;往里面注入属于人类…...

Oh-My-Posh 多会话管理终极指南:在不同终端中保持一致的完美体验

Oh-My-Posh 多会话管理终极指南&#xff1a;在不同终端中保持一致的完美体验 【免费下载链接】oh-my-posh2 A prompt theming engine for Powershell 项目地址: https://gitcode.com/gh_mirrors/oh/oh-my-posh2 Oh-My-Posh 是一款强大的 PowerShell 提示符主题引擎&…...

终极RVM Gemset完全指南:如何优雅隔离Ruby项目依赖

终极RVM Gemset完全指南&#xff1a;如何优雅隔离Ruby项目依赖 【免费下载链接】rvm Ruby enVironment Manager (RVM) 项目地址: https://gitcode.com/gh_mirrors/rv/rvm Ruby开发中&#xff0c;项目依赖冲突是开发者最头疼的问题之一。Ruby enVironment Manager (RVM) …...

猫抓资源嗅探扩展完整配置指南:从零开始掌握网页资源捕获

猫抓资源嗅探扩展完整配置指南&#xff1a;从零开始掌握网页资源捕获 【免费下载链接】cat-catch 猫抓 浏览器资源嗅探扩展 / cat-catch Browser Resource Sniffing Extension 项目地址: https://gitcode.com/GitHub_Trending/ca/cat-catch 还在为无法下载网页视频而烦恼…...

Boost电路与SMC滑模控制策略:文章复现及性能优化探讨

boost电路&#xff0c;smc滑模控制&#xff0c;文章复现Boost电路在电力电子里算是老熟人了&#xff0c;但真要玩转它的闭环控制可不容易。最近在复现一篇用滑模控制&#xff08;SMC&#xff09;搞Boost电路的论文&#xff0c;实测发现这货对付负载突变确实有两把刷子。今天咱们…...

Nginx性能优化-压缩

但很多开发者在配置nginx时容易混淆两个概念&#xff1a;Gzip动态压缩和Gzip静态压缩。本文将带你彻底搞懂这两者的区别、配置方法以及最佳实践。什么是Gzip动态压缩&#xff1f;原理&#xff1a; 当客户端&#xff08;浏览器&#xff09;发起请求时&#xff0c;Nginx接收到请求…...

不只是CTF:把攻防世界Reversing题当‘活教材’,提升你的Linux二进制分析实战力

从CTF到实战&#xff1a;用x64Elf-100案例解锁Linux逆向工程核心技能 逆向工程常被视为黑客的专属领域&#xff0c;但它的价值远不止于破解几个CTF题目。当一位金融科技公司的安全工程师通过逆向分析阻止了针对交易系统的0day攻击&#xff0c;或当一位恶意软件研究员仅凭二进制…...

别再纠结了!手把手教你用FreeSWITCH 1.10 + Verto模块搭建WebRTC智能外呼系统(含完整配置文件)

WebRTC智能外呼实战&#xff1a;基于FreeSWITCH与Verto的高效解决方案 在数字化转型浪潮中&#xff0c;企业通信系统正经历从传统电话向互联网融合的深刻变革。我曾为多家金融机构和电商平台设计过智能外呼系统&#xff0c;发现一个共性痛点&#xff1a;如何在不依赖客户端安装…...