美文网首页
【Using English】59 Android System

【Using English】59 Android System

作者: 二手认知 | 来源:发表于2020-01-19 19:03 被阅读0次

    “Everything you see in Android that's not an app”

    SystemUI

    “那些你在Android中看到的,但不是一个应用的东西”

    SystemUI是一个持续运行的进程,它为系统提供UI但不属于系统服务进程。

    大多数SystemUI代码的起点都是继承了SystemUI 的一系列服务,这些服务被SystemUIApplication启动。这些服务随后由Dependency来提供一些自定义的依赖注入。

    与通常的监听器不同,针对SystemUI的输入通常来自于IStatusBar。来自SystemUI的输出则通过一系列的私有API发送到Android平台的各个角落。

    SystemUIApplication

    SystemUIApplication启动时,会启动配置文件config_systemUIServiceComponents和config_systemUIServiceComponentsPerUser中列出的服务。

    这些服务中的每一个都继承了SystemUI。SystemUI为它们提供了一个上下文对象Context,也提供了配置改变时的回调(由于历史原因,这是onConfigurationChanged的主路径,现在也会发生在ConfigurationController中)。由于这些服务可能在系统启动完成前启动,所以它们也会接收到系统启动完成的回调。

    SystemUI和SystemUIApplication也提供了方法来设置组件putComponent和获取组件getComponent, 这样现有的系统在依赖产生前就可以持有其他SystemUI组件。通常新的组件不应该被添加到putComponent中,相反地,推荐的方式是Dependency或其他的重构,这样可以保持SystemUI架构的简洁。

    每一个SystemUI的服务都是SystemUI的主要部分,目标是最小化服务之间的交互。所以,通常服务要相对地职责单一。

    Dependencies

    起一个被启动的SystemUI服务,应该是一个依赖项Dependency。Dependency提供了一个静态方法来获取跨越SystemUI生命周期的依赖项。Dependency提供了代码,用于创建所有手动添加的依赖项。SystemUIFactory也能够添加和替换这些依赖项。

    依赖项是懒加载的,所以如果一个依赖项从未在运行时被引用,它永远不会被创建。

    如果一个实例化的依赖实现了Dumpable接口,它会被加入到SystemUI(和bug报告)的转储中,允许它使用当前的状态信息。这就是控制器转存信息到bug报告中的方式。

    如果一个实例化的依赖项实现了配置更改接收器ConfigurationChangeReceiver接口,它会在配置信息更改时接收到配置信息更改onConfigurationChange的回调。

    IStatusBar

    命令队列是接收所有来自系统服务输入事件的对象。它继承了IStatusBar,并且把这些回调信息分发回任意数量的监听器。当StatusBar调用注册方法IStatusBarService#registerStatusBar时,系统服务system_server会持有对应的IStatusBar,所以如果StatusBar没有被引入到XML服务列表中,它将不会被系统注册。

    命令队列把所有输入回调发送到一个处理器中,然后分发这些信息到每一个当前已经注册的回调中。命令队列也会追踪关闭标签的当前值,对于任何添加的回调,都会立刻调用关闭#disable方法。

    有一些地方命令队列被用做一个总线,来负责跨SystemUI的交互。比如当StatusBar调用命令队列的重算关闭标签方法CommandQueue#recomputeDisableFlags.通常,这通常是一种触发命令队列CommandQueue的快捷方式,而不是调用StatusManager然后等待调用回到IStatusBar。

    Default SystemUI services list

    com.android.systemui.Dependency

    提供自定义的依赖注入。

    com.android.systemui.util.NotificationChannels

    创建或初始化SystemUI频道,用于发送通知。

    com.android.systemui.statusbar.CommandQueue$CommandQueueStart

    Creates CommandQueue and calls putComponent because its always been there and sysui expects it to be there :/

    com.android.systemui.keyguard.KeyguardViewMediator

    Manages keyguard view state.

    com.android.systemui.recents.Recents

    Recents tracks all the data needed for recents and starts/stops the recents activity. It provides this cached data to RecentsActivity when it is started.

    com.android.systemui.volume.VolumeUI

    Registers all the callbacks/listeners required to show the Volume dialog when it should be shown.

    com.android.systemui.stackdivider.Divider

    Shows the drag handle for the divider between two apps when in split screen mode.

    com.android.systemui.SystemBars

    This is a proxy to the actual SystemUI for the status bar. This loads from config_statusBarComponent which defaults to StatusBar. (maybe this should be removed and copy how config_systemUiVendorServiceComponent works)

    com.android.systemui.status.phone.StatusBar

    This shows the UI for the status bar and the notification shade it contains. It also contains a significant amount of other UI that interacts with these surfaces (keyguard, AOD, etc.). StatusBar also contains a notification listener to receive notification callbacks.

    com.android.systemui.usb.StorageNotification

    Tracks USB status and sends notifications for it.

    com.android.systemui.power.PowerUI

    Tracks power status and sends notifications for low battery/power saver.

    com.android.systemui.media.RingtonePlayer

    Plays ringtones.

    com.android.systemui.keyboard.KeyboardUI

    Shows UI for keyboard shortcuts (triggered by keyboard shortcut).

    com.android.systemui.pip.PipUI

    Shows the overlay controls when Pip is showing.

    com.android.systemui.shortcut.ShortcutKeyDispatcher

    Dispatches shortcut to System UI components.

    @string/config_systemUIVendorServiceComponent

    Component allowing the vendor/OEM to inject a custom component.

    com.android.systemui.util.leak.GarbageMonitor$Service

    Tracks large objects in sysui to see if there are leaks.

    com.android.systemui.LatencyTester

    Class that only runs on debuggable builds that listens to broadcasts that simulate actions in the system that are used for testing the latency.

    com.android.systemui.globalactions.GlobalActionsComponent

    Shows the global actions dialog (long-press power).

    com.android.systemui.ScreenDecorations

    Draws decorations about the screen in software (e.g. rounded corners, cutouts).

    com.android.systemui.biometrics.BiometricDialogImpl

    Biometric UI.

    original

    About 【Using English】

    相关文章

      网友评论

          本文标题:【Using English】59 Android System

          本文链接:https://www.haomeiwen.com/subject/czvrzctx.html