13 ServiceManager for Binder communication

ServiceManager for Binder Communication

I. Introduction

There are many services in the Android system. When an application calls the function of a certain service in the system, it often sends a request to the system to call the external interface of the service. This external interface is usually called a proxy interface, that is to say, to get the target The service needs to get the proxy of the target service first. At this time, if each application client side directly obtains the proxy object from the service side, it will inevitably cost a lot. Therefore, in the Android system, a serviceManager system service is introduced, which can also be called a Binder daemon process to manage these service objects.

The four elements of Binder: Client, Server, ServiceManager, Binder driver

The work of ServiceManager: register services, query services, list all services, start an infinite loop to analyze the read and write started by Binder.

2. When does ServiceManager start?

When the init process starts, load servicemanager.rc and start servicemanager:

insert image description here

ServiceManager.rc: /frameworks/native/cmds/servicemanager/servicemanager.rc


service servicemanager /system

Guess you like

Origin blog.csdn.net/Johnny2004/article/details/130857712