SlideShare una empresa de Scribd logo
1 de 23
Descargar para leer sin conexión
Android Internals
Android Montreal – November 3rd 2010

 Karim Yaghmour / @karimyaghmour
●   Overall Architecture   ●   Activity Manager
●   System startup         ●   Binder
●   Linux Kernel           ●   Stock Android Apps
●   Hardware Support       ●   Hacking
●   Native User-Space
●   Dalvik
●   JNI
●   System Server
Overall Architecture
Arch vs. Tools
                 SDK, Eclipse, .apk




                 Manifest:
                  Perms / SDK ver.




                 .dex, ddms

                 NDK, rootfs, initrc, adb

                 GNU toolchain


                 (fastboot)
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:
          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
Startup - Kernel
●   Core kernel initialization
●   Device drivers initialization
●   Root filesystem mounting
●   Execution of “/init”
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
        –   ...
Startup – Zygote, etc.
●   app_main:
    ●   runtime.start(“com.android.internal.os.Zygote”, ...)
         –   startVM()
         –   Call Zygote's main()
               ● preloadClasses()


               ● startSystemServer()


               ● ... magic ...


               ● Call SystemServer's run()


                   – Start all system services/managers
                   – Start ActivityManager:
                      ● Send Intent.CATEGORY_HOME

                         ● Launcher2 kicks in
Linux Kernel – Generic Features
Linux Kernel - Androidisms
●   Wakelocks
●   lowmem handler
●   Binder
●   RAM console
●   Logger
●   ...
Hardware Support
Bluetooth               BlueZ through D-BUS IPC (to avoid GPL contamination it seems)
GPS                     Manufacturer-provided libgps.so
Wifi                    wpa_supplicant
Display                 Std framebuffer driver (/dev/fb0)
Keymaps and Keyboards   Std input event (/dev/event0)
Lights                  Manufacturer-provided liblights.so
   Backlight
   Keyboard
   Buttons
   Battery
   Notifications
   Attention
