Marakana Android Internals

Marko Gargenta
Marko GargentaSoftware Developer à Marakana
Android	
  
 Internals	
  


Marko	
  Gargenta	
  
  Marakana	
  
Agenda	
  
•    Android	
  Stack	
  
•    Opera6ng	
  System	
  Features	
  
•    Android	
  Startup	
  &	
  Run6me	
  
•    Layer	
  Interac6on	
  
•    Na6ve	
  Development	
  Kit	
  
•    Summary	
  
ANDROID	
  STACK	
  
The	
  Stack	
  
Linux	
  Kernel	
  
Android runs on Linux.                                        Applications


                                    Home      Contacts          Phone             Browser              Other

Linux provides as well as:
    Hardware abstraction layer                            Application Framework
    Memory management              Activity        Window                    Content                   View

    Process management
                                   Manager         Manager                  Providers                 System

                                   Package    Telephony         Resource           Location            Notiication
    Networking                     Manager     Manager          Manager            Manager             Manager


                                                                Libraries
Users never see Linux sub system   Surface       Media
                                                                   SQLite                  Android Runtime
                                   Manager     Framework

                                                                                                 Core Libs

The adb shell command opens        OpenGL      FreeType            WebKit

                                                                                                  Delvik
Linux shell                          SGL          SSL               libc
                                                                                                   VM




                                    Display    Camera         Linux Kernel              Flash                Binder
                                    Driver      Driver                                  Driver               Driver

                                    Keypad      WiFi                                    Audio                Power
                                     Driver     Driver                                  Driver               Mgmt
Na6ve	
  Libraries	
  
Bionic, a super fast and small                              Applications


license-friendly libc library     Home      Contacts          Phone             Browser              Other

optimized for embedded use
                                                        Application Framework
Surface Manager for composing    Activity        Window                    Content                   View

window manager with off-screen   Manager         Manager                  Providers                 System


buffering
                                 Package    Telephony         Resource           Location            Notiication
                                 Manager     Manager          Manager            Manager             Manager


                                                              Libraries
2D and 3D graphics hardware      Surface       Media
                                                                 SQLite                  Android Runtime
support or software simulation
                                 Manager     Framework

                                                                                               Core Libs
                                 OpenGL      FreeType            WebKit

                                                                                                Delvik
Media codecs offer support for     SGL          SSL               libc
                                                                                                 VM

major audio/video codecs
                                  Display    Camera         Linux Kernel              Flash                Binder
                                                                                      Driver               Driver
SQLite database
                                  Driver      Driver

                                  Keypad      WiFi                                    Audio                Power
                                   Driver     Driver                                  Driver               Mgmt


WebKit library for fast HTML
rendering
Dalvik	
  
Dalvik VM is Google’s implementation of Java

Optimized for mobile devices




Key Dalvik differences:

    Register-based versus stack-based VM
    Dalvik runs .dex files
    More efficient and compact implementation
    Different set of Java libraries than SDK
Android	
  and	
  Java	
  

Android Java =
Java SE –
AWT/Swing +
Android API
Applica6on	
  Framework	
  
Activation manager controls the life                              Applications


cycle of the app                        Home      Contacts          Phone             Browser              Other




Content providers encapsulate data                            Application Framework
that is shared (e.g. contacts)         Activity        Window                    Content                   View
                                       Manager         Manager                  Providers                 System

                                       Package    Telephony         Resource           Location            Notiication
Resource manager manages               Manager     Manager          Manager            Manager             Manager


everything that is not the code                                     Libraries
                                       Surface       Media
                                                                       SQLite                  Android Runtime
                                       Manager     Framework

Location manager figures out the                                                                     Core Libs

location of the phone (GPS, GSM,
                                       OpenGL      FreeType            WebKit

                                                                                                      Delvik

WiFi)                                    SGL          SSL               libc
                                                                                                       VM




Notification manager for events         Display
                                        Driver
                                                   Camera
                                                    Driver
                                                                  Linux Kernel              Flash
                                                                                            Driver
                                                                                                                 Binder
                                                                                                                 Driver

such as arriving messages,              Keypad      WiFi                                    Audio
                                                                                            Driver
                                                                                                                 Power
                                                                                                                 Mgmt
                                         Driver     Driver
appointments, etc
Applica6ons	
  
OPERATING	
  SYSTEM	
  FEATURES	
  	
  
File	
  System	
  
The file system has three main mount points. One
for system, one for the apps, and one for whatever.

Each app has its own sandbox easily accessible to
it. No one else can access its data. The sandbox is
in /data/data/com.marakana/

SDCard is expected to always be there. It’s a good
place for large files, such as movies and music.
Everyone can access it.
Security	
  
