Android uses the binder mechanism to implement IPC, Binder communication is achieved with the help of Linux binder driver, two interprocess IPC feel like a process to enter another process to execute code, and locally can return the result of the remote function. Binder user space maintains an available thread pool for each process, the thread pool is used to process incoming call requests, including the requested message, and the remote response message.
Binder Communication in Android is based on service and client architecture, and all processes that require ibinder communication must create a IBinder interface with a system Service Manager, a special server, Android It automatically gets up when initialized and provides services to other application servers, including adding a service, querying for a service, and so on.
So for our camera system, we have the following four concepts,
1 System Service Manager Service_manager
2 Camera Server Cameraservice
3 Camera client Camera app.
4 Binder Drive Nuclear Binder Driver
The approximate process is summarized as follows:
When the Android system initializes and runs system Service Manager, the system Service Manager waits and responds to the registration request of the camera application server, so that the camera application server will tell the system server that it can provide camera application services, while the system Service Manager simultaneously binder Driver to generate a binder number
Camera application gets the Camera service handle, which is the Biner number, with this binder, the system can correspond to the Camera service through a mechanism. The camera application uses this binder to invoke the function provided by the camera service (that is, the service), through the IPC operation, corresponding to the camera server-side corresponding function, such as connect (), at which point the camera application will hang, The camera service will be awakened to execute this service connect (), after the camera server execution completes, the feedback results to the camera application, the camera application is then awakened and continues to execute. Like the camera application call Connect () is done locally.
The above process can be divided into the following processes to understand,
First, the system Service Manager Service_manager started. Register a special node 0 in the binder Drive core and wait for other services to register and query.
Second, Camera server registration/Add to the System Services Manager, a binder number (x) is generated in the system Service Manager Service_manager to camera server.
Third, the camera client obtains a camera service proxy to the system Service Manager Service_manager. The system server returns the generated binder number (x) to the camera client and converts it to the Icameraservice object.
Four, camera the client through the Icameraservice interface function [such as connect ()] calls, midway through the IPC operation, called to the camera server Cameraservice::connect (), and feedback the results to the camera client,
Follow-up will be based on the above process to analyze