Layered architecture of smartphones

1. User interface (UI)

In the smartphone architecture, the user interface (UI) is the medium for users to interact with applications. The UI can be regarded as an important part of the application layer, which includes all visual elements and user interaction components.
Here are some of the main components of the UI layer:

1. Layout

Layout defines how elements in a user interface are arranged on the screen. It includes information such as the position, size, arrangement of elements. Layouts are typically defined in XML or other formats in application code, and are then parsed and applied at runtime by the UI framework.

2. View and Widget

Views and controls are the basic elements of user interfaces.
A view is a rectangular area on the screen that handles the user's touch events and can draw its own content.
Controls are special views that provide some predetermined interaction modes, such as buttons, text boxes, sliders, scroll bars, etc.

3.Animation

Animation can add visual effects to the user interface, making the user interface more vivid and interesting. Animation can change the position, size, rotation angle, transparency and other properties of the view to create a variety of effects.


In the UI layer, various components work in coordination to provide user interaction functions. For example, when a user touches the screen, touch events are first sent to the corresponding view. The view will decide how to respond to the touch event based on the type and location of the touch event. This might include changing the state of the view, such as a button being pressed; or it might include performing some action, such as a slider being dragged. At the same time, the view will also decide how to draw its own content based on its own state and data.

Additionally, layout determines the position and size of views on the screen. When the layout changes, such as the screen rotates or the window size changes, the layout recalculates the position and size of the view and updates the view's display. At the same time, animation can change the properties of the view, such as position, size, etc., to create visual effects. The running of animation is also managed by the UI framework.

Overall, the UI layer exists so that users can interact with the application in an intuitive way. At the same time, because the UI framework provides prefabricated components such as views, controls, layouts, and animations, application developers can focus more on implementing user interaction logic without having to create these components from scratch, which greatly improves development efficiency.

2. Application Layer

The Application Layer is the top-level part of the smartphone architecture. It is the main interface for users to interact with the phone. This layer contains various applications such as browsers, games, music players, photo editors, etc. These applications provide users with a variety of functions and services.
Here are some of the main components of the application layer:

1. System application

System applications are usually pre-installed by the operating system, such as phone dialing, text messaging, cameras, browsers, calculators, etc. These apps provide the basic functionality of your phone.

2. Third-party applications

Third-party apps are apps developed by other developers or companies that users can download from app stores. These applications provide a variety of functions and services, such as social networking, games, music playback, video playback, office tools, etc.


In the application layer, each application implements its functions by calling the API provided by the application framework. For example, a music player application might need to use a file system service to read music files, an audio service to play the music, and a user interface component to display the player interface. These services and components are provided by the application framework and exposed to applications through APIs.

In addition, applications need to interact with the operating system and other applications. For example, an application may need to request permissions from the operating system, such as permission to access the network, permission to access the file system, etc. Or, an app might need to share data with another app, such as sharing a picture or a link. These interactions are also implemented through the API provided by the application framework.

In general, the existence of the application layer allows users to enjoy a variety of functions and services. At the same time, because the application framework provides a unified API, application developers can focus more on implementing the functions of the application without having to worry about how to use the services and components of the operating system, which greatly improves development efficiency.

3. Application Framework

Application Framework is a bridge between smartphone hardware infrastructure and applications. It provides a set of prefabricated basic services and components, which allows application developers to focus more on implementing specific application functions without having to start from scratch. Build from scratch.
Here are some of the main components of the application framework:

1. System services

System services are a set of prefabricated services provided by the application framework that provide the core functionality of the operating system.
For example,
the window manager is responsible for managing the windows of the user interface, including the creation, destruction, and updating of windows; the
notification service is responsible for managing and displaying notifications from applications;
the power manager is responsible for managing the power status of the device, etc.

2. Component library

The application framework provides a set of prefabricated user interface components, such as buttons, text boxes, list boxes, etc., as well as some non-user interface components, such as network access, database access, location services, etc. These components encapsulate some basic functions so that developers do not need to create these functions from scratch.

3.API (Application Programming Interface)

