Home network hardware Android operating system. Android file systems Android mobile application architecture

Android operating system. Android file systems Android mobile application architecture

The architecture of the Android OS is of interest, first of all, to developers who already know everything about it, so we will try to convey this information to ordinary users in an interesting and understandable way, so that they know how their favorite system works. There is no doubt that she is the favorite of many. But some still do not fully understand all the processes, why and why it makes sense to unlock the device, deprive it of warranty and security.

The first thing you need to know is that Android is a variant of the Linux OS, and at least here this system has found its home niche. Inside the system, at its most basic level, is a modified Linux kernel, which, like large systems, needs to be updated frequently. Much more often than in other mobile operating systems, otherwise you will lose the opportunity to use new features, sensors, applications and other useful things. The kernel works with applications and drivers through the system API, and only at this level of drivers and system applications can programs be written in C++. The middle part of the machine is occupied by a platform that can be compared to .NET from Microsoft. It is controlled by the Java language. Each user application spawns a process when the platform creates a virtual execution environment for it. At this point, Java applications in the form of class and library code are automatically translated into universal bytecode executed on the Delvik byte machine. This machine has a lot in common with the Java JVM.

Applications operate in an environment isolated from each other, capturing only the resources they need. This is a fundamental difference, for example, from programs on a PC, where any program can seize all resources. Although applications are optimized for code quality and isolated from each other, they not only have preemptive multitasking priorities, but also ways to share data and files by assigning them the same identifiers. This way, you can ensure that related programs spend a minimum of unnecessary resources when accessing APIs through the platform, as well as shared profile files, contact lists, etc. The interesting thing here is that you can slip other Java code into Delvik, which the virtual machine will accept as native. This allows you to implement numerous virtual development systems, use new programming languages, and even change the application framework to alternative options - as long as it can generate bytecode and comply with API calls.

The platform, or framework, works with data in a unified way, translating it into the SQLite database format - the same format that, for example, Mozilla works with on a PC. Access to the Internet is managed by the Chrome browser, optimized for mobile devices. To create flawless graphics, the API supports OpenGL ES v.3.0 technology, as well as a whole range of greedy graphics and video formats and containers for storing them, including h.264, mkv, MP4, etc.

Communication with other devices – wired (USB, memory cards) and wireless (BT, IR, Wi-Fi, EDGE/3G/LTE). Many sensors are tied to receiving signals from outside the system: GPS, accelerometer, compass, photography, darkness sensor, fitness sensors.

In its factory state, Android is very stable and secure, but does not allow the user to go beyond sites where alternative programs can be purchased. That is why, as well as for low-level programming, it is deprived of protection, after which it is necessary to install anti-virus software in the system.

Introduction

Story

Android distribution

Built-in Android Applications

Android architecture

Advantages and disadvantages of Android OS

1 Advantages

2 Disadvantages

What Android Isn't

Conclusion

Literature

Introduction

Google Android is not just an operating system for a smartphone, but an entire infrastructure. Android is the first free and open source operating system. The “green robot” runs phones, tablets, TVs, smart watches, and other gadgets, and soon cars will be controlled using Android. The OS is based on the Linux kernel and Google's own implementation of the Java Virtual Machine. It was originally developed by Android Inc, which was acquired by Google in 2005. Google subsequently initiated the creation of the Open Handset Alliance (OHA), which is now supporting and further developing the platform. Android allows you to create Java applications that control the device through Google-developed libraries. The Android Native Development Kit allows you to port (but not debug) libraries and application components written in C and other languages. Android OS is installed on 86% of smartphones (2014).

Figure 1 - emblem

1. History

Figure 2

In July 2005, Google acquired Android Inc. On November 2007, the company officially announced the creation of the Open Handset Alliance (OHA) and announced the open Android mobile platform, and on November 12, 2007, the alliance introduced the first version of the Android developer kit "Early Look" SDK and an Android emulator.

In September 2008, the first version of the operating system was officially released, as well as the first full-fledged development package SDK 1.0, Release 1. Since the release of the first version of the platform, several system updates have occurred. These updates usually concern fixing discovered bugs and adding new functionality to the system.