Audio                   Manufacturer-provided libaudio.so (could use ALSA underneath ... at least as illustrated in t
Camera                  Manufacturer-provided libcamera.so (could use V4L2 kernel driver underneath ... again as
Power Management        “Wakelocks” kernel patch
Sensors                 Manufacturer-provided libsensors.so
   Accelerometer
   Magnetic Field
   Orientation
   Gyroscope
   Light
   Pressure
   Temperature
   Proximity
Radio Layer Interface   Manufacturer-provided libril-<companyname>-<RIL version>.so
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, ...
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
Dalvik's .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
JNI – Java Native Interface
●   Call gate for other languages, such as C, C++
●   Equivalent to .NET's pinvoke
●   Usage: include and call native code from App
●   Tools = NDK ... samples included
●   Check out “JNI Programmer's Guide and
    Specification” - freely available PDF
System Server
Entropy Service             Device Policy               Audio Service
Power Manager               Status Bar                  Headset Observer
Activity Manager            Clipboard Service           Dock Observer
Telephone Registry          Input Method Service        UI Mode Manager Service
Package Manager             NetStat Service             Backup Service
Account Manager             NetworkManagement Service   AppWidget Service
Content Manager             Connectivity Service        Recognition Service
System Content Providers    Throttle Service            Status Bar Icons
Battery Service             Accessibility Manager       DiskStats Service
Lights Service              Mount Service               ADB Settings Observer
Vibrator Service            Notification Manager
Alarm Manager               Device Storage Monitor
Init Watchdog               Location Manager
Sensor Service              Search Service
Window Manager              DropBox Service
Bluetooth Service           Wallpaper Service
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
Binder
●   CORBA/COM-like IPC
●   Data sent through “parcels” in “transactions”
●   Kernel-supported mechanism
●   Check /proc/binder/*
Stock Android Apps – from AOSP

/packages/apps                           /packages/providers      /packages/inputmethods

AccountsAndSettings   Launcher2          ApplicationProvider      LatinIME
AlarmClock            Mms                CalendarProvider         OpenWnn
Bluetooth             Music              ContactsProvider         PinyinIME
Browser               PackageInstaller   DownloadProvider
Calculator            Protips            DrmProvider
Calendar              Provision          GoogleContactsProvider
Camera                QuickSearchBox     MediaProvider
CertInstaller         Settings           TelephonyProvider
Contacts              SoundRecorder      UserDictionaryProvider
DeskClock             SpeechRecorder
Email                 Stk
Gallery               VoiceDialer
HTMLViewer
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”
    ●   ...
AOSP contents
bionic        C library replacement
bootable      Reference bootloader
build         Build system
cts           Compatibility Test Suite
dalvik        Dalvik VM
development   Development tools
device        Device-specific files and components
external      Copy of external projects used by AOSP
frameworks    System services, android.*, Android-related cmds, etc.
hardware      Hardware support libs
libcore       Apache Harmony
ndk           The NDK
packages      Stock Android apps, providers, etc.
prebuilt      Prebuilt binaries
sdk           The SDK
system        pieces of the world that are the core of the embedded linux platform at
              the heart of Android.
Thank you ...


karim.yaghmour@opersys.com

Más contenido relacionado

La actualidad más candente

Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
Chethan Pchethan
 

La actualidad más candente (20)

Android graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspectiveAndroid graphic system (SurfaceFlinger) : Design Pattern's perspective
Android graphic system (SurfaceFlinger) : Design Pattern's perspective
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Overview of Android binder IPC implementation
Overview of Android binder IPC implementationOverview of Android binder IPC implementation
Overview of Android binder IPC implementation
 
Android internals By Rajesh Khetan
Android internals By Rajesh KhetanAndroid internals By Rajesh Khetan
Android internals By Rajesh Khetan
 
Learning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
 
Q4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
 
Embedded Android : System Development - Part III
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
 
Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)Embedded Android : System Development - Part IV (Android System Services)
Embedded Android : System Development - Part IV (Android System Services)
 
Learning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Deep Dive into the AOSP
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
 
Introduction to Android Window System
Introduction to Android Window SystemIntroduction to Android Window System
Introduction to Android Window System
 
Android Things : Building Embedded Devices
Android Things : Building Embedded DevicesAndroid Things : Building Embedded Devices
Android Things : Building Embedded Devices
 
Design and Concepts of Android Graphics
Design and Concepts of Android GraphicsDesign and Concepts of Android Graphics
Design and Concepts of Android Graphics
 
Booting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot images
 
Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
 
Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)
 
Android AIDL Concept
Android AIDL ConceptAndroid AIDL Concept
Android AIDL Concept
 
Project meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture OverviewProject meeting: Android Graphics Architecture Overview
Project meeting: Android Graphics Architecture Overview
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 

Destacado

Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
Opersys inc.
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
Opersys inc.
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
Opersys inc.
 

Destacado (20)

Porting Android
Porting AndroidPorting Android
Porting Android
 
Android Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and ResourcesAndroid Variants, Hacks, Tricks and Resources
Android Variants, Hacks, Tricks and Resources
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
An Introduction to Android Internals
An Introduction to Android InternalsAn Introduction to Android Internals
An Introduction to Android Internals
 
Enhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_osEnhancing and modifying_the_core_android_os
Enhancing and modifying_the_core_android_os
 
Fast-paced Introduction to Android Internals
Fast-paced Introduction to Android InternalsFast-paced Introduction to Android Internals
Fast-paced Introduction to Android Internals
 
Android Booting Sequence
Android Booting SequenceAndroid Booting Sequence
Android Booting Sequence
 
Aosp+
Aosp+Aosp+
Aosp+
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014Is Android the New King of Embedded OSes at Embedded World 2014
Is Android the New King of Embedded OSes at Embedded World 2014
 
Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014Android Platform Debugging and Development at ABS 2014
Android Platform Debugging and Development at ABS 2014
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Customizing Android's UI
Customizing Android's UICustomizing Android's UI
Customizing Android's UI
 
Leveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VILeveraging Android's Linux Heritage at AnDevCon VI
Leveraging Android's Linux Heritage at AnDevCon VI
 
Headless Android at AnDevCon3
Headless Android at AnDevCon3Headless Android at AnDevCon3
Headless Android at AnDevCon3
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
 
Project Ara
Project AraProject Ara
Project Ara
 

Similar a Android Internals

OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
Paris Open Source Summit
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 

Similar a Android Internals (20)

Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013Android Internals at Linaro Connect Asia 2013
Android Internals at Linaro Connect Asia 2013
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
OWF12/PAUG Conf Days Android tools for developpeurs, paul marois, design and ...
 
Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
 
Android Attacks
Android AttacksAndroid Attacks
Android Attacks
 
An Introduction To Android
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
 
Android crash debugging
Android crash debuggingAndroid crash debugging
Android crash debugging
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Porting Android ABS 2011
Porting Android ABS 2011Porting Android ABS 2011
Porting Android ABS 2011
 
Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013Inside Android's UI / ABS 2013
Inside Android's UI / ABS 2013
 
Inside Android's UI
Inside Android's UIInside Android's UI
Inside Android's UI
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3Leveraging Android's Linux Heritage at AnDevCon3
Leveraging Android's Linux Heritage at AnDevCon3
 
Android architechture
Android architechtureAndroid architechture
Android architechture
 
Begining Android Development
Begining Android DevelopmentBegining Android Development
Begining Android Development
 
Mobile operating systems - Application Benchmarking
Mobile operating systems - Application BenchmarkingMobile operating systems - Application Benchmarking
Mobile operating systems - Application Benchmarking
 
Android Development Tools
Android Development ToolsAndroid Development Tools
Android Development Tools
 
Android presentation
Android presentationAndroid presentation
Android presentation
 
Android Architecture
Android ArchitectureAndroid Architecture
Android Architecture
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 

Más de Opersys inc.

Más de Opersys inc. (20)

Android Automotive
Android AutomotiveAndroid Automotive
Android Automotive
 
Android 10 Internals Update
Android 10 Internals UpdateAndroid 10 Internals Update
Android 10 Internals Update
 
Android Security Internals
Android Security InternalsAndroid Security Internals
Android Security Internals
 
Embedded Android Workshop with Pie
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
 
Android's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
 
Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
 
Embedded Android Workshop with Oreo
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Android Things: Android for IoT
Android Things: Android for IoTAndroid Things: Android for IoT
Android Things: Android for IoT
 
Android Things Internals
Android Things InternalsAndroid Things Internals
Android Things Internals
 
Scheduling in Android
Scheduling in AndroidScheduling in Android
Scheduling in Android
 
Brillo / Weave Internals
Brillo / Weave InternalsBrillo / Weave Internals
Brillo / Weave Internals
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 
Embedded Android Workshop with Nougat
Embedded Android Workshop with NougatEmbedded Android Workshop with Nougat
Embedded Android Workshop with Nougat
 
Memory Management in Android
Memory Management in AndroidMemory Management in Android
Memory Management in Android
 

Último

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 

Android Internals

  • 1. Android Internals Android Montreal – November 3rd 2010 Karim Yaghmour / @karimyaghmour
  • 2. Overall Architecture ● Activity Manager ● System startup ● Binder ● Linux Kernel ● Stock Android Apps ● Hardware Support ● Hacking ● Native User-Space ● Dalvik ● JNI ● System Server
  • 4. Arch vs. Tools SDK, Eclipse, .apk Manifest: Perms / SDK ver. .dex, ddms NDK, rootfs, initrc, adb GNU toolchain (fastboot)
  • 5. System Startup ● Bootloader ● Kernel ● Init ● Zygote ● System Server ● Activity Manager ● Launcher (Home)
  • 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. Startup - Kernel ● Core kernel initialization ● Device drivers initialization ● Root filesystem mounting ● Execution of “/init”
  • 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. Startup – Zygote, etc. ● app_main: ● runtime.start(“com.android.internal.os.Zygote”, ...) – startVM() – Call Zygote's main() ● preloadClasses() ● startSystemServer() ● ... magic ... ● Call SystemServer's run() – Start all system services/managers – Start ActivityManager: ● Send Intent.CATEGORY_HOME ● Launcher2 kicks in
  • 10. Linux Kernel – Generic Features
  • 11. Linux Kernel - Androidisms ● Wakelocks ● lowmem handler ● Binder ● RAM console ● Logger ● ...
  • 12. Hardware Support Bluetooth BlueZ through D-BUS IPC (to avoid GPL contamination it seems) GPS Manufacturer-provided libgps.so Wifi wpa_supplicant Display Std framebuffer driver (/dev/fb0) Keymaps and Keyboards Std input event (/dev/event0) Lights Manufacturer-provided liblights.so Backlight Keyboard Buttons Battery Notifications Attention Audio Manufacturer-provided libaudio.so (could use ALSA underneath ... at least as illustrated in t Camera Manufacturer-provided libcamera.so (could use V4L2 kernel driver underneath ... again as Power Management “Wakelocks” kernel patch Sensors Manufacturer-provided libsensors.so Accelerometer Magnetic Field Orientation Gyroscope Light Pressure Temperature Proximity Radio Layer Interface Manufacturer-provided libril-<companyname>-<RIL version>.so
  • 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. 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. Dalvik's .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. JNI – Java Native Interface ● Call gate for other languages, such as C, C++ ● Equivalent to .NET's pinvoke ● Usage: include and call native code from App ● Tools = NDK ... samples included ● Check out “JNI Programmer's Guide and Specification” - freely available PDF
  • 17. System Server Entropy Service Device Policy Audio Service Power Manager Status Bar Headset Observer Activity Manager Clipboard Service Dock Observer Telephone Registry Input Method Service UI Mode Manager Service Package Manager NetStat Service Backup Service Account Manager NetworkManagement Service AppWidget Service Content Manager Connectivity Service Recognition Service System Content Providers Throttle Service Status Bar Icons Battery Service Accessibility Manager DiskStats Service Lights Service Mount Service ADB Settings Observer Vibrator Service Notification Manager Alarm Manager Device Storage Monitor Init Watchdog Location Manager Sensor Service Search Service Window Manager DropBox Service Bluetooth Service Wallpaper Service
  • 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. Binder ● CORBA/COM-like IPC ● Data sent through “parcels” in “transactions” ● Kernel-supported mechanism ● Check /proc/binder/*
  • 20. Stock Android Apps – from AOSP /packages/apps /packages/providers /packages/inputmethods AccountsAndSettings Launcher2 ApplicationProvider LatinIME AlarmClock Mms CalendarProvider OpenWnn Bluetooth Music ContactsProvider PinyinIME Browser PackageInstaller DownloadProvider Calculator Protips DrmProvider Calendar Provision GoogleContactsProvider Camera QuickSearchBox MediaProvider CertInstaller Settings TelephonyProvider Contacts SoundRecorder UserDictionaryProvider DeskClock SpeechRecorder Email Stk Gallery VoiceDialer HTMLViewer
  • 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. AOSP contents bionic C library replacement bootable Reference bootloader build Build system cts Compatibility Test Suite dalvik Dalvik VM development Development tools device Device-specific files and components external Copy of external projects used by AOSP frameworks System services, android.*, Android-related cmds, etc. hardware Hardware support libs libcore Apache Harmony ndk The NDK packages Stock Android apps, providers, etc. prebuilt Prebuilt binaries sdk The SDK system pieces of the world that are the core of the embedded linux platform at the heart of Android.