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

Android14 SystemUI 启动流程(2)

/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java

    启动实现了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);}

1.这里通过依赖注入将CoreStartable实现类保存这个Map中!

/frameworks/base/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java

   /*** Returns {@link CoreStartable}s that should be started with the application.*/Map<Class<?>, Provider<CoreStartable>> getStartables();

2.这里是对super_notification_shade.xml(整个下拉菜单栏布局文件)status_bar.xml(桌面状态栏)navigation_bar.xml(导航栏)等布局进行初始化

/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/dagger/StartCentralSurfacesModule.kt

@Module
interface StartCentralSurfacesModule {/** Start the CentralSurfaces   */@Binds@IntoMap :将这个实现类注入到Map<Class<?>, Provider<CoreStartable>>中取@ClassKey(CentralSurfaces::class) :map的键是CentralSurfaces.classabstract fun bindsCentralSurfaces(centralSurfaces: CentralSurfacesImpl): CoreStartable
}

/frameworks/base/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt

/*** Collection of {@link CoreStartable}s that should be run on AOSP.*/
@Module(includes = [MultiUserUtilsModule::class,StartControlsStartableModule::class,StartBinderLoggerModule::class,WallpaperModule::class,
])
abstract class SystemUICoreStartableModule {/** Inject into AuthController.  */@Binds@IntoMap@ClassKey(AuthController::class)abstract fun bindAuthController(service: AuthController): CoreStartable/** Inject into BiometricNotificationService */@Binds@IntoMap@ClassKey(BiometricNotificationService::class)abstract fun bindBiometricNotificationService(service: BiometricNotificationService): CoreStartable/** Inject into ClipboardListener.  */@Binds@IntoMap@ClassKey(ClipboardListener::class)abstract fun bindClipboardListener(sysui: ClipboardListener): CoreStartable/** Inject into GlobalActionsComponent.  */@Binds@IntoMap@ClassKey(GlobalActionsComponent::class)abstract fun bindGlobalActionsComponent(sysui: GlobalActionsComponent): CoreStartable/** Inject into InstantAppNotifier.  */@Binds@IntoMap@ClassKey(InstantAppNotifier::class)abstract fun bindInstantAppNotifier(sysui: InstantAppNotifier): CoreStartable/** Inject into KeyboardUI.  */@Binds@IntoMap@ClassKey(KeyboardUI::class)abstract fun bindKeyboardUI(sysui: KeyboardUI): CoreStartable/** Inject into MediaProjectionTaskSwitcherCoreStartable. */@Binds@IntoMap@ClassKey(MediaProjectionTaskSwitcherCoreStartable::class)abstract fun bindProjectedTaskListener(sysui: MediaProjectionTaskSwitcherCoreStartable): CoreStartable/** Inject into KeyguardBiometricLockoutLogger */@Binds@IntoMap@ClassKey(KeyguardBiometricLockoutLogger::class)abstract fun bindKeyguardBiometricLockoutLogger(sysui: KeyguardBiometricLockoutLogger): CoreStartable/** Inject into KeyguardViewMediator.  */@Binds@IntoMap@ClassKey(KeyguardViewMediator::class)abstract fun bindKeyguardViewMediator(sysui: KeyguardViewMediator): CoreStartable/** Inject into LatencyTests.  */@Binds@IntoMap@ClassKey(LatencyTester::class)abstract fun bindLatencyTester(sysui: LatencyTester): CoreStartable/** Inject into NotificationChannels.  */@Binds@IntoMap@ClassKey(NotificationChannels::class)@PerUserabstract fun bindNotificationChannels(sysui: NotificationChannels): CoreStartable/** Inject into PowerUI.  */@Binds@IntoMap@ClassKey(PowerUI::class)abstract fun bindPowerUI(sysui: PowerUI): CoreStartable/** Inject into Recents.  */@Binds@IntoMap@ClassKey(Recents::class)abstract fun bindRecents(sysui: Recents): CoreStartable/** Inject into ImmersiveModeConfirmation.  */@Binds@IntoMap@ClassKey(ImmersiveModeConfirmation::class)abstract fun bindImmersiveModeConfirmation(sysui: ImmersiveModeConfirmation): CoreStartable/** Inject into RingtonePlayer.  */@Binds@IntoMap@ClassKey(RingtonePlayer::class)abstract fun bind(sysui: RingtonePlayer): CoreStartable/** Inject into ScreenDecorations.  */@Binds@IntoMap@ClassKey(ScreenDecorations::class)abstract fun bindScreenDecorations(sysui: ScreenDecorations): CoreStartable/** Inject into GesturePointerEventHandler. */@Binds@IntoMap@ClassKey(GesturePointerEventListener::class)abstract fun bindGesturePointerEventListener(sysui: GesturePointerEventListener): CoreStartable/** Inject into SessionTracker.  */@Binds@IntoMap@ClassKey(SessionTracker::class)abstract fun bindSessionTracker(service: SessionTracker): CoreStartable/** Inject into ShortcutKeyDispatcher.  */@Binds@IntoMap@ClassKey(ShortcutKeyDispatcher::class)abstract fun bindShortcutKeyDispatcher(sysui: ShortcutKeyDispatcher): CoreStartable/** Inject into SliceBroadcastRelayHandler.  */@Binds@IntoMap@ClassKey(SliceBroadcastRelayHandler::class)abstract fun bindSliceBroadcastRelayHandler(sysui: SliceBroadcastRelayHandler): CoreStartable/** Inject into StorageNotification.  */@Binds@IntoMap@ClassKey(StorageNotification::class)abstract fun bindStorageNotification(sysui: StorageNotification): CoreStartable/** Inject into SystemActions.  */@Binds@IntoMap@ClassKey(SystemActions::class)abstract fun bindSystemActions(sysui: SystemActions): CoreStartable/** Inject into ThemeOverlayController.  */@Binds@IntoMap@ClassKey(ThemeOverlayController::class)abstract fun bindThemeOverlayController(sysui: ThemeOverlayController): CoreStartable/** Inject into ToastUI.  */@Binds@IntoMap@ClassKey(ToastUI::class)abstract fun bindToastUI(service: ToastUI): CoreStartable/** Inject into MediaOutputSwitcherDialogUI.  */@Binds@IntoMap@ClassKey(MediaOutputSwitcherDialogUI::class)abstract fun MediaOutputSwitcherDialogUI(sysui: MediaOutputSwitcherDialogUI): CoreStartable/** Inject into VolumeUI.  */@Binds@IntoMap@ClassKey(VolumeUI::class)abstract fun bindVolumeUI(sysui: VolumeUI): CoreStartable/** Inject into WindowMagnification.  */@Binds@IntoMap@ClassKey(WindowMagnification::class)abstract fun bindWindowMagnification(sysui: WindowMagnification): CoreStartable/** Inject into WMShell.  */@Binds@IntoMap@ClassKey(WMShell::class)abstract fun bindWMShell(sysui: WMShell): CoreStartable/** Inject into KeyguardLiftController.  */@Binds@IntoMap@ClassKey(KeyguardLiftController::class)abstract fun bindKeyguardLiftController(sysui: KeyguardLiftController): CoreStartable/** Inject into MediaTttSenderCoordinator. */@Binds@IntoMap@ClassKey(MediaTttSenderCoordinator::class)abstract fun bindMediaTttSenderCoordinator(sysui: MediaTttSenderCoordinator): CoreStartable/** Inject into MediaTttChipControllerReceiver. */@Binds@IntoMap@ClassKey(MediaTttChipControllerReceiver::class)abstract fun bindMediaTttChipControllerReceiver(sysui: MediaTttChipControllerReceiver): CoreStartable/** Inject into MediaTttCommandLineHelper. */@Binds@IntoMap@ClassKey(MediaTttCommandLineHelper::class)abstract fun bindMediaTttCommandLineHelper(sysui: MediaTttCommandLineHelper): CoreStartable/** Inject into ChipbarCoordinator. */@Binds@IntoMap@ClassKey(ChipbarCoordinator::class)abstract fun bindChipbarController(sysui: ChipbarCoordinator): CoreStartable/** Inject into RearDisplayDialogController) */@Binds@IntoMap@ClassKey(RearDisplayDialogController::class)abstract fun bindRearDisplayDialogController(sysui: RearDisplayDialogController): CoreStartable/** Inject into StylusUsiPowerStartable) */@Binds@IntoMap@ClassKey(StylusUsiPowerStartable::class)abstract fun bindStylusUsiPowerStartable(sysui: StylusUsiPowerStartable): CoreStartable@Binds@IntoMap@ClassKey(PhysicalKeyboardCoreStartable::class)abstract fun bindKeyboardCoreStartable(listener: PhysicalKeyboardCoreStartable): CoreStartable/** Inject into MuteQuickAffordanceCoreStartable*/@Binds@IntoMap@ClassKey(MuteQuickAffordanceCoreStartable::class)abstract fun bindMuteQuickAffordanceCoreStartable(sysui: MuteQuickAffordanceCoreStartable): CoreStartable/**Inject into DreamMonitor */@Binds@IntoMap@ClassKey(DreamMonitor::class)abstract fun bindDreamMonitor(sysui: DreamMonitor): CoreStartable/**Inject into AssistantAttentionMonitor */@Binds@IntoMap@ClassKey(AssistantAttentionMonitor::class)abstract fun bindAssistantAttentionMonitor(sysui: AssistantAttentionMonitor): CoreStartable@Binds@IntoMap@ClassKey(KeyguardViewConfigurator::class)abstract fun bindKeyguardViewConfigurator(impl: KeyguardViewConfigurator): CoreStartable@Binds@IntoMap@ClassKey(LockscreenWallpaper::class)abstract fun bindLockscreenWallpaper(impl: LockscreenWallpaper): CoreStartable@Binds@IntoMap@ClassKey(ScrimController::class)abstract fun bindScrimController(impl: ScrimController): CoreStartable@Binds@IntoMap@ClassKey(StatusBarHeadsUpChangeListener::class)abstract fun bindStatusBarHeadsUpChangeListener(impl: StatusBarHeadsUpChangeListener): CoreStartable
}