In 2009, as many as four platform updates were introduced. So, in February version 1.1 was released with various bug fixes. In April and September. Two more updates have been released - 1.5 “Cupcake” and 1.6 “Donut”, respectively. The Cupcake update brought significant changes: virtual keyboard, video playback and recording, browser and others. Donut is the first to support multiple screen resolutions, screen densities, and CDMA networks.

In October of the same year, the version of the Android 2.0 operating system “Eclair” was released with support for multiple Google accounts, browser support for the HTML5 language and other innovations, and after a small update within the version of “Eclair” (2.1), “live wallpapers” appeared and was modified lock screen.

In mid-2010, Google introduced Android version 2.2 under the name “Froyo”, and at the end of 2010, Android 2.3 “Gingerbread”. The "Froyo" update made it possible to use your smartphone as a hotspot, use traditional smartphone locking with a number or alphanumeric passcode, and other changes, while the "Gingerbread" update brought more control over copy and paste functionality, improved power management, and app control. , support for multiple cameras on the device, etc.

On February 2011, the Internet tablet-oriented Android 3.0 “Honeycomb” platform was officially introduced. 4.0 “Ice Cream Sandwich”, released on October 19, 2011, is the first universal platform that is designed for both tablets and smartphones. The update also introduced a new “Holo” interface, which was used before Android 4.4.4 KitKat, but has now been replaced by Material Design (Android 5).

In June 2012, an update called “Jelly Bean” was released with serial number 4.1, which changed to 4.2 due to a small update at the end of October of the same year and to 4.3 after an update in July 2013.

In October 2013, Google introduced the next version of the Android 4.4 operating system, which was named the “KitKat” chocolate bar under an agreement with the manufacturer Nestlé. KitKat first appeared on the Nexus 5; This version of Android is optimized to run on a wider range of devices, with 512MB of RAM as the recommended minimum.

June 2014 Google introduced Android L, available to developers, users of Nexus smartphones, as well as some other smartphones.

In 2014, the operating system for wearable devices Android Wear (for wristwatches) was announced. Also at Google I/O, versions of Android Auto (for cars) and Android TV (for TVs) were presented, thereby Android ceased to be an operating system only for mobile devices.

October 2014 Android 5.0 Lollipop was officially announced. The main update of the system is the new Material design. Also, if a password or pattern is set on an Android device, and if the owner’s watch with Android Wear is nearby, the device will automatically unlock. Instead of the previously used Dalvik virtual machine , begins to be used virtual machine ART.

December 2014 Google replaced the official development environment based on Eclipse (adt-bundle) with Android Studio.

In May 2015, Google introduced Android M. According to Google, the main goal of the new operating system is to improve the user experience of communicating with a smartphone, making interaction intuitive and easier.

On August 17, 2015, it officially became known that Android M was called Android 6.0 Marshmallow.

android program mobile

2. Android distribution

At the beginning of each month, Google traditionally publishes statistics on the distribution of Android versions. According to the latest data, in January 2016 the share of Android 6.0Marshmallow almost doubled, but so far only 1.2% of devices are running the new operating system. Alas, manufacturers are in no hurry to update already released gadgets, and most of the new products introduced recently still use Android Lollipop.

Figure 3

Table 1

VersionCodenameAPIDistribution2.2Froyo80.1%2.3.3 - 2.3.7Gingerbread102.7%4.0.3 - 4.0.4Ice Cream Sandwich152.5%4.1.xJelly Bean168.8%4.2.x1711.7%4.3183.4%4.4KitKat1935.5 %5.02117.0%5.1Lollipop2217.1%6.0Marshmallow231.2% Data as of February 1, 2016.

The share of Android 6.0 Marshmallow barely exceeded 1% almost four months after the platform's release. During the same time, 77% of Apple mobile gadgets were updated to iOS 9.

% of devices use iOS 9 (iPhone and iPad)

Figure 4

