Your SlideShare is downloading. ×
0
Android InternalsAndroid Montreal – November 3rd 2010 Karim Yaghmour / @karimyaghmour
●   Overall Architecture   ●   Activity Manager●   System startup         ●   Binder●   Linux Kernel           ●   Stock A...
Overall Architecture
Arch vs. Tools                 SDK, Eclipse, .apk                 Manifest:                  Perms / SDK ver.             ...
System Startup●   Bootloader●   Kernel●   Init●   Zygote●   System Server●   Activity Manager●   Launcher (Home)
Startup - Bootloader●   CPU fetches first instruction from bootloader●   Bootloader boots kernel from flash:          0x00...
Startup - Kernel●   Core kernel initialization●   Device drivers initialization●   Root filesystem mounting●   Execution o...
Startup - Init●   Open, parses, and runs /init.rc:    ●   Create mountpoints and mount filesystems    ●   Set up filesyste...
Startup – Zygote, etc.●   app_main:    ●   runtime.start(“com.android.internal.os.Zygote”, ...)         –   startVM()     ...
Linux Kernel – Generic Features
Linux Kernel - Androidisms●   Wakelocks●   lowmem handler●   Binder●   RAM console●   Logger●   ...
Hardware SupportBluetooth               BlueZ through D-BUS IPC (to avoid GPL contamination it seems)GPS                  ...
Native User-Space●   Rootfs:    ●   /system    ●   /data●   Libs:        Bionic, SQLite, SSL, OpenGL|ES,        Non-Posix:...
Dalvik●   Sun-Java =        Java language + JVM + JDK libs●   Android Java =        Java language + Dalvik + Apache Harmon...
Dalviks .dex files●   JVM munches on “.class” files●   Dalvik munches on “.dex” files●   .dex file = .class files post-pro...
JNI – Java Native Interface●   Call gate for other languages, such as C, C++●   Equivalent to .NETs pinvoke●   Usage: incl...
System ServerEntropy Service             Device Policy               Audio ServicePower Manager               Status Bar  ...
Activity Manager●   Start new Activities, Services●   Fetch Content Providers●   Intent broadcasting●   OOM adj. maintenan...
Binder●   CORBA/COM-like IPC●   Data sent through “parcels” in “transactions”●   Kernel-supported mechanism●   Check /proc...
Stock Android Apps – from AOSP/packages/apps                           /packages/providers      /packages/inputmethodsAcco...
Hacking●   Source:    ●   AOSP -- source.android.com / android.git.kernel.org    ●   Cyanogenmod -- www.cyanogenmod.com   ...
AOSP contentsbionic        C library replacementbootable      Reference bootloaderbuild         Build systemcts           ...
Thank you ...karim.yaghmour@opersys.com
Upcoming SlideShare
Loading in...5
×

Android Internals

29,962

Published on

Android Internals talk given ad Android Montreal on Nov. 3rd 2010 by Karim Yaghmour (author of O'Reilly's "Building Embedded Linux Systems.")

Published in: Technology, News & Politics
2 Comments
26 Likes
Statistics
Notes
  • its nice
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • You can see the full video of this presentation on Opersys’ site: http://www.opersys.com/blog/android-internals-101103

    You can also watch it on Vimeo: http://vimeo.com/18017921
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
29,962
On Slideshare
0
From Embeds
0
Number of Embeds
42
Actions
Shares
0
Downloads
946
Comments
2
Likes
26
Embeds 0
No embeds

No notes for slide

