Linux kernel control of Android includes security, memory management, process management, network stack, driver model and so on. Before downloading the Android source code, you should install its build tool Repo to initialize the source code. Repo is a tool used by Android to assist Git. APK is the suffix of Android application and the abbreviation of AndroidPackage, namely Android installation package (apk). APK is a file format similar to Symbian Sis or Sisx. It can be installed by directly transferring APK files to Android emulator or Android phone for execution. Like sis, apk files package the projects compiled by android sdk into apk format installer files. The APK file is actually in zip format, but the suffix is changed to apk. After decompression, you can see the Dex file. Dex is the full name of Dalvik VM executes, that is, Android Dalvik Executors, not Java ME bytecode, but Dalvik bytecode.
APK file structure
The APK file structure is:
1.META-INF\ (note: it can often be seen in Jar files);
2.res\ (note: the directory where the resource files are stored);
3.AndroidManifest.xml (note: program global configuration file);
4.classes.dex (note: Dalvik bytecode);
5.resources.arsc (note: compiled binary resource file).
To sum up, we found that when running a program, Android needs to be decompressed first, and then installed directly like Symbian, which is different from PE files in Windows Mobile. This does not require high confidentiality and reliability of the program. You can decompile through the dexdump command, but it conforms to the development law. Microsoft's Windows gadget or WPF also adopts this architecture.
On the Android platform, the execution file of dalvik vm is packaged in apk format. Eventually, the runtime loader will decompress and get the security access related to the permission branch in the compiled androidmanifest.xml file, but there are still many security restrictions. If you transfer the apk file to the /system/app folder, you will find that the execution is unrestricted.
Finally, the files we usually install may not be in this folder, but the apk files of the system will be placed in this folder by default in android rom, and have root permissions. HAL (Hardware Abstraction Layer) of Android can provide hardware driver module in the form of closed source code. HAL's purpose is to separate the Android framework from the Linux kernel, so that Android will not rely too much on the Linux kernel, so as to achieve the concept of kernel independence. The development of Android framework can not consider the implementation of drivers.
HAL Stub is a concept of proxy, and Stub exists in the form of *. So file it. Stub "provides" operations to HAL, and the Android runtime obtains Stub operations from HAL, and then calls back these operations. HAL contains many stubs (proxies). As long as the runtime specifies the "type", that is, the module ID, the operation function can be obtained. The bridge between the operating system and the application, the application is divided into two layers: functional layer (library) and virtual machine (virtual machine). Bionic is an improved version of libc for Android. Android also includes Webkit, the engine behind Apple's Safari browser. Surface flinger displays 2D or 3D content on the screen. Android uses Google's self-made bionic Libc tool chain.
Android is based on OpenCORE, open core. The open core can be divided into seven blocks: PVPlayer, PVAuthor, Codec, Packet Video Multimedia Framework (PVMF), Operating System Compatibility Library (oscl), Common and OpenMAX.
Android uses skia as the core graphics engine and cooperates with OpenGL/ES. The function of Skia is the same as that of Linux Cairo, but compared with Linux Cairo, the function of skia is still in the primary stage. Skia was acquired by Google in 2005, and the source code of Skia GL was made public in early 2007. Skia is also the graphics engine of Google Chrome.
The multimedia database of Android adopts SQLite database system. Databases are divided into * * * databases and private databases. Users can obtain the database of * * * through the ContentResolver class (column).
The middle layer of Android is mostly implemented in Java, using a special Dalvik virtual machine. Dalvik virtual machine is a register-based Java virtual machine. Variables are stored in registers, and the instructions of the virtual machine are relatively reduced.
Dalvik virtual machine can have multiple instances, and each Android application is run by a Dalvik virtual machine, so that the system can be optimized when running the program. Instead of running Java bytecode, the Dalvik virtual machine runs a program called. Dex format. Android itself is an independent operating system. In this operating system, each application runs with a unique system identification identity (Linux user ID and group ID). Each part of the system also uses its own independent identification method. This is how Linux separates applications from applications and applications from systems.
More security functions of the system are provided through the authority mechanism. Permissions can restrict specific operations of a specific process, or restrict the access of each URI permission to a specific data segment.
The core design idea of Android security architecture is that by default, all applications have no right to operate other applications, systems or users. This includes reading and writing users' private data (contacts or emails), reading and writing other application files, accessing the network or preventing devices from standby.
When installing an application, the software package installer will give the application permission after checking the permission mentioned in the program signature and confirming it by the user. From the user's point of view, Android applications usually need the following permissions:
Make a phone call, send SMS or MMS, modify/delete the content on SD card, read contact information, read information of schedule letter, write schedule data, read phone status or identification code, accurately (based on GPS) geographic location, blur (based on network) geographic location, create Bluetooth connection, fully access the Internet, check network status, check WiFi status, avoid standby of mobile phone, modify system global settings, and read synchronization settings.
According to the functions provided by the application, it should require reasonable permissions. Users can also analyze the permissions required by an application, so as to simply judge whether the application is safe or not. If an application is a stand-alone version without advertisements and there is no additional content to download, it is suspicious that it needs to access the network.