What’s most surprising is that Android 4.4 KitKat, announced in 2013, is still in the lead in Google’s ranking (35.5%). In second place in popularity is the Lollipop version with a share of 34.1%, and the third place is occupied by Jelly Bean (23.9%).

3. Built-in Android apps

Android devices come with a set of pre-installed programs developed by the Android Open Source Project (AOSP).

We list the main ones:

E-mail - client;

Application for working with SMS (starting from Android 5.0 replaced by Hangouts);

A complete set of tools for managing the user’s personal data, including a calendar and address book;

WebKit-based browser (since Android 4.4 replaced by Google Chrome);

Music player and photo gallery (starting with Android 5.0 replaced by Google Play Music and Google Photos);

Calculator;

"Desktop";

Alarm

In many cases, Android also includes the following licensed software from Google:

Google Play Store for downloading third-party programs developed for the Android platform, purchasing films, music, books and press;

Full Google Maps app including Street View, Driving Directions, routed navigation, satellite map and traffic information;

Program for working with Gmail mail;

Google Hangouts instant messaging program;

A program for working with Google Drive files;

Video player for working with the YouTube service.

Data accessed from these applications, such as the address book, is also open to third-party programs. In addition, applications can, for example, respond to incoming calls.

The appearance of the programs that are installed on new phones can vary greatly depending on the hardware manufacturer and/or operator or distributor.

The open nature of the Android platform means that operators or OEMs can change the user interface and software on any Android device.

Some manufacturers have developed their own interfaces, such as HTC's Sense, Motorola's Moto Blur, and Samsung's Touch Wiz.

4. Android architecture

Figure 5 Google Android platform structure

The Google Android architecture consists of four layers (the numbering indicates the order of the layers from bottom to top).

Level - OS Linux kernel version 2.6 ensures the functioning of the system. It is responsible for security, memory, power and process management, and also provides a network stack and driver model. It also plays a connecting role between the hardware and the rest of the software stack.

Layer - Middleware - a set of libraries (Libraries) designed to provide critical functionality for applications.

Here are some of them:

Surface Manager is a composite window manager. Instead of drawing graphics to the display buffer, the system sends incoming drawing commands to the off-screen buffer, where they accumulate together with others, making up a certain composition, and then are displayed to the user on the screen. This allows you to create interesting seamless effects, window transparency and smooth transitions.

Media Framework - libraries implemented on the basis of PacketVideo OpenCORE. With their help, the system records/plays audio and video content, as well as displays static images. MPEG4, H.264, MP3, AAC, AMR, JPG and PNG formats, etc. are supported.

SQLite is a relational DBMS used in Android as the main engine for working with databases used by applications to store information.

3D libraries - used for rendering 3D graphics; if possible, use hardware acceleration. Implemented based on the OpenGL ES 1.0, 2.0, 3.0 and 3.1 API.

FreeType is a library for working with rasterizing fonts and performing operations on them.

LibWebCore - WebKit browser engine libraries.

SGL (Skia Graphics Engine) is a library for working with 2D graphics.

Libc is a standard C language library configured to run on Linux-based devices.

All libraries are written in C++ and compiled for specific device hardware.

The Android Runtime environment is located at the same level. It consists of the Dalvik/ART Java virtual machine and kernel libraries. Dalvik/ART supports simultaneous operation of several applications and executes files in a special format. dex, optimized for devices with low memory. The core libraries are written in Java and support a wide range of functionality.

Each application in the Android Runtime runs in its own instance of the Dalvik/ART virtual machine. That is, all running processes are isolated from the operating system and from each other. A feature of the Android Runtime structure allows programs to run strictly within a virtual machine. Thanks to this, the operating system kernel is protected from influence by other components. Error code or malware will not be able to damage the system or the device itself. The protection function, in addition to direct execution of program code, is one of the key ones for this level.

Level - Application Framework, or application framework. It is through application frameworks that developers gain access to APIs provided by underlying system components. In addition, thanks to the architecture of the framework, any application is provided with already implemented capabilities of other applications that are allowed to access.

The basic set of services and systems that underlie each application and are parts of the framework include:

