Android 12.0 startup optimization PMS scanning apk time-consuming related function optimization

1 Introduction


  In the android12.0 system rom customization development, when developing products in the system, third-party apps will be built in according to customer requirements. At this time, if there are too many built-in apps or too many apps installed,
the When pms scans and installs apps, it will be time-consuming. At this time, it is necessary to optimize the function code of pms scan and install apps, and use multi-threading to realize pms scan and install apps to speed up the boot time. Next, we will implement this function
.

2. The core class of PMS scanning apk time-consuming related function optimization for startup optimization

frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

3. Core function analysis and implementation of PMS scanning apk time-consuming related function optimization for startup optimization

When the Android 12.0 system starts up, the reason why the Android system starts slowly is that when starting the PMS, it needs to perform time-consuming operations
such as scanning folders, processing permissions, and installing system applications (file decompression and copying).
There are two parts that take a lot of time during the startup phase, namely preload classes and scan packages.
The preload classes are processed in the zygote stage. This chapter does not discuss this issue. The main discussion here is the processing of time-consuming operations
when scanning the app in the PMS stage. In the process of installing the app in the pms, it is mainly Execution
Call the scanDirTracedLI method to scan the /data/app folder, (the scanDirTracedLI method call will
execute the call layer by layer from the PackageManagerService main method, and then analyze the specific execution process

 

おすすめ

転載: blog.csdn.net/baidu_41666295/article/details/131691180