You are on page 1of 25

Android: An Open Software

Platform for Mobile Devices


CHEN Xinyu

2011-08-01
Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Outline
What is Android? Android application components Android boot sequence Binder: Inter-process communication Conclusion

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Various OSs for Mobile Devices


Googles Android Open Source Apples iOS Microsofts Windows Phone RIMs BlackBerry OS

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Android History
Google acquired Android Inc. in Aug. 2005 Open Handset Alliance: Nov. 2007

Google, Intel, Motorola, Nvidia, Samsung, TI,

1.0 : Oct. 2008 2.3 Gingerbread: Dec. 2010 3.0 Honeycomb: Feb. 2011

A tablet-oriented release

3.2 Honeycomb: July 2011

Cloud Client?
4

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Android is not GNU/Linux

Based on Linux kernel 2.6.*


Open source Memory management, Process management Permission-based security model Driver model Shared libraries

No native windowing system No glibc support

Bionic libc: custom libc implementation, optimized for embedded use Apache license, version 2

GPL (GNU General Public License)?

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Android Architecture
APPLICATIONS (Java)
Home Screen Phone Browser

APPLICATION FRAMEWORK (Java/JNI)


Activity Manager Window Manager Content Providers Notification Manager

Package Manager Telephony Manager Resource Manager Location Manager

View System

NATIVE LIBRARIES (C/C++)


Surface Manager Media Framework

ANDROID RUNTIME
Core Libraries (Java) Dalvik Virtual Machine

SQLite
WebKit libc

OpenGL | ES SGL

FreeType SSL

LINUX KERNEL (C)


Display Driver Keypad Driver Camera Driver WiFi Driver Flash Memory Driver Audio Drivers Binder (IPC) Driver Power Management
6

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Android Software Development

SDK (Software Development Kit): Java

Tools and APIs to begin developing applications


Eclipse plug-in QEMU-based handset emulator

NDK (Native Development Kit): C/C++

Build applications in native code

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Outline
What is Android? Android application components Android boot sequence Binder: Inter-process communication Conclusion

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Android Application
Android application is component-based .apk

Application manifest
AndroidManifest.xml

Every Android application runs in its own process

with its own instance of the Dalvik VM

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Application Building Blocks


Activity

Service
Content Provider

Broadcast Receiver

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

10

(1) Activity

Activity Manager

View System

The presentation layer of Android application Every screen or window is an extension of the android.app.Activity class Activities use Views to form GUI

All UI controls are derived from android.view.View

android.widget.Button, TextView, ListView, CheckBox,

Activity Manager controls the lifecycle of activities

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

11

The Activity Lifecycle

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

12

Intent

A message-passing mechanism

Declare intentions to start new activities


explicitly: specifying the class to load implicitly: requesting that an action be performed on a piece of data

Broadcast messages across system


Encourage the decoupling of components Allow the seamless replacement of application elements

Using Intents to propagate actions


Intent intent = new Intent(MyActivity.this, MyOtherActivity.class); startActivity(intent); Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:31634257")); startActivity(intent);
Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

13

(2) Service
android.app.Service Faceless components that run in the background Used to perform regular processing that needs to continue even when applications Activities arent active or visible E.g. music player, network download, etc.

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

14

(3) Content Provider

Content Providers

android.content.ContentProvider Shareable data store Provide an interface for publishing and consuming data

Based around a simple URI addressing model using the content:// schema

Decouple the application layer from the data layer Native Content Providers

Contact, Media store,


15

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

(4) Broadcast Receiver


android.content.BroadcastReceiver Intent broadcast consumer

SMS message received incoming phone call

Like global event listener

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

16

Outline
What is Android? Android application components Android boot sequence Binder: Inter-process communication Conclusion

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

17

Android Boot Sequence


System Server Activity Manager registration Android Runtime

adbd rild debuggerd usbd


Daemons Daemons Daemons

Package Manager

Home
Home Dalvik VM

Service Manager

Dalvik VM

Zygote Zygote provides fork service through socket

Contacts fork Contacts Dalvik VM


18

Init Linux Kernel

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

Outline
What is Android? Android application components Android boot sequence Binder: Inter-process communication Conclusion

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

19

Android Task
Process A Task
Activity

Process B
Activity

Activity

Content Provider
.apk package

Service

.apk package

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

20

IPC (Inter-Process Communication)

Linux/UNIX

Semaphore Message queue Shared memory Signal Pipe Socket Binder

Android

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

21

Android Binder

Driver to facilitate IPC


Light-weight CORBA Client-server

High performance through shared memory Per-process thread pool for processing requests Mapping of object references across processes Android Interface Definition Language (AIDL)

Objects are stored within an android.os.Parcel

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

22

Binder
Client
IXXX

Service Manager
service list

Server
onTransact()
thread pool

Name:Handle
Name:Handle Name:Handle

Handle=0 transact()

User Space Kernel Space

Binder Driver: /dev/binder


memory mapping
Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

23

Conclusions
Android is a software platform for mobile devices working as cloud clients Android is not GNU/Linux Android application is component-based

Activity, Service, Content Provider, Broadcast Receiver

Android uses Zygote to fork processes Android Binder driver is its IPC mechanism

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

24

Dept. of Computer Science & Engineering, The Chinese University of Hong Kong

25

You might also like