A rich and extensible set of Views that can be used to create visual application components, such as lists, text fields, tables, buttons, or even an embedded web browser.

Content Providers, which manage the data that some applications make available to others so that they can use it for their work.

Resource Manager, which provides access to resources without functionality (not carrying code), for example, string data, graphics, files, and others.

Notification Manager, thanks to which all applications can display their own notifications to the user in the status bar.

Activity Manager, which manages application lifecycles, stores activity history data, and also provides a navigation system for them.

Location Manager, which allows applications to periodically receive updated data about the geographic location of the device.

Thus, applications in the Android OS can have auxiliary tools at their disposal.

Differences between a framework and a library

The framework only executes the code written for it, the libraries execute themselves.

The framework consists of libraries with different functionality and purposes, and the libraries combine sets of functions that are similar in logic.

Level 4 - Applications. This includes the basic programs that come pre-installed on Android. This is a browser, email client, program for sending SMS, maps, calendar, contact manager. The list of integrated applications may vary depending on the device model and Android version. Third-party software is also located at this level. The system allows you to install it without restrictions, so all standard applications can be replaced by analogues. Android applications are written in Java .

5. Advantages and disadvantages of Android OS

1 Advantages

Some observers note that Android performs better than one of its competitors, Apple iOS, in a number of features, such as web surfing and integration with Google Inc. services. and others. Also, Android, unlike iOS, is an open platform, which allows you to implement more functions on it.

Android devices usually have a microSD card reader, which makes it possible to quickly transfer files from your computer to your phone. In addition, in Windows Phone 7 it is impossible to directly transfer any files from and to the phone, except through synchronization programs (Zune), while Android phones export the file system of the memory card as a USB mass storage device (in versions starting from 3.0 at the discretion of the manufacturer) or using Media Transfer Protocol (MTP).

Unlike Windows Phone 7, Android claims a full implementation of the Bluetooth stack, which allows, among other things, the transfer and reception of files. There is an implementation of an FTP server, a network access point mode (PAN services) and a group peer-to-peer network via Bluetooth (GN services).

Despite the initial ban on installing programs from “unverified sources” (for example, from a memory card), this restriction is disabled by standard means in the device settings, which allows you to install programs on phones and tablets without an Internet connection (for example, users who do not have Wi-Fi Fi-access points and those who do not want to spend money on mobile Internet, which is usually expensive), and also allows everyone to write Android applications for free and test them on their device. Available for various hardware platforms, such as ARM, MIPS, x86.

There are alternative app stores to Google Play: Amazon Appstore (English), Opera Mobile Store, Yandex.Store, GetUpps!, F-Droid (English) and others.

Version 4.2 introduced support for multi-user mode.

5.2 Disadvantages

The presence in some Android devices of Google services that provide the ability to transfer identification information to the company’s servers, for example, information about the user’s movement in real time.

In version Android 1.6, the developers added the Native Development Kit, which allows you to write your own low-level modules for the system in C/C++ languages, relying on standard Linux libraries. Although, for example, the standard C library on the Android platform, known as Bionic, is not standard and is completely compatible with libc.

To access Google Play and other services from Google, you must use proprietary applications that the phone manufacturer has the right to install on the phone only after concluding a contract with Google.

Android's competitors have criticized the platform, accusing it of being overly fragmented and hampering developers. Google has denied all accusations, saying that there are no such problems.

Google's decision not to publicly release the Android 3.0 Honeycomb code, which is only available to members of the Open Handset Alliance or upon individual request after the agreement is signed, has been criticized. Google motivates this by the unavailability of the platform and a measure to prevent its careless implementation. Richard Stallman stated that "it's clear and simple: with the exception of the Linux kernel, Android 3 is proprietary software" and "even though Android phones today are not as bad as Apple or Windows smartphones, it cannot be said that they respect your freedom.” Currently, Google has open sourced all versions of Android up to 6.0, and has also released all changes to Linux under the GPL.

According to Lookout Security Mobile, in 2011, about a million US dollars were stolen from Android smartphone users (for example, sending SMS without the knowledge of the phone owner). However, this often occurs for users who do not carefully read permission lists.

