0% found this document useful (0 votes)
52 views

Unit 2

The document discusses the architecture of the Android operating system, which consists of layers including the Linux kernel, hardware abstraction layer, native libraries, Android runtime, application framework, and application layer. It describes the role and components of each layer.

Uploaded by

Leah Gabriel
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)
52 views

Unit 2

The document discusses the architecture of the Android operating system, which consists of layers including the Linux kernel, hardware abstraction layer, native libraries, Android runtime, application framework, and application layer. It describes the role and components of each layer.

Uploaded by

Leah Gabriel
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/ 11

UNIT 2 ANDROID ARCHITECTURE

2.0 Introduction
2.1 Objectives
2.2Android Architecture
2.2.1Check Your Progress
2.2.2Video V3: Android Architecture
2.2.3 Check Your Progress
2.3 Types of mobile applications
2.3.1Check Your Progress
2.4 Application Fundamentals
2.5 Summary
2.6Further Readings

2.0 INTRODUCTION

This unit gives you an overview of the basic internal architecture of Android. The first
part of this unit focuses on the Android architecture and the application framework,
which developers can leverage in developing Android applications. Later it discusses
different types of mobile applications with their pros and cons. This unit has one video
that you need to watch and three activities to complete.

2.1 OBJECTIVES

After studying this unit, you should be able to :

 illustrate the components of Android Operating System.


 differentiate mobile application development.
 identify the components provided by the application framework.
Outcomes

Linux: Name of the operating system that Android is


built on

Dalvik: Runtime and Virtual Machine used by the Android


Terminology system for running Android applications

Native app: apps that are fully programmed in the


development environment specific to each
operating system

ART: (Android Run Time ) is the successor of Dalvik and


used in latest versions of Android

19
Android Architecture
2.2 ANDROID ARCHITECTURE

The architecture of an Android system is a collection of different layers. Each layer


has a specific role and set of functionality. Each layer provides the functionality to the
layer above it.

As you can see in the Figure 2.1 that Android Architecture (also called Software
Stack) has the following layers:

 Linux Kernel
 Hardware Abstraction Layer (HAL)
 Native Libraries
 Android Run Time
 Android Application Framework
 Application Layer

Figure 2.1: Android System Architecture