The application framework provides a set of APIs that allow applications to use system services and component libraries. The API defines a set of functions and data structures that describe how to use system services and component libraries.


In an application framework, various components work together to provide services and functionality. For example, when an application needs to create a button, it can call the button component provided by the application framework through the API. The button component handles all the details related to creating and displaying buttons, such as button drawing, button event handling, etc. At the same time, applications can also use system services through APIs, such as using a window manager to manage windows in the user interface, or using a notification service to display notifications.

The existence of application frameworks allows application developers to focus more on implementing the functions of the application without having to worry about how to create and manage the user interface, or how to use the core functions of the operating system. At the same time, because the application framework provides a unified API, developers can use the same set of APIs to develop different applications, which greatly improves development efficiency.

4. Libraries and Runtime

Libraries and runtime layers play a key role in smartphone software architecture. This layer provides many basic services and functions for use by application frameworks and applications. These services and functions include graphics rendering, database access, file access, network access, thread management, etc.
For Android, this layer includes the Android Runtime (ART) and some C/C++ system libraries.
For iOS, this layer is called Core Services, including Core Foundation, Foundation and other libraries.
Here are some of the main components of the "Libraries and Runtime" layer:

1. System library

System libraries provide many basic services and functions.
For example,
the graphics library provides functions for drawing images and rendering 3D graphics;
the network library provides functions for sending and receiving data; and
the database library provides functions for storing and querying data.
These libraries provide methods for applications to access and use hardware resources.

2. Runtime environment

The runtime environment is responsible for loading and executing the application's code.
For example, Android's runtime environment (Android Runtime, ART) can load and execute Android applications written in Java or Kotlin. The runtime environment also provides garbage collection, memory management and other functions.

3.API(Application Programming Interface)

API is the interface provided by the library and runtime layer to the application program. The application program can call the services and functions provided by the library and runtime layer through the API. An API defines a set of functions and data structures that describe how to use services and functionality.


In this layer, the various components work in coordination to provide services and functionality. For example, when an application needs to send network data, it calls the functions provided by the network library through the API. The network library handles all the details related to network communication, such as establishing connections, sending data, receiving data, etc. The runtime environment manages the execution of the application, including loading the application's code, scheduling the application's threads, managing the application's memory, etc.

The existence of this layer allows application developers to focus more on implementing the functionality of the application without having to worry about how to use hardware resources or manage the execution of the application. At the same time, because the library and runtime layer provide a unified API, developers can use the same set of APIs to develop different applications, which greatly improves development efficiency.

5. Hardware Abstraction Layer (HAL)

Hardware Abstraction Layer (HAL) is a software library whose role is to provide an abstract interface between hardware and high-level software. This interface hides the specific implementation details of the hardware, allowing the upper-layer software to use the functions of the hardware without knowing the specific implementation of the hardware.
The following are some of the main responsibilities and components of the hardware abstraction layer:

1.Device interface

The hardware abstraction layer provides an interface for each type of hardware device. This interface defines a set of functions that cover all operations required to use hardware devices, such as opening the device, closing the device, reading data, writing data, etc. For example, for a camera device, the interface may provide functions to open the camera, set the resolution, start taking pictures, stop taking pictures, etc.

2.Device driver abstraction

The hardware abstraction layer implements device interfaces through the use of device drivers. A device driver is a piece of code that can interact with a specific hardware device. The hardware abstraction layer hides the specific implementation of the device driver behind the device interface, allowing the upper-layer software to use the device's functions without knowing the specific implementation of the device driver.

3. Equipment management

The hardware abstraction layer is also responsible for managing devices. This includes detecting the presence of the device, initializing the device, handling device errors, etc.
For example, when an application opens a device, the hardware abstraction layer might check whether the device exists, then use the device driver to initialize the device and provide error handling if the device fails.


We can think of the hardware abstraction layer as a bridge that connects hardware and upper-layer software. By providing a unified device interface and hiding the specific implementation of the device driver, the hardware abstraction layer enables upper-layer software to use the functions of the hardware without knowing the specific implementation of the hardware. This allows software developers to focus more on implementing the functionality of the application without having to worry about the specific implementation of the hardware. At the same time, due to the existence of the hardware abstraction layer, even if the hardware device changes, as long as the device interface remains unchanged, the upper-layer software can continue to work without any modifications.