6. What Android is not

Unsurprisingly, the introduction of revolutionary technology has caused some confusion about what Android actually is. We can confidently say what it is not.

-Implementation of the Java ME platform. Android applications are written using the Java language, but they are not used in the Java ME (Mobile Edition) virtual machine, so classes and executables compiled for Java will not run on the Android platform.

-Part of the Linux Phone Standards Forum (LiPs) initiative or the Open Mobile Alliance (OMA). Android runs on the open source Linux kernel, but while the goals are similar, the entire Android platform software stack is intended to solve more promising problems compared to the standards initiatives of the mentioned organizations.

-Standard application level (for example, UiQ or S60). While Android has an application layer, it also spans the entire software stack, from the lowest level - the operating system - to the level of API libraries and the applications themselves.

-Type of mobile phones. Android includes reference designs for mobile phone manufacturers, but there is no Android branded phone in the wild. Quite the opposite: Android was designed to be used on a wide variety of devices.

-Google's answer to the iPhone. iPhone is Apple's proprietary software and hardware platform. At the same time, Android is a set of open source software developed and maintained by the Alliance for Open Mobile Architectures. Android is designed to work on any compatible device.

Conclusion

Today, the operating system for mobile platforms Google Android has become quite popular. The prospects for an OS for mobile devices are very promising: improved and simplified user interface; improved graphics; wider multimedia capabilities; development of a set of service and game programs; compatible with PC and file formats; continuation and development of the use of the Java platform for mobile devices; development of mobile devices themselves: improving screen resolution, accelerating processors, increasing memory capacity, implementing new fast communication technologies.

The architectural features of the Google Android platform have allowed it to take first place among other platforms. The main ones:

1A well-designed kernel borrowed from the Linux system.

2Register-oriented Dalvik/ART virtual machine for running applications.

Innovative libraries that significantly expand the functionality of devices.

4"Lightweight" SQLite DBMS for data storage.

5The ability to support 3D and 2D graphics, and even combine them in one application.

Multitasking and isolation of processes from each other.

Versatility of architecture along with high quality.

Literature

1) Goloshchapov A.L. Google Android: system components and network communications. - St. Petersburg: BHV-Petersburg, 2012. - 384 p.

2) Felker D. Android: application development for dummies. - M.: Dialectics, 2012. - 336 p.

3) Hashimi S., Komatineni S., McLean D. Android application development. - St. Petersburg: Peter, 2011. - 736 p.

4) Mayer R. Android 4. Programming applications for tablet computers and smartphones. - M.: Eksmo, 2013. - 816 p.

5)Android developer

)Apple developer

In this article I will try to look at security a little higher than the kernel, namely: how security works in the Native user space. We will touch on the topic of the operating system boot process and look at the structure of the Android file system. As I already said, I’m not very strong in Linux, so if you notice any inaccuracies, then correct them - teach me and improve the article. Since this topic is quite extensive, I decided to break it into two parts. In the first part we will look at the process of loading the operating system and the features of the file system. Anyone interested is welcome!

List of articles

Here are links to my articles from this topic:
  1. Basic security of the Android operating system. Kernel level
  2. Basic security of the Android operating system. Native user space, part 1
  3. Basic security of the Android operating system. Native user space, part 2
  4. Basic security of the Android operating system. Security at the Application Framework level. Binder IPC

What is meant by Native user space

Native user space refers to all user space components that run outside of the Dalvik Virtual Machine and that are not part of the Linux kernel.

Android File System

First, let's take a look at the Android file system structure. Although Android is based on the Linux kernel, we will not see the familiar file system structure here. Let's fire up the emulator and see what we have. To do this, run the command:

Adb shell ls -al
In my terminal for an Android 4.2 emulator I see the following output:

