This article is based on the source code Scenario Analysis of the Android system, by Luo shengyang
I. Architecture code:
~ /Android/frameworks/base/core/java/android/OS
---- IInterface. java (Interface)
---- IServiceManager. java (IServiceManager)
---- IBinder. java (IBinder)
---- Binder. java (BinderProxy, Binder)
---- ServiceManagerNative. java (ServiceManagerProxy, ServiceManagerNative)
---- ServiceManag
In this article, we will thoroughly analyze servicemanager, the service administrator of the Android system.
Servicemanager is the manager of Android system services. All processes that need to communicate with each other through the Binder Mechanism must first obtain the proxy object of the Service Manager for binder communication. For example, the system contains the audioflingerservice for audio mixing,
prepare bullets before you leave .We know that the process, the virtual address is different, is not directly communication, this is a protection mechanism. Open Task Manager and look at the N-ary process, just imagine what happens if these processes communicate directly?And the user space can communicate with the kernel space through system calls, if there is a module in kernel space, can complete the data forwarding, then is not two processes can communicate? Such as:The above mentioned some u
Either the client or the server, the head must first be calledSP What did Defaultservicemanager () do, and what instance did it return?The function is defined in the frameworks/native/libs/binder/iservicemanager.cpp:33SpDefaultservicemanager () {if(Gdefaultservicemanager! = NULL)returnGdefaultservicemanager; {Automutex _l (gdefaultservicemanagerlock); while(Gdefaultservicemanager = =NULL) {Gdefaultservicemanager= interface_cast(Processstate::s
PrefaceIn the ServiceManager of Binder source analysis, we introduce the process of using binder to communicate, that is, after ServiceManager registers itself as "administrator", it is responsible for the add operation of other service, or other client's get operations. In this process, there are some interfaces we do not have in-depth analysis, such as:
1. Open Binde
As an IPC communication mechanism, the binder mechanism plays a very important role in the Android system, so I also spent some time to study it, according to my understanding, I will from 4 aspects of the binder, if there is a wrong place, but also hope that we can advise. The following examples will be in mediaserver terms.First, ServiceManagerServiceManager in the bi
First, prefaceIn the previous blog Android IPC mechanism (ii): Aidl's basic usage, the author describes a major way of communication between Android processes. Use Aidl for communication. The basic usage of aidl is also introduced.In fact, the Aidl method uses binders for cross-process communication. Binder is a way of communicating across processes in Android. The underlying implementation principle is more complex. Limited to the author level, can n
Analysis of Android aidl Binder framework, aidlbinderReprinted please indicate the source: http://blog.csdn.net/lmj623565791/article/details/38461079, this article from [Zhang Hongyang's blog]1. Overview
What can Binder do? Binder provides global services that can be accessed by any program in the system. Of course, this function should be provided by any system.
Scene:1) IMediaPlayer.cppBp, BnSpInterface_castReply->writeint32 (Setvideosurfacetexture (bufferproducer));Use in Mediaplayerservicesp2) Pass the BP object in the Mediaplayerservice process to another process using theVirtual status_t Connect (const sp{Parcel data, reply;Data.writeinterfacetoken (Iremotedisplay::getinterfacedescriptor ());Data.writestrongbinder (Iinterface::asbinder (bufferproduce));Data.writestrongbinder (Iinterface::asbinder (sinkclient));Remote ()->transact (CONNECT, data, re
When more than one client makes a request to the server, it creates multithreading to process the request if the server is not busy.Then who's going to judge?The server process has a BINDER_PROC structure with a todo list (with the data sent by the client) and wakes up the thread waiting on the binder_proc.wait, and if the threads wait on wait, the surface server process is busy. If the wait is over, the surface server is too busy, and the driver will give feedback to the application(1) drive to
Some time ago have been looking at the knowledge of binder, recently just have time, summed up some knowledge, hope and everyone exchange study.Speaking of Binder I believe that you learn more and more about the development of Android, the binder mechanism as a mechanism of communication between Android, the application of the Android bottom is very much. We all
Binder: Pins, paper clips. In life, we use a paper clip to "do not" with two sheets. In Android, Binder is used for interprocess communication, and two processes are "not" together.Binder is an architecture with 3 modules (server-side interface, Binder driver, customer-service interface), such as:The binder server, in
Either the client or the server, the head must first be calledSP What did Defaultservicemanager () do, and what instance did it return?The function is defined in the frameworks/native/libs/binder/iservicemanager.cpp:33SpKey steps can be broken down into several steps: 1, Processstate::self (), 2, Processstate::getcontextobject (...), 3, interface_cast1 processstate::self ()Frameworks/native/libs/binder/proc
Thinking analysis, is the following process:How did the ServiceManager start?According to our previous blog ideas, we have a servicemanager agent on the systemserver side, Then the Android system should provide inheritance like AMS or indirectly inherit from Java layer Binder and then rewrite the Ontransact method to handle the request. However, ServiceManager does not use a complex binder class structure
Essentials of Android Binder driver's Working Mechanism
Recently, I have read many books, articles, and Android source code for Android Kernel Analysis. I feel that I have a thorough understanding of the working mechanism of Android Binder.
However, it takes a lot of time and effort to achieve this. For most people, I am afraid it will not be as easy as I am to spend so much money to understand this. There
First, create a custom model binder:The process of modeling a model object with request data and passing an object to an action parameter is called model binding.Most of the time the action parameter is the primary key or other unique identifier of the object, so we do not have to place a duplicate data access code in all the actions (the "\\Before" section of the code below), but instead use a custom model binder (the "\\After" section of the code be
First, create a custom model binder:The process of modeling a model object with request data and passing an object to an action parameter is called model binding.Most of the time the action parameter is the primary key or other unique identifier of the object, so we do not have to place a duplicate data access code in all the actions (the "\\Before" section of the code below), but instead use a custom model binder (the "\\After" section of the code be
Objective
Interlacing as Foster, the same sentence applies at any time, the same professional, deep down, the difference is also huge. Today, talk about how you learn about the mechanics of binder interprocess communication. At first, it was only known that Binder was a very low-level thing, and it was not even clear what was being used.
There are two main ways of doing this:
Read the
Service Manager is one of the core components of binder interprocess communication:It plays the role of binder between the interprocess communication context ManagerResponsible for managing service components in the systemProviding services to the client component to obtain proxy objectsFirst, Service manager start-up1, ServiceManager is initiated by Init, startup script in System/core/rootdir/init.rc.Servi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.