 Okay, welcome back Linux terminal commands. I am going to continue that. There is small break. I will give some simple examples how Linux is similar to Android and what a dissimilar it is. What is Kernel? Core of the operating system, it manages all the hardware, processes, memory, jobs etc etc. So the core kernel is same in both the cases that means Android also uses same Linux kernel and Linux of course uses the Linux kernel and any one of you know that recently only the Linux kernel and Android kernel, they got merged. What happened? Earlier Android people, they forked Linux kernel tree, you understand fokking? Yes, fokking means they got a branch from Linux kernel tree, tree means source code and they built their own drivers set of whatever optimization whatever they did and Linux people they did not accepted those changes immediately but very recently it got resolved. So when you download source from kernel.org you get source for both Android and Linux kernel. Of course Android kernel is also Linux kernel but as this is a fork and it was not officially the part of the Linux kernel but things got resolved and now you have a single source tar file download from kernel.org and you can optimize it for either for your mobile phone or for your desktop environment. Both are compatible with GNU applications. So what is GNU? See in 1983 I think Richard Stahlman he got source code from Unix source there was some license by which you can take source from Unix similar your Mac, Apple it also forked from basic Unix operating systems source code and it created as it was a BHD licensed source code. So you can easily fork your source code and he can create a independent distribution from that source code and he may close the source also means with BHD license how BHD license work you can have the open source components with you you can compile it and you may not release the source code again and what is GNU license? GNU license says that if you are downloading source and if you are compiling and if you are redistributing the binary you have to give a copy of that source to the user. This was GNU says and what does, what I was talking, BHD license, BHD license is completely more open and it is more industry supported license. What it says if you download source code ok no problem if you compile it and use the binary for your purpose ok with that if you do not want to release the modifications you did in the previous code source code which you have downloaded it is ok. So Apple did like that it use the BHD license it exploited it not exploited it sorry it is not exploited it use the open source thing it build its own components added some components if you ever visit open source dot apple dot com you can see the list of open source packages which Apple uses in its operating system just if we get time sometime just visit the site open source dot apple dot com you will find all the applications there. So in a way you can say Apple is also Unix based but though it saw big development chain it followed so now it become little bit different from basic Unix thing but if you run Mac book ever you will see you are all the commands bash etc. everything works there without any modification ok that was not the part of the discussion licensing so GPL force you to have open source license means if you are using you have to give the source code and if you are redistributing then also you have to redistribute the source. So Richard Stahlman he proposed the GNU license called GNU GPL license and GNU is the set of softwares applications so at 1989 I think not share over the date he started writing a kernel who started Richard Stahlman started writing a kernel but by the time he should he was able to deliver the kernel before that Linus Torvalds has already released his kernel as open source and he named his kernel as Linux. So applications were already built like Emacs or some core utilities like LS, CP they are known as core utilities they were already there in GNU licensing so what Richard Stahlman did he contacted with Linus Torvalds and they named the operating system as GNU Linux. So wherever you see official documentation people do not say Linux they say GNU Linux because GNU is the set of softwares and Linux is the core operating system. So both are compatible to GNU applications means I will show you the demo of Android Tablet just after 5-10 minutes you can see LS, CP those things they are also work though you have to install it but it supports GNU applications these are the similarities so users and permissions so there also you can have users groups and others same thing. File system of latest version of Android same as Linux excuse me if you are using Android 4.0 that is ICS Ice Cream Sandwich the file system recommended for Ice Cream Sandwich is EXT4 extension for file system which is very common and popular file system for Linux desktop environments. If you have ever come formatted your machine and installed Ubuntu or any operating system it will ask for by which file system you want to format the device if you can select from EXT2, EXT3, EXT4, FACE2 different file systems are there. So file system are also compatible with Android and Linux from present version rather dissimilarity this is important and this is why we are trying to port many applications to Android if it is completely compatible you could have port it immediately. Problem is the Android operating system uses a stripped down version of Lib C you all understand Lib C. Lib C is a library of Lib C is a C library so if you download bare minimal operating systems see Ubuntu desktop sorry Ubuntu distribution is available for 50 MB distro also if you any if sometime if you browse your Ubuntu site in CD images you find this is a minimal installation image that is 50 MB image is also there means download ubuntu.ios for 50 MB it is called net installed you should have your Ethernet cable plugged in and you can download the rest of operating system from internet but in that 50 MB also the main component is Lib C, G Lib C because whatever code operating system utilities are there they all compiled in C that C code basically most almost all of the Linux kernel is written in C. So to run any C program you need some library support there are two ways to compile a C program just we have seen I did C C space hello dot C it give me A dot out so let me it is there yeah so I want to know what kind of file this is A dot out so file space A dot out will tell me the details of that file. So it says ELF 64 LSB executable but it is dynamically linked uses shared lips what does it mean that means it uses G Lib C for information for libraries I can compile this hello dot C I think my hello dot C is in home directory yeah I can compile this hello dot C by giving a flag known as hyphen static by default it will create A dot out suppose I want to name my output file let me give it hello. Now if you see file hello it will say statically linked okay why I am showing this because if you build all your applications statically it will contain your library information whatever STDW dot H or printer function we used the information is kept inside my binary itself if you see the size of this LS hyphen L H hello for the same code it is 859 K LS hyphen L H today A dot out it is 8.2 K why this difference because this A dot out uses shared libraries and my hello binary uses statically linked libraries. So due to this size constraint what we do we ship the library files by default with any operating systems. So whatever source code you have suppose LS LS is not statically linked statically compiled it is dynamically compiled to use LS you need libc are you getting so for the 50 MB distro also or 25 MB distro also minimum requirement is G libc that should be present there but in android environment we do not have G libc why because probably in G libc we have lot of extra stuff which is not required for mobile phone tablet probably because that G libc which we are talking about means desktop G libc it contains many default libraries which are frequently used for desktop applications but for mobile phone which is a single user small scale device we do not need those libraries. So what did Google and android community did they created a stripped down version of same G libc and they name it as bionic libc. So what is the difference now G libc and bionic libc whatever suppose I compile this hello though this is compile for x64 base device isn't it for this laptop it is compiled I have a cross compiler installed in my machine you understand the concept of cross compiler no cross compiler is a compiler by which we can compile from this native machine host machine for any other architecture. So this is an 64 bit architecture machine we have 32 bit inter processors we have 64 bit AMD processors we have power PC processors we have AVR processors different processors we have similarly we have ARM processors. So in most of the mobile phone devices or small scale devices tablet devices ARM processors are very popular and ARM processors they have a family name like we have code to do core i3 core i5 core i7 similarly in the ARM scenario we say as ARM version 5 ARM version 6 ARM version 7 okay unlike your x86 system that is code to do core i3 core i7 where binary is compatible if I compile this binary means this I compile for 64 bit machine and this is core i3 machine if I run this same binary in my core code to do a machine which is also a dual core machine 64 bit machine it will work but in ARM based devices the development is not like that. So if you compile something in ARM version 7 it is not backward compatible so if you compile a.out for ARM version 7 that will work for ARM version 7 and above it would not work in ARM version 6 ARM version 5 ARM version 4 like that okay fine. So the major difference is the version of C library is different and this is only creating a big problem for us suppose I want to port Sylab on this tablet what I have to do I have to compile entire Sylab code for Bionic Lib C based ARM processor not G Lib C based if I compile it for G Lib C based that will work on any other ARM device which does not have Bionic Lib C which has G Lib C have you ever seen vehicle board no embedded knowledge okay. So vehicle board is a development board and it has similar processor ARM Quotex A8 so as you already know the present version of Aakash tablet will have ARM Quotex A8 processor which is ARM family 7 processors version 7 family processors. So the speed of the processor is 800 megahertz it can be increased software by software means also that is not important. So whatever you compile in ARM version 7 it will work in only ARM version 7 and I am talking about tablet this tablet has Android operating system that means Bionic Lib C which it uses is Bionic Lib C Android uses Bionic Lib C but I can run ARM Quotex A8 I can run full Ubuntu version on ARM Quotex A8 also are you getting what I am trying to make a point. See there are some development boards have you seen 8051 development board or 8085 development board in your lab no there are processor boards development boards on which there are some input output boards you can connect it to monitor you can connect it to keyboard there is an HD card similar to hard disk there are procedures given in internet you can download even in Ubuntu website you get an image for ARM Quotex A8 Beagle board just download that image copy to HD card follow the steps there are some steps to follow start the machine your Ubuntu will run from your ARM Quotex A8 development board okay but that Ubuntu has ARM version of G Lib C ARM version of G Lib C that is different form your tablets because your tablet is same processor but it has Bionic Lib C instead of G Lib C I hope I made my point in any Linux environment whatever I am running is an X server running in the back end I can install a bare minimal Linux distro with no X also that means it will have only consoles control alt F1 control alt F2 it will give you a console ports okay in older days we used to come nick means there are only consoles there were no X environment so in console you can type your commands Linux commands of course but there will be no graphical output and this terminal is an emulator you understand emulator so it emulates the console so whatever commands you can type in control alt F1 I cannot do control alt F1 I think monitor won't support sorry projector won't support but you can try that later so yeah what I am trying to say is X server is important in any Linux desktop distribution or development board ARM Quotex A8 distribution you can install an X server I think this user bin X so X is a program it's a server server means serves so whatever so I have different windows here like this is one terminal this is one browser this is a chromium browser okay so my X manages all this but in android you don't have any X environment that's one of the difference android runs on Dalvik virtual machine you heard of Dalvik okay if you heard of android you probably heard of Dalvik Dalvik is a process virtual machine what it does it runs dot dex files which are executable and they are compiled from native Java files okay so what is there there is a Linux kernel there is an interaction flame buffer layer there is a Dalvik virtual machine running over the kernel and all your UI's are communicated through this Dalvik only we have touch screen of different layers are there of course I am not going in that detail so there are no there is no X server running in your tablet or mobile phone okay that's the difference native Linux UI apps user interface apps they won't work in tablet or your android phone why because there is no X server you can install an X server in probably no android but that's the other thing because X server consumes lot of memory and in tablet or phone based distros we don't have that much memory so native Linux UI apps can't be ported android directly and there are some other changes also now this is a tablet this is very similar to Akash tablet I have it actually I don't have with me so it has same processor ARM Cortex A8 which the proposed version of Akash has and it is installed it has ice cream sandwich running ice cream sandwich means android 4.0 it's the latest android operating system so I have connected this through and USB so what I can do is before that I want to show you some development if you go to the site developer.android.com actually I am running the site locally I don't have internet here so if you search for internet search in internet about android source code or android SDK you will get the first link the same site so SDK what is SDK software development kit and what it does it helps you to write code for android phone or tablet and it helps you to debug phone or tablet also debugging is important because you can write code in eclipse IDE how many of you used eclipse before good anyway I am not covering eclipse in this part so installing SDK is very simple all you have to do is you have to download source there will be a if you see you can download source from sorry you can download SDK from a link I have to locate that link I don't want to waste time with that I have already downloaded so I can show you how it looks so we can go through the file browser only so I will go to Srekan documents android SDK so I downloaded a tar file tar dot gz I untied it using command line or graphical and I got these many folders and different things so there is no eclipse folder here so by default when you download android SDK you don't get eclipse with it you have to download eclipse and send JDK separately and you have to put it in a path everything is well documented there are tens and thousands of tutorials on internet and YouTube you won't be alone for this purpose so there are some directories which have some significance that you can get it from here so basic environments are SDK tools SDK platform tools and SDK platform so they contains the platform information means what platform you are using and of course we will see these things later yeah so coming back to terminal let me go to document android SDK so I have these many folders let me see the size of this du-sh android SDK I think I downloaded a 100 MB tar file and after uncompressing it becomes around guess 400 MB the time it's taking and it's embarrassing it's 2.5 GB okay because I created many android virtual devices and probably I copied some image files inside this during development so size increased but it's not 2.5 GB when you untie it so first thing to start with is what is an SDK and why android is free yeah what does Google do actually how Google earned through advertisements so if it has an operating system it can easily control the advertisements on one's phone and based on your search terms in phone or in desktop by default you are logged in whenever you search so Google maintains a complete history of you complete profile of your search and it gives you a customized ads for them if you are searching for flights from Mumbai to Delhi for say last week for next one month probably you will get advertisements from different sites which provides ticketing for flights like that so phone is an integrated part of everyone's life now so people stick to phone more than the laptop or desktop so if you are using android you probably have seen ads in android if you are connected to internet so by default except core apps like Gmail or some yeah Gmail and Google talk in all other apps you get ads and you can't control them you can't make like in YouTube if you are getting ad you can close that ad now they have force enforce the ads also in YouTube that you have to wait 30 seconds or 4 seconds to skip the ad etc etc but during the video whatever pop up and you get you can close that isn't it but in phone you can't do that they enforce that completely and that's how they earn that's why they created android operating system and of course there is quite a bit of competition and Google or any other company it's a partnership actually Google, LG, China phone, Samsung many companies have came together to build android and it's very competitive well because Google is coming into TV industry also so you have Google TV similarly we have Apple TV Google and Apple they are always rival so whatever see Google can't had tens and millions tens and thousands of developers to write code so what it does it made it open source so people like you and me will code for Google and we will make apps and Google push ads in those apps and everyone is happy what I did I just connected this tablet to my laptop and I am going to access this phone from laptop this tablet from laptop for that HDK is enough so I downloaded HDK I am HDK I am in HDK directory actually if you have seen my bash rc file I have already set the path for android HDK somewhere see export path to dollar path homes recant document android HDK tools so in tools I have binaries for HDK and android HDK platform tools in these two locations I have my binaries okay you want to see you can just copy this and you can just cd to that so all whatever you see in green are binaries so there is a binary as adb android will see each one of them so let's start with android what is android as path is set phone is connected I want to disconnect phone for a while to just demo you something so when I hit enter it gives a graphical output finally and in this graphical output I have different options see it says extras are in for installed android 2.2 API is installed okay so Google releases APIs for each development release so if you remember from 1 to 1.5 Google android 1.6 then it came 2.1 eclair 2.2 Froyo 2.3 gingerbread 3.0 honeycomb ice cream sandwich and 5.0 is jelly beans so yeah jelly beans android so I have installed latest API for this HDK which is android 4.0.3 API 15 in tools I have AVD android virtual device manager so manage AVP is sorry yeah so android virtual device manager so these are my test emulators so I have written some code and I have to test it on phone or tablet and my tablet is not around I don't want to connect my tablet every time suppose I am in lab and I don't have tablet my tablet is in my hostel or home wherever how would I program for then program then I can use a emulator in that case of course it is recommended to use on emulator first then on tablet or your device so you can let me show you how to create a new AVD so let me delete one I don't have space in my home make it full screen so let me remove the stem so that I can make some space it's deleted now let me create a new one so what I am creating here is important this is emulator a virtual device I am creating why I need this virtual device to run my applications any android software comes with extension dot apk like in Windows we have dot exe in Ubuntu we have dot dev for android we have dot apk okay so give anything like now when I hit target I have these many options say I choose android 2.3 point or android 2.2 old one but no problem I can create a SD card also suppose let me create a 100 MB SD card snapshot will save your particular state of the virtual machine for further development suppose you are doing some development and you have to stop the development in between you can take the snapshot of that version of development and the next time you run it it will start from there okay is important when you are doing some important stuff so this is the resolution you can set qvga hvga these are the terms so qvga is 320 to 240 so this wvga is 800 into 480 resolution etc etc that's it create avd it says result of creating avd is successful with following hardware configurations this this this so I can see my Shrikant avd here what I can do is I can start it immediately so it pop up some launch options you want to scale the device no I don't want to scale it now launch so it will pop up a window which will emulate as a phone so I have not connected my device now I will show what is the difference between this and that we will just copy one apk to here and to virtual device also and you will see the difference it will take some time to boot meanwhile we will explore some other possible commands so we have seen android there is another command known as adb what is adb android debug bridge this command allows you to connect your device from your desktop why you need to connect maybe you want to change some system permissions in your phone maybe you want to execute some command inside your phone maybe you want to wipe up wipe out complete dalvik cache many things you you may because if you are a system designer for android you probably need many things to work around so adb will allow you to connect to device and adb will also help you to reinstall your phone software but that is not available for all the phones and devices because most of the devices comes with factory locked means vendor locked so suppose you are using Samsung or LG phone it comes by default the boot loader is by default locked by the vendor so you can unlock the boot loader and you can install custom ROMs probably this is going to much detail what do you mean by custom ROMs see android is an open source project so I can also download a source of course I have downloaded source I will show you the android source now so cd slash stuff home cd android so this is my android source this is my android directory inside that is a system directory u-sh dot means tell me the size of this directory this will around I do not want to guess it should be around 11 GB let us see okay so meanwhile let us see our AVD yeah it is booted so I have full functioning mobile phone on my system itself which is capable of running all the general functionality except of calls and SMS of course you are not connected to network so I can play around with it but this is not the purpose okay it is 11 GB this time I am right so you have to download yeah as I told you android is an open source project you can download this copy of android you can compile the android source and you can create your own operating system that is very easy it looks 11 GB of source oh my god it will take lot of time of course it will take lot of time it will have some dependency issues also but once it is resolved you can make frequent bills and you can test lot of customization you can do lot of customization on your android phone so there is a very famous customized version of android on a cyanogen mode okay cyanogen mode is also open source they have changed it from the original android source they added some extra features so original android phone as you can see does not have many options like you do not have a graphical equalizer you do not have an intergenome browser many features means you cannot install themes by default but the cyanogen mode provides you the extra functionality so from where we started yeah this is there this is the android source now I was telling you about the adb command now my phone is booted adb command is android debug bridge first we have seen android command what it does it allows you to download the latest api latest api and it allows you to create a emulator that part is done now I have a second and most important command there are many other commands but they are not relevant for us this is sufficient enough adb just type adb and hit enter it will list lot of options do not try all these options on your phone so most important options I will list out like adb devices or it will show it will show list of devices connected with this computer so it says there is an emulated device running on port 5554 is there now I can type adb shell what it will do it will give me access to the device it will just send me inside the device adb shell so it will give me a hash prompt why hash prompt because I am not in bash environment anymore so this was a bash environment which was giving me the proper complete home path user name at the rate host name etc. etc. but now I am in this phone I am inside this phone my prompt signifies that hash prompt signifies that I am inside this phone and this hash signifies something else also what else by default you probably have seen the prompt is dollar means it is a user prompt if I do I get a hash prompt so means super user so I am root now so when I did adb shell I got a hash prompt that means I am a root user for this phone that means this phone is already rooted in general android term the spell it as rooted phone rooted device if surgeon internet just I rooted there are lot of suggestions rooted android rooted nuke phone this this this etc. but this is not the general case as this is an emulator so Google allows you to play around with this emulator so it gave you hash prompt but with default phones whatever you buy from market if you connect it and do adb shell you will get a dollar prompt that means you are not super user you are a user some user are you getting even with the tablet if I connect the tablet this tablet is rooted tablet so when I connect it it will show the hash prompt as it is a rooted tablet otherwise it will show a dollar prompt that means you are a user if you get a dollar prompt in adb shell you cannot do anything means you can do things but you cannot change system properties you cannot set the path variables you cannot mount many things many restrictions you have enough talking ls ls works so out of the box lx works ls works that means my bionic libc has ls means sorry my ls command is compiled for bionic libc okay ls is a core utility GNU program okay so is there is which which sh which is not there so many commands won't be there like touch this touch is there tab completion also doesn't work because this is a shell prompt it's not bash bash is born again shell which is an advanced shell environment and this is a sh so if touch is there touch is not there sorry clear also not works what can I do I can okay so I have restrictions I don't have complete command set to work around with this what I want to show is this similarly let me show you another terminal ls sorry so this is the file hierarchy of my android phone emulator which I have run through android command and this is the file hierarchy of my desktop machine linux machine just ignore these files these are created by myself but by default bin boot ch ch root is also created by myself dev etc home these are the default files available in file system if you compare do you see the same file hierarchy here you have config cache account only mnt is there mnt is also in linux environment if you see you have mnt what else you find do we have system here no no system sys bin has been these much linux machine means desktop this is my phone I am just switching the windows very fast don't confuse so this is my phone and it doesn't have similar file structure as that of my desktop machine so by this you can see the level of optimization or customization android people have done they removed many unnecessary stuff which is not required for mobile phone and they made it everything compatible to phone for single user machine now the important thing is system and data at least for now we will concentrate on these two things what is system and what is data unlike linux desktop which has all the files under slash partitions important files system bin files we have in the android all the important system files and folders they are inside slash system so if I go cd system and ls-l let me clear it ls slash system so my system has user app lib etc xbin bin media fonts and this is very similar to this can you see the similarity I have been I have etc I have lib I have user isn't it in slash system so android stores every system information system based files inside the slash system partition so inside a user you will have some binaries user binaries so you want to see ls slash system slash bin so these are the binaries like rm you recognize mount we have seen mount and some other binaries so slash system partition normally no user has permission to read write inside that unless it is rooted form rooted device rooted means you have root permissions you can do anything what you want but slash data is system partition so ls slash data if you do it has user level permissions similar to you can say similar to your home partition whatever you saw in my laptop slash home slash we can this is similar to that but you do not have those directories here but the permissions are similar even if the vendor want he can lock this device also means this directory also means you can create directory here you can copy files here he can do anything but by default you have permissions here okay so here also you can see there are some there is an folder app so ls slash data slash app will list all the apk's what are apk's apk's are executables means these are the packages which android recognizes and it installs packages unlike other packages like in windows or ubuntu desktop we have dot exe and dot dev when you install it after installation you do not need the packages isn't it suppose you have installed a dot dev file or dot exe file after installation you can remove the dot exe file but android is different for android if you install dot apk it will read from apk itself of course it will create some temporary files and other files and folders but it needs dot apk also to run if I remove all the apk's here my phone will not my all the apps in my phone will want are you getting so why I want to show all this because sometime later if you want to program or if you want to do system level changes in android you can come to this folder you can release your app you can remove your app you can add something you can create a directory you can write a shell script which will automatically detect that okay if your data folder is actually you have similar apps in android market which will copy all your apk's to sd card or some external media but you can write your custom programs here fine so this is about android adb shell so adb has some other options also like you can directly install from your device suppose I have an apk here I can directly install from this adb command to my phone let me show you how so let me go to the directory where I have the apk so I have apk in so you can see there is an apk known as android vnc dot something something apk okay I can directly install that apk in my phone also I can just have to download and I have to click on that apk it will install automatically just because I have created this apk using my some third party software and I want to test this apk right away in the android virtual device what I will do I will just adb install android this and this will install this apk to the default avd connected so default avd is connected what this one so when I hit enter so it says package goes to data local temp and success so it installed so I didn't go inside the phone and inside the hd card or android market to install the apk I installed from here now I will I want to see whether this apk is actually installed or not so that apk name was android vnc so you can see android vnc is here okay similarly you can uninstall also and you can copy files to your avd means this android device you haven't we have created 100 mb hd card if you remember so what I can do is I can go to adb shell and I want to verify whether hd card is there or not it's there so ls let me go inside hd cards what is there only one directory that is loss dot it is created default by android so only one directory I can copy files to my hd card directly from my host machine how adb push this will push my file to my phone hd card or phone data folder wherever I want depending upon permission by default any user will have at least permission to copy into hd card so adb push what file I have say same apk file I am pushing there to where slash hd card so I have to give the absolute path slash mount slash hd card actually the problem is not that problem was yeah I have to give a trailing slash also so it says that copy inside the hd card directory otherwise it will replace the hd card and hd card is directly so it copied the file you want to verify it yes what you have to do you have to go actually I I don't have any file browser here otherwise I could have shown you api demos you can see no I don't have a file browser I can show you that adb shell I can go inside my phone cd hd card so my file is here suppose during development you probably need many files to copy paste or you want to get some files from android phone so as to analyze better suppose I want to copy entire slash data folder to my local machine so that I want to check where I can click the changes so that I will get a result what I will do adb pull from where slash data say I have an app folder there if you remember to present working directory so it's probably pulling all the apps so probably that apk directory doesn't has apps apk so it pulled some files probably I have given the wrong path to give the correct part if we put all the files in that directory okay oh so it copied see this apk also cube live wall papers copy this apk api demos apk copied other than these apk's we have some files that also it copied from same location so what I mean to say is you can copy files from your machine to your device reverse is also possible you can install packages apk files you can uninstall packages you can restart the phone from adb itself adb reboot will reboot the phone probably this is an emulator I don't think it will work so you have lot more options with adb suppose you want to install a new version of operating system you are a developer you are not an end user you are a developer and you want to create a you want to give an update for your operating system suppose you are given a phone with 2.3 android and there is an update of android 3.0 so first you will test it on emulator then on real device then you will release it in the market and ask people to download the latest operating system so that they can update so what you can do is you can there are options like yeah adb reboot bootloader so this will reboot the device into a bootloader mode where you can put something in your sd card some image file in sd card it will detect the default is sd card only it will detect the sd card and it will install from the sd card so it's like os update are you getting suppose you have an ubuntu distribution you want to update to some other version of ubuntu what you do you mainly either you do an update or you uninstall the operating system and install a fresh copy of operating system in phones case in tablets case what we do exactly is the data portion is the user portion slash data as I told you slash data is a user portion so user data you don't have to touch what you have to change is slash system only are you getting so if you download an image of slash system and you reboot your phone and instead of slash system image you replace with the new slash system image that will serve your purpose are you getting so by that you can update your operating system also you can change your operating system version also these are probably you won't be using now these things but just they are available I am telling you let me connect the real device so let me kill the adb okay now if I do adb shell directly send put me into shell environment of this phone this phone okay so root at that android is the environment set by this phone so I am inside this phone adb shell let me get out of this let me do adb devices so it shows it doesn't shows emulator 5541 now it shows 2008 04 11 so the manufacturer has set the name like this so this device is connected no AVD nothing you can see I am not running any AVD so immediately if I do adb shell instead of hash prompt I get a path username at the rate local host android so I can do lot of tweaking from here itself what I want to show is I can kill some running apps suppose I think top is there what does top do top will list the running processes and memory uses so what I can see is so it gives me the system properties so CPU 1% used by case this top top top so if you are a system designer or system engineer what you will see suppose your phone is getting hang after 10 minutes you don't know what is happening you will just go into the adb shell you will run top command and you will see which process is using CPU probably some process got zombie and it is in some deadlock and it is using using all of your CPU time you can just kill that process from here and later of course you can change your program and you can modify the bug remove the bug so this how it works so I can even after my processes I can just control l works here clear works no so again I have to adb shell there is another tool known as android ndk I will stop here with android ndk there are lot of things to discuss what is android ndk ndk is native development kit suppose I have ls command I have cp command already in my android adb shell what if I want my custom command suppose a dot out I created a dot out with hello world program suppose I want to run similar program in my android phone so can I compile it my cross compiler and directly put it on android with arm cross compiler if time permits I can show you that so I have a cross compiler installed for arm versions so that is gcc yeah so I can run this command this is a cross compiler program this is not the cc command cc is my default x86 compiler and this is my arm Linux android ea by gcc okay if I compile hello dot c using this cross compiler and if I execute that hello dot c here critically it should work and if I compile it statically that means it will not take the files from bionic libc it will directly execute within itself because it has all the files so where is my hello dot c I think it is probably here only yeah so just give a static flag it is created what I want to do is file a dot out default I have I haven't provided hyphen o and output file name so it says elf 32 bit executable for arm and it's a statically linked it's not dynamically linked so it doesn't depends on bionic libc because whatever components required it's already there what I will do is adb push a dot out to my slash data slash data so what I did I just compiled one source code using cross compiler and I put my binary inside some slash data folder slash data is user folder now I will go inside my phone and I will execute that a dot out and it should print hello or whatever you can adb shell I am inside the phone cd slash data ls hyphen l a dot out so its h is there hyphen h is not implemented in this version of ls so the relevant information for us is this so our file is there in slash data I want to execute how to execute dot slash it works why because I created a statically image statically linked binary file it uses how much memory it uses around 33 kb let me try it here what is a file size ls hyphen lh of a dot out it's around 332 kb so just to print srikan I spent 332 kb of precious embedded memory and in embedded world memory is very important so is it recommended to do like this of course not so what I have to do I have to use the system libc that is bionic libc instead of my statically compiled program so for that I need a special kit that is known as ndk native development kit I also downloaded that and it's in document android ndk and it is not that easy that I will copy my hello dot c here and I will just run some command it will create a binary and it will dynamically in android you have to do some changes you have to write one make file there are steps there are steps available in the default site so if you see android ndk is it visible if you see android ndk you can download the ndk you have the steps to follow and there are examples also how to compile the hello dot program hello dot c and etc etc is this clear so after this you have to download eclipse ide you have to install adt plugin adt plugin is a special plugin which will enable eclipse to debug android programs it will have an inbuilt icon by which if you click you can create an avd you understand avd the same avd which we have created using android command virtual device remember so in eclipse what we will have you can write your java code you can click a button it will build it it will create an apk it will automatically send that apk to your avd and you can easily see your output of your program on the virtual device if you have connected your real device and also it will show on real device also so try on eclipse if you are using anything on android possibly and it is very easy of course means it is not that difficult but you must know the system level things also that is why I introduced adb shell and android binary before you do something on real device it is recommended to try it on emulator though the final end product you should test it on real device 100 times and never use rm-rf to just check whether permissions are there or not okay don't try to remove any directory if you are not sure inside your phone suppose I am here I am in root at the rate android clear doesn't work okay clear the screen adb shell so I have files I have root permission what I can do I can do rm-rf sorry adb shell rm-rf slash data what it will do if I have permissions properly it will remove all my content of data folder so don't leave your system unattended if you are sitting somewhere in public place or in lab somewhere with android device connected in real mode so let me try what it happens exactly oh f is not implemented so what I can do is I will try with hyphen r f means force it won't ask me fail for slash data device or resource busy unfortunately it didn't remove I forgot that I am running on real device actually I was thinking that I was running on emulator so I tried this command if I remember this I was actually running from tablet I never have been tested on this device anyway I have backup rm for this I can reinstall later see the point so not at all recommended so what I can do is I can type you can see a display I can just type reboot so my phone will be restart so let's see actually removed something or not anyway that's all about today's presentation thanks for attending thank you everyone