6. Kernel

The kernel is the core part of the operating system, which connects the hardware and software layers of the smartphone. Simply put, the kernel is like a big housekeeper, responsible for managing all the resources in the phone, such as processors, memory, and hardware devices, and allocating these resources to various applications as needed.
Here are some of the main responsibilities and components of the kernel:

1. Process management

The kernel is responsible for creating, scheduling, and terminating processes. A process is an instance of a running program. The kernel uses a scheduling algorithm to decide which process can use the processor and for how long. When you open an app on your phone, the kernel creates one or more processes for it.

2. Memory management

The kernel is responsible for allocating and reclaiming memory. When a program needs to store data or code, it requests memory from the kernel. The kernel keeps track of which memory is in use and which is free, and ensures that each program can only access its own memory.

3.Device management

The kernel controls hardware devices through device drivers. A device driver is a special program that knows how to communicate with a specific hardware device. When an application needs to use a hardware device (such as a display, camera, or network adapter), it sends a request to the kernel, which then controls the device through the corresponding device driver.

In smartphone architecture, drivers are often considered part of the kernel, as they interact directly with the hardware and provide a unified interface for use by upper layers such as the operating system and applications.

4. File system

The kernel manages data on storage devices through the file system. The file system determines how data is organized into files and directories, and how data is stored on and read from storage devices.

5.Network management

The kernel handles network communications. When an application needs to send or receive network data, it does so through the kernel. The kernel will package the data into network packets and then send them out through the network device, or receive the network packets from the network device and extract the data.



Due to the critical role of the kernel in smartphones, the design and implementation of the kernel must be very careful and precise to ensure system stability and efficiency. At the same time, because the kernel interacts directly with hardware devices, the kernel usually needs to run at a very low system level, and sometimes even needs to be written in a special, hardware-closely related programming language (such as assembly language).

7. Hardware

The hardware layer of a smartphone consists of many different parts that work together to enable the phone to run various applications and functions.
Here are some of the major components of a mobile phone’s hardware architecture:

1. Central processing unit (CPU)

The CPU is the "brain" of the phone, executing instructions from the operating system and applications. Modern smartphones usually use multi-core CPUs that can perform multiple tasks simultaneously.

2. Memory (RAM)

When you open an app or game, its data and program code are loaded into RAM. RAM is a fast storage device that allows the CPU to quickly access data in use.

3. Storage device (such as flash memory)

This is the "hard drive" in your phone, where it stores system files, apps and their data, your photos and videos, and more. When you close and reopen an app, its data is reloaded from storage into RAM.

4.Battery

The phone's battery powers all the hardware. Modern smartphones typically use lithium-ion or lithium-polymer batteries.

5.Display

The display screen is used to display the graphical user interface, including the interface of the operating system, the interface of the application program, videos, etc. Modern smartphones typically use liquid crystal displays (LCD) or organic light-emitting diode displays (OLED).

6.Input devices

Including touch screen, buttons, camera, microphone, etc. The touch screen and buttons are used for user input, and the camera and microphone are used to take photos, record audio and video.

7.Communication equipment

Including cellular network module, Wi-Fi module, Bluetooth module, etc. These devices allow your phone to connect to the Internet for phone calls and data communications.

8. Sensor

Including light sensors, proximity sensors, accelerometers, gyroscopes, magnetometers, etc. These sensors can detect various physical states of the phone, such as light intensity, the location and orientation of the phone, the movement status of the phone, etc.

These hardware parts communicate with each other through various electronic and electrical signals.
For example,
when you touch the screen, the touch screen will send a signal to the CPU to tell it where you touched; when the CPU executes an instruction and needs to read some data, it will send a signal to the RAM to
request to read the data;
When you play a video, the CPU sends signals to the display and speakers, controlling them to display images and play sound.


The hardware of a mobile phone is like a complex orchestra, and the various parts need to work together accurately to complete various tasks.

Guess you like

Origin blog.csdn.net/u012881779/article/details/134771142