The following articlesArticleIs a more in-depth analysis of the binder mechanism.
Directory
1.Android-Binder Mechanism-servicemanager
2. Android-Binder Mechanism-General Service Registration
3. Android-Binder Mechanism-get common service
4. Android-Binder Mechanism-interaction between client and common service
5. Android-Binder Mechanism-binder framework Summary
6. Android-Binder Mechanism-processstate and ipcthreadstate
7. Android-Binder Mechanism-driver
Android-Binder Mechanism-interaction between client and common service UML and description
The structure is basically the same as that in the previous two articles. Only a few special points are described:
1. The camera client executes startpreview () through bpcamera;
2. icamera defines the camera operation interface, which is an abstract class and bpcamera is the implementation of the client;
3. cameraservice: the client is the server. Each camera client corresponds to a cameraservice: client;
4. Implementation of icamera on the bncamera server;
5. bbinder has never been seen before. It implements ibinder on the server. The main interface is ontransact ();
6. In this figure, bpbinder and bbinder correspond to a group of processstate and ipcthreadstate, because they exist in each binder process, whether it is a client or a server;
Interaction Process
1. The startpreview () of camera calls the startpreview () of bpcamera ();
2. bpcamera executes remote ()-> transact (start_preview, Data, & reply), while remote () is bpbinder;
3. The mhandle in bpbinder is the handle index of cameraservice: client;
4. The camera process's ipcthreadstate transact forwarding request;
5. The server ipcthreadstate receives the above request through talkwithdriver. Of course, mhandle plays a very important role;
6. The ontransact of bbinder and ontransact and bncamera are executed in sequence;
7. The ontransact of bncamera calls the startpreview () function, which is the startpreview () function of cameraservice: client ();
8. return values are returned in the opposite path;