Android system service

Source: Internet
Author: User
System_Server Process

Many services run in the system server process, which is the basis of the entire android framework.

 

Native service

SurfaceFlinger

 

This is a service for framebuffer synthesis. It combines the logical window image data (surface) of various applications and applications into a physical window and displays the service program of framebuffer.

 

Java service:

Most of these services have a manager class for processes. This is an RPC call. You can call the xxxManager method, in fact, it is sent by the Binder to the method corresponding to xxxManagerService in the system_server process, and the result is taken back through the binder.

 

 

1. EntropyService

Entropy service, periodic loading and storage of random information. It is mainly because after linux is started, the/dev/random status may be predictable, so some applications that require random information may have problems. No application interface is required.

 

2. PowerManagerService-> PowerManager

Android power management is also an important part. For example, you can turn off unnecessary devices in the standby mode, the screen and keyboard Backlight in the standby mode, and the number of devices to be turned on during user operations.

 

3. ActivityManagerService-> ActivityManager

This is the most core service in the entire Android framework. It manages the core implementation of tasks, process management, and Intent parsing in the entire framework. Although the Manager Service is called Activity, it is not only subject to Activity, but also has three other components and processes. That is to say, the user is responsible for application lifecycle management.

 

4. TelephonyRegistry-> TelephonyManager

The telephone registration and management service module can obtain the telephone connection status, signal strength, and so on. <You can delete it, but you can see it clearly.>

 

5. PackageManagerService-> PackageManager

This includes unpacking, verification, installation, and upgrade of the software package. To solve the problem that we cannot install the. so file, we should first analyze the cause from this.

 

6. AccountManagerService-> AccountManager

A system service that provides account, password, and authtoken management for all

Accounts on the device.

 

7. ContentService-> ContentResolver

Content services are mainly services that provide solutions such as databases.

 

8. BatteryService

Monitors battery charging and status services. Intent is broadcast when the status changes.

 

9. HardwareService

Generally, it is the service program of ring and vibrate.

 

10. SensorService-> SensorManager

Manages the services of the Sensor device, registers the client device, and activates the sensor when the client needs to use the Sensor.

 

11. WindowManagerService-> WindowManager-> PhoneWindowManager

Highly bonded with ActivityManagerService

Window Management, the core here is the distribution and management of input events.

 

12. AlarmManagerService-> AlarmManager

Alarm service program

 

13. Define thservice-> define thdevice

Bluetooth background management and service programs

 

14. StatusBarService-> StatusBarManager

It is responsible for the statusBar Standard update, animation, and other services with little service.

 

15. ClipboardService-> ClipboardManager

Similar to the clipBoard service of other systems, it provides copy and paste capabilities.

 

16. InputMethodManagerService-> InputMethodManager

The Management Service Program of the input method, including when to enable the input method, and switching the input method.

 

17. NetStatService

Mobile Network Service

 

18. ConnectivityService-> ConnectivityManager

The network connection status service can be queried by other applications. When the network status changes, it can also be broadcast and changed.

 

19. AccessibilityManagerService-> AccessibilityManager

This may take a closer look. It mainly involves the distribution and management of click, focus, text changes, and other events, debugging and problem locating of the entire system, you also need to carefully view this service.

 

20. icationicationmanagerservice-> icationicationmanager

Responsible for managing and notifying the occurrence of background events. This is glued together with statusbar, and the response icon is usually added to statusbar. You can use this to know what happened in the system background.

 

21. MountService

A service program for disk loading usually works with a linux daemon program, such as vold/mountd, to listen for and broadcast device mount/unmount/bad removal events.

 

22. DeviceStorageMonitorService

Monitors disk space services. If the disk space is less than 10%, a warning is given to the user.

 

23. LocationManagerService-> LocationManager

To join the GPS service, take a closer look at this part. Now the navigation in the application does not respond. You can start to look at it.

 

24. SearchManagerService-> SearchManager

The search manager service handles the search UI, and maintains a registry of searchable activities.

 

25. Checkin Service (FallbackCheckinService)

It seems that checkin service is a package provided by google, with no source code. The source code is fallbackCheckinService.

 

26. WallpaperManagerService-> WallpaperManager
Services that manage the desktop background and deeply customize the Desktop System, which need to be understood and expanded <compatibility at the same time>

 

27. AudioService-> AudioManager

The upper-Layer Management encapsulation of AudioFlinger mainly manages volume, sound effects, sound channels, and ringtones.

 

28. HeadsetObserver

Monitoring cycle of earphone plugging events

 

29. DockObserver

If there is a license in the system, when the mobile phone is installed or pulled out, it will have to be managed by him.

 

30. BackupManagerService-> BackupManager

Backup Service

 

31. AppWidgetService-> AppWidgetManager

Android allows users to write programs on the desktop as Widgets. This is the interface for this process and service.

 

32. StatusBarPolicy

Specifies the icon to display on the status bar.

 

 

MediaServer service process

