SystemUI启动流程

SystemUI启动流程梳理

  • 流程图及简介

 

SystemUI简介:

SystemU包含功能有:导航栏,状态栏,通知栏,近期列表等(R.array.config_systemUIServiceComponents)

所有 SystemUIService 都是继承自 SystemUI.class , SystemUI.class 是一个抽象类

  1. <item>com.android.systemui.util.NotificationChannels</item> 通知信息 
  2. <item>com.android.systemui.keyguard.KeyguardViewMediator</item> 锁屏 
  3. <item>com.android.systemui.recents.Recents</item> 近期列表
  4. Android 10之后近期列表的显示被移到Launcher里面了。在Launcher3的一个 类中TouchInteractionService.java   IBinder mMyBinder = new IOverviewProxy.Stub() 通过AIDL的方法与systemUI通信
  5. ————————————————
  6. <item>com.android.systemui.volume.VolumeUI</item> 声音UI显示 
  7. <item>com.android.systemui.statusbar.phone.StatusBar</item> 状态栏及下拉面板
  8. <item>com.android.systemui.usb.StorageNotification</item> usb通知管理 
  9. <item>com.android.systemui.power.PowerUI</item>  电源UI显示管理
  10. <item>com.android.systemui.media.RingtonePlayer</item> 播放铃声 
  11. <item>com.android.systemui.keyboard.KeyboardUI</item>键盘UI 
  12. <item>com.android.systemui.shortcut.ShortcutKeyDispatcher</item>快捷方式  
  13. <item>@string/config_systemUIVendorServiceComponent</item>厂商相关定制 
  14. <item>com.android.systemui.util.leak.GarbageMonitor$Service</item>垃圾监测器  
  15. <item>com.android.systemui.LatencyTester</item> 延迟测试仪 
  16. <item>com.android.systemui.globalactions.GlobalActionsComponent</item>  关机界面的显示、全局控制
  17. <item>com.android.systemui.ScreenDecorations</item>屏幕装饰  
  18. <item>com.android.systemui.biometrics.AuthController</item>生物识别  
  19. <item>com.android.systemui.SliceBroadcastRelayHandler</item> 切片广播 
  20. <item>com.android.systemui.statusbar.notification.InstantAppNotifier</item>  
  21. <item>com.android.systemui.theme.ThemeOverlayController</item>  
  22. <item>com.android.systemui.accessibility.WindowMagnification</item>  
  23. <item>com.android.systemui.accessibility.SystemActions</item>  
  24. <item>com.android.systemui.toast.ToastUI</item>  Toast
  25. <item>com.android.systemui.wmshell.WMShell</item> 

二、代码控制流程

2.1相关类

  1. frameworks/base/services/java/com/android/server/SystemServer.java  
  2. frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java  
  3. SystemUI/src/com/android/systemui/SystemUIService.java  
  4. frameworks/base/packages/SystemUI/res/values/config.xml  
  5. frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUI.ja

2.2、启动流程

navigation_bar_window.xml

SystemServer.startSystemUi()

  1. private static void startSystemUi(Context context, WindowManagerService windowManager) {  
  2.     PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);  
  3.     Intent intent = new Intent();  
  4.     intent.setComponent(pm.getSystemUiServiceComponent());  
  5.     intent.addFlags(Intent.FLAG_DEBUG_TRIAGED_MISSING);  
  6.     //Slog.d(TAG, "Starting service: " + intent);  
  7.     context.startServiceAsUser(intent, UserHandle.SYSTEM);  
  8.     windowManager.onSystemUiStarted();  
  9. }  

SystemUIService.onCreate()

  1. public void onCreate() {  
  2.     super.onCreate();  
  3.   
  4.     // Start all of SystemUI  
  5.     ((SystemUIApplication) getApplication()).startServicesIfNeeded();  
  6.   
  7.     // Finish initializing dump logic  
  8.     mLogBufferFreezer.attach(mBroadcastDispatcher);  
  9.   
  10.     // If configured, set up a battery notification  
  11.     if (getResources().getBoolean(R.bool.config_showNotificationForUnknownBatteryState)) {  
  12.         mBatteryStateNotifier.startListening();  
  13.     }  
  14.      ……
  15.     // Bind the dump service so we can dump extra info during a bug report  
  16.     startServiceAsUser(  
  17.             new Intent(getApplicationContext(), SystemUIAuxiliaryDumpService.class),  
  18.             UserHandle.SYSTEM);  

SystemUIApplication. startServicesIfNeeded()

  1. private void startServicesIfNeeded(String metricsPrefix, String[] services) {  
  2.     if (mServicesStarted) {  
  3.         return;  
  4.     }  
  5.     mServices = new SystemUI[services.length];  
  6.   
  7.     if (!mBootCompleteCache.isBootComplete()) {  
  8.         // check to see if maybe it was already completed long before we began  
  9.         // see ActivityManagerService.finishBooting()  
  10.         if ("1".equals(SystemProperties.get("sys.boot_completed"))) {  
  11.             mBootCompleteCache.setBootComplete();  
  12.             if (DEBUG) {  
  13.                 Log.v(TAG, "BOOT_COMPLETED was already sent");  
  14.             }  
  15.         }  
  16.     }  
  17.   
  18.     final DumpManager dumpManager = mSysUIComponent.createDumpManager();  
  19.   
  20.     Log.v(TAG, "Starting SystemUI services for user " +  
  21.             Process.myUserHandle().getIdentifier() + ".");  
  22.     TimingsTraceLog log = new TimingsTraceLog("SystemUIBootTiming",  
  23.             Trace.TRACE_TAG_APP);  
  24.     log.traceBegin(metricsPrefix);  
  25.     final int N = services.length;  
  26.     for (int i = 0; i < N; i++) {  
  27.         String clsName = services[i];  
  28.         if (DEBUG) Log.d(TAG, "loading: " + clsName);  
  29.         log.traceBegin(metricsPrefix + clsName);  
  30.         long ti = System.currentTimeMillis();  
  31.         try {  
  32.             SystemUI obj = mComponentHelper.resolveSystemUI(clsName);  
  33.             if (obj == null) {  
  34.                 Constructor constructor = Class.forName(clsName).getConstructor(Context.class);  
  35.                 obj = (SystemUI) constructor.newInstance(this);  
  36.             }  
  37.             mServices[i] = obj;  
  38.         } catch (ClassNotFoundException  
  39.                 | NoSuchMethodException  
  40.                 | IllegalAccessException  
  41.                 | InstantiationException  
  42.                 | InvocationTargetException ex) {  
  43.             throw new RuntimeException(ex);  
  44.         }  
  45.   
  46.         if (DEBUG) Log.d(TAG, "running: " + mServices[i]);  
  47.         mServices[i].start();  
  48.         log.traceEnd();  
  49.   
  50.         // Warn if initialization of component takes too long  
  51.         ti = System.currentTimeMillis() - ti;  
  52.         if (ti > 1000) {  
  53.             Log.w(TAG, "Initialization of " + clsName + " took " + ti + " ms");  
  54.         }  
  55.         if (mBootCompleteCache.isBootComplete()) {  
  56.             mServices[i].onBootCompleted();  
  57.         }  
  58.   
  59.         dumpManager.registerDumpable(mServices[i].getClass().getName(), mServices[i]);  
  60.     }  
  61.     mSysUIComponent.getInitController().executePostInitTasks();  
  62.     log.traceEnd();  
  63.   
  64.     mServicesStarted = true;  

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值