8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 1/31
© William W.-Y. Liang @ NTUT CSIE
Note: The Copyrights of the referenced slides go to its original author listed in each slide.
As a result, this slide is provided for internal reference only!
System Integration for
the Android Operating SystemWilliam W.-Y. Liang (梁文耀), Ph. D. Assistant Professor
Dept. Computer Science and Information EngineeringNational Taipei University of Technology
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 2/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
Android Handsets
2SJU 2004-04 Android
Motorola CliqHTC G1 HTC HeroSamsung i7500
Samsung Moment Motorola Droid HTC Magic HTC Tattoo
Sony X10
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 3/31
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 4/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
2010 Prediction
4SJU 2004-04 Android
資料來源:DIGITIMES,2009/12
Near 9% Increment
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 5/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
A Prediction by Gartner
5SJU 2004-04 Android
Android currently runs on less than 2% of all smartphones.
Predicted forecast for smartphone OS‟s by
2012: Symbian, 203 million devices sold (39% of the
market)
Android, 76 million devices sold (14.5% of the
market)
iPhone, 71.5 million devices sold (13.7% ofthe market)
Windows Mobile, 68.8 million devices sold
(12.8% of the market)
BlackBerry, 62.25 million devices sold (12.5%
of the market) Palm‟s WebOS, 11 million devices sold (2.1%
of the market)
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 6/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
6SJU 2004-04 Android
About Android
Based on Slides in “Discussion on Android”, Mobile SIG, Larry Copeland ©
Android is a software platform and operating system mainly formobile devices based on the Linux operating systemdeveloped by Google and later the Open Handset Alliance.
It allows developers to write managed application code in Javalanguage that utilizes Google-developed Java libraries.
The unveiling of the Android platform on 5 November 2007 was
announced with the founding of the Open Handset Alliance(OHA), a consortium of 34 hardware, software, and telecomcompanies, such as Qualcomm, TI, Broadcom, Intel, Marvell,Nvidia, SiRF, WindRiver, T-Mobile, Sprint Nextel, China Mobile,KDDI, NTT DoCoMo, Motorola, Samsung, HTC, etc., devotedto advancing open standards for mobile devices.
Google has made most of the Android platform available underthe Apache free-software and open-source license, in Oct.2008 (to prevent the „GPL obstacle‟ problem in commercializingopen sources for industry companies.)
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 7/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
7SJU 2004-04 Android
The First Complete Android Phone
T-Mobile G1
Qualcomm® MSM7201A™, 528 MHz ROM: 256 MB, RAM: 192 MB Touch screen (320x480) Real Web browsing capabilities 3.2 MP camera
Customizable screen QWERTY keyboard Trackball 3G WCDMA, Quad-band GSM, Wi-Fi, Bluetooth 2.0
Software:
Easy access to Google applications
Maps (including satellite, traffic, and
street views), Gmail, YouTube,
Calendar, Google Talk
IM/text/e-mail
Music player, Video playback
One-click Google Search
Android Market
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 8/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
Google Nexus One
8SJU 2004-04 Android
Source:http://blog.xuite.net/jon6773/blog/29930408
Estimated BOM Cost: US$174
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 9/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
SJU 2004-04 Android
Android Architecture
99
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 10/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
10SJU 2004-04 Android
The Linux Kernel
Based on Slides in “Smart Phone”, by Xiaohua Du and Xiaoyi Sheng ©
Android differs from the typical GNU/Linux in that
it adopts only the Linux kernel, not everything.
The first process „init‟ transfers to Android‟s own
application environment.
There is no shell by default, except using adb.
BSD libc is used instead of glibc or uClibc.
As a result, it is called Android/Linux, not
GNU/Linux.
Why Linux?
• Great memory and process management
• Permissions-based security model
• Proven driver model
• Support for shared libraries
• It‟s already open source!
Android relies on Linux version 2.6 for core systemservices such as security, memory management, processmanagement, network stack, and driver model.
Android relies on Linux version 2.6.25 and above for Android releases (1.0, 1.1, 1.5, and 2.0).
The kernel also acts as an abstraction layer between thehardware and the rest of the software stack.
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 11/31
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 12/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
12SJU 2004-04 Android
Development Tools for Android Applications
Currently supported development platforms include x86-basedcomputers running Linux (any Linux Distribution), Mac OS X 10.4.8 orlater, Windows XP or Vista.
The Android SDK includes a comprehensive set of developmenttools, including a debugger, libraries, a handset emulator (QEMU),documentations, sample code, and tutorials.
http://developer.android.com/sdk/
Android Virtual Device (AVD)
Requirements also include Java Development Kit (JDK 5 or 6).
The officially supported integrated development environment (IDE) isEclipse (3.3 or 3.4) with the Android Development Tools (ADT) plugin.
http://www.eclipse.org/downloads/
Eclipse Android Plug-in: https://dl-ssl.google.com/android/eclipse/
Android Developer‟s Website
http://developer.android.com/index.html
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 13/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
13SJU 2004-04 Android
The IDE for Android
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 14/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
14SJU 2004-04 Android
Android SDK
Based on slides from GreenLiff ©
ADT: Android Development Tool, an Eclipe plugin
Two debuggers
adb: Android Debug Bridge
ddms: Dalvik Debug Monitor Server
aapk : Android Application package tool
All resources are bundled into an archive, called apk file.
dx : java byte code to Dalvik executable translator
Android emulator : QEMU
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 15/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
15SJU 2004-04 Android
Major Elements in Application Framework
Activity
Intent and Intent-Filter
Service
Content Provider
Broadcast Receiver
ActivitiesUI component typically
corresponding to one screen.
BroadcastReceivers Respond to broadcast Intents.
ServicesFaceless tasks that run in the
background.
ContentProvidersEnable applications to share
data.
Android Version API Level Release Time
2.1 7 2010.01
2.0.1 6 2009.12
2.0 5 2009.101.6 4 2009.09
1.5 3 2009.04
1.1 2 2009.02
1.0 1 2008.09
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 16/31
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 17/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
Activity (cont‟d)
Each activity is given a default window to draw in. Typically, the
window fills the screen, but it might be smaller than the screen andfloat on top of other windows.
The visual content of the window is provided by a hierarchy of views— objects derived from the base View class.
Android has a number of ready-made views that you can use — including buttons, text fields, scroll bars, menu items, check boxes,and more.
A view hierarchy is placed within an activity's window bythe Activi ty.setContentView () method. The content view is the Viewobject at the root of the hierarchy.
17SJU 2004-04 Android
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 18/31 NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
User Interface
18SJU 2004-04 Android
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 19/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
19SJU 2004-04 Android
Life Cycle of an Activity
Life cycle not directly controlledby application
System can kill an application tofree up memory.
Controll through onCreate(),onPause(), onStop() ... methods
Based on Slides from GreenLiff ©
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 20/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
An Example
20SJU 2004-04 Android
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 21/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
21SJU 2004-04 Android
Intents/Intent Filters
Slides from “Deep inside Android,” Gilles Printemps, Esmertec ©
Example:
Intent newActivity = new Intent (MyActivity.this, OtherActivity.class);
star tAct iv i ty( newActivity);
Provide a late runtime (asynchronous) binding between the code in
different applications (for activities, services, and broadcast receivers) Intents: Simple message objects that represent an intention to do
something
Intent Filters: A declaration of capacity and interest in offeringassistance to those in need
An “intent” is made up a number of pieces of information describing
the action or the service. (Specifically for activities and services) action -- The general action to be performed, such as
ACTION_VIEW, ACTION_EDIT, ACTION_MAIN, etc.
data -- The data to operate on, such as a person record in thecontacts database, expressed as a URI (Universe ResourceIdentifier).
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 22/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
22SJU 2004-04 Android
Services
Similar to activities, but without UI
For long-running background tasks
Framework “Service” class must be extended
Slides from “Deep inside Android,” Gilles Printemps, Esmertec ©
Exampe:startService(new Intent(this_activity.this, some_service.class));
Core Services
Activity Manager
Package Manager
Window Manager
Resource Manager
Content Providers
View System
Hardware Services
Telephony Service
Location Service
Bluetooth Service
WiFi Service
USB Service
Sensor Service
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 23/31
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 24/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
24
Binder Example
SJU 2004-04 Android
Activity
Mp3PlayerWithService
Service
mp3Service
Binder
Mp3PlayerBinder
IBinder
A more complex IPC: AIDL - Android
Interface Definition Language
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 25/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
The Library Layer
25SJU 2004-04 Android
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 26/31
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 27/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
27SJU 2004-04 Android
Example
Slides from "Android Anatomy and Physiology," Patrick Brady ©
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 28/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
Traditional Linux Model vs. Android Model
28SJU 2004-04 Android
native C program
glibc & shared libs
Kernel
Hardware
System call
Hardware
System call
Kernel
JNI
bionic & shared libs
Android Framework
Application Service
getService ()
JNI Method
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 29/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
Shared Library
29SJU 2004-04 Android
class HelloWorld {
public native void helloworld();
static {System.loadLibrary("hello");
}
public static void main(String[] args) {
new HelloWorld().helloworld();
}
}
JNI: Java Native InterfaceStandard interface between Java and C/C++
Libraries offer some form of sharing, allowing the samelibrary to be used by multiple programs at the same time.
Dynamic loading
Sharing
Examples
DLL (Dynamic Link Library): Windows
SO (Shared Object): Linux/Unix
8/12/2019 Android System Integration (SJU 2010.04)
http://slidepdf.com/reader/full/android-system-integration-sju-201004 30/31
NTUT CSIE 嵌 式 平行系統實驗室
© William W.-Y. Liang @ NTUT CSIE
30SJU 2004-04 Android
Hardware Abstraction Layer
Slides from "Android Anatomy and Physiology," Patrick Brady ©
Recommended