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

SystemUIService启动-Android13

SystemUIService启动-Android13

  • 1、SystemUIService启动
  • 2、其他SystemUI services启动
    • 2.1 Dagger依赖注入
    • 2.2 Recents为例

1、SystemUIService启动

SystemUI启动,及其SystemUIService启动

    <!-- SystemUi service component --><string name="config_systemUIServiceComponent" translatable="false">com.android.systemui/com.android.systemui.SystemUIService</string>

在这里插入图片描述

2、其他SystemUI services启动

2.1 Dagger依赖注入

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

  1. 注解驱动: Dagger基于Java注解进行配置。@Component@Module@Inject 是三个核心注解,它们定义了依赖关系的结构。
    @Component 定义了一个接口,表示一组相关对象的集合,以及它们之间的依赖关系。
    @Module 用于封装提供者方法,这些方法可以生成或提供依赖项。
    @Inject 告诉Dagger需要自动注入某个字段或构造函数。
  2. 代码生成: 在编译时,Dagger会根据上述注解生成对应的类和方法,这些生成的代码负责实际的对象创建和依赖注入。这种静态类型和编译时检查避免了运行时错误,并提高了性能。

Dagger Android Injection: 简化Android应用的依赖注入
用 Dagger2 在 Android 中实现依赖注入

2.2 Recents为例

frameworks/base/packages/SystemUI/README.md
frameworks/base/packages/SystemUI/src/com/android/systemui/Dependency.java
frameworks/base/packages/SystemUI/src/com/android/systemui/dagger/SystemUICoreStartableModule.kt

    /** Inject into Recents.  */@Binds@IntoMap@ClassKey(Recents::class)abstract fun bindRecents(sysui: Recents): CoreStartable

frameworks/base/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java
frameworks/base/packages/SystemUI/src/com/android/systemui/recents/RecentsModule.java

    /*** @return The {@link RecentsImplementation} from the config.*/@Providespublic static RecentsImplementation provideRecentsImpl(Context context,ContextComponentHelper componentHelper) {final String clsName = context.getString(R.string.config_recentsComponent);if (clsName == null || clsName.length() == 0) {throw new RuntimeException("No recents component configured", null);}RecentsImplementation impl = componentHelper.resolveRecents(clsName);if (impl == null) {Class<?> cls = null;try {cls = context.getClassLoader().loadClass(clsName);} catch (Throwable t) {throw new RuntimeException("Error loading recents component: " + clsName, t);}try {impl = (RecentsImplementation) cls.newInstance();} catch (Throwable t) {throw new RuntimeException("Error creating recents component: " + clsName, t);}}return impl;}
<string name="config_recentsComponent" translatable="false">com.android.systemui.recents.OverviewProxyRecentsImpl</string>

使用了dagger@IntoMap 注入相关类。只要是 继承 CoreStartable 类的都将会被注入。在这里插入图片描述

http://www.lryc.cn/news/398208.html

相关文章:

  • linux权限深度解析——探索原理
  • Qt学生管理系统(付源码)
  • 重磅!新公司法正式实施,这些变化你必须知道! ️
  • [Flask笔记]一个完整的Flask程序
  • 企业专利布局怎么弄
  • ArduPilot开源飞控之AP_Mount_Topotek
  • React组件间通信的几种方式
  • 2024最新国际版抖音TikTok安装教程,免root免拔卡安卓+iOS,附全套安装工具!
  • kafka与zookeeper的SSL认证教程
  • 为何数字化转型项目会夭折?深入分析失败的关键因素
  • 数据结构(其二)--线性表
  • 软链接node_modules
  • Apache中使用SSI设置
  • Java Stream API详解:高效处理集合数据的利器
  • Python使用策略模式和openpyxl库创建Excel文件并追加内容
  • libcoap3对接华为云平台
  • 【鸿蒙学习笔记】关系型数据库概述
  • Find My网球拍|苹果Find My技术与网球拍结合,智能防丢,全球定位
  • windows环境下部署多个端口Tomcat服务和开机自启动设置保姆级教程
  • 科普文:一文搞懂jvm实战(四)深入理解逃逸分析Escape Analysis
  • 中文大模型发展到哪一个阶段了?
  • 【PostgreSQL】Spring boot + Mybatis-plus + PostgreSQL 处理json类型情况
  • 华为910b推理Qwen1.5-72b
  • legoloam算法环境配置和调试笔记
  • 如何用CSS3画一个三角形?
  • 不同型号的GD32 MCU如何区分?
  • 关于windows下编译xLua插件的流程记录
  • Hadoop简明教程
  • 基于STM32设计的药品柜温湿度监测系统(华为云IOT)(184)
  • SpringBoot源码阅读(10)——后处理器