MediaServer services are basically native services, and the mediaServer process is started in init. rc. It is not a daemon process, which is easy to confuse. It is also a system service process similar to the systemserver process. It provides the location where the real service code of the RPC call of the application process runs. Its services are related to media recording and playback. There are three main services:

 

AudioFlinger

Audio Recording and playback services, including sound mixing

 

MediaPlayerService

The media playback service is provided. opencore is the core module of this module.

 

CameraService

Supports recording and preview functions of camera.

 

AudioPolicyService

The main functions include checking the connection status of the input and output devices and switching the system's audio policy.



9.4.1 start various system service threads

The SystemServer process plays a "neural Hub" role in the running environment of Android. Most system services that can directly interact with the APK application run in this process, common examples include WindowManagerServer (Wms), ActivityManagerSystemService (AmS), and PackageManagerServer (PmS). These system services exist in the SystemServer process as a thread. The following describes all the service threads and their startup sequence.

The main () function of SystemServer first calls the init1 () function, which is a native function that initializes Dalvik virtual machines. After the function is executed, it calls the init2 () function at the Java end. This is why init2 () is not referenced in Java source code, and the main system services are in init2 () completed in the function.

The function first creates a ServerThread object, which is a thread and runs the thread directly, as shown in the following code:

Therefore, various service threads are started from inside the run () method of ServerThread.

Basically, each service has a corresponding Java class. From the coding standard perspective, the mode for starting these services can be categorized into three types, as shown in 9-3.

Figure 9-3 startup modes of different services

Mode 1 refers to constructing a service directly using constructor. Because most services correspond to one thread, a thread is created and runs automatically in the constructor.

Mode 2 means that the service class will provide a getInstance () method to obtain the service object. The advantage is that the system only contains one service object.

Mode 3 refers to execution starting from the main () function of the service class.

Regardless of the preceding mode, after a service object is created, you may also need to call the init () or systemReady () function of the service class to start the object, of course, these are all customized within the service class. To differentiate the preceding startup processes, a new method is used to describe the startup process. For example, if a service object is created in Mode 1 and init () is called to start the service, we use mode 1.2. If the constructor is started after it returns, no other call is required, that is, nothing is done. We use the 1.1 mode.

Table 9-2 lists all the services started in SystemServer and the startup modes of these services.

Table 9-2 List of startup services in SystemServer

Service Class Name

Role description

Startup Mode

EntropyService

Provide pseudo-random number

1.0

PowerManagerService

Power Management Service

1.2/3

ActivityManagerService

One of the core services, managing Activity

Custom

TelephonyRegistry

Register the call module event response through this service, such as restart, close, start, etc.

1.0

PackageManagerService

Package Management Service

3.3

AccountManagerService

Account management service refers to a contact account, not an account in Linux.

1.0

ContentService

ContentProvider service that provides cross-process data exchange

3.0

BatteryService

Battery Management Service

1.0

LightsService

Natural Light Intensity Sensor Service

1.0

VibratorService

Vibrator Service

1.0

AlarmManagerService

Timer Management Service, which provides timed Reminder Service

1.0

WindowManagerService

One of the most core services of Framework, responsible for Window Management

3.3

BluetoothService

Bluetooth service

1.0 +

DevicePolicyManagerService

Provides system-level settings and attributes

1.3

StatusBarManagerService

Status Bar Management Service

1.3

ClipboardService

System clipboard Service

1.0

InputMethodManagerService

Input Method Management Service

1.0

NetStatService

Network Status Service

1.0

NetworkManagementService

Network Management Service

NMS. create ()

ConnectivityService

Network Connection Management Service

2.3

ThrottleService

I am not clear about its role

1.3

(Continued table)

Service Class Name

Role description

Startup Mode

AccessibilityManagerService

The management program intercepts all user input and

Some input to the user for some additional feedback, to help the effect

1.0

MountService

Mount service. You can use this service to call the mount program at the Linux level.

1.0

Icationicationmanagerservice

Notification Bar management service, notification bar and form in Android

State columns, but the former is on the left and the latter is on the right.

1.3

DeviceStorageMonitorService

Disk Space status detection service

1.0

LocationManagerService

Geographic location service

1.3

SearchManagerService

Search Management Service

1.0

DropBoxManagerService

Use this service to access Dropbox programs at the Linux level

1.0

WallpaperManagerService

The wallpaper management service, unlike the desktop background,

In the View system, the wallpaper can be used as the background of any window.

1.3

Audioservice

Audio Management Service

1.0

Backupmanagerservice

System Backup Service

1.0

Appwidgetservice

Widget Service

1.3

Recognitionmanagerservice

Identity Recognition Service

1.3

Diskstatsservice

Disk Statistics Service

1.0

The Startup Mode of AmS is as follows:

Call the main () function and return a Context object, instead of the AmS service itself.

Call AmS. setSystemProcess ().

Call AmS. installProviders ().

Call systemReady (). After AmS executes systemReady (), it starts the systemReady () function of the associated service one after another to complete the overall initialization.

For details about the internal Startup Process of a service, refer to the source code. These processes are generally relatively simple.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.