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

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.xdnf.cn/news/15953.html

相关文章:

  • 笔试大题20分值(用两个栈实现队列)
  • Unity物理响应函数与触发器
  • C++类和对象(一)基础内容讲解
  • 2025暑假训练树状数组
  • 自动化立体仓库堆垛机控制系统上报堆垛机状态 FC5
  • MySQL 写入性能优化全攻略(附 GitHub 面试题项目链接)
  • 最终分配算法【论文材料】
  • laravel RedisException: Connection refused优雅草PMS项目管理系统报错解决-以及Redis 详细指南-优雅草卓伊凡
  • WSL的功能及用途
  • JavaScript空值安全深度指南
  • 单调队列深度解析(下)
  • 前端开发技巧:浏览器模拟弱网络环境
  • 【Linux】重生之从零开始学习运维之Nginx
  • 高可用架构设计与实践综述
  • XSS总结
  • 【RK3576】【Android14】固件烧录
  • 零基础学后端-PHP语言(第一期-PHP环境配置)
  • SQL核心语法与实战应用指南
  • MacOS:如何利用终端来操作用户
  • kafka--基础知识点--6.1--LEO、HW、LW
  • 2025 Data Whale x PyTorch 安装学习笔记(Windows 版)
  • react+antd+表格拖拽排序以及上移、下移、移到顶部、移到底部
  • react17更新哪些新特性
  • ARINC818协议综述
  • 48Days-Day03 | 删除公共字符,两个链表的第一个公共结点,mari和shiny
  • uniapp相关地图 API调用
  • servicemesh 学习
  • 实战分享:Web3 前端开发Defi项目
  • [硬件电路-39]:激光光路的光信号处理、模拟电路的电信号处理、数字电路的电信号处理、软件的信号处理,有哪些共通的操作、运算、变换?
  • 06-人机共生:Prompt之外的思考