Android has 3 broad categories of service, which are in different frame layers of the Android system, as explained below:
1 service in the Init.rc
Keyword "service" name binary executable program path
Service Servicemanager/system/bin/servicemanager
Class Core
User System
Group system
Critical
Onrestart Restart HEALTHD
Onrestart Restart Zygote
Onrestart Restart Media
Onrestart Restartsurfaceflinger
Onrestart Restart DRM
In fact, this kind of service is to define the start of the program, the type of service object is a can be executed binary program. Define it as a service to better describe the properties of the binary run, such as running a user, a group, starting once (oneshot), or starting again (after the program dies). More importantly, it can also describe the relationships between programs. For example Onrestart Restart DRM, this description means that when the DRM program restarts, the program also actively reboot.
You can also dynamically start or shut down a service by using the following command, with root permissions
Property_set ("Ctl.start", "ServiceManager");p roperty_set ("Ctl.stop", "ServiceManager");
adb shell SetProp ctl.start servicemanager;adb Shell SetProp ctl.stop ServiceManager
2 system-level service
Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/
This kind of service is very close to what we normally understand, that is, the services provided in the system that define the service interface through which other modules can use the service. The execution body of such a service can be either binary or Java code. Like what:
C + + type of service:
Surfaceflinger,cameramanagerservice, Mediaplayerservice
Java-type service:
Activitymanagerservice,windowmanagerservice,networkmanagerservice
The implementation mechanism is that the service registers its services with the ServiceManager mentioned above, and other modules get the interface of the service from the ServiceManager by name. The shell uses the command "service list" to list all of the service types in the system.
C + + type service-related interfaces:
sp<iservicemanager> sm = Defaultservicemanager ();
Sm.addservice (name, XX)/sm.getservice (name)
Java type Service-related interfaces:
Servicemanager.getservice (name)/addservice (NAME,XX)
3 service for the SDK layer
Unlike the previous two types of service, they are a generic term for a class of objects, and the service is a very specific Java class Android.app.Service.java that developers often contact. It is used by the Android SDK to be exposed to third party applications. It is equivalent to activity and is one of the four major Android components (Activity,service, Provider, Broadcastreceiver).
Summarize:
First class service: System Integration Engineer is responsible for
The second type of Service:framework system engineer is responsible for
Category III Service: Daily intimate contact with Android app developers
Author: csdn Blog Itleaks