OS Unit V Final
OS Unit V Final
OS Unit V Final
for security.
ANDROID ARCHITECTURE
Android architecture contains different number of components to support any android device
needs. Android software contains an open-source Linux Kernel having collection of number of
C/C++ libraries which are exposed through an application framework services.
1
Among all the components Linux Kernel provides main functionality of operating system functions
to smartphones and Dalvik Virtual Machine (DVM) provide platform for running an android
application.
The main components of android architecture are following:-
● Applications
● Application Framework
● Android Runtime
● Platform Libraries
● Linux Kernel
Pictorial representation of android architecture with several main components and their sub
components
Applications –
Applications is the top layer of android architecture. The pre-installed applications like home,
contacts, camera, gallery etc and third party applications downloaded from the play store like chat
applications, games etc. will be installed on this layer only.
2
It runs within the Android run time with the help of the classes and services provided by the
application framework.
Application framework –
Application Framework provides several important classes which are used to create an Android
application. It provides a generic abstraction for hardware access and also helps in managing the
user interface with application resources. Generally, it provides the services with the help of which
we can create a particular class and make that class helpful for the Applications creation.
It includes different types of services activity manager, notification manager, view system, package
manager etc. which are helpful for the development of our application according to the
prerequisite.
Application runtime –
Android Runtime environment is one of the most important part of Android. It contains
components like core libraries and the Dalvik virtual machine(DVM). Mainly, it provides the base
for the application framework and powers our application with the help of the core libraries.
Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a register-based virtual
machine and specially designed and optimized for android to ensure that a device can run multiple
instances efficiently. It depends on the layer Linux kernel for threading and low-level memory
management. The core libraries enable us to implement android applications using the standard
JAVA or Kotlin programming languages.
Platform libraries –
The Platform Libraries includes various C/C++ core libraries and Java based libraries such as
Media, Graphics, Surface Manager, OpenGL etc. to provide a support for android development.
● Media library provides support to play and record audio and video formats.
● Surface manager responsible for managing access to the display subsystem.
● SGL and OpenGL both cross-language, cross-platform application program interface (API)
are used for 2D and 3D computer graphics.
● SQLite provides database support and Free Type provides font support.
● Web-Kit This open source web browser engine provides all the functionality to display web
content and to simplify page loading.
● SSL (Secure Sockets Layer) is security technology to establish an encrypted link between a
web server and a web browser.
Linux Kernel –
Linux Kernel is heart of the android architecture. It manages all the available drivers such as
display drivers, camera drivers, Bluetooth drivers, audio drivers, memory drivers, etc. which are
required during the runtime.
The Linux Kernel will provide an abstraction layer between the device hardware and the other
components of android architecture. It is responsible for management of memory, power, devices
etc.
The features of Linux kernel are:
● Security: The Linux kernel handles the security between the application and the system.
● Memory Management: It efficiently handles the memory management thereby providing
the freedom to develop our apps.
3
● Process Management: It manages the process well, allocates resources to processes
whenever they need them.
● Network Stack: It effectively handles the network communication.
● Driver Model: It ensures that the application works properly on the device and hardware
manufacturers responsible for building their drivers into the Linux build.
Some diagrams designed to graphically depict the iOS software stack show an additional box
positioned above the Cocoa Touch layer to indicate the applications running on the device. In the
above diagram we have not done so since this would suggest that the only interface available to
the app is Cocoa Touch. In practice, an app can directly call down any of the layers of the stack
to perform tasks on the physical device.
That said, however, each operating system layer provides an increasing level of abstraction away
from the complexity of working with the hardware. As an iOS developer you should, therefore,
always look for solutions to your programming goals in the frameworks located in the higher
level iOS layers before resorting to writing code that reaches down to the lower level layers. In
general, the higher level of layer you program to, the less effort and fewer lines of code you will
have to write to achieve your objective. And as any veteran programmer will tell you, the less
code you have to write the less opportunity you have to introduce bugs.
4
The Cocoa Touch Layer
The Cocoa Touch layer sits at the top of the iOS stack and contains the frameworks that are most
commonly used by iPhone application developers. Cocoa Touch is primarily written in
Objective-C, is based on the standard Mac OS X Cocoa API (as found on Apple desktop and
laptop computers) and has been extended and modified to meet the needs of the iPhone
hardware.
The Cocoa Touch layer provides the following frameworks for iPhone app development:
UIKit Framework (UIKit.framework)
The UIKit framework is a vast and feature rich Objective-C based programming interface. It is,
without question, the framework with which you will spend most of your time working. Entire
books could, and probably will, be written about the UIKit framework alone. Some of the key
features of UIKit are as follows:
● User interface creation and management (text fields, buttons, labels, colors, fonts etc)
● Application lifecycle management
● Application event handling (e.g. touch screen user interaction)
● Multitasking
● Wireless Printing
● Data protection via encryption
● Cut, copy, and paste functionality
The role of the Media layer is to provide iOS with audio, video, animation and graphics
capabilities. As with the other layers comprising the iOS stack, the Media layer comprises a
number of frameworks which may be utilized when developing iPhone apps. In this section we
will look at each one in turn.
The Core Video Framework provides buffering support for the Core Media framework. Whilst
this may be utilized by application developers it is typically not necessary to use this framework.
7
Core Text Framework (CoreText.framework)
The iOS Core Text framework is a C-based API designed to ease the handling of advanced text
layout and font rendering requirements.
The Image I/O framework, the purpose of which is to facilitate the importing and exporting of
image data and image metadata, was introduced in iOS 4. The framework supports a wide range
of image formats including PNG, JPEG, TIFF and GIF.
The Assets Library provides a mechanism for locating and retrieving video and photo files
located on the iPhone device. In addition to accessing existing images and videos, this
framework also allows new photos and videos to be saved to the standard device photo album.
The iOS Core Graphics Framework (otherwise known as the Quartz 2D API) provides a
lightweight two dimensional rendering engine. Features of this framework include PDF
document creation and presentation, vector based drawing, transparent layers, path based
drawing, anti-aliased rendering, color manipulation and management, image rendering and
gradients. Those familiar with the Quartz 2D API running on MacOS X will be pleased to learn
that the implementation of this API is the same on iOS.
A new framework introduced with iOS 5 providing a set of video and image filtering and
manipulation capabilities for application developers.
The purpose of the Quartz Core framework is to provide animation capabilities on the iPhone. It
provides the foundation for the majority of the visual effects and animation used by the UIKit
8
framework and provides an Objective-C based programming interface for creation of specialized
animation within iPhone apps.
For many years the industry standard for high performance 2D and 3D graphics drawing has
been OpenGL. Originally developed by the now defunct Silicon Graphics, Inc (SGI) during the
1990s in the form of GL, the open version of this technology (OpenGL) is now under the care of
a non-profit consortium comprising a number of major companies including Apple, Inc., Intel,
Motorola and ARM Holdings.
OpenGL for Embedded Systems (ES) is a lightweight version of the full OpenGL specification
designed specifically for smaller devices such as the iPhone. iOS 3 or later supports both
OpenGL ES 1.1 and 2.0 on certain iPhone models (such as the iPhone 3GS and iPhone 4).
Earlier versions of iOS and older device models support only OpenGL ES version 1.1.
9
AudioUnit.framework)
The frameworks that comprise Core Audio for iOS define supported audio types, playback and
recording of audio files and streams and also provide access to the device‟s built-in audio
processing units.
OpenAL is a cross platform technology used to provide high-quality, 3D audio effects (also
referred to as positional audio). Positional audio may be used in a variety of applications though
is typically used to provide sound effects in games.
The iOS Media Player framework is able to play video in .mov, .mp4, .m4v, and .3gp formats at
a variety of compression standards, resolutions and frame rates.
Introduced in iOS 4, the Core MIDI framework provides an API for applications to interact with
MIDI compliant devices such as synthesizers and keyboards via the iPhone‟s dock connector.
The iOS Core Services layer provides much of the foundation on which the previously
referenced layers are built and consists of the following frameworks.
The Address Book framework provides programmatic access to the iPhone Address Book
contact database allowing applications to retrieve and modify contact entries.
The CFNetwork framework provides a C-based interface to the TCP/IP networking protocol
stack and low level access to BSD sockets. This enables application code to be written that
10
works with HTTP, FTP and Domain Name servers and to establish secure and encrypted
connections using Secure Sockets Layer (SSL) or Transport Layer Security (TLS).
This framework is provided to ease the creation of data modeling and storage in Model-View-
Controller (MVC) based applications. Use of the Core Data framework significantly reduces the
amount of code that needs to be written to perform common tasks when working with structured
data within an application.
The Core Foundation framework is a C-based Framework which provides basic functionality
such as data types, string manipulation, raw block data management, URL manipulation, threads
and run loops, date and times, basic XML manipulation and port and socket communication.
Additional XML capabilities beyond those included with this framework are provided via the
libXML2 library. Though this is a C-based interface, most of the capabilities of the Core
Foundation framework are also available with Objective-C wrappers via the Foundation
Framework.
The Core Media framework is the lower level foundation upon which the AV Foundation layer is
built. Whilst most audio and video tasks can, and indeed should, be performed using the higher
level AV Foundation framework, access is also provided for situations where lower level control
is required by the iOS application developer.
The iOS Core Telephony framework is provided to allow applications to interrogate the device
for information about the current cell phone service provider and to receive notification of
telephony related events.
An API designed to provide applications with access to the calendar, reminders and alarms on
11
the device.
The Foundation framework is the standard Objective-C framework that will be familiar to those
who have programmed in Objective-C on other platforms (most likely Mac OS X). Essentially,
this consists of Objective-C wrappers around much of the C-based Core Foundation Framework.
The Core Location framework allows you to obtain the current geographical location of the
device (latitude, longitude and altitude) and compass readings from with your own applications.
The method used by the device to provide coordinates will depend on the data available at the
time the information is requested and the hardware support provided by the particular iPhone
model on which the app is running (GPS and compass are only featured on recent models). This
will either be based on GPS readings, Wi-Fi network data or cell tower triangulation (or some
combination of the three).
The iOS Mobile Core Services framework provides the foundation for Apple‟s Uniform Type
Identifiers (UTI) mechanism, a system for specifying and identifying data types. A vast range of
predefined identifiers have been defined by Apple including such diverse data types as text, RTF,
HTML, JavaScript, PowerPoint .ppt files, PhotoShop images and MP3 files.
The purpose of the Store Kit framework is to facilitate commerce transactions between your
application and the Apple App Store. Prior to version 3.0 of iOS, it was only possible to charge a
customer for an app at the point that they purchased it from the App Store. iOS 3.0 introduced
the concept of the “in app purchase” whereby the user can be given the option to make additional
payments from within the application. This might, for example, involve implementing a
subscription model for an application, purchasing additional functionality or even buying a faster
car for you to drive in a racing game. With the introduction of iOS 6, content associated with an
in-app purchase can now be hosted on, and downloaded from, Apple‟s servers.
12
SQLite library
Allows for a lightweight, SQL based database to be created and manipulated from within your
iPhone application.
The System Configuration framework allows applications to access the network configuration
settings of the device to establish information about the “reachability” of the device (for example
whether Wi-Fi or cell connectivity is active and whether and how traffic can be routed to a
server).
The Quick Look framework provides a useful mechanism for displaying previews of the contents
of file types loaded onto the device (typically via an internet or network connection) for which
the application does not already provide support. File format types supported by this framework
include iWork, Microsoft Office document, Rich Text Format, Adobe PDF, Image files,
public.text files and comma separated (CSV).
The Core OS Layer occupies the bottom position of the iOS stack and, as such, sits directly on
top of the device hardware. The layer provides a variety of services including low level
networking, access to external accessories and the usual fundamental operating system services
such as memory management, file system handling and threads.
The Accelerate Framework provides a hardware optimized C-based API for performing complex
and large number math, vector, digital signal processing (DSP) and image processing tasks and
calculations.
Provides the ability to interrogate and communicate with external accessories connected
13
physically to the iPhone via the 30-pin dock connector or wirelessly via Bluetooth.
14
Security Framework (Security.framework)
The iOS Security framework provides all the security interfaces you would expect to find on a
device that can connect to external networks including certificates, public and private keys, trust
policies, keychains, encryption, digests and Hash-based Message Authentication Code (HMAC).
System (LibSystem)
As we have previously mentioned, iOS is built upon a UNIX-like foundation. The System
component of the Core OS Layer provides much the same functionality as any other UNIX like
operating system. This layer includes the operating system kernel (based on the Mach kernel
developed by Carnegie Mellon University) and device drivers. The kernel is the foundation on
which the entire iOS platform is built and provides the low level interface to the underlying
hardware. Amongst other things, the kernel is responsible for memory allocation, process
lifecycle management, input/output, inter-process communication, thread management, low level
networking, file system access and thread management.
As an app developer your access to the System interfaces is restricted for security and stability
reasons. Those interfaces that are available to you are contained in a C-based library called
LibSystem. As with all other layers of the iOS stack, these interfaces should be used only when
you are absolutely certain there is no way to achieve the same objective using a framework
located in a higher iOS layer.
15