0% found this document useful (0 votes)
39 views42 pages

Chapter 3 - System Architecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views42 pages

Chapter 3 - System Architecture

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

CHAPTER 3: SYSTEM ARCHITECTURE

Android Architecture: An Overview

Android Dalvik Java Virtual Machine

Android Components: Activities

Android Components: Intents

Android Components: Services

OUTLINE Android Components: Content Providers

Android Application Distribution and Markets

2
 Android is a Linux-based platform for
mobile devices …

 Operating System
 Middleware

 Applications

 Software Development Kit (SDK)


ANDROID … WHAT?
Which kind of mobile devices … (examples)
?

SMARTPHONES TABLETS EREADERS ANDROID TV GOOGLE GLASSES

3
ANDROID MICROWAVE

SMART FRIDGE
ANDROID … WHAT?

SMARTPHONES TABLETS EREADERS ANDROID TV GOOGLE GLASSES


?
4
 Google buys Android from the Android Inch
2005

 Open Handset Alliance (OHA) created for open


2006 standards for mobile devices. Partners of OHA: Google,
Motorola, Samsung, Vodafone, T-Mobile, etc

2007
 Android 1.0 Released

2008  The first Android smartphone: G1 HTC-Dream

 Android 1.1 Released


ANDROID … WHEN?
2009
 Android 1.5 (CupCake) Released
Time

5
 Android 1.6 (Donut) Released
2008
 Android 2.0 (Eclair) Released

2009  Android 2.2 (Froyo) Released

 Android 2.3 (Gingerbread) Released


2010
 Android 3.0 (Honeycomb) Released
(First version for devices with larger screens such as tablets)
2011
 Android 4.0 (Ice-Cream Sandwich) Released. (It merges
the 3.x tab centric design and the v2.x phone based design into a single
ANDROID
2012
… WHEN?
version.)

Time

6
 Android 4.4 (Kitkat) Released
2012

 Wireless printing capability


2013  Ability for applications to use "immersive mode”
 Performance optimization
2014  New experimental runtime virtual machine, ART…

API Level 19 (Android 4.4):


ANDROID 5.0
 Support to new embedded sensors (e.g. STEP_DETECTOR)
 Adaptive video playback functionalities
ANDROID … WHEN?
 Read and write SMS and MMS messages
(managing default text messaging client)
Time

7
ANDROID … WHEN?

2012 Market Share www.gartner.com 2013 Market Share


8
http://opensignal.com/reports/fragmentation-2013/

11,868 different devices in 2013!

ANDROID … WHEN?

9
ANDROID … WHEN?
http://developer.android.com/about/dashboards/index.html
Updated at February 2014

10
http://en.wikipedia.org/wiki/Android_version_history

1.6-2.0
2.2.x
2.3.x

ANDROID VERSION
HISTORY AND POPULARITY

(2009-2013)

ANDROID … WHEN? 4.x

11
ANDROID APP CATEGORIES ANDROID APP PRICE

ANDROID … WHEN?
http://www.appbrain.com/stats/android-market-app-categories http://www.onlinemarketing-trends.com/2011/07/android-
marketplace-top-5-statistics.html

12
} Stack
Architectur
e

THE ANDROID ARCHITECTURE Open Source Architecture


(Apache/MIT License v.
2.0)

Business-friendly License

13
Built on top of
Linux kernel (v. 2.6-
3.4)
Advantages:

 Portability (i.e. easy to


compile on different
hardware architectures)

 Security (e.g. secure


multi-process
THE ANDROID ARCHITECTURE environment)

 Power Management

14
Native Libraries
(C/C++ code)

Graphics (Surface Manager)

Multimedia (Media Framework)

Database DBMS (SQLite)

Font Management
(FreeType)

 WebKit
THE ANDROID ARCHITECTURE C libraries (Bionic)

….

15
Application Libraries
(Core Components of Android)

Activity Manager

Packet Manager

Telephony Manager

Location Manager

Contents Provider

THE ANDROID ARCHITECTURE Notification Manager

….

16
Applications
(Written in Java code)

Android Play Store

Entertainment

Productivity

Personalization

Education

THE ANDROID ARCHITECTURE Geo-communication

….

