In the previous sessions we covered the init process and zygote process.
We also looked at the code from their site code for the system server process.
Let's start from there and see what exactly System Server is doing.
So in the previous session we looked at the zygote in Java, right?
So there we saw that the system server is system server processes created using fork mechanism.
So it's done here.
So for system server.
So inside for system server method, we could see that the command line is hardcoded and here we could
see this system server class.
It refers to the system server dot java class.
And using these arguments.
Here.
It's calling the pork system server.
So inside work systems are basically calling a JNI method called core system server.
So this you can find within.
This zip file.
So if you look at, you can see that it's the package name and the class name.
Com dot android dot internal dot always dot zygote.
So the zygote is cycle java from which it is called.
So this one.
So finally this method will come back to the system.
So the systems, our main method and as you could see from the main method, it simply calls system
server road run.
So within run there are three main methods.
So the START Bootstrap Services method, the START Core Services method and START other services method,
the START Bootstrap Services method starts small tangle of critical services that are needed to get
the system off the ground.
These services have complex mutual dependencies, which is why it is initialized at one place.
So in case if you are planning to add a service that is very much interdependent on these bootstrap
services, then you could add it within this method.
But if it is not dependent on any of these bootstrap services, you should not add it here.
You should consider adding it in these other methods start core services or start other services.
So mostly this will be the preferable place if you.
The service which you are going to add doesn't have any dependency on these, then it's advisable.
You can add it in the start.
Other services method.
So the START Bootstrap Services is responsible to start a set of services which are actually interrelated.
So here is a list of major services which are started by bootstrap services.
So here we have INSTALLER, which is basically a service class used when the system installs the APK
and then we have the activity manager service or AMS, which is basically responsible for startup switching
and scheduling of these four major components of the system.
Then the Power Manager Service for power related calculations in the system lights service for managing
the back leads Display Manager Service for handling the display devices within the System User Manager
Service Multi User Mode Management Sensor services are basically to provide various sensor services
for the system.
And finally, the package manager service for installing and installing the EPCs.
So in this method you can see it starts each of the services one by one, like the install restarted
here, power stats services started here and the activity manager.
Our manager, thermal manager and many of the services are started here.
So you can also look at the trace logs.
You could see when it is started and when it is up and running.
So next we have start core services.
So the START Core Services method starts some essential services that are not dependent on the bootstrap
process.
So here is a list of main services within the core service.
So here we have the battery service which manages the battery related services.
Usage stats service.
It collects how often users use each app and how often they are used.
Then Web view update service service related to Web updates.
And then we have the CPU service.
It's basically to handle CPU and GPU driver.
So we can start core services, we can see it starts all these services, the usage service.
The View Update service.
And here you can see if the device supports feature webview then it really it starts it.
So similarly, there are many conditions across these methods.
So if the device supports a particular feature to start some services and the binder called Stats Service
Loop Loop Stats Service, then finally the GPU service.
So next is the start.
Other services start other services method starts a set of miscellaneous services.
So here is a list of major services started by start of the service method.
So the camera service this handles the camera later steps allow manager service.
It's the global timer management service input management service.
So this is for the IMEI, the input keyboard.
And then we have the window manager service handles, the window management, the VR Manager Service
for the VR Mode Management Services.
Bluetooth Service.
Bluetooth Management Service.
Notification Manager.
Service Handles and notifications of the system.
Device storage monitor service.
So it's related to the SD card storage related management services and the location manager service
handles the location stuffs and audio service.
It handles all audio related services.
So we'll look in detail some of the services in the later sessions.
So there are a few more things which we need to note down here.
Like some of the services are only for some devices.
So here you can see these only for ease.
Watch.
And then.
Well, we have some condition.
So if it is disabled camera service, then do that, not disabled, then do that.
And similarly, there are some cases where it's only for automotive and there are some cases where it's
only for EV.
So this is only car.
So this case, we check if there is a feature wi fi, then only start the wi fi and here if it has a
USB feature, then start the USB service.
So if you as a backup feature, then start that feature, then start the app service.
So there are many conditions here.
So not all services are started for all devices.
So based on the device and some configurations, it will ignore some of the services.
And if you come down at this spot, we can see that it says to activity manager service that the system
is ready and this tells the activity manager that it's okay to run the third party code.
So this is an example where it checks for feature automotive.
So this will get started only if the build is an automotive build.
And at this point will basically start the system UI.
So this method is responsible for starting the system UI.
We'll dig deeper into this when we cover the system UI startup process.
So this is basically the last service within the start other services method.