Drwxr-xr-x root root 2013-04-10 08:13 acct drwxrwx--- system cache 2013-04-10 08:13 cache dr-x------ root root 2013-04-10 08:13 config lrwxrwxrwx root root 2013-04-10 08:13 d -> /sys/kernel/debug drwxrwx--x system system 2013-04-10 08:14 data -rw-r--r-- root root 116 1970- 01-01 00:00 default.prop drwxr-xr-x root root 2013-04-10 08:13 dev lrwxrwxrwx root root 2013-04-10 08:13 etc -> /system/etc -rwxr-x--- root root 244536 1970-01-01 00:00 init -rwxr-x--- root root 2487 1970-01-01 00:00 init.goldfish.rc -rwxr-x--- root root 18247 1970-01-01 00:00 init.rc -rwxr-x--- root root 1795 1970-01-01 00:00 init.trace.rc -rwxr-x--- root root 3915 1970-01-01 00:00 init.usb .rc drwxrwxr-x root system 2013-04-10 08:13 mnt dr-xr-xr-x root root 2013-04-10 08:13 proc drwx------ root root 2012-11-15 05: 31 root drwxr-x--- root root 1970-01-01 00:00 sbin lrwxrwxrwx root root 2013-04-10 08:13 sdcard -> /mnt/sdcard d---r-x--- root sdcard_r 2013-04 -10 08:13 storage drwxr-xr-x root root 2013-04-10 08:13 sys drwxr-xr-x root root 2012-12-31 03:20 system -rw-r--r-- root root 272 1970-01-01 00:00 ueventd.goldfish.rc -rw-r--r-- root root 4024 1970-01-01 00:00 ueventd.rc lrwxrwxrwx root root 2013-04-10 08:13 vendor -> /system/vendor
I will note here only the main directories and those that will be useful to us in the future. You can find descriptions and purposes of other directories on the Internet. You will notice that some directories are the same as in Linux, for example, /dev, /proc, /sys, /mnt, /etc And their purpose is basically the same as in Linux. By the way, note that we don't see /bin And /lib directory. I’ll tell you where they hid a little later.

On the other hand, you can notice directories that do not exist in Linux at all. Among them we are interested in /data, /system, /cache, /init, /init.rc Let's take a closer look at their purpose.
/system This is the main directory where the immutable components of the Android system are stored. If we draw an analogy, this folder is similar to the folder C:\windows\, read-only. Those. We cannot change the data in this directory. This is where you can find the directories /bin And /lib, where various executable files and shared libraries are stored. In addition, there are system applications that are built into the operating system and which, by default, cannot be deleted. The contents of this directory are generated during compilation of the operating system.
/data Because /system Since we have read-only access, there must be a directory where the changeable data is stored. /data that's exactly what it is. For example, to this directory in /data/app apk files of installed applications are saved, and in /data/data their data is stored (we discussed this directory in detail in the previous article).
/cache This is just temporary storage. System updates are also saved to this directory and then launched from it.

To understand what it is /init file and why incomprehensible files with the *.rc extension are needed, let's look at the system boot process.

Android boot process

Let's look at a few steps of the Android operating system download process. This picture is taken from the book “Embedded Android”, where you can also find a more detailed description. Although in general I understand the process, for me it’s more magic :)

CPU. When you press the power button, voltage is supplied to the processor of your device. Since up to this point the processor was turned off, and since it is not able to maintain its state without applying voltage, then immediately after the start it is in some uninitialized state. In this case, the processor reads some hard-wired address from its special register and begins executing instructions starting from it. Most often, this address points to the chip into which the bootloader is embedded.
Bootloader. Bootloader initializes RAM and loads the Linux kernel into it. In addition, Bootloader creates a RAMdisk.
Linux kernel. The kernel initializes various subsystems, built-in drivers, and mounts the root filesystem. The kernel can then run the first program.
This is where the magic ends and then everything becomes more or less clear.

Init

The first program in the case of Android is init. The executable file is located in the root directory ( /init). It is this program that the kernel starts after it is loaded. Its sources are located in the folder Let's dig into them a little. We are interested in :