17
Dalvik Virtual
Machine (VM)
Novel Java Virtual
Machine implementation
(not using the Oracle JVM)

Open License (Oracle


JVM is not open!)

Optimized for memory-


constrained devices

THE ANDROID ARCHITECTURE Faster than Oracle JVM

….

18
Java Source Java Source
Java Standard Edition
Code Code
Java Java
Compiler Compiler
Java Byte Java Byte
Code Code
Dex
Compiler
Stack-based Dalvik Byte
byte-code Code
Register-based
byte-code
DALVIK
JavaJAVA
Virtual VIRTUAL MACHINE (JVM)
Dalvik Virtual
Machine
Machine (VM)
(JVM)

19
APPLICATION DESIGN:

 GUI Definition

 Events Management

 Application Data Management

 Background Operations
ANDROID APPLICATIONS DESIGN
 User Notifications

20
APPLICATION COMPONENTS
 Activities & Fragments

 Intents

 Services

 Content Providers

ANDROID APPLICATIONS DESIGN


 Broadcast Receivers

21
 An Activity corresponds to a single screen
of the Application.
Android HelloWorld
 An
Application can be composed of
Button1 multiples screens (Activities).
Hello World!
 TheHome Activity is shown when the user
launches an application.
ANDROID COMPONENTS: ACTIVITIES
 Different
activities can exhange
information one with each other.
22
 Each activity is composed by a list of graphics components.
 Some of these components (also called Views) can interact
with the user by handling events (e.g. Buttons).
 Two ways to build the graphic interface:
PROGRAMMATIC APPROACH

Example:

Button button=new Button (this);


ANDROID COMPONENTS:
TextView ACTIVITIES
text= new TextView();
text.setText(“Hello world”);

23
 Each activity is composed by a list of graphics components.
 Some of these components (also called Views) can interact
with the user by handling events (e.g. Buttons).
 Two ways to build the graphic interface:
DECLARATIVE APPROACH

Example:

< TextView android.text=@string/hello” android:textcolor=@color/blue


ANDROID COMPONENTS: ACTIVITIES
android:layout_width=“fill_parent” android:layout_height=“wrap_content” />
< Button android.id=“@+id/Button01” android:textcolor=“@color/blue”
android:layout_width=“fill_parent” android:layout_height=“wrap_content” />

24
EXAMPLE

- Build the application layout


through XML files (like HTML)
- Define two different XML layouts
for two different devices
Device 1 Device 2
HIGH screen pixel density LOW screen pixel density - At runtime, Android detects the
current device configuration
Java App Code and loads the appropriate
resources for the application
- No need to recompile!
ANDROID COMPONENTS: ACTIVITIES
- Just add a new XML file if you
need to support a new device
XML Layout File XML Layout File
Device 1 Device 2
25
EXAMPLE SCREEN CONFIGURATION DISTRIBUTION

Device 1 Device 2
HIGH screen pixel density LOW screen pixel density

Java App Code

ANDROID COMPONENTS: ACTIVITIES


XML Layout File XML Layout File
http://developer.android.com/about/dashboards/index.html
Device 1 Device 2
26
 Android applications typically use both the approaches!

DECLARATIVE APPROACH

Define the Application layouts


XML Code and resources used by the
Application (e.g. labels).

PROGRAMMATIC APPROACH

ANDROID COMPONENTS: Manages


ACTIVITIES
the events, and
Java Code handles the interaction with the
user.
27
 Viewscan generate events (caused by human interactions)
that must be managed by the Android-developer.

TextEdit
Button

ESEMPIO

public void onClick(View arg0) {


ANDROID COMPONENTS: ACTIVITIES
if (arg0 == Button) {
// Manage Button events
}
}

28
 The Activity Manager is responsible for
creating, destroying, managing activities.

 Activities can be on different states:


starting, running, stopped, destroyed,
paused.

 Only one activity can be on the running


state at a time.

ANDROID COMPONENTS:
 Activities areACTIVITIES
organized on a stack, and
have an event-driven life cycle (details later
…)

29
 Main difference between Android-programming and Java