(Source: https://source.android.com/source/index.html)
Let us discuss each layer one by one.

Linux Kernel
Android is designed on the top of Linux Kernel which is an open source operating
system as explained in the previous unit.

Basic services like process management, memory management, security management,


power management and providing hardware driver for different devices (like
Bluetooth, WI-FI, Camera etc.) are managed by Linux Kernel as in Figure 2.2.

Figure 2.2: Linux kernel


(Source: http://androidfulcrum.blogspot.com/2014/02/what-is-android-architecture.html)

20
Linux Kernel never really interacts with the users and developers, but is at the heart of Features of Android
the whole system. Its importance stems from the fact that it provides the following
functions in the Android system:

 Hardware abstraction
 Memory management programs
 Security settings
 Power management software
 Other hardware drivers (Drivers are programs that control hardware devices.)
 Support for shared libraries
 Network stack
In this section we have learned how Linux is involved with Android. Now you need to
complete the given activity before reading further in this unit.

2.2.1 Check Your Progress


Explain the role of Linux Kernel in Android

Hardware Abstraction Layer (HAL)


The Hardware Abstraction Layer (HAL) provides an interface for hardware vendors to
define and implement the drivers for specific hardware without affecting lower level
features. HAL implementations are packaged into modules, you will find these as files
with .so extension and loaded by the Android system at the appropriate time. Figure
2.3 shows the components of Hardware abstraction layer (HAL).

Figure 2.3: Hardware abstraction layer (HAL) components

(Source: https://source.android.com/source/index.html)

Native Libraries
Native libraries run over the HAL and it consist various C / C++ library like libc. It
also includes following standard libraries:

 Secure Sockets Layer (SSL):It is responsible for Internet security.


 Graphics Library: OpenGL and SGL used to create 2D and 3D graphics.
 WebKit: It is open source web browser engine that gives the functionality to
render the web content.
21
Android Architecture  SQLite: This is an open source relational database management system which
is designed to be embedded in Android devices.
 Media Library: These libraries are used to play the audio/video media etc.

The following Figure 2.4 shows the Android library layer and its components.

Figure 2.4: Android Libraries Layer

(Source: http://androidfulcrum.blogspot.com/2014/02/what-is-android-architecture.html)

Libraries carry a set of instructions to guide the device in handling different types of
data. For instance, the playback and recording of various audio and video formats is
guided by the Media Framework Library. This layer enables the device to handle
different types of data with the use of these libraries.

Dalvik Virtual Machine (DVM)


It is a modified Java virtual machine (JVM) which is introduced for low end devices
to run application objects efficiently. It is a register based virtual machine that
isoptimized to run multiple objects efficiently. It depends on the Linux kernel for
efficiently execute the instances because memory management and thread
management is part of the Linux kernel. DVM executes the Dalvik Executable Code
(.dex), which is optimized to take least memory and processing resources.

Android Run Time


Android Runt time (ART) includes Dalvik Virtual Machine (DVM) and Core
Libraries which help your apps to run on an Android mobile device.

Figure 2.5: Android Runtime

(Source:http://androidfulcrum.blogspot.com/2014/02/what-is-android-architecture.html)

ART is the successor of Dalvik Virtual machine. ART is the managed runtime system
that helps to run applications and system services. ART and its predecessor Dalvik
were originally created specifically for the Android project. ART is compatible with
DVM, so it helps to run Dalvik Executable codes. For devices running Android

22
version 5.0 (API level 21) or higher, each app runs in its own process and with its own Features of Android
instance of the Android Runtime (ART)ART has the following features:

 Ahead-of-time (AOT) compilation


 Improved garbage collection
 Improvements in development and debugging

Core Libraries
Core libraries are the collection of Android specific core java libraries. You will be
using these libraries when writing your Android applications in later units.

2.2.2 Video V3: Android Architecture

What you have read upto now regarding Android Architecture


is presented in this video. After watching the video you may
attemptbActivity 2.2.

URL: https://tinyurl.com/ya7t24et

2.2.3 Check Your Progress


Describe the use of Dalvik Virtual Machine and Android Runtime in
Android operating systems.

Android Application Framework


Application framework contains the classes used to create an Android application.
This behaves as an abstraction layer for hardware access. It also manages application
resources and user interface. Content provider, activity manager, fragment manager,
telephony manager, location manager, package manager, notification manager and
view system are the parts of Android Application Framework.

Application Layer
Figure 2.6 shows the application layer which is the top layer of Android architecture.
Every application (e.g. Contacts, Browsers, etc.), whether it is a native application or a
third party application, runs in Application layer. Preinstalled applications provided by
the vendors are called native apps and applications developed by another developer
are called third party applications. In application layer, third party apps can replace the
native apps. This is the beauty of Android.

Figure 2.6: Android application layer

(Source: http://androidfulcrum.blogspot.com/2014/02/what-is-android-architecture.html)

23
Android Architecture
2.3 TYPES OF MOBILE APPLICATIONS

It is obvious that mobile technologies have been evolving rapidly in recent years, with
a huge amount of creativity on mobile application development. As a result, there are
more prominent needs than at any other time for a mobile application client platform
which can not only deliver mobile-optimized user experience, but also support the
increasingly complex business logic that the application must support.

It is important to consider various factors related to the purpose of the developing the
app when deciding between which types of app you should build. Therefore, it is
important to check your current priorities and where you want to be in the future
before selecting the app. The quality of the user experience you need your app to have,
the complexity of the features you need for your app to work and the budget, helps
you choose which approach is best.

Today, we often speak of three types of mobile applications according to how they are
developed: native, web and hybrid. Further explanations on these types are given
below.

Native apps
Those that are fully programmed in the development environment specific to each
operating system.

Native applications can leverage the full array of features and functions available
through the mobile device’s core operating system. Generally, they are fasterand offer
a significantly usable interface than the others.

Advantages:

 Smooth performance
 Good user experience
 App icon available on the device
 Can receive push notifications
 Runs inside the operating system
 Can use the platform APIs

Disadvantages:

 Developers need to know each of the platforms languages


 Source code only works on the targeted platform
 Slower to market due to multiple source codes

Web apps
Fully developed in HTML 5, Mobile Web apps offer an attractive option for
companies that do not want to invest in building native applications across four
different mobile platforms. Whether getting a new application up and running or
maintaining or updating an existing mobile solution with Mobile Web Apps is simple
and inexpensive. Better yet, HTML5-driven mobile Web apps are cross-platform
compatible and, more secure than native applications (given that very little data is
stored locally on the native device.)
24
Advantages: Features of Android

 Cross platform
 Single code base
 Fast to production
 Lower development cost

Disadvantages:

 Sluggish performance
 Require loading
 Network connection required
 Not available in the app stores
 Extremely limited API access Lives in the browser

Hybrid apps
Apps developed partly with the native development environment and partly in WEB
language (HTML 5).

Today, technology changes so rapidly that most businesses require immense flexibility
and scalability to adapt content, design and even application architecture. By
deploying applications that rely on a robust combination of HTML5 Web technologies
and native operating system features, you preserve a large degree of control over the
content and design of the solutions we build for mobile platforms.

Many companies find that this hybrid development process empowers them to
perform fast, easy, on-demand updates, without losing the inherent advantages that
come from hosting a solution in the iTunes Apps Store or the Android Marketplace.

Advantages:

 Single source code


 Access to all platforms
 Less time for deployment
 Available in app store
 Has application icon on the device

Disadvantages:

 Dependent on such as phone gap


 Middleware may be slow to update
 More bug prone
 Some bug fixes need middleware updates
 Some bug fixes are outside of your control
 Slower performance
 More issues from device fragmentation

Each has its positives and negatives that can and should influence the decision when
making a choice for development. Which is most appropriate will vary based on your

25
Android Architecture particular requirements. The Table 2.1 shows a summary of the features discussed in
each type.

Table 2.1: Hybrid vs. Native vs. Mobile Web


Feature Native HTMAL5 Hybrid
Graphics Native APIs HTML, HTML, Canvas,
Canvas, SVG SVG
App performance Fast Moderate Moderate
Distribution App Web App
Store/Market Store/Market
Native look and feel Native Emulated Emulated
Camera Yes No Yes
Push Notifications Yes No Yes
File upload Yes Yes Yes
Contacts, calendar Yes No Yes
Connectivity Online and Online and
Mostly online
offline offline
HTML5,
Development skills HTML5, CSS,
XML, Java CSS,
needed Javascript
Javascript
Geolocation Yes Yes Yes

2.3.1 Check Your Progress


Differentiate native, web, and hybrid mobile apps by stating the
advantages, disadvantages and special features.

2.4 APPLICATION FUNDAMENTALS

Android apps are written in the Java programming language. The Android SDK tools
compile your codealong with any data and resource filesinto an APK: an Android
package, which is an archive file with an .apk suffix. One APK file contains all the
contents of an Android app and this is the file that Android-powered devices use to
install the app.

 Once installed on a device, each Android app lives in its own security
sandbox
 The Android operating system is a multi-user Linux system in which each app
is a different user.
 By default, the system assigns each app a unique Linux user ID (the ID is
used only by the system and is unknown to the app). The system sets permissions for
all the files in an app so that only the user ID assigned to that app can access them.
 Each process has its own virtual machine (VM), so an app's code runs in
isolation from other apps.
 By default, every app runs in its own Linux process. Android starts the
process when any of the app's components need to be executed, then shuts down the

26
process when it's no longer needed or when the system must recover memory for other Features of Android
apps.
In this way, the Android system implements the principle of least privilege. That is,
each app, by default, has access only to the components that it requires to do its work
and no more. This creates a very secure environment in which an app cannot access
parts of the system for which it is not given permission.

However, there are ways for an app to share data with other apps and for an app to
access system services:

 It's possible to arrange for two apps to share the same Linux user ID, in which
case they are able to access each other's files. To conserve system resources, apps with
the same user ID can also arrange to run in the same Linux process and share the same
VM (the apps must also be signed with the same certificate).
 An app can request permission to access device data such as the user's
contacts, SMS messages, the mountable storage (SD card), camera, Bluetooth, and
more. The user has to explicitly grant these permissions.
That covers the basics regarding how an Android app exists within the system.

The rest of this unit introduces you to:

 The core framework components that define your app.


 The manifest file in which you declare components and required device
features for your app.
 Resources that are separate from the app code and allow your app to
gracefully optimize its behaviour for a variety of device configurations.

App components are the essential building blocks of an Android app. Each component
is a different point through which the system can enter your app.
Not all components are actual entry points for the user and some depend on each
other, but each one exists as its own entity and plays a specific role—each one is a
unique building block that helps define your app's overall behaviour.

There are four different types of app components. Each type serves a distinct purpose
and has a distinct lifecycle that defines how the component is created and
destroyed.Here are the four types of application components. These four components
are further explained in unit 5.

Activities
An activity represents a single screen with a user interface. For example, an email app
might have one activity that shows a list of new emails, another activity to compose an
email, and another activity for reading emails. Although the activities work together to
form a cohesive user experience in the email app, each one is independent of the
others. As such, a different app can start any one of these activities (if the email app
allows it). For example, a camera app can start the activity in the email app that
composes new mail, in order for the user to share a picture.

An activity is implemented as a subclass of Activity and you can learn more about
activity lifecycle in the next unit.

27
Android Architecture Services
A service is a component that runs in the background to perform long-running
operations or to perform work for remote processes. A service does not provide a user
interface. For example, a service might play music in the background while the user is
in a different app, or it might fetch data over the network without blocking user
interaction with an activity. Another component, such as an activity, can start the
service and let it run or bind to it in order to interact with it.

A service is implemented as a subclass of Service and you can learn more about it in
the Services developer guide.

Content providers
A content provider manages a shared set of app data. You can store the data in the file
system, SQLite database, on the web, or any other persistent storage location your app
can access. Through the content provider, other apps can query or even modify the
data (if the content provider allows it). For example, the Android system provides a
content provider that manages the user's contact information. As such, any app with
the proper permissions can query part of the content provider (such as contact data) to
read and write information about a particular person.

Content providers are also useful for reading and writing data that is private to your
app and not shared. For example, the Note Pad sample app uses a content provider to
save notes.

A content provider is implemented as a subclass of ContentProvider and must


implement a standard set of APIs that enable other apps to perform transactions. For
more information, see the Content Providers developer guide.

Broadcast receivers
A broadcast receiver is a component that responds to system-wide broadcast
announcements. Many broadcasts originate from the system—for example, a
broadcast announcing that the screen has turned off, the battery is low, or a picture
was captured. Apps can also initiate broadcasts—for example, to let other apps know
that some data has been downloaded to the device and is available for them to use.
Although broadcast receivers don't display a user interface, they may create a status
bar notification to alert the user when a broadcast event occurs. More commonly,
though, a broadcast receiver is just a "gateway" to other components and is intended to
do a very minimal amount of work. For instance, it might initiate a service to perform
some work based on the event.

2.5 SUMMARY

The objective of this study unit was to introduce the architecture of


Android. In the first part of this study unit, we discussed about the
different types of layers of Android operating system and the role of each
layer with functionalities. Further, it discussed about the three types of
mobile applications: native, web and hybrid. The rest of the unit
discussed about the fundamental components of an Android application.

28
Features of Android
2.6 FURTEHR READINGS
https://source.android.com/devices/ (CC-BY)
http://androidfulcrum.blogspot.com/2014/02/what-is-android-architecture.html (CC-
BY)
https://source.android.com/source/index.html (CC-BY)

29

You might also like