Each Android application            Android Application
runs inside its own Linux
process.                                     Linux Process
Additionally, each application
has its own sandbox file                                   File
system with its own set of                     Prefs
                                       DB                 System
preferences and its own
database.

Other applications cannot
access any of its data,
unless it is explicitly shared.
ANDROID	
  	
  
STARTUP	
  &	
  	
  
RUNTIME	
  
Startup	
  Walkthrough	
  
Run6me	
  Overview	
  
Layer	
  Interac6ons
                                     	
  
There are three main
scenarios for your app to talk
to native library:

-  Directly
-  Via native service
-  Via native daemon

It will depend on the type of
app and type of native library
which method works best.
App	
  –	
  Run6me	
  Service	
  -­‐	
  Lib	
  
App	
  –	
  Run6me-­‐Na6ve	
  Service-­‐Lib	
  
App–Run6me–Na6ve	
  Daemon-­‐Lib	
  
Binder	
  IPC	
  




High-performance IPC: shared memory, per-process thread pool, synchronous
Java	
  Na6ve	
  Interface	
  

JNI defines naming and coding
convention so that Java VM can find
and call native code.

JNI is built into JVM to provide
access to OS I/O and others.
Building	
  and	
  Running	
  JNI	
  Code	
  
NATIVE	
  
DEVELOPMENT	
  
KIT	
  
What’s	
  in	
  NDK?	
  
Tools to build and compile your native code for the device
architecture (such as ARM)


A way to package your library into the APK file so you can
distribute your application easily


A set of native system headers that will be supported for
the future releases of Android platform (libc, libm, libz,
liblog, JNI headers, some C++ headers, and OpenGL)



(some) documentation, sample code and examples
Why	
  NDK?	
  

NDK allows you to develop parts of your Android
application in C/C++.

You cannot develop native-only apps in NDK –
your app is still subject to security sandboxing.

Main motivation for native code is performance.
Using	
  NDK	
  
Summary	
  
     For most applications, you will just
     need Android SDK to develop apps.

     Sometimes you may need NDK to
     make parts of your app run faster.

     Ultimately, you can build your own
     Android platform from source.



     Marko Gargenta, Marakana.com
     marko@marakana.com
     +1-415-647-7000



     Licensed under Creative Commons
     License (cc-by-nc-nd). Please Share!
1 sur 28

Contenu connexe

Tendances(20)

Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
National Cheng Kung University12.2K vues
Binder: Android IPCBinder: Android IPC
Binder: Android IPC
Shaul Rosenzwieg2.8K vues
Android presentationAndroid presentation
Android presentation
Siva Ramakrishna kv3.4K vues
Android - ADBAndroid - ADB
Android - ADB
Yossi Gruner5.6K vues
Android Chromium Rendering PipelineAndroid Chromium Rendering Pipeline
Android Chromium Rendering Pipeline
Hyungwook Lee11.5K vues
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)
Emertxe Information Technologies Pvt Ltd10.7K vues
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
Yu-Hsin Hung2.5K vues
Applied Computer Science Concepts in AndroidApplied Computer Science Concepts in Android
Applied Computer Science Concepts in Android
National Cheng Kung University4.2K vues
Embedded Android : System Development - Part IIIEmbedded Android : System Development - Part III
Embedded Android : System Development - Part III
Emertxe Information Technologies Pvt Ltd2.7K vues
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSP
Dr. Ketan Parmar5.1K vues
Intro to Flutter SDKIntro to Flutter SDK
Intro to Flutter SDK
digitaljoni980 vues
Android is NOT just 'Java on Linux'Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi24.3K vues
Inside Android's UIInside Android's UI
Inside Android's UI
Opersys inc.7.6K vues
Android - Application FrameworkAndroid - Application Framework
Android - Application Framework
Yong Heui Cho11.2K vues

En vedette

Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven DevelopmentMarakana Inc.
2.6K vues32 diapositives
DABiS800DABiS800
DABiS800Ralph Andreas
1.6K vues32 diapositives
30 Band Marks30 Band Marks
30 Band MarksBill_Rosner
294 vues32 diapositives
Mapa MentalMapa Mental
Mapa Mentaledwinfloresorozco
256 vues1 diapositive
New concepts in humanNew concepts in human
New concepts in humanbechikmn
456 vues25 diapositives