(Oracle) -programming:

 Mobile devices have constrained resource capabilities!

 Activity lifetime depends on users’ choice (i.e. change of


visibility) as well as on system contraints (i.e. memory
shortage).
ANDROID COMPONENTS: ACTIVITIES
 Developer must implement lifecycle methods to account
for state changes of each Activity …
30
Called when the Activity
public class MyApp extends Activity { is created the first time.

public void onCreate() { ... }


Called when the Activity
public void onPause() { ... } is partially visible.

public void onStop() { ... }


public void onDestroy(){ ... } Called when the Activity
is no longer visible.
….
ANDROID
} COMPONENTS: ACTIVITIES
Called when the Activity
is dismissed.

31
 Intents:
asynchronous messages to activate core
Android components (e.g. Activities).
 Explicit
Intent  The component (e.g. Activity1) specifies
the destination of the intent (e.g. Activity 2).

LOGIN Welcome Marco!


marco
Activity1

Activity2
PASSWORD

ANDROID COMPONENTS: INTENTS


**********

Login Intent
Login

32
 Intents:
asynchronous messages to activate core
Android components (e.g. Activities).
 ImplicitIntent  The component (e.g. Activity1) specifies
the type of the intent (e.g. “View a video”).

Activity2
Multiple choices
might be available

}
Activity1

to the user!
Intent-
View Filters
ANDROID COMPONENTS: INTENTS
Implicit Intent

Activity2
33
 Services: like Activities, but run in background and do not provide
an user interface.
 Used for non-interactive tasks (e.g. networking).
 Service life-time composed of 3 states:

Starting Destroyed

onCreate()
onDestroy()
onStart()
ANDROID COMPONENTS: SERVICES
Running

(on background)

34
ANDROID COMPONENTS: CONTENT PROVIDERS

 Each Android application has its own private set of data


(managed through files or through SQLite database).
 Content Providers: Standard interface to access and
share data among different applications.

insert()
APP
update()
Content
delete( Provider DB
)
query() e.g. Photo
Gallery

35
ANDROID COMPONENTS: BROADCAST RECEIVERS

 Publish/Subscribe
paradigm

 Broadcast Receivers:
An application can
be signaled of
external events.

 Notification types:
Call incoming, SMS
delivery, Wifi network
detected, etc
36
ANDROID COMPONENTS: BROADCAST RECEIVERS

BROADCAST RECEIVER example


class WifiReceiver extends BroadcastReceiver {
public void onReceive(Context c, Intent intent) {
String s = new StringBuilder();
wifiList = mainWifi.getScanResults();
for(int i = 0; i < wifiList.size(); i++){
s.append(new Integer(i+1).toString() + ".");
s.append((wifiList.get(i)).toString());
s.append("\\n");
}
mainText.setText(sb);
}
}
37
ANDROID COMPONENTS: SYSTEM API

Using the components described so far, Android


applications can then leverage the system API …
SOME EXAMPLEs …

 Telephony Manager data access (call, SMS, etc)


 Sensor management (GPS, accelerometer, etc)
 Network connectivity (Wifi, bluetooth, NFC, etc)
 Web surfing (HTTP client, WebView, etc)
 Storage management (files, SQLite db, etc)
 ….
38
ANDROID COMPONENTS: GOOGLE API

… or easily interface with other Google services:

39
Android Application Distribution

Each Android application is contained on a single


APK 
APK file.
FILE
 Java Byte-code (compiled for Dalvik JVM)

 Resources (e.g. images. videos, XML layout files)

XML C  Libraries (optimal native C/C++ code)


Files

40
ANDROID APPLICATION DISTRIBUTION

 Each application must be


signed through a key before
being distributed.

 Applications can be distributed


via Web or via Stores.

 Android Play Store: application


store run by Google … but
several other application stores
are available (they are just
normal applications).
41
ANDROID APPLICATION SECURITY

 Android applications run with a distinct system identity


(Linux user ID and group ID), in an isolated way.
 Applications must explicitly share resources and data.
They do this by declaring the permissions they need for
additional capabilities.
 Applications statically declare the permissions they require.
 User must give his/her consensus during the installation.
ANDROIDMANIFEST.XML

<uses-permission android:name=“android.permission.IACCESS_FINE_LOCATION" />

<uses-permission android:name=“android.permission.INTERNET" />

42

You might also like