First, Packagemanagerservice START process
Systemserver starts first, creates a serverthread thread to start all Android Core Services, where the Packagemanagerservice.main method initiates Packagemanagerservice.
The main method is to instantiate the Packagemanagerservice object and register it in ServiceManager.
the construction process of Packagemanagerservice is designed to several important operations:
1. Create a Settings object, add Shareduser to it, Shareduserid defined in the Android manifest file, for example Android.uid.system is defined here. The settings constructor also creates a series of directories and files, such as the/data/system directory.
UID Range in Android:
system_uid = +;
non-system application 10000~19999;
isolation sandbox process 99000~99999;
2. Create the App Installer installer.
3. Start the message processing thread--a handlerthread named Packagemanager.
4, create user management object Usermanager.
5. The XML file under/etc/permissions is read and parsed through the Readpermissions () method, including the permissions assigned to the UID, the hardware information under the feature tag, and the configuration information of the system library.
6, read the installation package information, including the following important files:
/data/system/packages.xml The package information installed in the system.
/data/system/packages-stopped.xml records The package information that is forced to stop in the system.
/data/system/packages.list Save all non-system-brought APK information from the system.
7. Monitoring and scanning System Package installation directory:
/system/framework System Library
/system/app default System Application
/vendor/app Manufacturer-specific applications
8. Scan non-system APK information:
/data/app/
/system/preloadapp/
/data/app-private/
II, Packagemanager framework
Android's Packagemanager framework is a typical aidl framework. Code path Dir=framework/base/core/java/android/.
ipackagemanager.aidl files in dir/content/pm/ Ipackagemanager.aidl, in accordance with the Android standard aidl processing mode, generates a stub ipackagemanager.stub and a proxy IPackageManager.Stub.Proxy.
stub implementations are Packagemanagerservice, and the actual implementation of the agent is actually Applicationpackagemanager,packagemanager is its parent class.
Applicationpackagemanager path is dir/app/ Applicationpackagemanager.java.
Packagemanager path is Dir/content/pm/packagemanager.java.
The method in Context.getpackagemanager is actually called when the Contextimpl () method is called. This method takes a Ipackagemanager proxy object from the Activitythread and instantiates the Applicationpackagemanager with this proxy.
Android Packagemanager Basics