The application layer binder Learning

1 Binder Introduction
for security and stability considerations, Android does not allow direct access between applications, only indirectly communicate via socket, pipes, shared memory and other ways. Binder inter-process communication mechanism is unique to Android, its essence is to implement shared memory between processes through a driver layer to achieve.
Access between processes does not mean a simple function call, such as SystemUI source file which can import the package name lock screen, lock screen and then call the project directory interface, this is not the way communication between two processes, but rather simply complete SystemUI function during compilation write, essence or run a program in SystemUI inside. Communication between two processes were running means to access each other's resources, so that, in the process A real-time access to data in order to process B of (these data in real time with the use of dynamic refresh process B). To accomplish this operation, the process can be designed for A- B,> B of communication open up a sub-thread to make the call interface. Because, in a process, a plurality of sub-thread can be shared data resources. Essentially, Binder communication is to do so. Each time the client requests the server to communicate binder, will end service in the process of opening up a binder child thread for this request. The system is set up, binder for each sub-thread server process running at the same time up to 16. When exceptional circumstances, binder call abnormal, leading to sub-thread can not end binder, binder while a large number of calls occur when more than 16, will result in the service process directly Caton ANR. If this happens in the service process is a system process system_server, it will cause the entire system Caton even phone restart, ANR various application modules appear. Since ActivityManagerService / PowerManagerService / PackageManagerService and other system services are running system_server process, and the application layer app frequent calls to these services, so the process appears system_server 16 binder is filled widespread phenomenon occurs. From this analysis can be performed when analyzing stability problems.

2Binder manifestation
2.1 Binder implemented in two ways
in fact, is a server-side binder object implemented in two ways:
2.1.1 implemented by AIDL
to the status bar management services, for example, the server usually follows:
StatusBarManagerService the extends IStatusBarService.Stub {

Guess you like

Origin blog.csdn.net/qq_42894864/article/details/104075614