System UI booting source code analysis.
In this section, we'll have a look at how the system UI is booted and which all classes modules are
responsible for booting systems UI.
So let's get started.
So let's first open up the emulator.
The Lockett window only.
So the emulator is now up and here you can see the logcat logs and here I have filtered with system
UI.
So this is just to show you these logs.
So from these logs we can make out that the system UI start is happening from the system server.
So here you can see system server timing starting the system UI and it took 9 milliseconds to just trigger
the system UI.
So once this is triggered, it's getting into that package.
So complete Android system UI and then you could see here that the system UI application is constructed
first and the system UI application is created.
And then there are some boot timing here.
You can see dependency injection 1 milliseconds.
So here basically system UI uses dagger two to do some dependency injection.
So here it's basically doing that.
And then later on it's initializing all these different, different models of system UI.
So here the recent module volume UI, status bar power UI, ringtone player, keyboard UI, etc., etc..
Finally, it completed in 860 milliseconds.
So by this time the system UI is completely up and we got all these same UI modules.
So this is how on a very high level it works.
So now let's get into the code and see how it is actually triggering and which classes are responsible
for what in detail.
So let's now look at the code.
I have added bookmarks or important execution points.
So as we discussed earlier, the system UI is started from system server.
So within the system server there is a function called START other services.
So this is basically the function which start a lot of other services system server is one of the most
important class of Android and system server is basically responsible for starting a lot of services,
including System UI, activity management system, window management system and many, many other services.
So System UI is getting started from START other services and it's started at this point.
So there is another function called START System UI, this one you go there.
So this function is pretty important.
What it does is it's a handle to the manager internal and then it uses the GET system UI service component
function within that.
So if you go there, it's basically an abstract class, it's defined within the packet manager service
dot Java.
And within that you can see that it gets the system UI service component.
From my next config file, it's nothing but this one config system, UI service component.
So that's the one here.
Here you can see that it's pointing to the home dot android dot system UI service.
So we started from the system server.
So system server is having the start other services which is actually responsible for calling START
System UI and within START system UI creates an indent.
So here you can see it creates an intent, uses this particular component from the package manager service
and then it starts the service as the user with this intent.
It also tells Windows Manager that the system UI started by calling this particular function.
So it informs the window manager service that the system UI is started.
So in short, the START System UI basically creates a handle to package manager and from package manager
it gets the system UI service component.
These are nothing but system UI service class.
And with this indent it calls the system UI service class.
Also, it informs the window manager that the system UI is started.
That is basically the functionality of START System UI.
So now let's go to system UI service.
So within system UI service it basically extends the service and it has some constructor here and in
on create the first line which you can see here actually reference the system UI application class calls
this particular function which is the most important thing which we need to look at.
It also does some other steps here and this is the most important for us.
So let's go there.
And here you can see that it gets the system UI service components and the system UI service components.
It picks up from this configuration config system, UI service components.
So let's go inside that.
So config system UI service components within config system, UI service component, you can see that
it has all the system UI components defined.
Basically, we loop through all these items and we start them one by one.
Let's see how the system is starting each of these modules.
Yeah.
Which actually gives us that.
Ari.
So here you can see that it gets the names.
And with this name, this name is actually passed to start service if needed.
And within START services if needed, you come to the bottom here.
You can see that there is one for loop which actually loops through all those services.
So any cycle, the service length, it goes through one by one starts it.
So here you can see on boot camp it's also calling on boot completed.
So on boot completed is nothing but a function from the system UI or Java or the system UI or Java classes
are actually inherited by most of the components are extended by most of these components.
So in short, what happens is that the system starts process from the system server and the system server
course the START system UI from the system, from the START system UI, it actually picks the component
and creates an intent and starts the system UI service.
So system UI service and within the system UI service IT the system UI application.
And of course this particular function starts with if needed and within the start service needed.
It calls start services if needed, function this local function which actually loops through all these,
all these different packages and starts them one by one.
And that's exactly what we are seeing in these logs.
So that's exactly what we are seeing in this log.
So here you can see that it's starting each of these services one by one, it will be in the same same
sequence as defined should be starting the notification channel, first notification channel and then
the key view, mediator, mediator.
And then the reasons, the reasons volume UI that is bar and so on.
The toast UI shall.