Android bottom-up knowledge for Android app developers (8)

Source: Internet
Author: User

(10) PMS and app installation process

PMS, full name Packagemanagerservice, is used to get the information of the APK package.

In the previous analysis of the four components and AMS communication, we have introduced, AMS will always use the PMS load package information, encapsulated it in the class object loadedapk, and then we can take out in the manifest declaration of the four components of information.

A

In the process of downloading and installing the app, the APK will be stored in the Data/app directory.

APK is a zip compression package, the file header will record the size of the compressed package, so the subsequent in the file tail even if the addition of a small movie, will not affect the decompression-the Trojan is actually this idea, in executable exe tail hanging a trojan virus, execution EXE will also execute this trojan, And then you're in the middle of it.

We can use the Trojan idea on the Android multi-channel packaging. In older versions of Android 4.4, we'll append a few bytes to the APK tail to mark the APK channel. When the APK starts, it reads the channel value from the tail on the APK.

Google also found this security vulnerability, in the new version of the system, will be in the APK installation, check the actual size of the APK, to see if this value and the size of the APK header record of the compression package, is equal, the difference will be error said installation failed.

Two

We continue to talk about the app installation process. The Android system uses PMS to parse the manifest file in this apk, including:

    • Information about the four components, for example, the static receiver mentioned above. For example, the activity is started by default.
    • Assign the user ID and user group ID. The user ID is unique because Android is a Linux system. User group ID refers to a variety of permissions, each of which is in a user group, such as reading and writing the SD card, such as network access, which user group ID assigned to what permissions.

3) in launcher generates a icon,icon that holds the information for the activity that is started by default.

4) At the end of the app installation process, the above information is recorded in an XML file for reuse at the next installation.

Three

In fact, every time the Android phone system starts, it will use the PMS to install all the APK in the Android system once, altogether 4 steps, as follows:

The steps 3rd, 4th, and the individual installation of an app are the same. Let's analyze the first two steps:

The 1th step, because the installation information will be saved in the XML file when the installation is finished, so when the Android system starts again, reinstall all the APK, you can directly read the previous saved XML file.

2nd step, read and install all APK from 5 directories.

Finally, answer one of the questions mentioned earlier, why not unzip it when the app is installed? Is it faster to read the resource files directly from the extracted files than the slices? In fact, this is not the case, this part of the logic needs to the bottom C + + code to find, I did not specifically read, just hearsay asked Lody, he is so explained to me:

Every time from the APK to read the resources, not to extract and then find the image resources, but to parse the apk RESOURCE.ARSC file, this file stores all the information of the resource, including the resources in the APK address, size, etc., retrace, from this file to quickly find the corresponding resource file. This is a very efficient algorithm.

The benefits of the puzzle apk are naturally space-saving.

Android Bottom-up knowledge for Android app developers (8)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.