How and how Android apps are installed

Source: Internet
Author: User

How and how Android apps are installed

Four kinds of installation methods:

1. System Application Installation-complete on boot, no installation interface

2. Network download application installation-completed through market application, no Installation interface

3.ADB Tool Installation – no installation interface.

4. Third-party application installation-through the APK file installed in the SD card, there is an installation interface, the interface for the installation and uninstallation process is handled by the PACKAGEINSTALLER.APK application.

Process and path for application installation
Application installation involves the following directories:

System/app---------------System comes with an application that gets the ADB root permission to delete

Data/app---------------The directory where the user program is installed. Copy the apk file to this directory during installation
Data/data---------------Store data for your application
Data/dalvik-cache--------Install the Dex file in the APK into the Dalvik-cache directory (the Dex file is the executable file for the Dalvik virtual machine, which is approximately one-fourth of the original apk file size)

Installation process:

Copy the APK installation package into the Data/app directory, unzip and scan the installation package, save the Dex file (Dalvik bytecode) to the Dalvik-cache directory, and create the corresponding application Data directory in the Data/data directory.

Uninstall process:

Delete the files and directories created in the above three directories during the installation process.

Detailed installation process

Process resolution for installing an application

I. Start-up installation
Packagemanagerservice handles the installation, uninstallation, management of various applications, and starts the service by Systemserver when booting

(source file path: Android\frameworks\base\services\java\com\android\server\packagemanagerservice.java)

Packagemanagerservice Service START Process:

1. First scan the jar package installed in the "System\framework" directory

2. Scanning the application that installs the system System/app

3. Manufacturer's catalogue under/vendor/app application package

4. Scan the "Data\app" directory, which is a user-installed third-party app

5. Scan the "data\app-private" directory, that is, install the DRM-protected apk file (a protected song or protected video is a DRM-protected file)

And from this scanning method you can see that the scanpackagelist () is called.

Private Packageparser.package scanpackagelist (File scanfile,int parseflags, int scanmode, long currenttime)

After tracing the Scanpackagelist () method, it is found that the program passes many times if else filtering, and finally decides that it can be installed and call the Minstaller.install

Minstaller.install () passed

Localsocketaddress address = new Localsocketaddress (

"Installd", LocalSocketAddress.Namespace.RESERVED);

Command INSTALLD to complete the work in the C language file

Packagemanagerservice section:

1) Load the pacakge information from the APK, XML, and store it in the internal member variable for subsequent lookups. The key approach

is Scanpackagelist ().

2) various query operations, including query intent operation.
3) operation of the install package and delete package. And the key method behind it is installpackagelist ().

Second, download the application from the network:

After the download is complete, the installation method of Packagemanager is automatically called InstallPackage ()

The InstallPackage () function of the Packagemanagerservice class

This is done by Packagehandler instance Mhandler.sendmessage (msg) to the class Handlemessage () method that inherits handler ... Finally came back to the same place as the boot installation. Call the unified method with the power-on installation.

Iii. Installing from ADB tools

Its entry function source file is Pm.java

(source file path: Android\frameworks\base\cmds\pm\src\com\android\commands\pm\pm.java)

Where \system\framework\pm.jar package Management library

Package Management Script \SYSTEM\BIN\PM parsing

One of the Packageinstallobserver obs = new Packageinstallobserver ();

Mpm.installpackage (Uri.fromfile new File (Apkfilepath), Obs, Installflags,

Installerpackagename);

Iv. Installing from SD card

System Call Packageinstalleractivity.java (/home/zhongda/androidsrc/vortex-8inch-for-hoperun/packages/apps/ Packageinstaller/src/com/android/packageinstaller)

Entering this activity will determine if the information is wrong, and then call

private void Initiateinstall () to determine if a package has been installed with the same name, or if the package has been installed

After executing private void startinstallconfirm () Click OK button after a series of installation

Reprinted from: http://www.cnblogs.com/meizixiong/p/3551891.html

How and how Android apps are installed

Related Article

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.