Example of C program use for binder systems
Ipc:inter-process Communication, interprocess communication
Rpc:remote Procedure Call, remote procedure calls
Here we use only the BINDRT system that has been implemented in the Android system directly.
The specific source code is in the Frameworks\native\cmds\servicemanager\ directory.
Service_manager.c:
A. Binder_open
B. Binder_become_context_manager
C. Binder_loop (BS, Svcmgr_ handler);
C.1 res = IOCTL (BS->FD, Binder_write_read, &BWR);
C.2 Binder_parse
//parsing
//Processing : Svcmgr_handler
svc_mgr_get_ Service/svc_mgr_check_service: Get Service
Svc_mgr_add_service: Registration Services
//reply
Bctest.c
Procedures for registering a service:
A. Binder_open
B. Binder_call (BS, &msg, &reply, 0, Svc_mgr_add_service)
Name containing the service
It will contain the data of ServiceManager reply
0 = ServiceManager
Code: Indicates that you want to invoke the "AddService function" in ServiceManager
Procedure for getting a service:
A. Binder_open
B. Binder_call (BS, &msg, &reply, Target, Svc_mgr_check_service)
Name containing the service
It will contain the data of the ServiceManager reply, indicating the process of providing the service
0 = ServiceManager
Code: Indicates that you want to invoke the "GetService function" in ServiceManager
BINDER.C (packed C function)
Linux Embedded Learning-Remote procedure Call-binder system