Android Packagemanager Overview

Source: Internet
Author: User


1. Application Layer
Calling the Getpackagemanager () function of the Contextimpl class returns a Packagemanager object that invokes various API interfaces through the object.
The procedure for the Getpackagemanager () function and Getsystemservice () is basically similar to the IBinder object that obtains the specified name from ServiceManager, where the name is "package"-- Getsystemservice ("package").

2. Packagemanagerservice Service Layer
The package management service runs in the systemserver process.
Packagemanagerservice Saving related package management information using XML files in two directories
(1) under the/system/etc/permissions directory
① defines which feature are included in the system. The APP uses <use-feature> tags in the androidmanifest.xml file to declare which feature are required.
<use-feature android:name= "Android.hardwate.wifi" android:required= "true"/>
②platform.xml file. Assign some default permissions to some special UID and GID
A. Assigning permissions to GID use <permission> tags
<permission name= "Android.permission.BLUETOOTH_ADMIN" >
<group gid= "Net_bt_admin"/>
</permission>
B. Assigning permissions to the UID use <assign-permission> tags
<!--standard permissions granted to the shell. -
<assign-permission name= "Android.permission.WRITE_EXTERNAL_STORAGE" uid= "Shell"/>


(2)/data/system/packages.xml, contains the app package name, the installation package path, which system permissions are used
Total Rights statement
<packages>
<last-platform-version internal= "external="/>
<permission-trees/>
<permissions>
<item name= "Com.sec.android.app.gallery3d.READ_PICASA" package= "Com.sec.android.gallery3d"/>
<item name= "Com.sec.android.app.gallery3d.WRITE_PICASA" package= "Com.sec.android.gallery3d"/>
<item name= "Com.sec.android.app.gallery3d.WRITE_STROKEDB" package= "Com.sec.android.gallery3d"/>
<item name= "Com.sec.android.app.gallery3d.WRITE_SNS" package= "Com.sec.android.gallery3d"/>
<item name= "Com.sec.android.app.gallery3d.READ_SNS" package= "Com.sec.android.gallery3d"/>
</permissions>

Information for each package. <perms> claims permissions can also be used in each package
<package
Name= "Com.sec.android.gallery3d"
Codepath= "/system/app/secgallery2013.apk"
Nativelibrarypath= "/data/app-lib/secgallery2013"
Flags= "1621061"
ft= "143fbeddf38"
it= "143fbeddf38"
ut= "143fbeddf38"
Version= "17"
Userid= "10088" >
<sigs count= "1" >
                <cert index= "3" key = "308204a830820390a003020102020900936eacbe07f201df300d06092a864886f70d0101050500308194310b3009060355040613025553311330110 603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643110 300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440616 e64726f69642e636f6d301e170d3038303232393031333334365a170d3335303731373031333334365a308194310b3009060355040613025553311330 110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773110300e060355040a1307416e64726f69643 110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a864886f70d0109011613616e64726f696440 616e64726f69642e636f6d30820120300d06092a864886f70d01010105000382010d00308201080282010100d6931904dec60b24b1edc762e0d9d8253 E3ecd6ceb1de2ff068ca8e8bca8cd6bd3786ea70aa76ce60ebb0f993559ffd93e77a943e7e83d4b64b8e4fea2d3e656f1e267a81bbfb230b578c20443be4c7218b846f5211586f038a14e89c2be387f8e Becf8fcac3da1ee330c9ea93d0a7c3dc4af350220d50080732e0809717ee6a053359e6a694ec2cb3f284a0a466c87a94d83b31093a67372e2f6412c06 E6d42f15818dffe0381cc0cd444da6cddc3b82458194801b32564134fbfde98c9287748dbf5676a540d8154c8bbca07b9e247553311c46b9af76fdeec cc8e69e7c8a2d08e782620943f99727d3c04fe72991d99df9bae38a0b2177fa31d5b6afee91f020103a381fc3081f9301d0603551d0e0416041448590 0563d272c46ae118605a47419ac09ca8c113081c90603551d230481c13081be8014485900563d272c46ae118605a47419ac09ca8c11a1819aa4819730 8194310b3009060355040613025553311330110603550408130a43616c69666f726e6961311630140603550407130d4d6f756e7461696e20566965773 110300e060355040a1307416e64726f69643110300e060355040b1307416e64726f69643110300e06035504031307416e64726f69643122302006092a 864886f70d0109011613616e64726f696440616e64726f69642e636f6d820900936eacbe07f201df300c0603551d13040530030101ff300d06092a864 886f70d010105050003820101007aaf968ceb50c441055118d0daabaf015b8a765a27a715a2c2b44f221415ffdace03095abfa42df70708726c2069e5c36eddae0400be29452c084bc27eb6a1 7eac9dbe182c204eb15311f455d824b656dbe4dc2240912d7586fe88951d01a8feb5ae5a4260535df83431052422468c36e22c2a5ef994d61dd7306ae 4c9f6951ba3c12f1d1914ddc61f1a62da2df827f603fea5603b2c540dbd7c019c36bab29a4271c117df523cdbc5f3817a49e0efa60cbd7f74177e7a4f 193d43f4220772666e4c4d83e1bd5a86087cf34f2dec21e245ca6c2bb016e683638050d2c430eea7c26a1c49d3760a58ab7f1a82cc938b4831384324b D0401fa12163a50570e684d "/>
</sigs>
</package>

In addition to PMS, there are two additional services for program installation
①defaultcontainerservice, mainly copy the installer to the program directory
The ②installer service, not binder, is the socket client, and the PMS interacts directly with the socket client. The socket server is responsible for extracting work and data Catalog creation.
For example, extract the Dex file from the APK, delete the Dex file under Dalvik-cache, create a program-specific data directory, and so on.

3. Data file Layer
(1) Program Files
① system app saved in/system/app directory
② third-party apps are saved in the/data/app directory
Before installation, can be arbitrarily named, save in any place; after installation, the PMS will put the apk file in the/data/app directory, the file name is named after the package name, and automatically append a "-X" suffix

The second installation, the number 1 will become 2, the third installation, 2 becomes 1, like the ping-pong mechanism.
The execution code in the program is saved in the ③/data/dalvik-cache directory.


APK is actually a jar compression type of file, the compressed package contains various resource files, resource index files, androidmanifest files and program Files
Before the application runs, the PMS extracts the code files from the APK (that is, the Dex file, which exists in the directory for quick operation)

(2) Framework library file
These library files exist in the/system/framework directory, and the type is APK or jar
After the system is powered on, the Dalvik virtual machine loads the library files
If these jars or apk are not converted to Dex files when the PMS is started, the PMS will convert the library files to Dex files and save them in the/data/dalvik-cache directory.

(3) data files used by the app
① save mode, the app can store parameters, database storage, file storage
② storage directory, generally saved in the/data/data/xxx directory, XXX is the package name.


③ In addition to the/data/data directory, the system also provides three additional directories
A./data/secure saves encrypted data. The framework provides an encrypted class interface, and all encrypted files are stored in that directory.
B./data/drm stores data files that contain digital copyrights. The framework provides a DRM-related class interface for indirect access to files in this directory
C./data/app-private, the same as the/DATA/DRM function. The framework may not use/DATA/DRM, instead use/data/app-private instead

Android Packagemanager Overview

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.