Understanding how an Android app is installed by PackageManagerService

So, I was digging AOSP trying to figure out how the Android app was installed. While I am here:

The apk file will be sent from PackageInstallerActivity to InstallAppProgress, where it calls the PackageManager installPackage () method .

The previous PackageManager call is passed to the PackageManagerService with AIDL magic (it took me a while to figure this out).

In the main installPackageWithVerification () method , an instance of PackageHandler is created, and the message is transmitted in a reliable way using a combination of status codes such as INIT_COPY, PACKAGE_VERIFIED, etc.

Based on the status codes of messages received in the handler, ops is executed. To start with INIT_COPY - adds a package to the list of pending installations and calls a message with the code MCS_BOUND .

This copies the core files extracted from apk files such as data files.

And somewhere on the lane a message appears with the CHECK_PENDING_VERIFICATION flag , which takes a packet from the waiting list, analyzes the entries, especially the AndroidManifest file. Checks and verifies things like package signature, package_name, etc. Etc.

Then the updateSettingLI () call is made , which in turn calls up 3 more important function calls.

  • moveDexFilesLI ()
  • setPermissionsLI() - dir res/files, resources.arsc, Manifest.xml
  • updatePermissionsLPw() - grantPermissionLPw - ,

Package , , Permissions . , , -, PackageManagerService, scanPackageLI, .

, , - , linux, uid gids. . , PackageManagerService linux.

, "installd" . , ( linux) ( Linux)?

, .

+2
1

. , , . Android, Zygote. ( , ), Android .

Android Zygote . gid, . , Zygote , . , uid gids. , gids.

+2

All Articles