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:
- Application Framework
- Android Runtime and Core/Native Libraries
- Core Libraries
- Linux Kernel
- Device Drivers
- Memory Management
- Process Management
The following are the layers that compose the Android architecture as labeled on the diagram:
- 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 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.
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.
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.
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.
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.
In this segment, we will discuss some of the core libraries that are present in the Android operating system.
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.
Android also has an SQLite database that enables applications to have very fast native database functionality without the need for third party libraries.
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.
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.
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.
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.
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.
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.
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:
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.
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.
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.
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.
- Android architecture is organized in layers.
- Each layer solves a unique set of problems.
- End-users interact with apps on the Application layer
- Application developers develop apps to be used on the Application layer. They do so using tools and abstractions provided by the Application Framework.
- Android Framework layer simplifies access to low-level components by creating an API over native libraries.
- Android Runtime and Core-Libraries use low-level languages together with optimizations for mobile devices. This ensures code written by application developers runs smoothly despite Android device constraints.
- At the bottom of the Android software stack is the Linux kernel. It interfaces with the hardware components common in Android devices.