startable.start();启动每个CoreStartable实现类的start()方法

/frameworks/base/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java

  private void startServicesIfNeeded(Map<Class<?>, Provider<CoreStartable>> startables,String metricsPrefix,String vendorComponent) {if (mServicesStarted) {return;}mServices = new CoreStartable[startables.size() + (vendorComponent == null ? 0 : 1)];int i = 0;for (Map.Entry<Class<?>, Provider<CoreStartable>> entry : startables.entrySet()) {String clsName = entry.getKey().getName();int j = i;  // Copied to make lambda happy.timeInitialization(clsName,() -> mServices[j] = startStartable(clsName, entry.getValue()),log,metricsPrefix);i++;}for (i = 0; i < mServices.length; i++) {CoreStartable service = mServices[i];if (mBootCompleteCache.isBootComplete()) {notifyBootCompleted(service);}if (service.isDumpCritical()) {dumpManager.registerCriticalDumpable(service.getClass().getName(), service);} else {dumpManager.registerNormalDumpable(service.getClass().getName(), service);}}}private static CoreStartable startStartable(String clsName, Provider<CoreStartable> provider) {if (DEBUG) Log.d(TAG, "loading: " + clsName);if (Trace.isEnabled()) {Trace.traceBegin(Trace.TRACE_TAG_APP, "Provider<" + clsName + ">.get()");}CoreStartable startable = provider.get();Trace.endSection();return startStartable(startable);}private static CoreStartable startStartable(CoreStartable startable) {if (DEBUG) Log.d(TAG, "running: " + startable);if (Trace.isEnabled()) {Trace.traceBegin(Trace.TRACE_TAG_APP, startable.getClass().getSimpleName() + ".start()");}startable.start();Trace.endSection();return startable;}

3.主要看CentralSurfacesImpl.java(整个下拉菜单栏的启动入口)

http://www.dtcms.com/a/287348.html

相关文章:

  • Spring MVC @RequestParam注解全解析
  • Spring MVC源码分析 DispatcherServlet#getHandlerAdapter方法
  • C# 中的强大运算符
  • 掌握配置文件(一):精通`properties`与`yml`的语法及选择
  • 【iOS】ZARA仿写
  • MySQL详解二
  • ros2高级篇之高可用启动文件及配置编写
  • 深入解析HDFS写入流程:管道机制与数据可靠性保障
  • (Python)类和类的方法(基础教程介绍)(Python基础教程)
  • 7月19日日记
  • SpringAI_Chat模型_DeepSeek模型--基础对话
  • Word快速文本对齐程序开发经验:从需求分析到实现部署
  • 嵌入式单片机开发 - Keil MDK 复制工程
  • Python day18
  • MySQL事务管理(上)(12)
  • xss-labs靶场1-8
  • DAMA数据管理具像化解读|第一章数据管理|业务驱动因素
  • 暑期训练8
  • 13.4 Meta LLaMA开源模型家族全面解析:从Alpaca到Vicuna的技术内幕
  • 外观设计模式
  • 删除debian xdm自启动ibus的配置项
  • 2021 RoboCom 世界机器人开发者大赛-本科组(初赛)解题报告 | 珂学家
  • c语言-数据结构-如何用分冶法求得二叉树的节点数与高度?
  • CSS篇——第一章 六十五项关键技能(上篇)
  • Node.js特训专栏-实战进阶:17.会话管理与安全存储
  • Rust+ChatBoxAI:实战
  • 多模态交互视角下生成式人工智能在中小学探究式学习中的认知支架效能研究
  • SpringBoot项目部署至云服务器
  • Django接口自动化平台实现(三)
  • YOLOv11改进 | RFAConv重塑空间注意力助力性能提升