 All right, so just to just to make sure I'm I'm in sync Who is here at the talk? Yes. I'm my talk yesterday A good chunk. Okay, so I'll expense I'll expend the some of the basics as fast as possible. All right, so In case you don't remember this from yesterday Or at least books on embedded Linux and embedded Android and the purpose of the slide is to say that I don't know everything And in otherwise in other words, it's an invitation for you guys to please jump in and actually add stuff As I'm moving if you have something to say Somebody came up to me after my talk yesterday and said you lied I said why is that well? He said you said you're gonna slow down after a bit and you didn't slow down, so I Will try doing this sorry no funnies today. Okay, I I don't have any funny things in my slides, but what I'll try to do here in the next hour or so Since it's actually after lunch, right? So hopefully you've got a good dose of intravenous caffeine somewhere I'm gonna try to walk you through the different ways in which you can run Code in the Android stack and it's a pretty big stack. So there's a lot of things that you can do I am sure some of you will be familiar with some of the stuff And I'm hoping that on average by the end of the session There is a lot of stuff that you will not have known about that at least introduce you to okay I'm very easy going about these things So if you have any questions and you want to interrupt or whatever please feel free to do so We'll pick it up from from there and and move from that Okay, so the basics I showed this yesterday. I don't want to spend too much time on it There's some specific kind of hardware for which Andrew's designed the whole system the Jeep What's in the SOC and that's the stack that you've got and I'm gonna spend a little bit more time on this one today Because I think it's it's important because that's the whole point of my conversation is Where can you run code in this thing? All right? And you can literally run code almost anywhere here Okay, the question of the question then becomes What's what are the hooks? What can I do? with you know my Code if I run it as a native daemon as a system service What are the benefits and trade-offs of every one of those layers? You know and and how does it connect to the next layer up or underneath it? Okay? Yes, is that a question? No, okay, I'm sorry How so on okay? What can you program in an Android? Well if you've got control over The platform you can use anything that you can dream of all right Basically the out of the box The stack will allow you to run Java and see all right both at the app level and at the platform level So if I go back to my architecture diagram from two slides over both in the orange ish yellow ish and obviously not the gray stuff for see if for Java, but you know both in the App layer and in the system services you can have either Java or C That's not a problem Some people want to try to write their applications as a Jax or you know JavaScript CSS and stuff like that and there are frameworks that actually Facilitate this okay, so you can create an app that has a Webkit object and then you can put everything in there if you wanted to all right there are Frameworks such as the titanium app accelerator. There's phone gap. There's probably a couple other ones out there and what they kind of Promise you is that if you write your application in that framework it will work regardless of You know the device that you're running it on okay, so for example titanium app accelerator allows you to write your your app in a Jax and then it will compile native applications for iPhone and Android so if you're in the application if you're looking at from an application perspective That could be something that's interesting to you what I've heard is feedback from At least even if you kind of Google around you'll find that is people will tell you that the field the look and feel of the application that's generated is not quite the same thing as if you really read it into the The native kind of language that the system has all right If you want to use C sharp all right our friends over at Mono who actually now have a company called Zimion They actually no actually not He's looking at me where the Marin Zimion was the whole thing that got by not well, thank you Jake That's like that's with the luxe right Yeah, I'm sorry I've been around too long So as a Marin is the name of the company today They have a framework for actually running C sharp code both on my phone and Android. Okay So if that's your thing then go ahead and do that Obviously the fact that you have control over the framework means that you can compile whatever you want It could be pearl Python anything that you have and you can run that in the stack Okay, you can just shove it in there as an even a static link binary and have the interpreter run from there. Okay Standard application mechanisms. Okay, so that's essentially you're at the top of the stack completely over the API That's provided to app developers. What can and can you not do? Okay, so the basic components? activities Content providers Services and so on that's standard stuff I'm not gonna waste too much of your time on this because some of this is gonna be basic for some of you guys and If nothing else there's a lot of documentation on it, but just kind of give you a very rapid rundown of the mechanisms you have That are available to app developers. So apps are made of components. There isn't a single entry point There are several components inside an application each one of them can be activated independently of one another So app developer have to you know, create their things with that in mind. There are four types of components One is a visual which is activity services are kind of like background things content providers or databases and broadcast receivers They're kind of a very high-level interrupt handlers like him batteries low USBs been plugged in that kind of stuff Okay, so you deal with those things you create an app like that and the components will get activated based on rules Which are spelled out and what's called a manifest file gets done a second the way those components activate each other Is with a mechanism called an intent and tents are actually passive objects is what you do with that object I will activate a component the intense will get resolved by some of the system services namely the activity manager or the package manager I am talking fast because that part's supposed to be basic The components can be stopped and restarted the whole framework is made so that applications can get Essentially stop on the tracks and then restart later The whole goal is what is that the user can start as many apps as he wants and if he gets bored He can continue doing that without having to go back and manually shut them off They will die off naturally if they're not being used for a long time This is the life cycle of what's called an activity So it starts off on this blue the blue thing up there And then it gets an on create and if you Google around for app examples You'll see a lot of those on create and eventually it's running and then if it's no longer in the foreground it gets a pop or whatever there's going to be a on pause and You know it goes from there You specify an application using what's called a manifest file, which is an XML file Which where you have to spell out all of the components that you have statically There's only the broadcast receiver that you can actually create at runtime Everything runs in a single Linux process Single threads unless you do something special and by way of special I mean something like using Java threads or Creating a service that provides a remote interface or have a content provider that is callable remotely in those two cases The call these side runs on a thread pool So there's no need for you to start threads, but there are threads going to be involved in the running of that Okay, all remote procedure calls are done through binder Which is the core mechanism a communication mechanism that you have in Android? It's used between system services and between applications and system services Okay, so what are the constraints that come with the fact that you have this kind of environment? first of all There's this component lifecycle which makes it so that when you run an application your application could randomly be Shutdown because the system as Predicate is low memory And therefore if the there's too many too much stuff running at some point it will go around say well That's not been used for a long time. Let's just shut this down Right, and if you have some critical piece of code that you want to have all the time, that's a problem okay the other inherent thing with This is that and I don't have a slide for this on right here But it you're straight jacketed into the security model that Android has which means that your application cannot access dev foobar Okay, your application can only do rpc through binder and get access to whatever is on the other side That doesn't mean that you can't tweak the permissions or grant your application specific permissions to access a certain device Device entry and slash dev, but that's not what happens by default Okay The other thing So one of the tricks that yeah, so what are the tricks that's pulled off with regards to? Applications that are stopped and restarted Is in the framework there's at least two applications that kind of circumvent that mechanism of life cycle and the way they do that Is they create what's called a persistent application all right The very good example a very good example of that is the phone application Okay, the phone application houses the phone system service And if you're familiar a little bit with the framework, you know that typically system services are not part of apps Okay, simply because they can get stopped and restarted so you don't have a control of that So what they do is they actually use the application component and let me actually show you that so Let me go here Nope Apologies or not to those of you who use vi. So if I go to packages apps Phone this is the manifest file for the phone application. All right, and One of the key things this has is this Android persistent equals true. What does that mean? Well, let me actually show you so Lunch Let's get this guy running by the way. I'm not very good on time here But when's the next presentation starting? No, the next presentation not the well this guy's starting up Three clock. Okay, cool. Alrighty. So this guy's starting up and let me actually turn that into a different schema Maybe shell come on you can do better than that ps All right starting up All right. Okay. Here we go. So ps you can see here. There's an application called calm Android phones somewhere up here Pid number 394. Is that right 394? All right. So let me show you one thing So there is say for example the calendar calendar is 642 if I do six kill tix 42 642 is gone. All right, and There's no calendar anymore So far so good take the phone guy and kill the phone guy off 394 PS the phone back phone guy is back. All right, and he's going to keep coming back Forever and ever and ever no actually that would be nice to do something like that And here it is. Okay. That's the that's that's the fact that the application is persistent now the obvious thing For those of you who are familiar with the app development API. The obvious question is okay. Well What actually is getting started, you know, because the Application is getting back up But usually what happens is for an application to start you have to send an intent and starts an activity starts a content provider Starts a service. What exactly is running right when it's resurrected. Well, that's the application Component that you see here. Okay. There's an application component that usually app developers won't use But these key applications do use them and that application Component gets kicked up or started a kick top or started whenever The thing is resurrected and in the case of the phone application this application thing is used to actually register system service Okay, so this is one way of actually housing system services So if you want to extend the framework and add your system services, I'll show you later One way to do it is encompass it inside an application and have it mark just persistent and use this application thing Yes, sir Awesome question. So can I actually publish a application on the app store that uses persistent equals true and the answer is no you can't You can only use this if you are actually part of the AOSP buildings part of the ASP. All right Do they have to have a specific user know they don't but usually in the case of at least the Phone application it does so in the case of the phone application if you go for the manifest file you go to the top It has something like Shared user is phone so on and the only reason this one has this is because there's an entry slash dev that needs to access And and that is is I think it's radio This ID is the radio user and so the phone application runs as radio and then there's an entry entries in slash dev Which belong to radio? Hmm In as far as I understand it the persistency of the application is not tied to the user It is tied to the actual Builds as part of the ASP and starting as part of the system applications All right widgets The clock that you see in this plenty of the widgets you can have those they're actually started after the launcher starts There's plenty of documentation for that online So if you need to write a widget this have a look at the documentation that's up there There are some special mechanisms that you can use that aren't you know Commonly used all the time, but there are they are interesting still so for example if you want to write a standard application for a phone That is persistent right the only way to do that is to use what's called foreground notifications foreground services So the way you do that is you have to post an icon on the status bar that says that your app is running Okay, so for example here I have a vast which is the nivirus thing and it shows up as an icon on the right hand top left hand side Okay, if you've got Skype running It will also show up as an icon there and the only way these apps can do that I'm sorry the only way these apps can run in the background is by posting that icon if that icon's gone The things shut down Okay, so that's one way to do it The persistent thing I kind of showed you There's something called sync adapters. So if you have a If you've ever installed like a Twitter application or something or or g plus all right that kind of connects to back end To sync events. This is what the mechanism that's being used Essentially register sync adapter and every so often that sync adapters kind of launched by the system And it connects over to some back end and checks if there's new data And then puts that in a database and it gets updated in the in the UI backup agents So there's you can actually have Your app back its data up into Google's cloud It is safe and secure up there so It's being outsourced to some third-party So That's a mechanism that's available to have developers input methods if you want to create your own virtual Keyboard there's documentation how to do that So sometimes it's just a formal language, but sometimes you actually want to have controls which are specific to whatever device we're creating, right? So you can have input methods and there are examples of that out there alarm services If you will get want to get woken up after a certain amount of time or a specific time and date You can use that as you can see I'm kind of like pointing you URLs here because a lot of the stuff is already out there So I'm you know I'm gonna stick to the things which aren't to Document it in terms of the slides if you want to have a live wallpaper of that too is documented out there account managers so Whenever you go into settings and you go add account and then there's like oh well You've got this application installed and you can add account for it There's a mechanism that ties those two things together and there's sample code out there on the developer website on how to actually do that device administration so if you want to You know when you the bring your own device kind of thing, right? Some enterprises want to control the strength of your password or the number of times if you're not wrong wipes the Device away and that kind of stuff. So there's an API for that There's a flag called core app that you will find in some applications and some NFS files in the AOSP To be quite frank with you. I'm not sure exactly what this does But you've got an only core flag in system server dot Java that is by default set to To to false so therefore You know they don't just run the core applications But the core applications will be something like it's as it says here, you know status bar settings and you know some packages But you know most of them aren't marked as core application If you need to start applications, how do you do that? You usually use intense and if you need to communicate with a specific content resolver You use a content provider use a content resolver that will automatically start applications Remotely, okay Let's say you want to start you want to create your own native utilities and daemons So this starts to get more interesting Essentially if you're not too familiar with the build system What's important is what kind of build? Targets are you going to generate so in this case if you use if you generate something that? Uses build executable then it will actually generate a command line Utility so if I go for example to The sources here and let me go for say frameworks native commands service So service is the command I was using yesterday to show you the list of services So I'm actually going to do refresh here if I do service list it lists all the system services This is a native binary and if you look at the Android MK here essentially ends up with this build executable Which means just build a binary, okay? And I'm giving it the sources and so on and so forth and if you look at the sources of this So the sources of a native Binary such as this one They're you know almost typically the same thing as a you know standard Unix Application right main and then you do from main whatever it is that you're expecting to do to have this thing do right? Nothing really special about this Okay, obviously the question is where can I start this from when I have a native application like that? You can use the shell you can have it in a in an RC file So for example, let me show you the service manager remember If you go back in my diagrams I said that for a system service to be recognized as a system service it has to be Seen or registered with the service manager the service manager here is actually command line utility So if I go back to the same location I was underneath service their service manager And if I open the service manager up, it's got a main entry point Somewhere in here Okay, and it goes from there. All right But you don't actually start this one off the command line yourself instead of what you do is if I go into system core Root Dear and this is what I want the internet RC file So the init RC file is the file that is parsed by the init process and I'll come back to this In more detail a little bit later. I will find the service manager here Okay, so that's being started at startup automatically Right, so if you have a native tool that you need to run you can just go ahead And have it also run by the init RC file going back to my slide here Okay You can also have shell scripts and I'll show you a slide about that and you can also have And it's kind of a little bit weird But you can do that you can have an application start a command line utility and I'll show you snippet of code That actually does that So you can get you can actually write an application that you can put on the market that does log cat So you just put it in the market name and it issues log cat on the command line retrieves it off the device Okay, so though the I showed you two examples I showed you an example where it's a command line utility I tap the command does the result and I showed you the one which is actually Damon Okay, running in the background doing stuff both of them are possible as native executables To start from an Android app here's actually the slide So essentially this is just standard Java. This is not actually specific to Android You talk to what's called the runtime and you tell the runtime here's something you want to run off the shell The important thing is that this is actually if it is something that's running in the background It might actually continue running even after the application is dead Because it's it's just it's just there running in the background Okay Java utilities, so most of us at least That have played around with the Android a little bit know that If I go back to here all of this stuff running up here is typically in Java, right? The applications are written in Java. Okay, now remember yesterday Where was I? So I went on the command line here And it's something like I Used am okay to actually start an application on the on the system remember that Okay So well How does am actually work right? Where is that and what does it do? Right because I used it to start an app off the command line. Okay, so let's go see this If I am is actually in system been Am here's am Wow, lo and behold. It's actually self script Okay And what does that shell script do? Anybody know what this is? It's it's starting a class, right? That's in a jar file Okay, and how does it do that it uses this thing called app process, right app process is actually It's actually a command in and of itself app process here This is a command line utility and if you go in the sources Let me actually close a few windows here Go back to this guy if I go to frameworks native Commands, I have actually they put it. Oh They've been moving stuff around and I'm not there we go app process. It's a C file. Okay, and This is how The zygote if you're not Familiar with it actually gets started with this app process thing So it starts a Dalvik virtual machine and tells the Dalvik virtual machine run this Java class. Okay So in other words, I should be able to find am around here and if I go here, there's am Remember that shell script I showed you earlier. It's right over here Okay And if I look in here, I have an android mk that at the end is going to generate a java library Okay, and if I actually go in src com android commands am am the java. I actually have here standard android classes Being imported and lo and behold what I've got underneath here is a java based command line utility Right, this is really cool Because it means that I can write a command line utility that talks straight to the framework Now that doesn't mean that I can create activities and that kind of stuff But it does mean that I can use the classes that applications at least some of the classes Or most of the classes that an application would have access to As a as a as part of the regular api Okay, that's that's really powerful So in this case they use it to actually talk to the activity manager directly Right and and invoke it directly and in fact One of I was giving a class at some points and somebody said wait a second am can do things I can't do it in application And the reason it can do that is because it's being built part of the a osp And if you've ever done such work, you know that when you're building as part of the a osp You have access to apis which are not available to app developers Okay, if you look around the api So for example, let me get let me give you a good example here if I go to frameworks base core Java Android say os and I look for Power manager. Okay. I power manager dot a idl. That's the interface definition for the power manager system service It's marked with ad hide Okay, which means that this is not going to show up in the sdk You can have something else showing up in an sdk that kind of gives you the almost the same thing But it's this is not it anything that's marked with ad hide in the sources Will not be available to you as part of the sdk But will be available to you if you're billing as part of the osp So therefore That command line tool can do things that a standard application can't do because it has access to all those hidden apis Um and the same thing goes actually for a couple of those things. So I showed you am But um say for it's a pm. I'm sorry pm is the same thing you have a pm script and then Sources of the java thing svc is the same thing Wm is the same thing and so on. So whenever you need to talk to the framework. Um, this is a nice trick to know about all right system services, so this really is um, you know us How can I say this? Of the many things that you may want to add in the framework This is probably the one that's most interesting. Okay If I go back here to my architecture diagram Remember, I said those um the applications here can get stopped and Restarted at whim Well the system services on the other hand are there from boot to reboot And essentially what happens is that the system services act as a gateway for accessing the hardware So that means permission checking It means sharing the same hardware piece amongst many Collars which can be different applications. It also means enabling the the hardware functionality for other system services Okay, um, so being a system service is something that is very useful So let me actually show you this you have system services which are um Where am I? Okay, you've got um system services which are part of the bulk of the system services which are written in java You've got at least one which is part of an application. That's the phone up phone system service Um, and you've got a couple which are completely written in c Okay, um Anybody have an idea where some of them are written in c and others are written in java So my best guess is um, it's a time critical thing Anything that seems to be time critical seems to be written in c. So the media Uh system service is written in c the surface flanger is written in c Uh, the sensor service is written in c. All right, all of these things have to do with human interaction And the you know the assumption is that it has to be snappy. Okay Whereas a lot of the other stuff like the activity manager window manager Battery and and so on they're they're all in java. Okay The construct of how that works is um Somewhat complicated. So let me kind of walk you through this You have an application, all right that's trying to talk to a system service All right, it's actually not talking to the system service directly through binder Uh, it'll start start off by doing a get system service, which will give it an object Okay, that's this part here get system service gives it an object and um, actually there's um those Files java files and c files. They're actually um, you you can look on the web. I have a whole Thing on github, which is the all those files are up there. So if you want to play around with this It's an example that's out there. So um, you grab Uh, the application gets an object which is called an operasus manager and this manager is just a gateway Okay, it's a dumb object. It doesn't really do much But that object turns around and actually talks to a remote api through a binder Which is implemented through in this interface here in this case, I called it i operasus service And that thing is the gateway for the actual system service, which is written in java Which is part of the other system services and then that system service turns around and talks to an actual JNI counter side which talks which goes and through the hell grabs a SO file which actually has the hell module that talks to the hardware Why are we doing it this way? Because essentially This application can't talk to the driver at the kernel level The applications don't have access to the slash dev entries Right, they have to remotely ask something to do that on their behalf And that's the job of system service Now, why is the system service so complicated? Well, because it goes through a howler and the howler's purpose is to allow manufacturers to keep things in in uh, And the user land which can be proprietary and therefore not put in the driver that's underneath Okay, so if you want to run a system service You have to play around with these with these pieces All right So here's the example code actually So I have here a operasus service which extends i operasus service stub. That's defined in this aidl file Okay, don't mind too much what the actual system service does But the aidl file specifies the public api that this system service has and it is marked as ad hide Which means that an application won't be able to see this in the sdk But something building in the a osp can call upon this all right Um, I have to manually add the aidl file as part of the files that have to be built in the framework Um, I also have to add the system service here as part of the system services that get started in system server dot Java and from that point on that system service can be called from within the a osp If I want to make that available outside the a osp, I then have to go inside The actual framework and then make my system service available through get system service Which is the public interface And there's a few things that have to do to actually make that happen And then eventually you have to have this operasus manager Which going back again to my earlier diagram is just a shrink wrap object Which acts as a gateway for calling the remote thing Okay Questions so far No, okay Okay, you can write shell scripts, right? It used to be that the shell script they had the Shell they had an android sucked royally. It was a net bsd based one Recently they added a The mere bsd corn shell Which is a lot more powerful a lot more interesting and essentially you can Um add stuff in the init rc file that will get started as a shell script and The emulator actually does that Which gets me to the init rc file. So Let me go grab the init rc file and kind of show you around a very very quick tour here Of what's in that thing. So if I got a system core root dear init dot rc So that's the configuration file for the init process there are Two types of entries in the init rc file There are actions and there are service declarations The actions start with the on keyword you can already see you should see one up there And the services start with the service keyword The services in the init rc files have nothing to do with system services or the service components as part of applications A init service is a init service and nothing else Okay, so these are the two types of declarations that you have in those files each one has different semantics In action which starts with the on keyword has a list of commands that it runs So on early init you can run this stuff on init you do all of this stuff and so on and so forth services on the other hand Okay, have properties for whatever is getting started. So service service manager Starts what's on the other side here. This is the binary and this is the parameters that tell init how to actually start this service Services have all have to be all have to be part of a class This is where you have this class core and there's a class main underneath here And as part of one of the actions So in the on boot the last thing this on thing does is class start core and class start main So those instructions are actually starting all the init services that follow underneath Okay, so what you want to do is if you want to add something to you want to add something to the startup you can Add a service declaration and make sure it's part of core or main and then it will start as the system starts out Um, there's a main init rc file that is for all a osp builds of a given version So if you get 4.3, there's an in rc file for all 4.3 in in our For a 4.3 base devices and then you can have a purse product in an rc file That has that specific devices in its stuff inside of it Okay, you want to write a c library? Just make sure your code builds with Build shared library and it will just generate essentially A dot s o file. Okay, there's nothing really magical about that. There's plenty of examples of libraries inside the asp The if you want to look for examples in fact if you go to system core There's a lot of those lib foobars over here. Okay, you grab say for example libc utils Here's an android mk and it will tell you how it builds that can have fun. Look at this um Right and obviously you can load c libraries from java code explicitly like this System load library which here will load the lib. Hello, j and i dot s o file Or in some cases The so's will be loaded automatically elsewhere. You can generate java libraries with build java library. Remember those a m p m n w m commands I was showing you earlier as command line tools written in java the jars are actually generated with this um build java library Okay And if you don't want to generate your own sdk, you can generate what's called sdk add-ons So that allows you to extend the api an app developer has access to Without generating your own sdk for For your developers that's really interesting for a lot of people who are doing a better work because it allows You to actually tell the the the the developers who are writing for your whole platform Will go grab the sdk from google Okay, and here's an add-on that i'm giving you that it gives you access to this other api that that you don't get Okay, and that additional api could be talking to system service you have running on the device That's really special to your thing that's not accessible through the regular apis and then you know, it's accessible by By way of having that sdk add-on available Okay, and i'm going to end with this part. Well as we were saying this morning Android's really interesting, but sometimes I actually want more than whatever google's giving me. Okay, how do I do this? Okay Obviously the why's and what ifs are here if you want to care to read my slide But essentially, you know For whatever reason that you want to get a legacy linux system such as say something that's generated by build route Or that's generated by yakto and you want to get this this in android You know there's You know the question becomes so how do I do this? How do I mix those things because I mean if you look at what they're doing So let me actually show you an example of what they're doing and it'll kind of give you an idea of how complicated I think can become so if we go to external let me go grab something that comes straight from linux So let's go for hey s trace. I should know about this So um, how is s trace typically built? Well, we should have some kind of make following here I'm not seeing it or I'm blind No, that's not the one I want to show you so forget about s trace. Let me show you Zlib, uh, no not zlib. Oh, come on Lib jpeg is that there? All right, this is not going to be my consensus There I this is one is good. This is a good one. Okay, so um, bzip 2 all right bzip 2 if you look in the sources it has a Makefile right classic capital M makefile. However, they're not using this they have a android mk and you can actually Browse through those sources and there are other multiple examples of this where essentially they're generating an mk for Any given thing they're importing from the outside world. That's interesting for them But for you that can be just overkill. All right, so there is a good reason for being able to stick around with the common stuff So let's try to get something like this having essentially My stack which is based on glipsy talking to something remotely on android and this is fairly trivial You have a whole bunch of customers doing this essentially use sockets or whatever other mechanism that's built inside the kernel You're running on the same kernel. So really is a matter Okay, um, and then you just use that to talk or you could if I'm some people has said well, why why don't you use binder? Well, it's just a Dilip binder is not built against glipsy, but you can probably get that to build with glipsy or whatever And you know, whatever it is whatever mechanism you use you can have those two stacks talk to each other Okay, it's pretty trivial But what you want to do is actually Have some way of having the build system Lump those two things together To the out the resulting images that it generates. Okay, and that's really the trick here Is how do you do that? How do you make and how do you make it work? Okay? So the first thing that's really important to remember and it was actually mentioned in the talk earlier this morning With the non, you know, the non mobile android stuff Is essentially android doesn't use the same file system hierarchy As a typical linux system or even an embedded linux system and most importantly android puts its libraries and Its binaries in slash system lib and slash system bin Okay, so it doesn't use slash lib and slash bin. Those are free for us to use So what we do is we actually populate those Okay, with whatever we generate with the other tool Okay, so let me actually show you an example of what I did with the I sat down with Tamar and Maxim from free electrons earlier at the abs This year and we just you know, just as I was mentioning earlier At the keynote this morning. It took us about like 10 minutes to get this to work. So I'm going to go here in two three seven Glypsy one so you can see I have a build root directory Okay, um, I went in here. Sorry So this is just a standard build route. I didn't really change anything in here. Um four minutes. Thank you sir so, um I extracted build route and what I've got is a custom android mk That actually just says, uh, by the way, um, why don't you add build root fs to all pre-built and then in here what we're going to do is we're going to we're going to extract the Tarball that got generated by build root into the resulting output Direct trees and you know, that's it So once you build build root, you go back to the top of the eosp you build and voila your final root file system has got Build root stuff inside of it. Okay. There is a few A few things you have to keep in mind all pre-built doesn't exist in four point x Uh, you have to change one of the main mks to actually add this as a target That really isn't too much of a problem. The kicker, however, is the following thing um If you go into system core and this one took me kind of some time to discover here. There's um system core include private android file system config.h So here's the thing The users And the rights are defined statically in this file. You don't have a etsy password All right, and the other thing, um, so here's the users And the other thing is that the rights for every file in the file system are laid out in this in in structures, which are here And so you've got um, essentially System bin, which is executable You have bin, which is executable, but you don't have slash lib star executable And if you forget to add slash lib star as executable in here when the system runs It will tell you that it can't run the binaries. Okay permission denied. So you have to add this in here So in fact all the kind of steps here and then you can change essentially in it rc to start sorry Sure, you're right. I mean it's just whatever it's just if you want the thing is if you just make the linker executable On the file system on the host and you don't put lib star What will happen is When it generates the final file system the linker won't be executable So this is why you have to add lib star or you could do lib slash the linker name But I just don't bother. I put link. I just put lib star um, so Um, you can change also the startup so that it starts busybox as the console instead of toolbox Um, and you can you know change adb So when you do an adb shell you get a busybox shell and all that kind of stuff But once you have this you can go in the init rc file and have essentially The android init rc start anything you have in this other stack. That's not a problem. Okay The only penalty you're paying by having this this kind of dual headed environment Is that you have more storage being taken but whatever you added And at runtime you have an additional c library in your ram in addition to bionic But that's it in terms of performance, whatever I mean the load of whatever you're adding on the other side is what you is the other penalty you're going to pay Questions What I'm sorry It's not clear why this works. Oh, okay, so why is the application linked against bionic? Essentially not kind of why is there no conflict by having to Sure, okay, so the the easy answer to that is is found by running What's called Where's my read elf All right. I'm in the wrong directory. Let's be four three pristine. So if you do read elf On out target product generic system. No, it's not magic. It's it's I mean, it's just the the linkers are different So if I go to service Yeah hyphen a less Okay Where is it? Where is it? Where is it before they kick me out? There we go. Okay requesting program interpreter system bin linker. Okay. Um, so this is using Yeah, I will stop in a second This is um This is the linker it's looking for if you actually look at a glib ceiling 20 will look for lib ld Whatever or you know, so The tool changes the difference. Yeah All right Yeah, go ahead quick Any It's a clean bill if you is any android stuff in the root fs star that was generated by build root none whatsoever build root was built I mean I could have built build root outside and still copied it. It doesn't make a difference All right. Thank you folks