Android - Department of Computer Science and Engineering - The ...

stuckwarmersMobile - Wireless

Dec 14, 2013 (3 years and 7 months ago)

208 views

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

Android
: An Open Software
Platform for Mobile Devices

CHEN Xinyu



2011
-
08
-
01

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

2

Outline

What is Android?

Android application components

Android boot sequence

Binder: Inter
-
process communication

Conclusion

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

3

Various OSs for Mobile Devices


Google’s
Android


Apple’s
iOS


Microsoft’s
Windows Phone


RIM’s
BlackBerry OS

3

Open Source

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

4

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

5

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


GPL (GNU General Public License)?


Apache license, version 2

5

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

6

Android Architecture

6

APPLICATION FRAMEWORK (Java/JNI)

Activity Manager

Window Manager

Content Providers

View System

Package Manager

Telephony Manager

Resource Manager

Location Manager

Notification Manager

APPLICATIONS (Java)

Home

Screen

Phone

Browser



ANDROID RUNTIME

Dalvik Virtual Machine

Core Libraries (Java)

NATIVE LIBRARIES (C/C++)

Surface Manager

OpenGL | ES

SGL

FreeType

SSL

SQLite

WebKit

libc

Media Framework

LINUX KERNEL (C)

Display Driver

Camera Driver

Flash Memory Driver

Binder (IPC) Driver

Keypad Driver

WiFi Driver

Audio Drivers

Power Management

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

7

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

7

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

8

8

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

9

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

9

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

10

Application Building Blocks

10

Activity

Service

Content
Provider

Broadcast
Receiver

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

11

(1) Activity


The presentation layer of Android application


Every screen or window is an extension of the
android.app.Activity

class


Activities use
View
s 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

View System

Activity Manager

11

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

12

The Activity Lifecycle

12

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

13

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


Using Intents to propagate actions


Encourage the decoupling of components


Allow the seamless replacement of application elements

Intent intent = new Intent(MyActivity.this, MyOtherActivity.class);

startActivity(intent);

Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:31634257"));

startActivity(intent);

13

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

14

(2) Service


android.app.Service


Faceless components that run in the
background


Used to perform regular processing that needs
to continue even when application’s Activities
aren’t active or visible


E.g. music player, network download, etc.


14

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

15

(3) Content Provider


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, …

Content Providers

15

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

16

(4) Broadcast Receiver


android.content.BroadcastReceiver


Intent broadcast consumer


“SMS message received”


“incoming phone call”


Like global event listener

16

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

17

17

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

18

Android Boot Sequence

18

Init

Zygote

Service
Manager

System Server

Dalvik VM

Activity Manager

Package Manager



Home

Dalvik VM

Home

Contacts

Dalvik VM

Contacts

Daemons

Daemons

Daemons

adbd

rild

debuggerd

usbd



Zygote provides fork
service through socket

registration

fork

Linux Kernel

Android Runtime

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

19

19

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

20

Android Task

Process A

Process B

Task

Activity

Activity

.apk package

.apk package

Content
Provider

Activity

Service

20

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

21

IPC (Inter
-
Process Communication)


Linux/UNIX


Semaphore


Message queue


Shared memory


Signal


Pipe


Socket


Android


Binder

21

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

22

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

22

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

23

Client

Binder

Server

Service Manager

Binder Driver: /dev/binder

Kernel Space

User Space

Handle=0

Name:Handle

Name:Handle

Name:Handle

service list

IXXX

onTransact(…)

thread pool

memory mapping

transact(…)

23

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

24

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

24

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

25

25