En vedette(20)

Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
Marakana Inc.2.6K vues
DABiS800DABiS800
DABiS800
Ralph Andreas1.6K vues
30 Band Marks30 Band Marks
30 Band Marks
Bill_Rosner294 vues
Mapa MentalMapa Mental
Mapa Mental
edwinfloresorozco256 vues
New concepts in humanNew concepts in human
New concepts in human
bechikmn456 vues
Optimizing the Virtual EnvironmentOptimizing the Virtual Environment
Optimizing the Virtual Environment
uptime software567 vues
TranzeoTranzeo
Tranzeo
Shahab Shahid1.3K vues
Dematic Logistics Review #4Dematic Logistics Review #4
Dematic Logistics Review #4
hagenbucksw2.3K vues
Tieto EnatorTieto Enator
Tieto Enator
svatle1K vues
Safend- DLSafend- DL
Safend- DL
danilopv1.6K vues
Estrategias y recursos iEstrategias y recursos i
Estrategias y recursos i
jkrls917 vues
E-group's pitchE-group's pitch
E-group's pitch
i7551 vues
Catalog Sew-EurodriveCatalog Sew-Eurodrive
Catalog Sew-Eurodrive
Bui Viet Phuong22.8K vues
History of the llano estacadoHistory of the llano estacado
History of the llano estacado
Mark McGinley8K vues
Desafios jurídicos de InternetDesafios jurídicos de Internet
Desafios jurídicos de Internet
Loreto Corredoira324 vues
Girl, interruptedGirl, interrupted
Girl, interrupted
shelbi_jennett5.9K vues

Similaire à Marakana Android Internals

Android InternalsAndroid Internals
Android InternalsMarko Gargenta
3.4K vues37 diapositives
Open AndroidOpen Android
Open AndroidMarko Gargenta
1.9K vues45 diapositives

Similaire à Marakana Android Internals(20)

Android InternalsAndroid Internals
Android Internals
Marko Gargenta3.4K vues
Android: A 9,000-foot OverviewAndroid: A 9,000-foot Overview
Android: A 9,000-foot Overview
Marko Gargenta2.3K vues
Android For Managers SlidesAndroid For Managers Slides
Android For Managers Slides
Marko Gargenta1.5K vues
Open AndroidOpen Android
Open Android
Marko Gargenta1.9K vues
Android for Java DevelopersAndroid for Java Developers
Android for Java Developers
Marko Gargenta1.6K vues
An Introduction To AndroidAn Introduction To Android
An Introduction To Android
GoogleTecTalks768 vues
Google Io Introduction To AndroidGoogle Io Introduction To Android
Google Io Introduction To Android
Bhavya Siddappa943 vues
Android and Intel InsideAndroid and Intel Inside
Android and Intel Inside
Intel Developer Zone Community1.3K vues
Tacademy techclinic-2012-07-11Tacademy techclinic-2012-07-11
Tacademy techclinic-2012-07-11
영호 라587 vues
Android application developmentAndroid application development
Android application development
Linh Vi Tường424 vues
Android unveiled (I)Android unveiled (I)
Android unveiled (I)
denian001K vues
Webinar The App Lifecycle PlatformWebinar The App Lifecycle Platform
Webinar The App Lifecycle Platform
Service2Media748 vues
Google Android Naver 1212Google Android Naver 1212
Google Android Naver 1212
Yoojoo Jang1.4K vues
Introduction to Android platformIntroduction to Android platform
Introduction to Android platform
maamir farooq94 vues

Plus de Marko Gargenta

Java Champion WantedJava Champion Wanted
Java Champion WantedMarko Gargenta
687 vues10 diapositives
Android Beyond The PhoneAndroid Beyond The Phone
Android Beyond The PhoneMarko Gargenta
658 vues29 diapositives
Android InternalsAndroid Internals
Android InternalsMarko Gargenta
1.8K vues24 diapositives
Android Deep DiveAndroid Deep Dive
Android Deep DiveMarko Gargenta
2K vues57 diapositives

Plus de Marko Gargenta(11)

LTE: Building New Killer AppsLTE: Building New Killer Apps
LTE: Building New Killer Apps
Marko Gargenta1.4K vues
Java Champion WantedJava Champion Wanted
Java Champion Wanted
Marko Gargenta687 vues
Android Beyond The PhoneAndroid Beyond The Phone
Android Beyond The Phone
Marko Gargenta658 vues
Android InternalsAndroid Internals
Android Internals
Marko Gargenta1.8K vues
Android Deep DiveAndroid Deep Dive
Android Deep Dive
Marko Gargenta2K vues
Marakana Android User InterfaceMarakana Android User Interface
Marakana Android User Interface
Marko Gargenta2.2K vues
Marakana android-java developersMarakana android-java developers
Marakana android-java developers
Marko Gargenta1.6K vues
Scrum OverviewScrum Overview
Scrum Overview
Marko Gargenta3K vues
Why Python by Marilyn Davis, MarakanaWhy Python by Marilyn Davis, Marakana
Why Python by Marilyn Davis, Marakana
Marko Gargenta2.6K vues