Int main(int argc, char **argv) ( ... /* clear the umask */ umask(0); /* Get the basic filesystem setup we need put * together in the initramdisk on / and then we will * let the rc file figure out the rest. */ mkdir("/dev", 0755); mkdir("/proc", 0755); mkdir("/sys", 0755); mount("tmpfs", "/dev" , "tmpfs", MS_NOSUID, "mode=0755"); mkdir("/dev/pts", 0755); mkdir("/dev/socket", 0755); mount("devpts", "/dev/pts" , "devpts", 0, NULL); mount("proc", "/proc", "proc", 0, NULL); mount("sysfs", "/sys", "sysfs", 0, NULL); ... init_parse_config_file("/init.rc"); ... )
First, we create and mount some directories necessary for work, and then we parse the file /init.rc and execute what we parsed. Format /init.rc The file is very well described in, and an example can also be found there. In short, this file is a set of actions (sections - a named sequence of commands). Each sequence of commands is triggered by a specific trigger. For example, the following sequence is an action, in which trigger is fs, and the command sequence is a set of mount commands:


Original file /init.rc is in Let's look at some of the main parts of it, although I highly recommend viewing it in its entirety. After this, many things should become clear to you. So, our file begins with the following lines:

Import /init.usb.rc import /init.$(ro.hardware).rc import /init.trace.rc
They mean that in addition to init.rc file, you must also import settings from the files init.usb.rc, init.trace.rc and from a file with an unclear name init.$(ro.hardware).rc However, $(ro.hardware) is just a variable whose value determines the type of hardware. In the case of an emulator, its value is, for example, - goldfish. The following environment variables are defined:

On init ... # setup the global environment export PATH /sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin export LD_LIBRARY_PATH /vendor/lib:/system/lib export ANDROID_BOOTLOGO 1 export ANDROID_ROOT /system export ANDROID_ASSETS /system/app export ANDROID_DATA /data export ANDROID_STORAGE /storage export ASEC_MOUNTPOINT /mnt/asec export LOOP_MOUNTPOINT /mnt/obb export BOOTCLASSPATH /system/framework/core.jar:/system/framework/okhttp.jar:/system /framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/ framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar ...
After this, the variables necessary for the operation of the device are initialized. If you are interested in this topic, you can easily find information about this or that command. Let's take a closer look at the following block (which I have already given in this article):

On fs # mount mtd partitions # Mount /system rw first to give the filesystem a chance to save a checkpoint mount yaffs2 mtd@system /system mount yaffs2 mtd@system /system ro remount mount yaffs2 mtd@userdata /data nosuid nodev mount yaffs2 mtd @cache /cache nosuid nodev
MTD - Memory Technology Devices. In general terms, MTD is a special chip with non-volatile (i.e. data on this chip is saved after a reboot or shutdown) flash memory (NOR or NAND type), on which disk images are saved. This article goes into more detail about this type of device, as well as its limitations. Special file systems, for example, YAFFS, have been developed specifically for these types of flash memory. One of the most important limitations of these types of memory is that in order to write data to a sector that already has some data written to it, you must completely erase the entire sector first. Therefore, manufacturers began to switch to a new type of block flash memory (eMMC), on which you can install a regular ext4 file system and get rid of this limitation. Because I'm showing an example init.rc file for the emulator, where all the work is emulated, it uses the YAFFS2 file system by default (I think this is a relic of the past, since YAFFS2 was used for all devices before Android 2.2). In a real device (this is just one example when it is necessary to use init.rc file for a specific hardware) these commands will be overwritten. For example, in the case of a device herring (Google Nexus S), in the file this section looks like this:

On fs mkdir /efs 0775 radio radio mount yaffs2 mtd@efs /efs noatime nosuid nodev chmod 770 /efs/bluetooth chmod 770 /efs/imei mount_all /fstab.herring ...
Where fstab.herring is , the contents of which look like this:

