Professional Documents
Culture Documents
Android Michaelmorckos May 13 09
Android Michaelmorckos May 13 09
Android Architecture
Michael Y. Morckos
German Univeristy in Cairo
Michael Y. Morckos
Android Architecture
What is Android
What is Android
Android is an operating system for mobile devices Its an integrated open source software stack for mobile device
Operating system Middleware Key mobile applications
Went open source in late 2008. Released under the Apache v2 license
Michael Y. Morckos
Android Architecture
What is Android
History
Michael Y. Morckos
Android Architecture
What is Android
History
Google acquired Android Inc. in July 2005 The Android team, led by Andy Rubin, developed a mobile device platform powered by Linux operating system
Michael Y. Morckos
Android Architecture
What is Android
History
Google acquired Android Inc. in July 2005 The Android team, led by Andy Rubin, developed a mobile device platform powered by Linux operating system This signaled Googles entry into the mobile-phone market
Michael Y. Morckos
Android Architecture
What is Android
Michael Y. Morckos
Android Architecture
What is Android
Michael Y. Morckos
Android Architecture
What is Android
Michael Y. Morckos
Android Architecture
What is Android
Michael Y. Morckos
Android Architecture
What is Android
Michael Y. Morckos
Android Architecture
What is Android
Innovative Features
Linux kernel Open system Component based Java programming language for applications development Enable mobile applications to exploit full advantage of all a handset has to oer No boundaries Fast & easy development
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Contents
Overview Linux Kernel Android Runtime Android Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Android Stack
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Android Architecture
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Kernel
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Overview
Android uses a heavily modied GNU/Linux kernel version 2.6 for handling core system infrastructure services as security, memory management, process management, network stack, and driver model The kernel provides an abstraction layer between the hardware and the rest of the software stack Include many enhancements and modications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
A light-weight power managemenr driver built atop the standard linux power management Constrainted power management policy
CPU shouldnt consume power if no applications or services require power Components make requests to keep the power on through Wake Locks
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Binder
An OpenBinder-based driver to facilitate inter-process communication (IPC) on the Android platform OpenBinder provides:
High performance through shared memory Per-process thread pool for processing requests Synchronous calls between processes
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Memory Management
Low Memory Killer: based on feedbacks from user applications, the low memory killer can kill processes to free up memory as necessary Provides more exibility than the Out Of Memory (OOM) killer in the standard kernel Android PMEM: the PMEM (physical memory) driver is used to provide contiguous physical memory regions to userspace libraries that interact with the processor and other hardware
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Other Components
Logger: A light weight logging device used to capture system, radio, logdata, etc. Android Alarm: A driver which provides timers that can wake the device up from sleep and a monotonic timebase that runs while the device is asleep M-Systems: for memory cards and other ash media storage Other conventional drivers:
Bluetooth Display Keypad Audio ...
Michael Y. Morckos Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Runtime
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Overview
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Overview
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
One of the most important components in Android Developed by Dan Bornstein, and named after the Dalvik village in Iceland
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
One of the most important components in Android Developed by Dan Bornstein, and named after the Dalvik village in Iceland Three main design targets:
runs on a limited CPU and RAM (250-500MHz) (20-40 MB) runs atop an OS with no swap space runs on a device with limited power
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Dalvik Features
Highly CPU optimized interpreter No just-in-time compiling Shared constants pool and data structures Static linking Bytes reordering
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Core Libraries
Androids core libraries provide most of the functionality available in the core libraries of Java needed for applications development:
I/O functionalities Collections File access ...
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Native Libraries
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Overview
This layer houses the core libraries providing the bulk of Android functionalities Implemented in C/C++ Developers can exploit the full capabilities of these libs through the application framework layer
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Bionic (libC)
A BSD-based implementation of the standard C library, tuned for embedded Linux-based devices 200 KB in size, roughly half the size of the standard GNU C library libc Bionic includes a very fast and small custom POSIX-thread implementation Compatability issue with GNU libc
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
SQLite
A powerful lightweight embedded relational database management system contained in a relatively small ( 500 kb) C library The engine is not a standalone entity. Instead, a SQLite database is just another program linked in and thus becomes an integral part of the program The database is stored as a single cross-platform le on the host machine Application access SQLite through conventional simple function calls
Michael Y. Morckos Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Surface Manager
Responsible for composing dierent drawing surfaces on the mobile screen Manages access for dierent processes to the underlying display subsystem and composites 2D and 3D graphic layers from multiple applications Layers passed as buers via Binder IPC calls Use OpenGL/ES and 2D hardware accelerator for its compositions
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Subset of the OpenGL 3D graphics API designed for embedded devices Dened and promoted by the Khronos Group, a graphics hardware and software industry consortium Can use either hardware 3D acceleration (hardware dependent) or the included highly optimized 3D software rasterize SGL is Androids specialized 2D graphics library
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Media Framework
Provided by PacketVideos multimedia package OpenCore The OpenCore provides a universal structure for mobile multimedia applications Support for standard video, audio, still-frame formats (MPEG4, MP3, AAC, AMR, JPG, and PNG, H.264) Support for codec plug-ins
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
FreeType
Implements a font rasterization engine Written in C It is used to rasterize characters into bitmaps and provides support for other font-related operations
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
LibWebCore (WebKit)
A framework providing the basis for building a web browser based on the open source WebKit browser Written in C++ Rendering of pages in full (desktop) view Support for modern web technologies; CSS, JavaScript, DOM, AJAX
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Framework Overview
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Overview
A general purpose toolkit that all applications use Written in Java Enable reuse and replacement of components
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
View System
Enabling applications to access data from other applications or to share their own data
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Resource Manager
Providing access to non-code resources (localized string, graphics, and layout les)
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Notication Manager
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Activity Manager
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Telephony Manager
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
XMPP Service
An Open, XML-based protocol originally aimed at near-real-time, extensible instant messaging Largely extended. VoIP Aims to:
Send simple P2P message between handsets Send and receive IMs using Googles Talk
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Location Manager
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Window Manager
The window manager creates display surfaces for the application Responsible for organizing the screen and display of dierent layers of application
Michael Y. Morckos
Android Architecture
Contents Overview Linux Kernel Android Runtime Native Libraries Application Framework Applications
Applications
Android comes with a bundle of core applications: email client SMS program calendar maps browser contacts ...
Michael Y. Morckos
Android Architecture
Overview
Michael Y. Morckos
Android Architecture
Overview
Written in Java (as you know) The compiled application is bundled by the aapt tool into an Android package .apk
Michael Y. Morckos
Android Architecture
Overview
Written in Java (as you know) The compiled application is bundled by the aapt tool into an Android package .apk Like .jad & .jar in J2ME, .apk les are distributed and installed on Android powered devices
Michael Y. Morckos
Android Architecture
Basic Facts
Every application: is a single Linux process has its own VM instance is assigned a unique Linux user ID
Michael Y. Morckos
Android Architecture
Basic Facts
A key feature of Android is that applications can publish their functionalities An application can use other functionalities provided by other applications Android applications dont have a single entry point
Michael Y. Morckos
Android Architecture
Application Diagram
Michael Y. Morckos
Android Architecture
Activities
Class in the API An activity presents the user with a visual UI for a specic functionality Application can have several activities Each activity is given a default window to draw in The visual content of the window is provided by a hierarchy of views User interacts with activities through the views Android provides several built-in views:
Buttons Menus Text elds ...
Michael Y. Morckos Android Architecture
Services
Michael Y. Morckos
Android Architecture
Content Provider
Provides applications with required applications data Data stored in a SQLite DB Applications talk to content provider through a content resolver
Michael Y. Morckos
Android Architecture
Broadcast Receiver
Receive and react to broadcast announcements Many originate from system level Persistent
Michael Y. Morckos
Android Architecture
Activation
Content providers are activated when targeted by applications (implicit activation) Broadcast receivers are activated when receiving Services and activities are activated by intent msgs Intent messages contains ID of component to be activated + URI of data to be used Intent lters
Michael Y. Morckos
Android Architecture
Deactivation
Content providers and broadcast receivers are shut down once they are done Activities and services require explicit shutdown Components might also be shut down by the system to reclaim memory for higher priority components (life cycle)
Michael Y. Morckos
Android Architecture
Tasks
Dierent activities can be activated on demand A group of activities composes a task. They are maintained in a stack Users experience of an application can actually be a task consisting of dierent activities from dierent applications Can have a stack of tasks as well
Michael Y. Morckos
Android Architecture
Activity
Activities can be in one of these states at an instance: Active: has the users focus, displayed in the foreground Paused: still visible but under another active activity Stopped: completely obscured by another activity, no longer visible If an activity is paused or stopped, the system can drop it from memory. When the user returns to it, the system must restore it to its previous state
Michael Y. Morckos
Android Architecture
Activity
Entire lifetime: from the moment the activity is created till destroyed Visible lifetime: from the moment the activity activated till stopped Foreground lifetime: between resuming and pausing an activity
Michael Y. Morckos
Android Architecture
Activity Lifecycle
Michael Y. Morckos
Android Architecture
Service
Services can be shutdown explicity or implicitly Entire lifetime: from creation till destruction Active lifetime: from activation
Michael Y. Morckos
Android Architecture
Broadcast Receiver
Broadcast receiver is active when receiving and reacting to a notication A process with an active broadcast receiver is protected from being killed Active lifetime: from activation
Michael Y. Morckos
Android Architecture
Overview
The SDK includes a full set of tools for developing and debugging application Designing UIs Major components in version 1.5:
Android Development Tools Plugin (for the Eclipse IDE) Android Emulator Android Virtual Devices (AVDs); speciying dierent platform, hardware options, skins... Dalvik Debug Monitor Service (ddms) Android Asset Packaging Tool (aapt) sqlite3 dx tool
Michael Y. Morckos Android Architecture
Michael Y. Morckos
Android Architecture
Summary
Michael Y. Morckos
Android Architecture
Android Closing...
Michael Y. Morckos
Android Architecture
References
http://developer.android.com/ http://androidlinux.com/ http://www.dalvikvm.com/ http://www.bindaaspoll.com/googleandroid/index.htm http://benno.id.au/blog/2007/11/26/what-is-android http://it.toolbox.com/wiki/index.php/Dalvik virtual machine http://blog.codebeach.com/2007/11/android-architectureoverview.html http://stuthathappens.com/blog/2009/04/12/google-io2008-dalvik-virtual-machine-internals/
Michael Y. Morckos Android Architecture
References
http://www.kandroid.org/android pdk/intro source code.html http://sites.google.com/site/io/dalvik-vm-internals http://www.brighthub.com/mobile/googleandroid/articles/17822.aspx http://glab.wordpress.com/2008/05/21/android-a-quickoverview/ http://moss.csc.ncsu.edu/ mueller/g1/slides/platform.ppt http://www.softdevtube.com/2008/09/16/inside-the-androidapplication-framework/ http://groups.google.com/group/androidframework/browse thread/thread/34a635dd68c8b4f4
Michael Y. Morckos Android Architecture