Android 10.0 PMS scanning apk time-consuming related function optimization when booting

1 Introduction


  In the android10.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 when starting up

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 when starting up

When the Android system starts up, 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.

     private void scanDirTracedLI(File scanDir, final int parseFlags, int scanFlags, long currentTime) {
               Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "scanDir [" + scanDir.getAbsolutePath() + "]");
               try {
                   scanDirLI(scanDir, parseFl

Guess you like

Origin blog.csdn.net/baidu_41666295/article/details/130665202