- Android — Architecture
- Linux kernel
- Libraries
- Android Libraries
- Android Runtime
- Application Framework
- Applications
- Android Architecture
- Applications –
- Application framework –
- Application runtime –
- Platform libraries –
- Linux Kernel –
- Android Architecture: Application Layers, Framework, Component
- Layers
- Android Application
- Application Framework
- 1) Activity Manager
- 2) Window Manager
- 3) Location Manager
- 4) Telephony Manager
- 5) Resource Manager
- 6) View System
- 7) Notification Manager
- 8) Package Manager
- 9) Content Provider
- Android Runtime and Core/Native Libraries
- 1) Android Runtime
- Core Libraries
- 2) MediaFramework
- 3) SQLite
- 4) Freetype
- 5) OpenGL
- 6) SSL
- 7) SGL
- 8) Libc
- 9) Webkit
- 10) Surface Manager
- Linux Kernel
- Device Drivers
- 1) USB Driver
- 2) Bluetooth Driver
- 3) Wifi Driver
- 4) Display Driver
- 5) Audio Driver
- 6) Power Manager
- 7) Flash Memory
- 8) Binder
- Memory Management
- Process Management
Android — Architecture
Android operating system is a stack of software components which is roughly divided into five sections and four main layers as shown below in the architecture diagram.
Linux kernel
At the bottom of the layers is Linux — Linux 3.6 with approximately 115 patches. This provides a level of abstraction between the device hardware and it contains all the essential hardware drivers like camera, keypad, display etc. Also, the kernel handles all the things that Linux is really good at such as networking and a vast array of device drivers, which take the pain out of interfacing to peripheral hardware.
Libraries
On top of Linux kernel there is a set of libraries including open-source Web browser engine WebKit, well known library libc, SQLite database which is a useful repository for storage and sharing of application data, libraries to play and record audio and video, SSL libraries responsible for Internet security etc.
Android Libraries
This category encompasses those Java-based libraries that are specific to Android development. Examples of libraries in this category include the application framework libraries in addition to those that facilitate user interface building, graphics drawing and database access. A summary of some key core Android libraries available to the Android developer is as follows −
android.app − Provides access to the application model and is the cornerstone of all Android applications.
android.content − Facilitates content access, publishing and messaging between applications and application components.
android.database − Used to access data published by content providers and includes SQLite database management classes.
android.opengl − A Java interface to the OpenGL ES 3D graphics rendering API.
android.os − Provides applications with access to standard operating system services including messages, system services and inter-process communication.
android.text − Used to render and manipulate text on a device display.
android.view − The fundamental building blocks of application user interfaces.
android.widget − A rich collection of pre-built user interface components such as buttons, labels, list views, layout managers, radio buttons etc.
android.webkit − A set of classes intended to allow web-browsing capabilities to be built into applications.
Having covered the Java-based core libraries in the Android runtime, it is now time to turn our attention to the C/C++ based libraries contained in this layer of the Android software stack.
Android Runtime
This is the third section of the architecture and available on the second layer from the bottom. This section provides a key component called Dalvik Virtual Machine which is a kind of Java Virtual Machine specially designed and optimized for Android.
The Dalvik VM makes use of Linux core features like memory management and multi-threading, which is intrinsic in the Java language. The Dalvik VM enables every Android application to run in its own process, with its own instance of the Dalvik virtual machine.
The Android runtime also provides a set of core libraries which enable Android application developers to write Android applications using standard Java programming language.
Application Framework
The Application Framework layer provides many higher-level services to applications in the form of Java classes. Application developers are allowed to make use of these services in their applications.
The Android framework includes the following key services −
Activity Manager − Controls all aspects of the application lifecycle and activity stack.
Content Providers − Allows applications to publish and share data with other applications.
Resource Manager − Provides access to non-code embedded resources such as strings, color settings and user interface layouts.
Notifications Manager − Allows applications to display alerts and notifications to the user.
View System − An extensible set of views used to create application user interfaces.
Applications
You will find all the Android application at the top layer. You will write your application to be installed on this layer only. Examples of such applications are Contacts Books, Browser, Games etc.
Источник
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.
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.
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 an 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 FreeType 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.
- 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.
Источник
Android Architecture: Application Layers, Framework, Component
Updated November 11, 2021
Android operating system’s initial release was in the year 2008. Even at its start, the team behind the operating system built it on top of the shoulders of giants. Beyond the user interface that the Android OS presents at the surface level, it is made up of multiple layers. These layers include custom code and open-source technologies that have been under continuous development for decades.
Android has been developed through massive collaborative efforts and investments by many companies. The main company behind android development is Google. Other companies include device manufacturers such as Samsung, LG; processor manufacturers such as Intel and ARM, but to name a few.
When we talk about Android architecture, we mean how the Android system has been designed, segmented into layers, and built up to work as a system. Building such a complex system requires careful structuring to ensure all the components work together cohesively. Its architecture ensures that the many components function as a whole without crashing.
In this tutorial, you will learn:
Layers
The following are the layers that compose the Android architecture as labeled on the diagram:
- Application
- Application Framework
- Android Runtime and Core Libraries
- Linux Kernel
Developing an operating system for mobile devices comes with a set of challenges. Using this layered architecture ensures that different problems are broken down and solved at different levels.
A layered architecture helps separate concerns and ensure android software developers don’t have to deal with low-level problems at every turn. They can instead focus on delivering business value concerned with the layer they’re working on.
Developers are working on making apps don’t have to worry about the application framework implementation. That work is left for the system developers working on the Application framework.
The Application Framework developers work on developer experience and don’t have to worry about the low-level drivers. Low-level system engineers can focus completely on low-level components such as Bluetooth or Audio drivers and the like.
Android’s layered structure makes it possible to apply updates with bug fixes or improvements to each layer on its own. This ensures that changes across layers don’t interfere with each other. This makes it possible for people working at a different level of the OS to work with obstructing each other as new updates and releases are done.
Android Application
Android Application
This is the layer that end-users interact with. It is on this layer where application developers publish their applications to run.
Android, by default, comes with a set of applications that make android devices usable from the offset.
- Home: The Homepage on Android consists of launcher icons for commonly used applications that the end-user may want quick access to. You can start the apps by clicking on the launchers of these apps. At the very top of the screen, you have widgets that show network, battery level, date, and time.
- Contacts: Android, by default, provides a means to store and retrieve contacts. Contact information is shared across other apps to enhance functionality.
- Messages: Android provides the capability to send and receive SMS messages.
- Email: Android comes with native support for email services. Setting up an Android device requires a Gmail account. Setting up Gmail activates other email-dependent components on Android devices. Some email dependent features include security and recovery mechanisms. Another email dependent feature is access to the Play Store, a marketplace for Android applications.
- Browser: Android comes with a default browser.
- Notification Drawer: Swiping down on the screen exposes the notification drawer. It provides application events that the user should be aware of. Above the notification are a set of shortcuts to some commonly used device settings that the users can toggle. These settings include on and off toggles for various hardware components such as Bluetooth and Wifi. Long pressing these events enables us to navigate to their configurations page.
This layer is also referred to as user-level in contrast to the layers below that are mostly tuned for application development. Application developers create and customize the experiences for their apps on this layer. The layers below the application layer are not customized by application developers. They are considered part of the system layer. These layers are customized by device manufacturers, Google android teams, or third parties who want to use the Android source code for their product or research.
Application Framework
The Android OS exposes the underlying libraries and features of the Android device that are using a Java API. This is what is known as the Android framework. The framework exposes a safe and uniform means to utilize Android device resources.
Application framework
1) Activity Manager
Applications use the Android activity component for presenting an entry point to the app. Android Activities are the components that house the user interface that app users interact with. As end-users interact with the Android device, they start, stop, and jump back and forth across many applications. Each navigation event triggers activation and deactivation of many activities in respective applications.
The Android ActivityManager is responsible for predictable and consistent behavior during application transitions. The ActivityManager provides a slot for app creators to have their apps react when the Android OS performs global actions. Applications can listen to events such as device rotation, app destruction due to memory shortage, an app being shifted out of focus, and so on.
Some examples of the way applications can react to these transitions include pausing activity in a game, stopping music playing during a phone call.
2) Window Manager
Android can determine screen information to determine the requirements needed to create windows for applications. Windows are the slots where we can view our app user interface. Android uses the Window manager to provide this information to the apps and the system as they run so that they can adapt to the mode the device is running on.
The Window Manager helps in delivering a customized app experience. Apps can fill the complete screen for an immersive experience or share the screen with other apps. Android enables this by allowing multi-windows for each app.
3) Location Manager
Most Android devices are equipped with GPS devices that can get user location using satellite information to which can go all the way to meters precision. Programmers can prompt for location permission from the users, deliver location, and aware experiences.
Android is also able to utilize wireless technologies to further enrich location details and increase coverage when devices are enclosed spaces. Android provides these features under the umbrella of the Location-Manager.
4) Telephony Manager
Most Android devices serve a primary role in telephony. Android uses TelephoneManager to combine hardware and software components to deliver telephony features. The hardware components include external parts such as the sim card, and device parts such as the microphone, camera, and speakers. The software components include native components such as dial pad, phone book, ringtone profiles. Using the TelephoneManager, a developer can extend or fine-tune the default calling functionality.
5) Resource Manager
Android app usually come with more than just code. They also have other resources such as icons, audio and video files, animations, text files, and the like. Android helps in making sure that there is efficient, responsive access to these resources. It also ensures that the right resources are delivered to the end-users. For example, the proper language text files are used when populating fields in the apps.
6) View System
Android also provides a means to easily create common visual components needed for app interaction. These components include widgets like buttons, image holders such as ImageView, components to display a list of items such as ListView, and many more. The components are premade but are also customizable to fit app developer needs and branding.
7) Notification Manager
The Notification Manager is responsible for informing Android users of application events. It does this by giving users visual, audio or vibration signals or a combination of them when an event occurs. These events have external and internal triggers. Some examples of internal triggers are low-battery status events that trigger a notification to show low battery. Another example is user-specified events like an alarm. Some examples of external triggers include new messages or new wifi networks detected.
Android provides a means for programmers and end-users to fine-tune the notifications system. This can help to guarantee they can send and receive notification events in a means that best suits them and their current environments.
8) Package Manager
Android also provides access to information about installed applications. Android keeps track of application information such as installation and uninstallation events, permissions the app requests, and resource utilization such as memory consumption.
This information can enable developers to make their applications to activate or deactivate functionality depending on new features presented by companion apps.
9) Content Provider
Android has a standardized way to share data between applications on the device using the content provider. Developers can use the content provider to expose data to other applications. For example, they can make the app data searchable from external search applications. Android itself exposes data such as calendar data, contact data, and the like using the same system.
Android Runtime and Core/Native Libraries
Libraries
1) Android Runtime
Android currently uses Android Runtime (ART) to execute application code. ART is preceded by the Dalvik Runtime that compiled developer code to Dalvik Executable files (Dex files). These execution environments are optimized for the android platform taking into consideration the processor and memory constraints on mobile devices.
The runtime translates code written by programmers into machine code that does computations and utilizes android framework components to deliver functionality. Android hosts multiple applications and system components that each run in their processes.
Core Libraries
In this segment, we will discuss some of the core libraries that are present in the Android operating system.
2) MediaFramework
Android also natively supports popular media codecs, making it easy for apps created on the Android platform to use/play multimedia components out of the box.
3) SQLite
Android also has an SQLite database that enables applications to have very fast native database functionality without the need for third party libraries.
4) Freetype
Android comes with a preinstalled fast and flexible font engine. This makes it possible for application developers to style components of their application and deliver a rich experience that communicates the developer’s intent.
5) OpenGL
Android also comes with the OpenGL graphics system. It’s a C library that helps Android use hardware components in the real-time rendering of 2D and 3D graphics.
6) SSL
Android also comes with an inbuilt security layer to enable secure communication between applications on Android and other devices such as servers, other mobile devices, routers 6.
7) SGL
Android comes with a graphics library implemented in low-level code that efficiently renders graphics for the android platform. It works with the higher-level components of the Android framework Android graphics pipeline.
8) Libc
The core of Android contains libraries written in C and C++, which are low-level languages meant for embedded use that help in maximizing performance. Libc provides a means to expose low-level system functionalities such as Threads, Sockets, IO, and the like to these libraries.
9) Webkit
This is an open-source Browser engine used as a basis to build browsers. The default Android browser before version 4.4 KitKat uses it for rendering web pages. It enables application developers to render web components in the view-system by using WebView. This enables apps to integrate web components into their functionality.
10) Surface Manager
The surface manager is responsible for ensuring the smooth rendering of application screens. It does this by composing 2D and 3D graphics for rendering. It further enables this by doing off-screen buffering.
Linux Kernel
The root component of the Android System is the Linux Kernel. It is the foundational piece that enables all of Android’s functionality.
The Linux Kernel is a battle-tested piece of software that has been used in developing operating systems for devices of wide range, from supercomputers to small gadgets. It has limited processing abilities like small networked gadgets for the Internet of Things (IoT).
The Linux Kernel can be tweaked to meet the device specifications to make it possible for manufacturers to make Android devices with different capabilities to match user experience.
With regards to Android, the Kernel is responsible for many foundational functionalities including but not limited to these:
- Device drivers
- Memory Management
- Process Management
Let’s expand on some of the functionality:
Device Drivers
The Linux Kernel houses the drivers needed to make it possible for the operating system to work with different hardware components. These drivers provide a standard interface with which hardware components sourced from different manufacturers can work with.
This makes it possible for device manufacturers to source different components, such as Bluetooth components, Wifi components, camera components. As long as the manufacturers match the Android standard specifications, integration is seamless.
1) USB Driver
Linux also provides Android with a means to interface with USB devices. Modern devices come with different USB ports, including USB 2.0 and new versions of USB, including USB-C. These drivers make it possible to use the USB port to charge, transfer live data such as logs from the Android devices, and interact with the android file system.
2) Bluetooth Driver
Linux Kernel provides support for interfacing with Bluetooth hardware components. It provides a way to read and write data received from supported bluetooth radio frequencies. It also provides a set of facilities for Android to configure Bluetooth.
3) Wifi Driver
The Linux kernel provides drivers to integrate the WiFi networking hardware components. WiFi components embedded in mobile devices enable Android devices to connect to wifi networks. The driver enables the wifi components to broadcast wifi networks and create hotspots.
4) Display Driver
Android makes it possible to interface with display components. For most devices, the interface component is an LCD touch-screen. It allows support for configuring and drawing pixels.
5) Audio Driver
Android devices commonly come with hardware components for audio input and output. Audio drivers in the kernel enable the Android system to use audio received from these components and also produce audio output.
6) Power Manager
Most Android devices are used while disconnected from power outlets. They thus depend on batteries to power them for a large chunk of their usage. Linux Kernel comes with a power management system that’s configurable to meet the needs of the devices using it.
Android OS uses the power manager to make other components on the device power-aware. It does this by broadcasting various power-related states. These states are Standby, Sleep, and Low-Battery. On Android, the power manager is tweaked to default to sleep mode to ensure maximum battery life.
The Power Manager exposes means for applications to react to different power modes. Applications can also change their behavior to match the current power state of the device.
An application can also request to change the default power policies. Applications can achieve the desired functionality, such as keeping the hardware components active. An example is keeping the screen active when reading a book to ensure a user isn’t interrupted. Another example is keeping the audio components turned on when listening to music in the background.
7) Flash Memory
Most Android devices use flash memory as a means of storage. Flash memory is fast and takes less space making it perfect for small devices. Linux kernel provides a means for Android devices to read and write into flash memory. It provides a means to partition the memory in such a way that the OS and other applications can easily and efficiently share the memory resource.
8) Binder
Android hosts many applications and system components that each run in their processes. In most cases, these processes should be isolated from each other to prevent interference and data corruption. Yet, there are instances that we wish to pass data from one process to another.
The Linux kernel enables data sharing functionality by providing binder drivers. Binder drivers enable inter-process communication, IPC. Using IPC processes can discover other processes and share information.
Memory Management
Another responsibility of the Linux Kernel is memory management. As different applications run, the Kernel ensures the memory space they use doesn’t conflict and overwrite each other.
It also helps ensure that all running apps get adequate memory to function, making sure no single app takes too much space.
Process Management
Every app in Android runs in a process. The Kernel is also responsible for managing processes. This means it’s responsible for creating, pausing, stopping, shutting, or killing down processes.
The Kernel enables various functionalities such as running multiple processes at the same time, communicating between processes, running processes in the background, and so on.
As each process requires its own memory space to function correctly, the Kernel ensures that memory spaces allotted for each process are protected from other processes. It also ensures that resources like RAM allotted to processes are freed up when the processes are shut down.
The Linux Kernel is also responsible for distributing work to the processors present in the device. This makes it possible to maximize the performance of devices with multiple cores as different apps will have processes being run on a different core.
The Linux Kernel does more task under the hood including enforcing security.
Источник