xref: /aosp_15_r20/frameworks/base/packages/SystemUI/README.md (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1*d57664e9SAndroid Build Coastguard Worker# SystemUI
2*d57664e9SAndroid Build Coastguard Worker
3*d57664e9SAndroid Build Coastguard Worker“Everything you see in Android that's not an app”
4*d57664e9SAndroid Build Coastguard Worker
5*d57664e9SAndroid Build Coastguard WorkerSystemUI is a persistent process that provides UI for the system but outside
6*d57664e9SAndroid Build Coastguard Workerof the system_server process.
7*d57664e9SAndroid Build Coastguard Worker
8*d57664e9SAndroid Build Coastguard WorkerInputs directed at sysui (as opposed to general listeners) generally come in
9*d57664e9SAndroid Build Coastguard Workerthrough IStatusBar. Outputs from sysui are through a variety of private APIs to
10*d57664e9SAndroid Build Coastguard Workerthe android platform all over.
11*d57664e9SAndroid Build Coastguard Worker
12*d57664e9SAndroid Build Coastguard Worker## SystemUIApplication
13*d57664e9SAndroid Build Coastguard Worker
14*d57664e9SAndroid Build Coastguard WorkerWhen SystemUIApplication starts up, it instantiates a Dagger graph from which
15*d57664e9SAndroid Build Coastguard Workervarious pieces of the application are built.
16*d57664e9SAndroid Build Coastguard Worker
17*d57664e9SAndroid Build Coastguard WorkerTo support customization, SystemUIApplication relies on the AndroidManifest.xml
18*d57664e9SAndroid Build Coastguard Workerhaving an `android.app.AppComponentFactory` specified. Specifically, it relies
19*d57664e9SAndroid Build Coastguard Workeron an `AppComponentFactory` that subclases `SystemUIAppComponentFactoryBase`.
20*d57664e9SAndroid Build Coastguard WorkerImplementations of this abstract base class must override
21*d57664e9SAndroid Build Coastguard Worker`#createSystemUIInitializer(Context)` which returns a `SystemUIInitializer`.
22*d57664e9SAndroid Build Coastguard Worker`SystemUIInitializer` primary job in turn is to intialize and return the Dagger
23*d57664e9SAndroid Build Coastguard Workerroot component back to the `SystemUIApplication`.
24*d57664e9SAndroid Build Coastguard Worker
25*d57664e9SAndroid Build Coastguard WorkerWriting a custom `SystemUIAppComponentFactoryBase` and `SystemUIInitializer`,
26*d57664e9SAndroid Build Coastguard Workershould be enough for most implementations to stand up a customized Dagger
27*d57664e9SAndroid Build Coastguard Workergraph, and launch a custom version of SystemUI.
28*d57664e9SAndroid Build Coastguard Worker
29*d57664e9SAndroid Build Coastguard Worker## Dagger / Dependency Injection
30*d57664e9SAndroid Build Coastguard Worker
31*d57664e9SAndroid Build Coastguard WorkerSee [dagger.md](docs/dagger.md) and https://dagger.dev/.
32*d57664e9SAndroid Build Coastguard Worker
33*d57664e9SAndroid Build Coastguard Worker## CoreStartable
34*d57664e9SAndroid Build Coastguard Worker
35*d57664e9SAndroid Build Coastguard WorkerThe starting point for most of SystemUI code is a list of classes that
36*d57664e9SAndroid Build Coastguard Workerimplement `CoreStartable` that are started up by SystemUIApplication.
37*d57664e9SAndroid Build Coastguard WorkerCoreStartables are like miniature services. They have their `#start` method
38*d57664e9SAndroid Build Coastguard Workercalled after being instantiated, and a reference to them is stored inside
39*d57664e9SAndroid Build Coastguard WorkerSystemUIApplication. They are in charge of their own behavior beyond this,
40*d57664e9SAndroid Build Coastguard Workerregistering and unregistering with the rest of the system as needed.
41*d57664e9SAndroid Build Coastguard Worker
42*d57664e9SAndroid Build Coastguard Worker`CoreStartable` also receives a callback for `#onBootCompleted`
43*d57664e9SAndroid Build Coastguard Workersince these objects may be started before the device has finished booting.
44*d57664e9SAndroid Build Coastguard Worker
45*d57664e9SAndroid Build Coastguard Worker`CoreStartable` is an ideal place to add new features and functionality
46*d57664e9SAndroid Build Coastguard Workerthat does not belong directly under the umbrella of an existing feature.
47*d57664e9SAndroid Build Coastguard WorkerIt is better to define a new `CoreStartable` than to stick unrelated
48*d57664e9SAndroid Build Coastguard Workerinitialization code together in catch-all methods.
49*d57664e9SAndroid Build Coastguard Worker
50*d57664e9SAndroid Build Coastguard WorkerCoreStartables are tied to application startup via Dagger:
51*d57664e9SAndroid Build Coastguard Worker
52*d57664e9SAndroid Build Coastguard Worker```kotlin
53*d57664e9SAndroid Build Coastguard Workerclass FeatureStartable
54*d57664e9SAndroid Build Coastguard Worker@Inject
55*d57664e9SAndroid Build Coastguard Workerconstructor(
56*d57664e9SAndroid Build Coastguard Worker    /* ... */
57*d57664e9SAndroid Build Coastguard Worker) : CoreStartable {
58*d57664e9SAndroid Build Coastguard Worker    override fun start() {
59*d57664e9SAndroid Build Coastguard Worker        // ...
60*d57664e9SAndroid Build Coastguard Worker    }
61*d57664e9SAndroid Build Coastguard Worker}
62*d57664e9SAndroid Build Coastguard Worker
63*d57664e9SAndroid Build Coastguard Worker@Module
64*d57664e9SAndroid Build Coastguard Workerabstract class FeatureModule {
65*d57664e9SAndroid Build Coastguard Worker    @Binds
66*d57664e9SAndroid Build Coastguard Worker    @IntoMap
67*d57664e9SAndroid Build Coastguard Worker    @ClassKey(FeatureStartable::class)
68*d57664e9SAndroid Build Coastguard Worker    abstract fun bind(impl: FeatureStartable): CoreStartable
69*d57664e9SAndroid Build Coastguard Worker}
70*d57664e9SAndroid Build Coastguard Worker```
71*d57664e9SAndroid Build Coastguard Worker
72*d57664e9SAndroid Build Coastguard WorkerIncluding `FeatureModule` in the Dagger graph such as this will ensure that
73*d57664e9SAndroid Build Coastguard Worker`FeatureStartable` gets constructed and that its `#start` method is called.
74*d57664e9SAndroid Build Coastguard Worker
75*d57664e9SAndroid Build Coastguard Worker## IStatusBar
76*d57664e9SAndroid Build Coastguard Worker
77*d57664e9SAndroid Build Coastguard WorkerCommandQueue is the object that receives all of the incoming events from the
78*d57664e9SAndroid Build Coastguard Workersystem_server. It extends IStatusBar and dispatches those callbacks back any
79*d57664e9SAndroid Build Coastguard Workernumber of listeners. The system_server gets a hold of the IStatusBar when
80*d57664e9SAndroid Build Coastguard WorkerStatusBar calls IStatusBarService#registerStatusBar, so if StatusBar is not
81*d57664e9SAndroid Build Coastguard Workerincluded in the XML service list, it will not be registered with the OS.
82*d57664e9SAndroid Build Coastguard Worker
83*d57664e9SAndroid Build Coastguard WorkerCommandQueue posts all incoming callbacks to a handler and then dispatches
84*d57664e9SAndroid Build Coastguard Workerthose messages to each callback that is currently registered. CommandQueue
85*d57664e9SAndroid Build Coastguard Workeralso tracks the current value of disable flags and will call #disable
86*d57664e9SAndroid Build Coastguard Workerimmediately for any callbacks added.
87*d57664e9SAndroid Build Coastguard Worker
88*d57664e9SAndroid Build Coastguard WorkerThere are a few places where CommandQueue is used as a bus to communicate
89*d57664e9SAndroid Build Coastguard Workeracross sysui. Such as when StatusBar calls CommandQueue#recomputeDisableFlags.
90*d57664e9SAndroid Build Coastguard WorkerThis is generally used as a shortcut to directly trigger CommandQueue rather than
91*d57664e9SAndroid Build Coastguard Workercalling StatusManager and waiting for the call to come back to IStatusBar.
92*d57664e9SAndroid Build Coastguard Worker
93*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.util.NotificationChannels](/packages/SystemUI/src/com/android/systemui/util/NotificationChannels.java)
94*d57664e9SAndroid Build Coastguard Worker
95*d57664e9SAndroid Build Coastguard WorkerCreates/initializes the channels sysui uses when posting notifications.
96*d57664e9SAndroid Build Coastguard Worker
97*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.keyguard.KeyguardViewMediator](/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java)
98*d57664e9SAndroid Build Coastguard Worker
99*d57664e9SAndroid Build Coastguard WorkerManages keyguard view state.
100*d57664e9SAndroid Build Coastguard Worker
101*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.recents.Recents](/packages/SystemUI/src/com/android/systemui/recents/Recents.java)
102*d57664e9SAndroid Build Coastguard Worker
103*d57664e9SAndroid Build Coastguard WorkerRecents tracks all the data needed for recents and starts/stops the recents
104*d57664e9SAndroid Build Coastguard Workeractivity. It provides this cached data to RecentsActivity when it is started.
105*d57664e9SAndroid Build Coastguard Worker
106*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.volume.VolumeUI](/packages/SystemUI/src/com/android/systemui/volume/VolumeUI.java)
107*d57664e9SAndroid Build Coastguard Worker
108*d57664e9SAndroid Build Coastguard WorkerRegisters all the callbacks/listeners required to show the Volume dialog when
109*d57664e9SAndroid Build Coastguard Workerit should be shown.
110*d57664e9SAndroid Build Coastguard Worker
111*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.status.phone.CentralSurfaces](/packages/SystemUI/src/com/android/systemui/status/phone/CentralSurfaces.java)
112*d57664e9SAndroid Build Coastguard Worker
113*d57664e9SAndroid Build Coastguard WorkerThis shows the UI for the status bar and the notification shade it contains.
114*d57664e9SAndroid Build Coastguard WorkerIt also contains a significant amount of other UI that interacts with these
115*d57664e9SAndroid Build Coastguard Workersurfaces (keyguard, AOD, etc.). CentralSurfaces also contains a notification listener
116*d57664e9SAndroid Build Coastguard Workerto receive notification callbacks.
117*d57664e9SAndroid Build Coastguard Worker
118*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.usb.StorageNotification](/packages/SystemUI/src/com/android/systemui/usb/StorageNotification.java)
119*d57664e9SAndroid Build Coastguard Worker
120*d57664e9SAndroid Build Coastguard WorkerTracks USB status and sends notifications for it.
121*d57664e9SAndroid Build Coastguard Worker
122*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.power.PowerUI](/packages/SystemUI/src/com/android/systemui/power/PowerUI.java)
123*d57664e9SAndroid Build Coastguard Worker
124*d57664e9SAndroid Build Coastguard WorkerTracks power status and sends notifications for low battery/power saver.
125*d57664e9SAndroid Build Coastguard Worker
126*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.media.RingtonePlayer](/packages/SystemUI/src/com/android/systemui/media/RingtonePlayer.java)
127*d57664e9SAndroid Build Coastguard Worker
128*d57664e9SAndroid Build Coastguard WorkerPlays ringtones.
129*d57664e9SAndroid Build Coastguard Worker
130*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.keyboard.KeyboardUI](/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java)
131*d57664e9SAndroid Build Coastguard Worker
132*d57664e9SAndroid Build Coastguard WorkerShows UI for keyboard shortcuts (triggered by keyboard shortcut).
133*d57664e9SAndroid Build Coastguard Worker
134*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.shortcut.ShortcutKeyDispatcher](/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java)
135*d57664e9SAndroid Build Coastguard Worker
136*d57664e9SAndroid Build Coastguard WorkerDispatches shortcut to System UI components.
137*d57664e9SAndroid Build Coastguard Worker
138*d57664e9SAndroid Build Coastguard Worker### @string/config_systemUIVendorServiceComponent
139*d57664e9SAndroid Build Coastguard Worker
140*d57664e9SAndroid Build Coastguard WorkerComponent allowing the vendor/OEM to inject a custom component.
141*d57664e9SAndroid Build Coastguard Worker
142*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.util.leak.GarbageMonitor$Service](/packages/SystemUI/src/com/android/systemui/util/leak/GarbageMonitor.java)
143*d57664e9SAndroid Build Coastguard Worker
144*d57664e9SAndroid Build Coastguard WorkerTracks large objects in sysui to see if there are leaks.
145*d57664e9SAndroid Build Coastguard Worker
146*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.LatencyTester](/packages/SystemUI/src/com/android/systemui/LatencyTester.java)
147*d57664e9SAndroid Build Coastguard Worker
148*d57664e9SAndroid Build Coastguard WorkerClass that only runs on debuggable builds that listens to broadcasts that
149*d57664e9SAndroid Build Coastguard Workersimulate actions in the system that are used for testing the latency.
150*d57664e9SAndroid Build Coastguard Worker
151*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.globalactions.GlobalActionsComponent](/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsComponent.java)
152*d57664e9SAndroid Build Coastguard Worker
153*d57664e9SAndroid Build Coastguard WorkerShows the global actions dialog (long-press power).
154*d57664e9SAndroid Build Coastguard Worker
155*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.ScreenDecorations](/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java)
156*d57664e9SAndroid Build Coastguard Worker
157*d57664e9SAndroid Build Coastguard WorkerDraws decorations about the screen in software (e.g. rounded corners, cutouts).
158*d57664e9SAndroid Build Coastguard Worker
159*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.biometrics.BiometricDialogImpl](/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java)
160*d57664e9SAndroid Build Coastguard Worker
161*d57664e9SAndroid Build Coastguard WorkerBiometric UI.
162*d57664e9SAndroid Build Coastguard Worker
163*d57664e9SAndroid Build Coastguard Worker### [com.android.systemui.wmshell.WMShell](/packages/SystemUI/src/com/android/systemui/wmshell/WMShell.java)
164*d57664e9SAndroid Build Coastguard Worker
165*d57664e9SAndroid Build Coastguard WorkerDelegates SysUI events to WM Shell controllers.
166*d57664e9SAndroid Build Coastguard Worker
167*d57664e9SAndroid Build Coastguard Worker---
168*d57664e9SAndroid Build Coastguard Worker
169*d57664e9SAndroid Build Coastguard Worker * [Plugins](/packages/SystemUI/docs/plugins.md)
170*d57664e9SAndroid Build Coastguard Worker * [Demo Mode](/packages/SystemUI/docs/demo_mode.md)
171