Android system service detailed

Source: Internet
Author: User

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

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.