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

Android14 SystemUI 启动流程(1)

1.从SystemServer启动

  private void run() {
		......
        // Start services.
        try {
            t.traceBegin("StartServices");
            startBootstrapServices(t);
            startCoreServices(t);
            startOtherServices(t);//从这里走
            startApexServices(t);
            // Only update the timeout after starting all the services so that we use
            // the default timeout to start system server.
            updateWatchdogTimeout(t);
        } catch (Throwable ex) {
            Slog.e("System", "******************************************");
            Slog.e("System", "************ Failure starting system services", ex);
            throw ex;
        } finally {
            t.traceEnd(); // StartServices
        }
		......

2.走startOtherServices()


    /**
     * Starts a miscellaneous grab bag of stuff that has yet to be refactored and organized.
     */
    private void startOtherServices(@NonNull TimingsTraceAndSlog t) {
		......
		
        t.traceBegin("StartSystemUI");
        try {
            startSystemUi(context, windowManagerF);
        } catch (Throwable e) {
            reportWtf("starting System UI", e);
        }
	    ......
    }

3.启动SystemUi

    private static void startSystemUi(Context context, WindowManagerService windowManager) {
        PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
        Intent intent = new Intent();
        intent.setComponent(pm.getSystemUiServiceComponent());
        intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);
        //Slog.d(TAG, "Starting service: " + intent);
        context.startServiceAsUser(intent, UserHandle.SYSTEM);
        windowManager.onSystemUiStarted();
    }
//frameworks/base/services/core/java/com/android/server/pm/PackageManagerInternalBase.java
    @Override
    @Deprecated
    public final ComponentName getSystemUiServiceComponent() {
        return ComponentName.unflattenFromString(getContext().getResources().getString(
                com.android.internal.R.string.config_systemUIServiceComponent));
    }
    <!-- SystemUi service component -->
    <string name="config_systemUIServiceComponent" translatable="false"
            >com.android.systemui/com.android.systemui.SystemUIService</string>

4.启动SystemUIService服务(SystemUI中)

public class SystemUIService extends Service {

    @Override
    public void onCreate() {
        super.onCreate();
        // Start all of SystemUI
        ((SystemUIApplication) getApplication()).startServicesIfNeeded();
    }
}
    启动实现了CoreStartable的实体类:如CentralSurfacesImpl等等,去start,去onBootCompleted
    /**
     * Makes sure that all the SystemUI services are running. If they are already running, this is a
     * no-op. This is needed to conditinally start all the services, as we only need to have it in
     * the main process.
     * <p>This method must only be called from the main thread.</p>
     */

    public void startServicesIfNeeded() {
        final String vendorComponent = mInitializer.getVendorComponent(getResources());

        // Sort the startables so that we get a deterministic ordering.
        // TODO: make #start idempotent and require users of CoreStartable to call it.
        Map<Class<?>, Provider<CoreStartable>> sortedStartables = new TreeMap<>(
                Comparator.comparing(Class::getName));
        sortedStartables.putAll(mSysUIComponent.getStartables());
        sortedStartables.putAll(mSysUIComponent.getPerUserStartables());
        startServicesIfNeeded(
                sortedStartables, "StartServices", vendorComponent);
    }

http://www.kler.cn/a/350301.html

相关文章:

  • Android系统开发(六):从Linux到Android:模块化开发,GKI内核的硬核科普
  • YOLO目标检测1
  • SDL2:Android APP编译使用 -- SDL2多媒体库使用音频实例
  • MIAOYUN信创云原生项目亮相西部“中试”生态对接活动
  • 光谱相机如何还原色彩
  • Kivy App开发之UX控件TabbedPanel选项面板
  • 工作日志:vue3各种警告
  • 【Flask】Flask数据库
  • 文件信息类QFileInfo
  • 微信小程序考试系统(lw+演示+源码+运行)
  • c++实现跳表
  • OpenCV-人脸检测
  • 中安 TH-OCR:强大的光学字符识别工具与数据处理优势
  • LeetCode讲解篇之2606. 找到最大开销的子字符串
  • 【Redis】List类型常用命令
  • Linux权限和开发工具(1)
  • leetcode 1027 最长等差数列 题目的思考
  • QOwnNotes:开源界的黑马,专业人士的不二之选
  • git merge啥意思
  • 力扣3194.最小元素和最大元素的平均最小值
  • 提升效率的秘密武器:如何选择合适的编程工具
  • STM32外设应用全解析
  • 【Unity】Unity中接入Admob聚合广告平台,可通过中介接入 AppLovin,Unity Ads,Meta等渠道的广告
  • 快速理解AUTOSAR CP的软件架构层次以及各层的作用
  • 第三弹:探索网络传输中的TFTP、UDP广播与多播技术
  • 打印杨辉三角形