Marakana Android Internals
Marakana Android Internals
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.
Home Contacts
Applications
Phone Browser Other
Linux provides as well as: Hardware abstraction layer Memory management Process management Networking Users never see Linux sub system The adb shell command opens Linux shell
Application Framework
Activity Manager Package Manager Window Manager Telephony Manager Resource Manager Content Providers Location Manager View System Notiication Manager
Libraries
Surface Manager OpenGL
Media Framework
SQLite
Android Runtime
Core Libs
FreeType
WebKit Delvik VM
SGL
SSL
libc
Linux Kernel
Na6ve
Libraries
Bionic, a super fast and small license-friendly libc library optimized for embedded use Surface Manager for composing window manager with off-screen buffering 2D and 3D graphics hardware support or software simulation Media codecs offer support for major audio/video codecs SQLite database WebKit library for fast HTML rendering
Applications
Home Contacts Phone Browser Other
Application Framework
Activity Manager Package Manager Window Manager Telephony Manager Resource Manager Content Providers Location Manager View System Notiication Manager
Libraries
Surface Manager OpenGL
Media Framework
SQLite
Android Runtime
Core Libs
FreeType
WebKit Delvik VM
SGL
SSL
libc
Linux Kernel
Dalvik
Dalvik VM is Googles 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
Applica6on
Framework
Activation manager controls the life cycle of the app Content providers encapsulate data that is shared (e.g. contacts) Resource manager manages everything that is not the code Location manager figures out the location of the phone (GPS, GSM, WiFi) Notification manager for events such as arriving messages, appointments, etc
Applications
Home Contacts Phone Browser Other
Application Framework
Activity Manager Package Manager Window Manager Telephony Manager Resource Manager Content Providers Location Manager View System Notiication Manager
Libraries
Surface Manager OpenGL
Media Framework
SQLite
Android Runtime
Core Libs
FreeType
WebKit Delvik VM
SGL
SSL
libc
Linux Kernel
Applica6ons
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. Its a good place for large files, such as movies and music. Everyone can access it.
Security
Each Android application runs inside its own Linux process. Additionally, each application has its own sandbox file system with its own set of preferences and its own database. Other applications cannot access any of its data, unless it is explicitly shared.
Android Application
Linux Process
DB
Prefs
File System
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.
AppRun6meNa6ve Daemon-Lib
Binder IPC
Whats
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)
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.