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