Marakana Android Internals

  • 1. Android   Internals   Marko  Gargenta   Marakana  
  • 2. Agenda   •  Android  Stack   •  Opera6ng  System  Features   •  Android  Startup  &  Run6me   •  Layer  Interac6on   •  Na6ve  Development  Kit   •  Summary  
  • 5. Linux  Kernel   Android runs on Linux. Applications Home Contacts Phone Browser Other Linux provides as well as: Hardware abstraction layer Application Framework Memory management Activity Window Content View Process management Manager Manager Providers System Package Telephony Resource Location Notiication Networking Manager Manager Manager Manager Manager Libraries Users never see Linux sub system Surface Media SQLite Android Runtime Manager Framework Core Libs The adb shell command opens OpenGL FreeType WebKit Delvik Linux shell SGL SSL libc VM Display Camera Linux Kernel Flash Binder Driver Driver Driver Driver Keypad WiFi Audio Power Driver Driver Driver Mgmt
  • 6. Na6ve  Libraries   Bionic, a super fast and small Applications license-friendly libc library Home Contacts Phone Browser Other optimized for embedded use Application Framework Surface Manager for composing Activity Window Content View window manager with off-screen Manager Manager Providers System buffering Package Telephony Resource Location Notiication Manager Manager Manager Manager Manager Libraries 2D and 3D graphics hardware Surface Media SQLite Android Runtime support or software simulation Manager Framework Core Libs OpenGL FreeType WebKit Delvik Media codecs offer support for SGL SSL libc VM major audio/video codecs Display Camera Linux Kernel Flash Binder Driver Driver SQLite database Driver Driver Keypad WiFi Audio Power Driver Driver Driver Mgmt WebKit library for fast HTML rendering
  • 7. Dalvik   Dalvik VM is Google’s implementation of Java Optimized for mobile devices Key Dalvik differences: Register-based versus stack-based VM Dalvik runs .dex files More efficient and compact implementation Different set of Java libraries than SDK
  • 8. Android  and  Java   Android Java = Java SE – AWT/Swing + Android API
  • 9. Applica6on  Framework   Activation manager controls the life Applications cycle of the app Home Contacts Phone Browser Other Content providers encapsulate data Application Framework that is shared (e.g. contacts) Activity Window Content View Manager Manager Providers System Package Telephony Resource Location Notiication Resource manager manages Manager Manager Manager Manager Manager everything that is not the code Libraries Surface Media SQLite Android Runtime Manager Framework Location manager figures out the Core Libs location of the phone (GPS, GSM, OpenGL FreeType WebKit Delvik WiFi) SGL SSL libc VM Notification manager for events Display Driver Camera Driver Linux Kernel Flash Driver Binder Driver such as arriving messages, Keypad WiFi Audio Driver Power Mgmt Driver Driver appointments, etc
  • 12. File  System   The file system has three main mount points. One for system, one for the apps, and one for whatever. Each app has its own sandbox easily accessible to it. No one else can access its data. The sandbox is in /data/data/com.marakana/ SDCard is expected to always be there. It’s a good place for large files, such as movies and music. Everyone can access it.
  • 13. Security   Each Android application Android Application runs inside its own Linux process. Linux Process Additionally, each application has its own sandbox file File system with its own set of Prefs DB System preferences and its own database. Other applications cannot access any of its data, unless it is explicitly shared.
  • 14. ANDROID     STARTUP  &     RUNTIME  
  • 17. Layer  Interac6ons   There are three main scenarios for your app to talk to native library: -  Directly -  Via native service -  Via native daemon It will depend on the type of app and type of native library which method works best.
  • 18. App  –  Run6me  Service  -­‐  Lib  
  • 19. App  –  Run6me-­‐Na6ve  Service-­‐Lib  
  • 21. Binder  IPC   High-performance IPC: shared memory, per-process thread pool, synchronous
  • 22. Java  Na6ve  Interface   JNI defines naming and coding convention so that Java VM can find and call native code. JNI is built into JVM to provide access to OS I/O and others.
  • 23. Building  and  Running  JNI  Code  
  • 25. What’s  in  NDK?   Tools to build and compile your native code for the device architecture (such as ARM) A way to package your library into the APK file so you can distribute your application easily A set of native system headers that will be supported for the future releases of Android platform (libc, libm, libz, liblog, JNI headers, some C++ headers, and OpenGL) (some) documentation, sample code and examples
  • 26. Why  NDK?   NDK allows you to develop parts of your Android application in C/C++. You cannot develop native-only apps in NDK – your app is still subject to security sandboxing. Main motivation for native code is performance.
  • 28. Summary   For most applications, you will just need Android SDK to develop apps. Sometimes you may need NDK to make parts of your app run faster. Ultimately, you can build your own Android platform from source. Marko Gargenta, Marakana.com marko@marakana.com +1-415-647-7000 Licensed under Creative Commons License (cc-by-nc-nd). Please Share!