1# SystemUI 2 3“Everything you see in Android that's not an app” 4 5SystemUI is a persistent process that provides UI for the system but outside 6of the system_server process. 7 8The starting point for most of sysui code is a list of services that extend 9SystemUI that are started up by SystemUIApplication. These services then depend 10on some custom dependency injection provided by Dependency. 11 12Inputs directed at sysui (as opposed to general listeners) generally come in 13through IStatusBar. Outputs from sysui are through a variety of private APIs to 14the android platform all over. 15 16## SystemUIApplication 17 18When SystemUIApplication starts up, it will start up the services listed in 19config_systemUIServiceComponents or config_systemUIServiceComponentsPerUser. 20 21Each of these services extend SystemUI. SystemUI provides them with a Context 22and gives them callbacks for onConfigurationChanged (this historically was 23the main path for onConfigurationChanged, now also happens through 24ConfigurationController). They also receive a callback for onBootCompleted 25since these objects may be started before the device has finished booting. 26 27Each SystemUI service is expected to be a major part of system ui and the 28goal is to minimize communication between them. So in general they should be 29relatively silo'd. 30 31## Dependencies 32 33The first SystemUI service that is started should always be Dependency. 34Dependency provides a static method for getting a hold of dependencies that 35have a lifecycle that spans sysui. Dependency has code for how to create all 36dependencies manually added. SystemUIFactory is also capable of 37adding/replacing these dependencies. 38 39Dependencies are lazily initialized, so if a Dependency is never referenced at 40runtime, it will never be created. 41 42If an instantiated dependency implements Dumpable it will be included in dumps 43of sysui (and bug reports), allowing it to include current state information. 44This is how \*Controllers dump state to bug reports. 45 46If an instantiated dependency implements ConfigurationChangeReceiver it will 47receive onConfigurationChange callbacks when the configuration changes. 48 49## IStatusBar 50 51CommandQueue is the object that receives all of the incoming events from the 52system_server. It extends IStatusBar and dispatches those callbacks back any 53number of listeners. The system_server gets a hold of the IStatusBar when 54StatusBar calls IStatusBarService#registerStatusBar, so if StatusBar is not 55included in the XML service list, it will not be registered with the OS. 56 57CommandQueue posts all incoming callbacks to a handler and then dispatches 58those messages to each callback that is currently registered. CommandQueue 59also tracks the current value of disable flags and will call #disable 60immediately for any callbacks added. 61 62There are a few places where CommandQueue is used as a bus to communicate 63across sysui. Such as when StatusBar calls CommandQueue#recomputeDisableFlags. 64This is generally used a shortcut to directly trigger CommandQueue rather than 65calling StatusManager and waiting for the call to come back to IStatusBar. 66 67## Default SystemUI services list 68 69### [com.android.systemui.Dependency](/packages/SystemUI/src/com/android/systemui/Dependency.java) 70 71Provides custom dependency injection. 72 73### [com.android.systemui.util.NotificationChannels](/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java) 74 75Creates/initializes the channels sysui uses when posting notifications. 76 77### [com.android.systemui.keyguard.KeyguardViewMediator](/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java) 78 79Manages keyguard view state. 80 81### [com.android.systemui.recents.Recents](/packages/SystemUI/src/com/android/systemui/recents/Recents.java) 82 83Recents tracks all the data needed for recents and starts/stops the recents 84activity. It provides this cached data to RecentsActivity when it is started. 85 86### [com.android.systemui.volume.VolumeUI](/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java) 87 88Registers all the callbacks/listeners required to show the Volume dialog when 89it should be shown. 90 91### [com.android.systemui.stackdivider.Divider](/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java) 92 93Shows the drag handle for the divider between two apps when in split screen 94mode. 95 96### [com.android.systemui.status.phone.StatusBar](/packages/SystemUI/src/com/android/systemui/status/phone/StatusBar.java) 97 98This shows the UI for the status bar and the notification shade it contains. 99It also contains a significant amount of other UI that interacts with these 100surfaces (keyguard, AOD, etc.). StatusBar also contains a notification listener 101to receive notification callbacks. 102 103### [com.android.systemui.usb.StorageNotification](/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java) 104 105Tracks USB status and sends notifications for it. 106 107### [com.android.systemui.power.PowerUI](/packages/SystemUI/src/com/android/systemui/power/PowerUI.java) 108 109Tracks power status and sends notifications for low battery/power saver. 110 111### [com.android.systemui.media.RingtonePlayer](/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java) 112 113Plays ringtones. 114 115### [com.android.systemui.keyboard.KeyboardUI](/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java) 116 117Shows UI for keyboard shortcuts (triggered by keyboard shortcut). 118 119### [com.android.systemui.pip.PipUI](/packages/SystemUI/src/com/android/systemui/pip/PipUI.java) 120 121Shows the overlay controls when Pip is showing. 122 123### [com.android.systemui.shortcut.ShortcutKeyDispatcher](/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java) 124 125Dispatches shortcut to System UI components. 126 127### @string/config_systemUIVendorServiceComponent 128 129Component allowing the vendor/OEM to inject a custom component. 130 131### [com.android.systemui.util.leak.GarbageMonitor$Service](/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java) 132 133Tracks large objects in sysui to see if there are leaks. 134 135### [com.android.systemui.LatencyTester](/packages/SystemUI/src/com/android/systemui/LatencyTester.java) 136 137Class that only runs on debuggable builds that listens to broadcasts that 138simulate actions in the system that are used for testing the latency. 139 140### [com.android.systemui.globalactions.GlobalActionsComponent](/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java) 141 142Shows the global actions dialog (long-press power). 143 144### [com.android.systemui.ScreenDecorations](/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java) 145 146Draws decorations about the screen in software (e.g. rounded corners, cutouts). 147 148### [com.android.systemui.biometrics.BiometricDialogImpl](/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java) 149 150Biometric UI. 151 152--- 153 154 * [Plugins](/packages/SystemUI/docs/plugins.md) 155 * [Demo Mode](/packages/SystemUI/docs/demo_mode.md) 156