 నరర్పంఠ్ కిర్నిస్చి పారినిలూన్ పఇతిశి కొతి నివరారారిస్పానిన్ నుదనండి సింటికికిసింది స్త్హేపి పరాసికి స్లికికొట్ ంపిస� మని tämäట౉వతార靈 మిసి నీజాన్వి సిసి � preliminary libraries సిసి. మనిసి స౿లి 對ోటిలై Kerry jlift shami. PU00 and నీట్ Titanbuilt Game for a time బిళ్రఀనా player Schmya మిఝరోల్ approved నిహోలైалలైలి. ఇంతిరారర్త్రం ఆరికింతాలూత్ ఆరిమ్త్మానో ఆండికిక్తెచెందివందియాద్ సాసితారిరడిందారికి స౗ిషానిటరిం౦ిందిందేత౏ందిన౉మానిక� నితకిసింమా బెంది నిసాభింద్దంపి మ౻తాది రిస్ని పిలెయాస్ప్త్లైముసి రెఎల్ని కారికి పి వాబిలోవాసిమి ఇదిలో కిందికి మానరిల్చ బార్ర్ర్గార్లు కార్టిమెన్ట్గాదారియియాన్చ్నింపాణ మిందార్ట్పిందియటార్ అథరిరోయికార్ప్టందిన్టిసిటార్లపనా ప్రర్వని పార� and next one is power management so that is mainly used for the mobile devices because our mobile devices have limited battery lifetime so we need to manage the power we try to use as much less power as possible next one is low memory killer so low memory killer basically what we do is sometime we start the many application in the mobile device so at one point will be reached when the memory your memory RAM will be full at that time you want to start some another process so what android will do it will check okay RAM is full now you you want to start the new process so for the new process android will automatically kill some other processes which are not used by user so that is our low memory killer so next one is a runtime walkthrough so the booting process of the android is the same as a linux bootloader will load the linux kernel and this linux kernel will initialize the environment for executing the c code once this is done android will kernel will mount the root file system and it will start the first user space process which is init process now once init process is started it will in a start the basic demons so few demons are like usb demons that is our connect connected with usb port then adb demon that is our android debug bridge demon so basically this android debug bridge demon will allow to communicate with your computer and debugger demon that is used for debugging purpose and last one is RILD demon that is a radio interface layer demon so this radio interface layer demon is connected with your mobile communication like you get SMS at that time this RILD we use if you are calling someone at that time this RILD demons will be used once this demon is started android will start the zygote process so this zygote what the zygote is zygote is the main part of the android so what it will do it will start the first delvik instant of the VM then it will links all core library and it will share between all the processes which is created by the zygote and it will use copion write mechanism so what is basically is thing when you are creating starting some new application like you pressed home button or maybe you press your contact button so at that time the request will be go to the zygote to open that contact that zygote once zygote will get the request it will start the contact process and it will share the library between zygote and the contact process so that's why he use the copion write so whenever contact will try to write anything which is the said between the zygote and the contact process at that time this copion write use will be used and separate copy will be created for that contact process so once this is the done zygote is done in it will start the runtime process of the android this runtime process will start the service manager so basically this service manager is a kind of a context manager for the binder so what what is the use of this service manager is to use that all our application which is providing some services which are service provider they all will register their services to service manager and now whenever you your application need to use some service like you want to use a location manager so you will contact the GPS location service provider at that time your application need to contact the service manager that I want I want to use the service of the GPS location so this service manager will return the binder object to the your application and then at that time your application will be able to communicate with the GPS location manager next one is one this is done then runtime will inform the zygote that now you can start the system server so for that zygote will start the new delvik vm instant and the system server code will be loaded and system server will be started so main purpose of the system server is to start the other application other application android application of the system so what we will do it will do it will first start the two native services which one is the audio flinger and the surface flinger that surface flinger is your screen that is screen of your device so like yeah whenever you are seeing the battery status your tower status or maybe your something else whichever is so on in your screen that is coming through the application which will contact the surface flinger the surface flinger will handle your screen now next one is audio flinger that audio flinger will connected with your speaker and your headphone part so whenever you boot your tablet you will listen sound that is the because of the audio flinger so if you are not starting audio flinger in at the boot time you will not able to listen it well this is done so surface flinger and audio flinger providing this type of the services like as I mentioned that surface flinger is providing a control of the screen and audio flinger is providing the control of the speaker so suppose you are writing an application for the media player okay so at that time your application will use the service provided by the audio flinger so as we can see here that both they have to register their services to the service manager so whenever you will write your application well like you are creating some new media player or yeah so at that time your application first will first will contact those service manager that I want to use the audio flinger service provided by audio flinger and that service manager will return the minor object and then at that time your application can only use the services was this is done so starting of native services is done it will start the other package men other manager which are used in the android like content manager window manager which is here related with your application window then activity manager which is used for a life cycle life cycle of the process then telephony service that is the telephony services as I mentioned that when you are calling someone or you are receiving call from someone at that time this telephony service will be used then bluetooth service that is bluetooth of the your devising package manager so basically package manager will know which are packages are installed for the particular application then connectivity service that is related with wi-fi and etc connection with the power manager that is used for managing power of your android device and then location manager that is providing location of your cell phone one this is that now your system is ready to run so what will happen when you are starting the home page so whenever you click a home button of your device so that new application request will be go to the zygote zygote what zygote will do it will create a copy its own memory layout so basically to make it faster zygote will instead of creating new memory layout for the application zygote will copy its own memory layout and it will see the common classes said between the home application and the zygote itself those common classes are linked with zygote and remaining classes are loaded in a home memory area so what this is done home application code will be loaded in the new delvik the new delvik instant and the new home process will be started so what this is done now suppose you are after opening home page you are opening a contact so same thing will happen new delvik instant VM will be created by the zygote and the process will be loaded so main point is that each and every application has their own address space their own delvik VM all those application will the share library through the zygote and those library are marked as a used copy on write now we will see the binder part so what are the inter process communication so two process trying to exchange the data like suppose maybe we can write in C language that code for the two process that both two process will use same file descriptor they are accessing the same file at the time with same file descriptor so they are mainly exchange the data with each other why we need IPC so as we have mentioned both to two different processes so if both processes are on different different address space if although both processes will run in same address space at that time we don't need to do the IPC mechanism the main reason is the behind the IPC mechanism is the because of its own address space then provide data isolation we are keeping some data isolated from other application we don't want to show the some data we want to only show the few data to the application another one is avoid direct interaction so obviously this is the main reason about the avoiding direct interaction like if you are putting two running two processes in same address space then there will be no data isolation will be there right that second process can access the any data of the process one so let's talk about the IPC mechanism in the Linux so first one is the signal so that is the just signal which is just some type of the interrupt to the given to the process so in that we cannot distribute differently means you need to create the as many signal as for each and everything like a wake-up signal you stop signal keep this iodix signal so all those are signal we need to create it and pipe that is our unidirectional community mechanism that is we can one process one go on to communicate with process two and process two with go on to communicate with process one so at that time they are co if you are there community communicating with pipe then we need to create two pipe first one is to write process one to process two data and the second one is the process two to process one then socket that socket is a bidirectional communication so in that process can listen from that particular socket and he can process can also write that data to that socket that same of four that is our said said variable between two different processes and message you that is one process will write two pointers are defined first one is a write pointer and second one is read pointer so writing process will write the data in the message you and it will update the write pointer and reading process will the read data from the message you and it will the read the data from the message you the third one is a said memory so said memory in the Linux how need two different processes are sharing the memory is the by their page table entry so two different process have their page table each every in that page table some physical frame are mapped so on the same physical frame is there their page table entry is pointing to the same physical frame and that's why they are sharing the memory now we are those old this these are old old mechanism and Android has introduced a new mechanism that is the binder that is the lightweight remote procedure code so what was the problem with the old mechanism where first one is the processes are separate and security hold so security hold in the same like as I mentioned if you are sharing the memory area so how sharing will be done sharing will be done at the process level it is not done at the kernel level because the sharing part there will be done through the page table entry so if it is possible that third process can have same page table will get the same page table entry and he is able to process can able to the access that said a said physical memory area so those are the problem with the old IPC mechanism now next one we have provided the solution so what can be possible the solution is let's move the shared IPC mechanism to the driver level it means we will provide the driver in the kernel part for the IPC mechanism we will use the shared memory here is the shared memory is different than the Linux shared memory because the in the Linux shared memory will done at the process level and in this thing shared memory will be done at the kernel level so kernel will be will handle this shared memory so we will see example one of example for the shared memory then per process thread pool so what different is application provider which is the providing some services those provider has some pool of the thread so each and every thread will be will be handled by the particular the client so each and every client has a one thread so whenever the client request will come client one request will come thread one will be handle and the client two request will become thread two will handle it that that request so each and every client has a particular thread then synchronization so synchronization in the sense like as I mentioned first client will communicate then service provider will communicate it so synchronization problem it may be happen in the old mechanism which is in the socket mechanism because socket is the bidirectional inter-process communication so it may be possible that when server client is writing something and the server can send the data at that time also so that avoid that we have provided synchronization here next one is like let see the binder with the service manager so how the binder how the client will able to access the service by provided the service provider so what will happen when service provided so service provider will start it will first register its services to the service manager for registering service registering service to the service manager add service function will be then in the service manager package so that function will be used and the service will be registered to service manager now service user want to use that service so each and every binder has its own address and its token number so service user don't know that binder address and that token number so what it will do it will contact to the service manager this service manager will contact okay that particular client want to the particular service so it will contact the binder driver so basic work of the binder driver is to create a memory shared memory for the state service provider and the service user so binder will binder driver will create that shared memory and it will return the information to the service manager and those old information like a binder address binder token number all those thing and shared memory area will return to the service user and now service user has binder of the service provider so he can communicate with the service provider next one is like as I mentioned now my process service user has its binder address and everything so now they will communicate through the binder so what you how to how it's working like process a will write something in a common common shared area so binder will not even notify it and when writing is done binder will send notification to the process B and the process B will read it from the that shared memory area so this is the how binder transaction will work so let's see the limitation of the binder so what when communication communication will happen between two processes what is exactly happening like process one one will send the data to the process two okay so what will happen process one will send the data to the binder binder will do the parceling of the data it will create the parcel of the data and that that parcel will go to the process B process two and that process two will unparsal it and read it the data so if your data is very large so that time will be consumed for the creating the parcel and then again time will be spent to unparsal that data so main limitation of the binder is to it is not ideal for transferring the large data between the two two processes so because the because of that the communication time will be increased while creating the parcel and while creating the parcel now next one is the layer interaction so we will see that we will we all of you know that Android has a four different layer those are application layer second one is application framework layer and library layer and the last one is the Linux kernel so how the those layer will interact with each and every layer we and how they will get the services from the kernel layer so first one is your application will contact the runtime service application and that service will directly contact to the library and that library will contact to the Linux kernel another way is to do is your application will contact to the runtime service this runtime service will contact to the native service and a that native service will contact through the library third one is application it will contact with the runtime service and it will contact with with the dating view and then it will contact with the library so, which type of the layer interaction will happen, it is a depend on the type of the application and the type of the negative library, so, let us see how the layer interaction will happen, so for the layer interaction we need, so, what we are doing is basically we are using నును నినిిండికండి.పునుచిండి.icial . so for that our application are written in the java which will try to communicate with the code written in the c or c++ for that we need the interface that is our java native interface which will the gateway for bridge between application layer and the library because our libraries are written in c or c++ so your java code will contact through a library through a j and i so first one is the try to contact you through the runtime service so what will happen so first one is your application which is running in your application layer so it will use the binder IPC and it will get the services provided by runtime service so basically this runtime service is your manager started by the system server it can be a window manager or maybe activity manager or package manager anything so that as runtime service which is running in the application framework layer it will use the j and i and it will contact through a native service binding so that is our library and this library dynamically load the hla library so this hla library is hardware abstraction layer library which is provided specially to communicate with the linux driver so hla will provide some sort of the library like audio library your radio interface library so those library are presented in hla layer and that hla this library will contact to the kernel driver so let us see an example suppose your application want to find the location of your cell phone so what will happen your application will contact to the service manager and it will ask for the service provided by the location manager so here is your runtime service which is your location manager so your application will get the binder from the service manager and it will use that binder to the contact to the location manager now that location manager will use the GPS location provider that is our java written code so what we will do is we will contact the already written code in the c or c++ that is our GPS location provided that is our library through j and i so it will contact to the libraries through j and i this library will load the gprs library which is provided in hardware abstraction layer so dynamically load it it will contact to the kernel driver and the process response will be written to the application so this way layer interaction will happen when you are getting the using the location manager so next one is the doing the native service so what will happen it may be possible sometime you use the native services so like native services are those services specially made for the android like as we see during the boot process that audio flinger and surface flinger two are native services so what will happen application will contact to the runtime services and this runtime service will contact to the native service binding through j and i and it will use the binder IPC so different between the previous layer interaction this one is that binder will take place here instead of here because in previous when you are using runtime services only at that time binder is taking interaction between application and application framework in this case binder will taking here between the native service binding code and the native services this service again will load the hla library and the hla library will contact the kernel driver so let's see the example so here is the example of the media player suppose your application is somehow using media player so what will happen so your application will contact to the media player and that media player will contact to the already built in library written in c or c++ code through j and i so this media player will contact to the audio flinger because audio flinger only will have only will able to handle the speaker part so that it will contact through a binder audio flinger will dynamically load leave audio and hardware library and it will contact to the kernel driver so this way layer interaction will happen during the native servicing now if you are using a native depot how layer interaction will happen so basically what is the different between native service and native depot is that native services are introduced by introduced by android itself and the native depot so those are depots which are taken from the linux itself so those are depots are taken from the linux which are using the socket to get any request so this is the majorly difference that native service will we can communicate to the native service only through a binder and we can communicate to the native depot through a socket so what will happen your application will contact to the runtime service that runtime service will contact to the native service binding through j and i this j and i will send a request to the particular socket which is related to particular depot that depot will load the hli library and that hli library will contact to the kernel yeah this is also so let us see the example of the native depot like if your application is using a telephony manager like your application sending some sms to some other mobile so what can happen application will contact the telephony manager it will contact the telephony manager library telephony manager library will send the request to particular socket for rild that is our radio interface layer depot and this depot will dynamically load the rl library and it will contact the kernel driver so that is why native depots will be used and when we are using the native depots socket will be used instead of the binder so let me zoom it so this is the all over architecture so here we can see is the first layer is your application layer so it is containing a stoke android application which are your application like bluetooth service browser which is coming by default in your mobile or in your android device and here is can be your application or market app so those app will the application api they will communicate to the system server or may be application provided at the application framework so at that time binder will come and that this application application framework layer will interact with the library layer this one is our library layer through a jni part application framework will always contact to the library through jni only and that jni will contact to the Linux kernel so that is it this is our normal layer interaction between among the layer