Transcript of "Android Internals"

  1. 1. Android InternalsAndroid Montreal – November 3rd 2010 Karim Yaghmour / @karimyaghmour
  2. 2. ● Overall Architecture ● Activity Manager● System startup ● Binder● Linux Kernel ● Stock Android Apps● Hardware Support ● Hacking● Native User-Space● Dalvik● JNI● System Server
  3. 3. Overall Architecture
  4. 4. Arch vs. Tools SDK, Eclipse, .apk Manifest: Perms / SDK ver. .dex, ddms NDK, rootfs, initrc, adb GNU toolchain (fastboot)
  5. 5. System Startup● Bootloader● Kernel● Init● Zygote● System Server● Activity Manager● Launcher (Home)
  6. 6. Startup - Bootloader● CPU fetches first instruction from bootloader● Bootloader boots kernel from flash: 0x000003860000­0x000003900000 : "misc" 0x000003900000­0x000003e00000 : "recovery" 0x000003e00000­0x000004300000 : "boot" Kernel 0x000004300000­0x00000c300000 : "system" /system 0x00000c300000­0x0000183c0000 : "userdata" /data 0x0000183c0000­0x00001dd20000 : "cache" /cache 0x00001dd20000­0x00001df20000 : "kpanic" 0x00001df20000­0x00001df60000 : "dinfo" 0x00001df60000­0x00001dfc0000 : "setupdata" 0x00001dfc0000­0x00001e040000 : "splash1" 0x000000300000­0x000001680000 : "modem" From Acer Liquid-E
  7. 7. Startup - Kernel● Core kernel initialization● Device drivers initialization● Root filesystem mounting● Execution of “/init”
  8. 8. Startup - Init● Open, parses, and runs /init.rc: ● Create mountpoints and mount filesystems ● Set up filesystem permissions ● Set OOM adjustments properties ● Start daemons: – adbd – servicemanager (binder) – vold – netd – rild – app_process -Xzygote (Zygote) – mediaserver – ...
  9. 9. Startup – Zygote, etc.● app_main: ● runtime.start(“com.android.internal.os.Zygote”, ...) – startVM() – Call Zygotes main() ● preloadClasses() ● startSystemServer() ● ... magic ... ● Call SystemServers run() – Start all system services/managers – Start ActivityManager: ● Send Intent.CATEGORY_HOME ● Launcher2 kicks in
  10. 10. Linux Kernel – Generic Features
  11. 11. Linux Kernel - Androidisms● Wakelocks● lowmem handler● Binder● RAM console● Logger● ...
  12. 12. Hardware SupportBluetooth BlueZ through D-BUS IPC (to avoid GPL contamination it seems)GPS Manufacturer-provided libgps.soWifi wpa_supplicantDisplay Std framebuffer driver (/dev/fb0)Keymaps and Keyboards Std input event (/dev/event0)Lights Manufacturer-provided liblights.so Backlight Keyboard Buttons Battery Notifications AttentionAudio Manufacturer-provided libaudio.so (could use ALSA underneath ... at least as illustrated in tCamera Manufacturer-provided libcamera.so (could use V4L2 kernel driver underneath ... again asPower Management “Wakelocks” kernel patchSensors Manufacturer-provided libsensors.so Accelerometer Magnetic Field Orientation Gyroscope Light Pressure Temperature ProximityRadio Layer Interface Manufacturer-provided libril-<companyname>-<RIL version>.so
  13. 13. Native User-Space● Rootfs: ● /system ● /data● Libs: Bionic, SQLite, SSL, OpenGL|ES, Non-Posix: limited Pthreads support, no SysV IPC● Toolbox● Daemons: vold, rild, netd, adbd, ...
  14. 14. Dalvik● Sun-Java = Java language + JVM + JDK libs● Android Java = Java language + Dalvik + Apache Harmony● Target: ● Slow CPU ● Relatively low RAM ● OS without swap space ● Battery powered● Now has JIT
  15. 15. Dalviks .dex files● JVM munches on “.class” files● Dalvik munches on “.dex” files● .dex file = .class files post-processed by “dx” utility● Uncompressed .dex = 0.5 * Uncompressed .jar
  16. 16. JNI – Java Native Interface● Call gate for other languages, such as C, C++● Equivalent to .NETs pinvoke● Usage: include and call native code from App● Tools = NDK ... samples included● Check out “JNI Programmers Guide and Specification” - freely available PDF
  17. 17. System ServerEntropy Service Device Policy Audio ServicePower Manager Status Bar Headset ObserverActivity Manager Clipboard Service Dock ObserverTelephone Registry Input Method Service UI Mode Manager ServicePackage Manager NetStat Service Backup ServiceAccount Manager NetworkManagement Service AppWidget ServiceContent Manager Connectivity Service Recognition ServiceSystem Content Providers Throttle Service Status Bar IconsBattery Service Accessibility Manager DiskStats ServiceLights Service Mount Service ADB Settings ObserverVibrator Service Notification ManagerAlarm Manager Device Storage MonitorInit Watchdog Location ManagerSensor Service Search ServiceWindow Manager DropBox ServiceBluetooth Service Wallpaper Service
  18. 18. Activity Manager● Start new Activities, Services● Fetch Content Providers● Intent broadcasting● OOM adj. maintenance● Application Not Responding● Ex. starting new app from Launcher: onClick(Launcher)->startActivity(Activity.java)- >Binder->ActivityManagerService- >startViaZygote(Process.java)->Socket->Zygote
  19. 19. Binder● CORBA/COM-like IPC● Data sent through “parcels” in “transactions”● Kernel-supported mechanism● Check /proc/binder/*
  20. 20. Stock Android Apps – from AOSP/packages/apps /packages/providers /packages/inputmethodsAccountsAndSettings Launcher2 ApplicationProvider LatinIMEAlarmClock Mms CalendarProvider OpenWnnBluetooth Music ContactsProvider PinyinIMEBrowser PackageInstaller DownloadProviderCalculator Protips DrmProviderCalendar Provision GoogleContactsProviderCamera QuickSearchBox MediaProviderCertInstaller Settings TelephonyProviderContacts SoundRecorder UserDictionaryProviderDeskClock SpeechRecorderEmail StkGallery VoiceDialerHTMLViewer
  21. 21. Hacking● Source: ● AOSP -- source.android.com / android.git.kernel.org ● Cyanogenmod -- www.cyanogenmod.com ● Moders sites ... aplenty ...● Tools: ● repo / git ● fastboot ● recovery ● Kernel privilege escalation exploits -- “one-click root” ● ...
  22. 22. AOSP contentsbionic C library replacementbootable Reference bootloaderbuild Build systemcts Compatibility Test Suitedalvik Dalvik VMdevelopment Development toolsdevice Device-specific files and componentsexternal Copy of external projects used by AOSPframeworks System services, android.*, Android-related cmds, etc.hardware Hardware support libslibcore Apache Harmonyndk The NDKpackages Stock Android apps, providers, etc.prebuilt Prebuilt binariessdk The SDKsystem pieces of the world that are the core of the embedded linux platform at the heart of Android.
  23. 23. Thank you ...karim.yaghmour@opersys.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×