... /dev/block/platform/s3c-sdhci.0/by-name/system /system ext4 ro wait /dev/block/platform/s3c-sdhci.0/by-name/userdata /data ext4 noatime,nosuid ,nodev,nomblk_io_submit,errors=panic wait,encryptable=/efs/userdata_footer
As you may have noticed, /system, /data, /cache- these are simply mounting points (file system mount points) that point to either the MTD of the device (in the case of an emulator) or to the block devices (in the case of a real device), where the corresponding disk images (system.img, userdata.img and cache) are written .img). I’m not sure, but I think that inside the smartphone there is one single chip with flash memory, divided into partitions (volumes), each of which contains a corresponding image. This flash memory chip is what we know as Internal storage(internal memory), the volume of which is one of the main parameters of a smartphone.

It should be noted that /system mounted read-only. This means that the contents of this section do not change while the device is running, but only when you, for example, update the system on your device (using system updates).

Let's continue to look at our init.rc. By trigger post-fs-data the basic structure of the file system is formed /data section. There, in general, everything is clear - a set mkdir, chown, chmod commands

Further init.rc launches several daemons. If you return to the figure at the beginning of the article, they are listed in the Native daemons block. We'll stop there for now. As you may have noticed from the figure, I did not fully cover the process of loading the operating system. I will look at some uncovered steps in the next article.

Conclusion

In the next part I will tell you where the system.img, userdata.img and cache.img images come from and look at security at the Native user space level. As always, corrections, additions, and suggestions on what to write are welcome. And although I already have some plan for what to write about in the next article, I’m ready to adjust it.

Android is a set of open software for mobile devices from Google, which includes an operating system and a set of basic cross-platform applications.

To develop applications for the Android platform, you will need a set of tools and API libraries - Android SDK, the latest version of which you can find.

The figure below shows the Android OS architecture.


Applications layer

Android includes a set of basic applications: email and SMS clients, a calendar, various maps, a browser, a program for managing contacts, and much more. All applications running on the Android platform are written in Java.

Application Framework layer

Android allows you to harness the full power of the APIs used in core applications. The architecture is built in such a way that any application can use the already implemented capabilities of another application, provided that the latter opens access to use its functionality. Thus, the architecture implements the principle of reuse of OS components and applications.

The basis of all applications is a set of systems and services:
1. Representation system ( View System) is a rich set of views with extensible functionality that serves to build the appearance of applications, including components such as lists, tables, input fields, buttons, etc.
2. Content providers ( Content Providers) are services that allow applications to access data from other applications, as well as share their own data.
3. Resource Manager ( Resource Manager) is intended for accessing string, graphic and other types of resources.
4. Notification manager ( Notification Manager) allows any application to display custom notifications in the status bar.
5. Action Manager ( Activity Manager) manages the life cycle of applications and provides a navigation system for the history of work with actions.

Libraries level

The Android platform includes a set of C/C++ libraries used by various OS components. For developers, access to the functions of these libraries is realized through the use of the Application Framework. Below are some of them:
1. System C library- A BSD implementation of the standard C system library (libc) for Linux-based embedded devices.
2. Media Libraries– libraries based on PacketVideo’s OpenCORE, designed to support playing and recording popular audio and video formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.).
3. Surface Manager– the surface manager controls access to the display subsystem of 2D and 3D graphic layers.
4. LibWebCore– a modern web browser engine that provides all the power of the built-in Android browser.
5. SGL– an engine for working with 2D graphics.
6. 3D libraries– an engine for working with 3D graphics, based on the OpenGL ES 1.0 API.
7. FreeType– a library designed to work with fonts.
8. SQLite– a powerful lightweight engine for working with relational databases.

Runtime layer (Android Runtime)

Android includes a set of core libraries that provide much of the functionality of the core Java language libraries.

The platform uses an optimized, register-oriented Dalvik virtual machine, unlike the standard Java virtual machine, which is stack-oriented. Each application runs in its own process, with its own virtual machine instance. Dalvik uses the Dalvik Executable (*.dex) format, which is optimized for minimal application memory usage. This is ensured by such basic Linux kernel features as threading and low-level memory management. The Java bytecode in which your applications are written is compiled into dex format using the dx utility included in the SDK.

Linux Kernel Level

Android is based on Linux OS version 2.6, thereby providing kernel system services such as memory and process management, security, networking and drivers. The kernel also serves as an abstraction layer between hardware and software.

New on the site

>

Most popular