CN117130617A - Compiling method and device of application program - Google Patents

Compiling method and device of application program Download PDF

Info

Publication number
CN117130617A
CN117130617A CN202310141098.1A CN202310141098A CN117130617A CN 117130617 A CN117130617 A CN 117130617A CN 202310141098 A CN202310141098 A CN 202310141098A CN 117130617 A CN117130617 A CN 117130617A
Authority
CN
China
Prior art keywords
compiling
application program
file
profile
target application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310141098.1A
Other languages
Chinese (zh)
Inventor
武晨阳
金鑫
朱金鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202310141098.1A priority Critical patent/CN117130617A/en
Publication of CN117130617A publication Critical patent/CN117130617A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis
    • G06F8/427Parsing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files

Abstract

The embodiment of the application provides a compiling method and device for an application program, relates to the field of terminals, and can ensure that the application program obtains a reference configuration file in a scene such as idle trigger compiling of electronic equipment, and can compile and optimize according to the reference configuration file, so that the performance of the application program can be improved, and the user experience of a user when the application program is used is improved. The method comprises the following steps: under a target compiling scene, the electronic equipment determines whether an installation package of the target application program comprises a reference configuration file or not, wherein the reference configuration file is used for indicating a hot spot function in the installation package of the target application program; the target compiling scene comprises a scene of triggering compiling by the electronic equipment in an idle state; if the installation package of the target application program is determined to comprise the reference configuration file, the electronic equipment verifies the dex file in the installation package of the target application program based on the first compiling mode, and compiles the hot spot function indicated by the reference configuration file.

Description

Compiling method and device of application program
Technical Field
The present application relates to the field of terminals, and in particular, to a method and apparatus for compiling an application program.
Background
An Application (APP) is running in a virtual machine, which includes two parts for execution of application code. The first part is to compile source code into byte code, also called front-end compilation, and the work performed at this time is mainly to analyze the morphology, grammar and semantics. The second part is to compile the byte code into machine code for interpretation execution. However, since the interpretation is performed with low efficiency, it has a serious influence on the user experience, and dex2oat (dalvik excutable file to optimized art file) has been developed to solve this problem. The dex2oat can compile the byte code of the application program into the machine code in advance, so that the machine code can be directly executed in actual operation, and the operation efficiency of the application program is greatly improved.
The dex2oat comprises a plurality of different compiling modes, and the compiling modes are ordered according to the performance of the application after execution, and currently common compiling modes comprise: a compiling mode of speed, a compiling mode of speed-profile, a compiling mode of verify, etc. The compiling mode of speed carries out compiling optimization on all application program codes, and the obtained product has good performance, but the generated file is large, the time consumption is long, and the memory space of the mobile phone is consumed. The compiling mode of speed-profile depends on profile file, and compiling optimization can be performed on hot spot functions of the application program. The verify compiling mode only checks the dex file of the application program. The verify coding mode is inferior to the speed-profile coding mode in terms of coding performance.
In some cases, an electronic device (e.g., an Android handset) may employ a background idle compilation optimization policy, that is, a compilation mode that triggers speed-profile when the electronic device is idle to compile and optimize an application. Whereas the compiling mode of speed-profile must depend on the profile file, when there is no profile file, the compiling mode of speed-profile is degraded to the verify compiling mode. The sources of the current profile file may include the following two: 1) When a user installs an application in an application market (e.g., the Hua Cheng application market or the Google application market), the application market provides a Data Meta (DM) file, which contains profile information; 2) After the electronic equipment is started up for the first time/is restored to factory settings, or after the electronic equipment is subjected to OTA upgrade, or after the application program is installed, the hot spot function of the application program can be recorded in the process of using the application program by a user so as to generate a profile file.
However, the sources of the profile files have corresponding disadvantages: 1) The DM file is often generated with hysteresis, and the application market is provided to the user after the application program is actually running for a period of time. For the application program which is just online or frequently updated, the application market cannot provide the DM file in time, or the DM file is invalid or is not configured due to some reasons, so that the compiling mode of speed-profile cannot be triggered to carry out compiling optimization, and the performance of the application program is lower; 2) Although the DM file is configured in the application market, the DM file may have the problem of incomplete or inaccurate hot spot function configuration, and even if the compiling mode of speed-profile is triggered to carry out compiling optimization, the application program performance is still lower; 3) After a user starts up/upgrades the system for the first time, only the compiling mode of the verify can be triggered to compile and optimize the application program, if the user does not use the corresponding application program (the system application program and/or the third party application program) all the time, the profile file cannot be generated, so that the compiling mode of speed-profile cannot be triggered to compile and optimize during the background idle compiling and optimizing, and the performance of the application program is lower. 4) After the application program is installed from the application market, if the user does not use the application program all the time, the profile file cannot be generated, so that the compiling optimization of the speed-profile compiling mode cannot be triggered during the background idle compiling optimization, and the performance of the application program is low.
Disclosure of Invention
The embodiment of the application provides a compiling method and a compiling device for an application program, which can ensure that the application program obtains a reference configuration file in a scene of idle triggering compiling of electronic equipment, and can compile and optimize according to the reference configuration file, so that the performance of the application program can be improved, and the user experience when a user uses the application program is improved.
In a first aspect, an embodiment of the present application provides a compiling method for an application program, including: under a target compiling scene, the electronic equipment determines whether an installation package of the target application program comprises a reference configuration file or not, wherein the reference configuration file is used for indicating a hot spot function in the installation package of the target application program; the target compiling scene comprises a scene of triggering compiling by the electronic equipment in an idle state; if the installation package of the target application program is determined to comprise the reference configuration file, the electronic equipment verifies the dex file in the installation package of the target application program based on the first compiling mode, and compiles the hot spot function indicated by the reference configuration file.
Based on the method provided by the embodiment of the application, in a target compiling scene (a scene of idle triggering compiling of electronic equipment), the electronic equipment can acquire a baseline profile file (reference configuration file) of a target application program, verify a dex file in an installation package of the target application program based on a first compiling mode (a compiling mode of speed-profile (have profile)), and compile a hot spot function indicated by the reference configuration file. After compiling is completed, when the electronic equipment runs the target application program, the compiling optimization file can be directly called, the dex file of the target application program is not required to be compiled in time, the compiling time is saved, the executing efficiency of the electronic equipment on the application program is improved, the running of the application program is smoother, and the user experience can be improved. The compiling method of the application program provided by the application does not need to rely on an application market to provide a DM file (the DM file comprises a profile file) for the application program, and does not need to wait for the hot spot function of the application program to record when the application program runs so as to generate the profile file. Even if the user cannot record the hot spot function of the application program to generate the profile file when the user runs due to the fact that the user does not use the target application program all the time, the compiling mode of speed-profile (have profile) can be triggered to compile and optimize the application program, the performance (performance such as starting and sliding of the application program) of the application program can be improved, and therefore better experience is brought to the user.
In one possible implementation manner, the target compiling scene further comprises a scene of triggering compiling when the electronic device is started for the first time and a scene of triggering compiling when the electronic device performs over-the-air OTA upgrading. It should be noted that, in the scene after the electronic device is first started/restored to the off-site setting or the scene where the electronic device performs OTA upgrade (the OTA upgrade starting process or after the OTA upgrade enters the desktop), according to the baseline profile file, the compiling and optimizing of the target application program are performed at the electronic device end in the compiling mode of speed-profile (have profile), which saves more storage space than the compiling and optimizing of the target application program in the compiling mode of speed-profile (have profile) in the preset stage (the stage of burning the operating system, the system application program and some three-party application programs of the electronic device). The volume of the baseline profile file is smaller than that of a compiling optimization file (the compiling optimization file obtained by compiling and optimizing a target application program in a speed-profile (have profile) compiling mode in a preset stage), so that the number of files preset by the electronic equipment can be reduced, and the storage space of the electronic equipment can be saved.
In one possible implementation, the method further includes: the method comprises the steps that when an electronic device runs a target application program, a hot spot function of the target application program is recorded, and a first configuration file is generated according to the recorded hot spot function; the electronic device verifying the dex file in the installation package of the target application program based on the first compiling mode, and compiling the hot spot function indicated by the reference configuration file comprises the following steps: and the electronic equipment verifies the dex file in the installation package of the target application program based on the first compiling mode, and compiles the hot spot function indicated by the reference configuration file and the hot spot function indicated by the first configuration file. In the target compiling scene, a more accurate and comprehensive hot spot function can be obtained by combining the baseline profile file and the profile file generated by the electronic equipment, and compiling and optimizing are carried out on the application program in a speed-profile (have profile) compiling mode. Compared with the compiling optimization of the speed-profile compiling mode only according to the profile file generated by the electronic equipment, the compiling optimization of the speed-profile compiling mode according to the baseline profile file and the profile file generated by the electronic equipment can better promote the application program performance, so that better experience is brought to users.
In one possible implementation, the electronic device determining whether the installation package of the target application includes the reference profile includes: the method comprises the steps that the electronic equipment analyzes a list file in an installation package of a target application program, a first flag bit is set in the list file, and the first flag bit is used for indicating whether the installation package of the target application program contains a reference configuration file or not; and reading the first flag bit, wherein if the first flag bit is true, the installation package representing the target application program contains the reference configuration file, and if the first flag bit is false, the installation package representing the target application program does not contain the reference configuration file. That is, the electronic device may determine whether the installation package of the target application program includes the reference configuration file according to the first flag bit in the manifest file, and if the installation package of the target application program includes the reference configuration file, the electronic device may verify the dex file in the installation package of the target application program based on the first compiling mode (compiling mode of speed-profile (have profile)), and compile the hotspot function indicated by the reference configuration file. Therefore, the performance of starting, sliding and the like of the target application program when the target application program is started for the first time can be improved, and better experience can be brought to the user.
In one possible implementation, the electronic device determining whether the installation package of the target application includes the reference profile includes: the electronic device detects whether a reference profile exists in an installation directory of the target application. That is, the electronic device may actively check whether the installation package of the target application program includes the reference configuration file, and if the installation package of the target application program includes the reference configuration file, the electronic device may verify the dex file in the installation package of the target application program based on the first compiling mode (the compiling mode of speed-profile (have profile)), and compile the hotspot function indicated by the reference configuration file. Therefore, the performance of starting, sliding and the like of the target application program when the target application program is started for the first time can be improved, and better experience can be brought to the user.
In one possible implementation manner, before the electronic device verifies the dex file in the installation package of the target application program based on the first compiling mode and compiles the hotspot function in the installation package of the target application program, the method further includes: the electronic equipment checks whether the first configuration catalog exists or not, and if the first configuration catalog does not exist, the first configuration catalog is created; the electronic equipment moves the reference configuration file from the installation catalog to the first configuration catalog; the electronic equipment sets and updates a second flag bit, the second flag bit is used for triggering merging processing of the reference configuration files, and the electronic equipment moves the reference configuration files under the first configuration directory to the second configuration directory.
In a second aspect, the present application provides a chip system comprising one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected by a wire.
The chip system described above may be applied to an electronic device including a communication module and a memory. The interface circuit is for receiving signals from a memory of the electronic device and transmitting the received signals to the processor, the signals including computer instructions stored in the memory. When executed by a processor, the electronic device may perform the method as described in the first aspect and any one of its possible designs.
In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions. When executed on an electronic device (such as a mobile phone) the computer instructions cause the electronic device to perform the method as described in the first aspect and any one of its possible designs.
In a fourth aspect, the present application provides a computer program product which, when run on a computer, causes the computer to carry out the method according to the first aspect and any one of its possible designs.
In a fifth aspect, an embodiment of the present application provides an application compiling apparatus, including a processor, where the processor is coupled to a memory, and where the memory stores program instructions, and where the program instructions stored in the memory, when executed by the processor, cause the apparatus to implement the method according to the first aspect and any one of the possible design manners thereof. The apparatus may be an electronic device; or may be an integral part of an electronic device, such as a chip.
In a sixth aspect, an embodiment of the present application provides an apparatus for compiling an application program, where the apparatus may be functionally divided into different logic units or modules, and each unit or module performs a different function, so that the apparatus performs the method according to the first aspect and any possible design manner thereof.
In a seventh aspect, an embodiment of the present application provides a compiling system for an application program, including an electronic device and an application server, where the electronic device and the application server respectively execute part of steps, and cooperate with each other to implement the method described in the first aspect and any one of possible design manners thereof.
It will be appreciated that the advantages achieved by the chip system according to the second aspect, the computer readable storage medium according to the third aspect, the computer program product according to the fourth aspect, the apparatus according to the fifth aspect, the sixth aspect, and the system according to the seventh aspect provided above may refer to the advantages as in the first aspect and any one of the possible designs thereof, and will not be described herein.
Based on the method provided by the embodiment of the application, in a target compiling scene (for example, a scene of idle triggering compiling of the electronic equipment), the electronic equipment can acquire a baseline profile file (reference configuration file) of a target application program, verify a dex file in an installation package of the target application program based on a first compiling mode (compiling mode of speed-profile (have profile)), and compile a hot spot function indicated by the reference configuration file. After compiling is completed, when the electronic equipment runs the target application program, the compiling optimization file can be directly called, the dex file of the target application program is not required to be compiled in time, the compiling time is saved, the executing efficiency of the electronic equipment on the application program is improved, the running of the application program is smoother, and the user experience can be improved. The compiling method of the application program provided by the application does not need to rely on an application market to provide a DM file (the DM file comprises a profile file) for the application program, and does not need to wait for the hot spot function of the application program to record when the application program runs so as to generate the profile file. Even if the user cannot record the hot spot function of the application program to generate the profile file when the user runs due to the fact that the user does not use the target application program all the time, the compiling mode of speed-profile (have profile) can be triggered to compile and optimize the application program, the performance (performance such as starting and sliding of the application program) of the application program can be improved, and therefore better experience is brought to the user.
Drawings
Fig. 1 is a schematic diagram of a trigger scenario of dex2oat provided in an embodiment of the present application;
fig. 2 is a schematic hardware structure of an electronic device according to an embodiment of the present application;
fig. 3 is a schematic software architecture diagram of an electronic device according to an embodiment of the present application;
fig. 4 is a schematic diagram of a compiling flow of an electronic device according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating interactions between modules of an electronic device according to an embodiment of the present application;
FIG. 6 is a schematic diagram of module interaction of a compiling method for an application according to an embodiment of the present application;
FIG. 7 is a schematic flow chart of processing a Baseline profile file according to an embodiment of the present application;
FIG. 8 is a schematic flow chart of processing a baseline profile file and a generated profile file according to an embodiment of the present application;
FIG. 9 is a schematic flow chart of invoking dex2oat by a compiling optimization module according to an embodiment of the present application;
fig. 10 is a schematic structural diagram of a chip system according to an embodiment of the present application.
Detailed Description
For clarity and conciseness in the description of the following embodiments, a brief description of the related art will be given first:
in order to enable an application program installed in the electronic equipment to be smoother in an operation stage, a dex file of the application program can be compiled by using a dex2oat before the application program is installed or started, and the application program is compiled into machine codes which can be directly operated by the electronic equipment, so that the machine codes can be directly loaded by the electronic equipment in the operation process of the application program, and the operation of the application program is smoother. The dex file of the application program exists in an Android Package (APK) of the application program, and includes all operation instructions and runtime data of the application program, that is, all codes of the application program are included in the dex file.
As shown in fig. 1, several scenarios where the dex2oat compiles the dex file include a scenario where the electronic device is first powered on, a scenario where the electronic device resumes a field setting, a scenario where the electronic device performs over-the-air technology (OTA) upgrade, a scenario where the electronic device installs an application program, a scenario where the electronic device clones applications in other devices, a scenario where the electronic device is idle to trigger compilation, a scenario where the application itself triggers compilation, and other scenarios where the dex2oat triggers compilation of the dex file of the application program.
Several scenarios for compiling the dex file by dex2oat are described below.
In a scenario where an electronic device is first powered on, a plurality of applications need to be installed in the electronic device. At this time, the dex2oat may be triggered to compile the dex file decompressed out of the installation package during the installation process of the application programs, so as to obtain the dex file. Based on the method, in the running process of the installed application program, the electronic equipment can directly load and execute the odex file, so that the running of the application program is smoother.
In a scenario where the electronic device resumes the off-site setting, multiple applications need to be reinstalled in the electronic device. At this time, the dex2oat may be triggered to compile the dex file decompressed out of the installation package during the installation process of the application programs, so as to obtain the dex file. Based on the method, in the running process of the installed application program, the electronic equipment can directly load and execute the odex file, so that the running of the application program is smoother.
In a scene that the electronic equipment performs OTA upgrading, the electronic equipment re-compiles the dex files of all application programs in the electronic equipment after the OTA is started or enters a desktop after the OTA is started, so that the dex files are obtained. Based on the method, in the running process of the recompiled application program, the electronic equipment can directly load and execute the recompiled odex file, so that the running of the application program is smoother.
In a scenario where an electronic device installs an application, the electronic device may download an installation package of the application to be installed from an application market. In the process of executing the installation package and installing the application program, the dex2oat can be triggered to compile the dex file decompressed out of the installation package of the application program so as to obtain the dex file. Based on the method, in the running process of the installed application program, the electronic equipment can directly load and execute the odex file, so that the running of the application program is smoother.
In a scenario where the electronic device clones applications in other devices, the electronic device locally installs the corresponding applications according to the applications installed on the other devices. During the process of installing the application programs by the electronic device, the electronic device can trigger the dex2oat to compile a dex file of the application programs cloned to the local electronic device so as to obtain the dex file. Based on the method, in the running process of the cloned application program, the electronic equipment can directly load and execute the odex file, so that the running of the application program is smoother.
In the scenario of electronic device idle trigger compilation, if the electronic device is in an idle state for a time greater than or equal to a preset duration (e.g., 31 minutes), and/or the electronic device is charging. For example, when the charging power of the electronic device reaches 90% of the idle state, the electronic device may trigger the dex2oat to compile a dex file of an application program that is already installed but not in an operating state, so as to obtain the dex file. At this point, the application is not started. Based on the method, when the application program runs again, such as application program cold start, the electronic equipment can directly load and execute the odex file in the application cold start process, so that the start process and the running process after the start of the application program are smoother.
In the scene of self triggering and compiling of the application program, under the condition that the self triggering condition of the application program is met, the dex file of the application program is compiled through the instruction triggering dex2oat to obtain the dex file, and based on the dex file, the electronic equipment can directly load and execute the dex file in the running process of the application program, so that the running of the application program is smoother.
Of course, there are other situations where the dex2oat is triggered to compile the dex file of the application program, for example, some application programs are set by the application provider to trigger the dex2oat to compile the dex file of the application program when the application program is started for the first time, and the application is not limited.
It should be noted that, the scene of the electronic device idle triggering compilation, the scene of the electronic device first boot/restore factory setting, and the scene of the electronic device OTA upgrading are all important scenes for improving user experience by utilizing compilation optimization. In these scenarios, a large amount of compilation optimization can be performed on the application program in the electronic device, so as to improve the performance of the application program, thereby improving the user experience.
Because the electronic equipment is in an idle state and the electric quantity is sufficient, the problems of blocking and the like caused by that the dex2oat compiling occupies more CPU resources, IO resources and memory resources of the terminal equipment when the foreground application is used can be avoided, meanwhile, the problem that a user wastes time to wait for compiling and optimizing and the problem that the electric quantity is insufficient caused by excessive electric quantity consumption of the electronic equipment can be avoided.
The dex2oat comprises a plurality of different compiling optimization modes, the compiling optimization modes are ordered according to the performance of the application after execution, and the common compiling optimization modes at present comprise: a compiling mode of speed, a compiling mode of speed-profile, a compiling mode of verify, etc. A comparison of these several typical compilation optimization modes is shown in table 1.
TABLE 1
In each of the above scenarios, when the dex2oat compiles the dex file, one of a plurality of compiling modes as shown in table 1 may be employed.
Compiling mode of speed: in the compiling mode, the dex2oat can perform AOT compiling on all function codes in the dex file to obtain corresponding compiling products: the odex and vdex. The compiling mode of speed carries out compiling optimization on all program codes, and the obtained product has good performance, but the generated file is large, the time consumption is long, and the memory space of the mobile phone is consumed.
Compiling mode of speed-profile (have profile): in the compiling mode, the dex2oat performs verification processing on the dex file to obtain a corresponding odex file, and performs AOT compiling on function codes specified by the profile file in the dex file of the application program according to the information of the specified function in the profile file to obtain a corresponding compiling product: an art file. The profile file refers to a file containing information of a hotspot function (may also be referred to as a hotspot code). The art file contains the addresses of the specified function codes to facilitate addressing the specified functions. The appointed function codes are codes of functions commonly used by the application program in running, so that the electronic equipment can quickly address and run the searched codes after loading the art file into the memory in the running process of the application program, and the application program can run more smoothly.
Compiling mode of speed-profile (no profile): in the compiling mode, the dex2oat checks the dex file and optimizes the dex instruction in the dex file, so that the corresponding dex file is obtained, and the optimized dex instruction has higher interpretation performance and can be efficiently identified by electronic equipment.
Wherein, since only the checksum dex instruction optimization is performed on the dex file in the compiling mode of speed-profile (no profile) without involving AOT compiling, the compiling mode of speed-profile (no profile) has shorter compiling time than the compiling mode of speed-profile (have profile), but the compiling mode of speed-profile (no profile) is worse than the compiling mode of speed-profile (have profile) in compiling performance.
The verify compiling mode: in the compiling mode, the dex2oat checks the dex file to obtain a corresponding dex file. Wherein, because only the dex file is checked in the verify compiling mode but AOT compiling and dex instruction optimizing are not involved, the verify compiling mode has shorter compiling time than the speed-profile (have profile) compiling mode and the speed-profile (no profile) compiling mode, but the verify compiling mode has poorer compiling performance than the speed-profile (have profile) compiling mode and the speed-profile (no profile) compiling mode.
Of course, if the dex2oat is not triggered or the dex2oat is triggered not to compile the dex file, the dex file is not processed at all. After the application is started, the dex file of the running application is loaded and interpreted. When the codes in the dex file are operated, the application program can check the dex file. Therefore, if the compiling optimization of any compiling mode is not executed on the dex file, the application program can be slower to run because the dex file is reloaded and checked after the application program is started, compared with the running process of directly loading the dex file after the application program is started.
It should be noted that, after the electronic device is first started/restored to the factory setting, or after the electronic device is subjected to OTA upgrade, or after the application program is installed, the user may not run the application program at the first time, so that the electronic device cannot record the hotspot function according to the running condition of the application program, and then generate the profile file. If the scene of idle triggering and compiling of the electronic equipment is reached before the user uses the application program, the electronic equipment can only trigger the dex2oat to compile the dex file decompressed in the installation package by adopting a speed-profile (no profile) compiling mode due to the lack of the profile file generated according to the hot spot function recorded according to the running condition of the application program. Although the compiling mode adopts speed-profile, no profile file is provided, and the actual effect is compiling optimization of a verify level. Thus, the performance of the application program is lower when the application program is started, and the user experience is poorer.
Aiming at the problem that the profile file cannot be provided in time, the industry proposes a baseline profile technology (baseline profile mechanism), which is a brand new mechanism for providing the profile file. The developer of the application program can count the hotspot function of the application program in advance to obtain a profile file, and then the profile file is sent to the application market as a part of the APK of the application program. When a user downloads an application program in an application market, a profile file is sent to the user's electronic equipment along with the APK from the application market. The profile file provided by the baseline profile technology can be automatically generated by using an Android Gradle plugin (google native tool). Alternatively, the developer may add the hotspot functions that the developer deems to be compilation-optimized to the profile file by manual definition.
In the baseline profile technology, a profile file carried in an APK of an application program can be processed in a cloud of google application market and sent to an electronic device of a user in the form of a DM file. When the baseline profile file is not available, the blank of an ART cloud profile file pipeline (namely, the baseline profile file can replace a DM file) is filled, and when the cloud profile file is available, the baseline profile file can be automatically combined with the ART cloud profile file (namely, the baseline profile file can be combined with the DM file) to obtain a more accurate and comprehensive profile file, so that speed-profile compiling optimization can be performed when an application program is installed. However, the existing baseline profile technology depends on cloud capabilities of application markets, and for some third party application markets (such as application treasures, pea pods and other third party application markets), even if baseline profile files are contained in APKs of application programs, the third party application markets cannot perform cloud processing on the baseline profile files carried in the APKs, that is, cannot provide DM files. Therefore, in the first boot/restore factory setting scene of the electronic device and the scene of OTA upgrade of the electronic device, the electronic device cannot compile the dex file of the application program in a speed-profile (have profile) compiling mode, so that the performance of starting, sliding and the like of the application program is low and the user experience is poor. In addition, if the user reaches the scene of idle triggering and compiling of the electronic device before using the application program, the electronic device cannot compile the dex file of the application program in a speed-profile (have profile) compiling mode due to the lack of the profile file generated by the hot spot function recorded according to the running condition of the application program, so that the performance of starting, sliding and the like of the application program in starting is low, and the user experience is poor.
The application provides a compiling method and a compiling device for an application program, which can combine a baseline profile technology with an application installation scene, does not need to rely on baseline profile files (reference configuration files) of an application market in a cloud processing APK, and processes baseline profile files embedded into the APK at an electronic equipment end (for example, a mobile phone end), so that the application program downloaded by the electronic equipment in an application market of a third party can be compiled in a compiling mode of speed-profile (have profile) when the application program is installed. Thus, the performance of starting, sliding and the like of the application program when the application program is started for the first time can be improved, and better experience can be brought to the user.
Based on the method provided by the embodiment of the application, in the scene of idle triggering and compiling of the electronic equipment, the scene of first starting/restoring factory setting of the electronic equipment and the scene of OTA upgrading of the electronic equipment, a baseline profile file (reference configuration file) of a target application program can be obtained, and compiling of a speed-profile (have profile) compiling mode is carried out on a dex file of the target application program according to the baseline profile file to obtain a compiling optimization file. After compiling is completed, when the electronic equipment runs the target application program, the compiling optimization file can be directly called, the dex file of the target application program is not required to be compiled in time, the compiling time is saved, the executing efficiency of the electronic equipment on the application program is improved, the running of the application program is smoother, and the user experience can be improved.
Fig. 2 is a schematic structural diagram of an electronic device 100 according to an embodiment of the present application.
As shown in fig. 2, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, a user identification module (subscriber identification module, SIM) card interface 195, and the like.
The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
It is to be understood that the structure illustrated in the present embodiment does not constitute a specific limitation on the electronic apparatus 100. In other embodiments, electronic device 100 may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
The controller may be a neural hub and command center of the electronic device 100. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it can be called directly from the memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous receiver transmitter (universal asynchronous receiver/transmitter, UART) interface, a mobile industry processor interface (mobile industry processor interface, MIPI), a general-purpose input/output (GPIO) interface, a subscriber identity module (subscriber identity module, SIM) interface, and/or a universal serial bus (universal serial bus, USB) interface, among others.
It should be understood that the connection relationship between the modules illustrated in this embodiment is only illustrative, and does not limit the structure of the electronic device 100. In other embodiments, the electronic device 100 may also employ different interfaces in the above embodiments, or a combination of interfaces.
The charge management module 140 is configured to receive a charge input from a charger. The charging management module 140 may also supply power to the electronic device through the power management module 141 while charging the battery 142.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like. In other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charge management module 140 may be disposed in the same device.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas may also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed into a diversity antenna of a wireless local area network.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA), etc. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 1 to radiate.
The modem processor may include a modulator and a demodulator. The modulator is used for modulating the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used for demodulating the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low frequency baseband signal to the baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and then transferred to the application processor. The application processor outputs sound signals through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or video through the display screen 194.
The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to the electronic device 100. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
In some embodiments, antenna 1 and mobile communication module 150 of electronic device 100 are coupled, and antenna 2 and wireless communication module 160 are coupled, such that electronic device 100 may communicate with a network and other devices through wireless communication techniques. The wireless communication techniques may include the Global System for Mobile communications (global system for mobile communications, GSM), general packet radio service (general packet radio service, GPRS), code division multiple access (code division multiple access, CDMA), wideband code division multiple access (wideband code division multiple access, WCDMA), time division code division multiple access (time-division code division multiple access, TD-SCDMA), long term evolution (long term evolution, LTE), BT, GNSS, WLAN, NFC, FM, and/or IR techniques, among others. The GNSS may include a global satellite positioning system (global positioning system, GPS), a global navigation satellite system (global navigation satellite system, GLONASS), a beidou satellite navigation system (beidou navigation satellite system, BDS), a quasi zenith satellite system (quasi-zenith satellite system, QZSS) and/or a satellite based augmentation system (satellite based augmentation systems, SBAS).
The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel. The display panel may employ a liquid crystal display (liquid crystal display, LCD), a light-emitting diode (LED), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (flex light-emitting diode, FLED), a mini, micro-OLED, a quantum dot light-emitting diode (quantum dot light emitting diodes, QLED), or the like.
The electronic device 100 may implement photographing functions through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like. The ISP is used to process data fed back by the camera 193. The camera 193 is used to capture still images or video. The digital signal processor is used for processing digital signals, and can process other digital signals besides digital image signals. Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 may play or record video in a variety of encoding formats, such as: dynamic picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
The camera 193 may include 1 to N. For example, the electronic device may include 2 front cameras and 4 rear cameras.
The NPU is a neural-network (NN) computing processor, and can rapidly process input information by referencing a biological neural network structure, for example, referencing a transmission mode between human brain neurons, and can also continuously perform self-learning. Applications such as intelligent awareness of the electronic device 100 may be implemented through the NPU, for example: image recognition, face recognition, speech recognition, text understanding, etc.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card. The internal memory 121 may be used to store computer executable program code including instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. For example, in an embodiment of the present application, the processor 110 may include a storage program area and a storage data area by executing instructions stored in the internal memory 121. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playing, recording, etc.
The audio module 170 is used to convert digital audio information into an analog audio signal output and also to convert an analog audio input into a digital audio signal. The audio module 170 may also be used to encode and decode audio signals. The speaker 170A, also referred to as a "horn," is used to convert audio electrical signals into sound signals. A receiver 170B, also referred to as a "earpiece", is used to convert the audio electrical signal into a sound signal. Microphone 170C, also referred to as a "microphone" or "microphone", is used to convert sound signals into electrical signals. The earphone interface 170D is used to connect a wired earphone.
The keys 190 include a power-on key, a volume key, etc. The keys 190 may be mechanical keys. Or may be a touch key. The electronic device 100 may receive key inputs, generating key signal inputs related to user settings and function controls of the electronic device 100. The motor 191 may generate a vibration cue. The motor 191 may be used for incoming call vibration alerting as well as for touch vibration feedback. The indicator 192 may be an indicator light, may be used to indicate a state of charge, a change in charge, a message indicating a missed call, a notification, etc. The SIM card interface 195 is used to connect a SIM card. The SIM card may be inserted into the SIM card interface 195, or removed from the SIM card interface 195 to enable contact and separation with the electronic device 100. The electronic device 100 may support 1 or N SIM card interfaces, N being a positive integer greater than 1. The SIM card interface 195 may support Nano SIM cards, micro SIM cards, and the like.
The methods in the following embodiments may be implemented in the electronic device 100 having the above-described hardware structure.
The software system of the electronic device 100 may employ a layered architecture, an event driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the application, taking an Android system with a layered architecture as an example, a software structure of the electronic device 100 is illustrated.
The layered architecture divides the software into several layers, each with distinct roles and branches. The layers communicate via interfaces. In some embodiments, an Android system may include an application layer, an application framework layer, an Zhuoyun rows (Android run) and libraries, a hardware abstraction layer (hardware abstraction layer, HAL), and a kernel layer. It should be noted that, in the embodiment of the present application, an Android system is illustrated, and in other operating systems (such as a hong mo system, an IOS system, etc.), the scheme of the present application can be implemented as long as the functions implemented by the respective functional modules are similar to those implemented by the embodiment of the present application.
The application layer may include a series of application packages, among other things.
As shown in fig. 3, the application package may include applications for cameras, gallery, calendar, phone calls, maps, navigation, WLAN, bluetooth, music, video, short messages, lock screen applications, setup applications, etc. Of course, the application layer may also include other application packages, such as application markets (e.g. ) And the like, the present application is not limited thereto.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions. For example, an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, etc., to which embodiments of the application are not limited in any way.
In an embodiment of the present application, the application framework layer may provide a packet management service (package manager service, PMS), where at least: and the application installation module and the compiling and optimizing preprocessing module.
The application installation module can be used for scanning an installation package of an application program in a scene of idle triggering and compiling of the electronic equipment, a scene of first starting/restoring factory setting of the electronic equipment and a scene of OTA upgrading of the electronic equipment, performing processing such as resource decompression and analysis of android management. The application installation module can also send information required by compiling such as package names, installation catalogues, compiling parameters and the like of the application program to the compiling optimization preprocessing module.
The compiling and optimizing preprocessing module is used for judging whether the electronic equipment is currently in a scene of idle triggering compiling (namely whether the electronic equipment triggers idle triggering compiling), a scene of first starting/restoring factory setting of the electronic equipment, a scene of OTA upgrading of the electronic equipment (namely whether the electronic equipment triggers idle triggering compiling), and the like, preprocessing related parameter information of compiling and optimizing, and preprocessing parameters and files for a compiling and optimizing process.
In an embodiment of the present application, the application framework layer may further provide a daemon thread (instrald), where instrom at least includes: a profile processing module and a compiling optimization module. The daemon thread may also be referred to as a background thread or a service thread, which is not limited by the present application.
The profile processing module may be configured to call a profman function, and perform merging processing (merge profile) on a profile file and/or a baseline profile file that are dependent on the compiling optimization process, that is, may integrate a hotspot function indicated by the profile file and/or baseline profile file into a data/misc/profiles/ref/< package name >/primary.
The compile optimization module may be used to invoke ART for dex2oat of the application.
The compiling and optimizing preprocessing module in the P M S can also call the performDexopt function to access the compiling and optimizing module in the Installd, and the compiling result is obtained from the compiling and optimizing module.
The system library may include a plurality of functional modules. For example: surface manager (surface manager), media Libraries (Media Libraries), three-dimensional graphics processing Libraries (e.g., openGL ES), 2D graphics engines (e.g., SGL), etc.
The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc.
OpenGL ES is used to implement three-dimensional graphics drawing, image rendering, compositing, and layer processing, among others.
SGL is the drawing engine for 2D drawing.
Android Runtime (ART) includes a core library and virtual machines. Android run time is responsible for scheduling and management of the Android system.
In an embodiment of the present application, the ART may include dex2oat, and dex2oat may be referred to as a bytecode optimization module. The dex2oat can compile the dex file of the application program.
The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android. The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The HAL layer is encapsulation of a Linux kernel driver, provides an interface upwards, and shields implementation details of low-level hardware.
The HAL layer may include Wi-Fi HAL, audio (audio) HAL, camera HAL (Camera HAL), etc.
The kernel layer is a layer between hardware and software. The inner core layer at least comprises a display driver, a camera driver, an audio driver and a sensor driver.
The hardware layer comprises a display, a camera, a sensor and the like.
The technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings in the embodiments of the present application. Wherein, in the description of the application, unless otherwise indicated, "at least one" means one or more, and "a plurality" means two or more. In addition, in order to facilitate the clear description of the technical solution of the embodiments of the present application, in the embodiments of the present application, the words "first", "second", etc. are used to distinguish the same item or similar items having substantially the same function and effect. It will be appreciated by those of skill in the art that the words "first," "second," and the like do not limit the amount and order of execution, and that the words "first," "second," and the like do not necessarily differ.
The application combines the baseline profile technology with a target compiling scene (a scene of electronic equipment idle triggering compiling, a scene of electronic equipment first starting/restoring factory settings or a scene of electronic equipment performing OTA upgrading). As shown in fig. 4, in a scenario where the electronic device is idle to trigger compiling, a scenario where the electronic device is first powered on/restored to factory settings, or a scenario where the electronic device performs OTA upgrade, the electronic device may obtain a baseline profile (reference configuration file) of a target application program from an installation package of the target application program, and perform speed-profile compiling on a dex file of the target application program according to the baseline profile file to obtain a compiling optimization file. Subsequently, after the installation of the target application program, the electronic device can directly call the compiling optimization file when the target application program is operated, and the dex file of the target application program is not required to be compiled in real time, so that the compiling time is saved, the execution efficiency of the electronic device on the application program is improved, the operation of the application program is smoother, and the user experience can be improved.
The target application program refers to any application program to be installed. For example, the target application may be a game application, a video application, an instant messaging application, a social application, a shopping application, etc., and the specific type of the target application is not limited in the embodiments of the present application.
The following describes software modules and interactions between modules involved in the compiling method of an application program provided by the embodiment of the present application.
As shown in fig. 5, the application installation module in the PMS of the electronic device executes an installer in an installation package of the application. And, the application installation module determines whether the installation package of the application program includes a baseline profile file. In some embodiments, the application installation module may determine whether the installation package of the application program includes a baseline profile file by parsing the android management file in the installation package and reading a flag bit in the android management file. The flag bit is used for indicating whether the installation package of the application program configures a baseline profile file or not. In other embodiments, the application installation module may actively check whether the installation package of the application includes a baseline profile file. If the application installation module determines that the installation package of the application program comprises the baseline profile file, the baseline profile file can be decompressed into a folder under the data/app/directory. In a scene of electronic equipment idle triggering compiling, a scene of electronic equipment first starting/restoring factory setting and a scene of electronic equipment OTA upgrading, a compiling optimization preprocessing module requests to a profile processing module of the instrument to process a baseline profile file. The profile processing module integrates hot spot function information in the baseline profile file. The compiling and optimizing preprocessing module can also preprocess related parameter information of compiling and optimizing at the PMS side, and preprocess parameters and files for the flow of compiling and optimizing. The compile optimization module may also call ART to do dex2oat for the application.
The following describes a compiling method of an application program according to an embodiment of the present application in detail with reference to the accompanying drawings.
As shown in fig. 6, an embodiment of the present application provides a compiling method for an application program, including:
601. when the electronic equipment (for example, a mobile phone) performs three-party application program installation, or when the electronic equipment is started up and scanned for the first time, or after the electronic equipment is restored to factory setting, an application installation module in a PMS of the mobile phone executes an installation program in an installation package of a target application program.
When the electronic device (for example, a mobile phone) performs three-party application program installation, or when the electronic device is first started up and scanned, or after the electronic device is restored to factory setting, an application installation module in a PMS of the mobile phone can scan an installation package of a target application program to extract a dex file in the installation package.
The target application program can be any one or more to-be-installed three-party application programs or any one or more preset application programs (system application programs or preset three-party application programs) in the electronic device. For example, the target application may be a game application, a video application, an instant messaging application, a social application, a shopping application, etc., and the specific type of the target application is not limited in the embodiments of the present application.
The three-party application program to be installed may be downloaded from an application market, or may be downloaded from a web page, or may be shared by other devices, which is not limited by the present application.
The application installation module may create an installation directory of the target application in the electronic device and write the dex file in the installation package into the installation directory of the electronic device.
For example, if the target application isThe application installation module can be created in the mobile phone +.>Is data/app/com.content.mm, and will +.>The dex file in the installation package of (a) is written into the installation directory.
602. The application installation module determines whether the installation package of the target application program contains a baseline profile file.
In some embodiments, when analyzing an android management file (manifest file) in an installation package of a target application program, the application installation module reads a flag bit (a first flag bit) configuring a baseline profile file, and determines whether the installation package of the target application program contains the baseline profile file according to the first flag bit.
In one possible design, a flag bit (first flag bit) may be set in android management. If the first flag bit is true (true), the installation package representing the target application program contains a baseline profile file; if the first flag bit is false, the installation package representing the target application program does not contain the baseline profile file.
Wherein the baseprofile file is a file compiled into the installation package of the target application. The hotspot function of the target application program recorded in the baseline profile file can be placed under the packages/dexopt/baseline prof directory of the installation package. The baseine profile file and android management.
When the target application program is installed, the application installation module can analyze the android management.xml file, read a first flag bit of the configuration baseline profile file, and store the first flag bit in a structure body for recording installation package information. If the first flag bit is true, the installation package representing the target application program contains a baseline profile file; if the first flag bit is false, the installation package representing the target application program does not contain the baseline profile file.
In other embodiments, the application installation module may check whether the installation package of the target application includes a baseline profile file. That is, the application installation module may actively detect whether an assembly/dexopt/baseline profile file (i.e., baseline profile file) exists in the installation package of the target application program in the installation directory of the target application program. If the presence of the basets/dexopt/baseline profile files is determined, determining that the baseline profile files are contained in the installation package of the target application program; if the basets/dexopt/baseine.prof files are not determined to exist, the baseine profile files are not included in the installation package of the target application program.
If the application installation module determines that the installation package of the application program contains the baseine profile file, that is, configures the flag bit of the baseine profile file as true, the baseine profile file of the application program can be decompressed into a folder under the data/app/directory of the electronic device. Wherein the/data/app directory is a directory in which an installation package of an application installed by a user is stored.
If the application installation module determines that the installation package of the target application program includes the baseline profile file, that is, configures the first flag bit of the baseline profile file as true, the mobile phone may verify the dex file in the installation package of the target application program based on the first compiling mode (that is, the compiling mode of speed-profile (have profile)), and compile the hotspot function in the installation package of the target application program, so that steps 605-609 may be executed.
If it is determined that the installation package of the target application program does not contain the baseline profile file, that is, the first flag bit of the baseline profile file is configured to be false, the mobile phone may verify the dex file in the installation package of the target application program based on the second compiling mode (the compiling mode of speed-profile (no profile) or the compiling mode of verify).
603. The compilation optimization preprocessing module determines a current compilation scenario (target compilation scenario).
In a mobile phone operating system (e.g., android 8.0), various compile opportunities (compile opportunities may also be referred to as compile reasons) may be included. The dexopt can perform different compiling processes according to different compiling occasions. The compiling methods used by the different compiling processes can be preset in the systemProperty in advance, and can be read from the systemProperty when in use.
As shown in table 2, the compiling modes and trigger scenarios corresponding to 7 compiling opportunities are shown.
TABLE 2
If the compiling optimization preprocessing module determines that the current compiling scene is a scene of idle triggering compiling of the electronic equipment, as shown in table 2, the compiling time corresponding to the current compiling scene is bg-dexopt, and the default compiling mode is a compiling mode of speed-profile.
If the compiling optimization preprocessing module determines that the current compiling scene is the scene after the electronic equipment is started for the first time or the scene after the electronic equipment is recovered from the field setting, as shown in table 2, the compiling time corresponding to the current compiling scene is first-boot, and the default compiling mode is the compiling mode of verify.
If the compiling optimization preprocessing module determines that the current compiling scene is a scene (in the process of starting up an OTA upgrade) of the electronic device, as shown in table 2, a compiling time corresponding to the current compiling scene is boot-after-OTA, and a default compiling mode is a verify compiling mode.
If the compiling optimization preprocessing module determines that the current compiling scene is a scene of performing OTA upgrading on the electronic device (after the OTA upgrading enters the desktop), as shown in table 2, a compiling time corresponding to the current compiling scene is a post-boot, and a default compiling mode is a verify compiling mode.
In some embodiments, if the current standard compiling scene is a scene after the electronic device is first started/restored to the off-site setting or a scene in which the electronic device performs OTA upgrade (an OTA upgrade starting process or after the OTA upgrade enters the desktop), if the installation package of the target application program includes the standard configuration file, the compiling optimization preprocessing module may modify the default compiling mode into a compiling mode of speed-profile (i.e., a compiling mode of speed-profile (have profile)). For example, the default compiling mode is verify or boot-after-ota or post-boot, and the modified compiling mode is speed-profile.
In some embodiments, if the current compiling scenario is a scenario in which the electronic device is idle to trigger compiling, the compiling optimization preprocessing module determines whether the target application program is compiled for the first time, if not, determines whether the compiling time (compiling reason) of the last compiling of the target application program is bg-dexopt, and if the compiling time of the last compiling of the target application program is not bg-dexopt, steps 604 and 605 may be executed.
The compiling optimization preprocessing module can check compiling time of the last compiling of the target application program from an odex file obtained by the last compiling of the target application program.
604. The compiling optimization preprocessing module sends a first request message to the profile processing module, wherein the first request message is used for requesting to process the baseprofile file.
The first request message may include information required for compiling, such as a package name (package name), an installation directory (e.g., data/app/directory), a compiling parameter, and the like of the target application program. Wherein the compiling parameters comprise a mode identification of a first compiling mode (compiling mode of speed-profile (have profile)), compiling time and the like.
For example, with the target application programFor example, the compilation optimization pre-processing module may be based on +.>Application name->The first request message is generated by the compiling parameters such as the mode identification and the compiling time of the installation catalog data/app/com.content.mm, the first compiling mode (the compiling mode of speed-profile (have profile)) and the like, and sent to the profile processing module.
605. The profile processing module processes the baseine profile file.
The profile processing module receives a first request message from the application installation module and performs the following processing according to the first request message:
(1) Checking whether a/data/misc/profiles/cur/0/< packagename > directory (first configuration directory) exists, and creating the directory if the path does not exist. Where < packagname > represents the package name of the target application.
(2) The baseprofile file is moved from under the data/app directory to under the data/mis/profiles/cur/0/< packagename > directory.
(3) Setting an update iscackforprofileepdates flag bit (second flag bit), wherein the second flag bit is used for triggering the merging process of the base profile file, namely triggering a merge profile flow, and providing an effective available profile file for dex2 oat.
As shown in fig. 7, the merge profile flow may refer to the profile processing module invoking hot spot function information in the baseline profile file in the profile function integration/data/MIsc/profiles/cur/0/< packagename > directory. The integrated hotspot function information is stored in a data/MIsc/profiles/ref/< packagename >/primary. Subsequently, the dex2oat is compiled from a file (base profile file) in the second configuration directory.
In some embodiments, the electronic device may collect a hotspot function of the target application program during the running process of the target application program, and generate a profile file (second configuration file) according to the collected hotspot function. The profile file in the DM file may be stored under the data/app/directory. The profile file may be stored under the/data/MIsc/profiles/cur/0/< packagename > directory. As shown in fig. 8, the profile processing module may integrate/data/risc/profiles/cur/0/< package name > the baseline profile file in the directory and the profile file generated by the electronic device generating the profile file according to the collected hotspot function, so as to obtain more accurate and comprehensive hotspot function information. The integrated hotspot function information is stored in a data/MIsc/profiles/ref/< packagename >/primary. Subsequently, the dex2oat is compiled according to a file (a baseline profile file) in the second configuration directory and a profile file generated by the electronic device according to the collected hotspot function generated profile file.
After the profile processing module completes processing the baseprofile file (i.e. completing the merge profile flow), the compilation optimization preprocessing module can be notified of completing processing the baseprofile file (i.e. completing the merge profile flow).
606. The compiling and optimizing preprocessing module preprocesses information required by compiling.
The compiling and optimizing preprocessing module can preprocess information required by compiling at the PMS side, and the parameters and the files are preprocessed for the compiling and optimizing flow in a scene that the electronic equipment is idle to trigger compiling, a scene that the electronic equipment is started up for the first time/is restored to factory setting, and a scene that the electronic equipment is subjected to OTA upgrading.
For example, the compilation optimization preprocessing module may perform security inspection and protection on information required for compilation, perform processing such as verifying, inspecting, judging necessity of compilation optimization according to the information required for compilation, and may perform processing of lock-holding operation and Split APK. The Split APK is a solution mechanism for the problem that APK installation packages are bigger and bigger. The Split APK can Split a huge APK into a plurality of independent APKs, and when an application program is updated, the whole APKs do not need to be downloaded, and only a certain module needs to be downloaded independently to install the update.
607. The compiling and optimizing preprocessing module sends a second request message to the compiling and optimizing module, wherein the second request message is used for requesting the compiling and optimizing module to start compiling and optimizing of the current compiling scene.
The second request message may include information required for compiling, such as a package name, an installation directory, and a compiling parameter of the target application program.
608. The compiling optimization module calls the dex2oat in the ART to compile the dex file of the target application program.
After receiving the fourth request message, the compiling optimization module may call the dex2oat in the ART to compile the dex file of the target application program in the compiling mode of speed-profile (have profile). As shown in fig. 9, the specific process includes the following steps S1 to S3.
S1, the compiling and optimizing module sends a compiling instruction to dex2oat in the virtual machine of the ART.
The compiling optimization module may add information required for compiling such as package name, installation directory, mode identifier of default compiling mode, compiling time and the like of the target application program to the compiling instruction, and send the compiling instruction to the dex2oat.
S2, the dex2oat compiles the dex files in the installation directory according to the compiling instruction.
In addition to checking the dex file, the dex2oat performs AOT compiling on the codes of the hot spot functions in the dex file of the target application program according to the information of the hot spot functions indicated by the profile file to obtain corresponding compiled products: an art file. The address of the codes of these hotspot functions is contained in the art file, facilitating the addressing of these hotspot functions. The codes of the hot spot functions are codes of functions commonly used for running the target application program, so that in the running process of the target application program, the electronic equipment can quickly address and run the found codes after loading the art file into the memory, and the running of the target application program is smoother.
The compiling optimization module may also adjust compiling optimization parameters, that is, check and adjust information in the fourth request message, create a path of the odex file to save the generated odex file, and so on.
S3, the dex2oat returns a compiling completion message to the compiling and optimizing module after compiling is completed.
The compiled message may include a package name of the target application program, so as to characterize that the dex file of the target application program is compiled.
609. And the compiling and optimizing module sends a compiling and optimizing result to the compiling and optimizing preprocessing module.
The compilation optimization result is used for indicating that the dex2oat has completed the compilation optimization of the dex file of the target application. The compiling optimization result may include a package name of the target application program, so as to represent that the dex file of the target application program is compiled.
The method and the device solve the problem that in a target compiling scene (for example, a scene that the electronic equipment is idle to trigger compiling, a scene that the electronic equipment is started up/restored to factory settings for the first time, and a scene that the electronic equipment is subjected to OTA upgrading), a compiling mode of speed-profile (have profile) cannot be triggered to carry out compiling optimization due to the lack of a profile file. According to the compiling method and device for the application program, the baseline profile technology can be combined with a target compiling scene, a DM file (comprising a profile file in a DM file) is not required to be provided for the application program by depending on an application market, and a hot spot function of the application program is not required to be recorded to generate the profile file when the application program runs. According to the method provided by the application, the baseline profile file embedded in the APK can be processed at the electronic equipment end (for example, the mobile phone end), so that in a target compiling scene, even if a user is not used for a target application program all the time, a hot spot function of the application program can not be recorded to generate the profile file when the application program runs, the compiling mode of speed-profile (have profile) can be triggered to compile and optimize the application program, and the performance (such as starting, sliding and the like of the application program) of the application program can be improved, thereby bringing better experience to the user.
In some embodiments, if the user has used the application, the electronic device may record the hotspot function of the application at the time of application running to generate the profile file. In the target compiling scene, a more accurate and comprehensive hot spot function can be obtained by combining the baseline profile file and the profile file generated by the electronic equipment, and compiling and optimizing are carried out on the application program in a speed-profile (have profile) compiling mode. Compared with the compiling optimization of the speed-profile compiling mode only according to the profile file generated by the electronic equipment, the compiling optimization of the speed-profile compiling mode according to the baseline profile file and the profile file generated by the electronic equipment can better promote the application program performance, so that better experience is brought to users.
It should be noted that, in the scene after the electronic device is first started/restored to the off-site setting or the scene where the electronic device performs OTA upgrade (the OTA upgrade starting process or after the OTA upgrade enters the desktop), according to the baseline profile file, the compiling and optimizing of the target application program are performed at the electronic device end in the compiling mode of speed-profile (have profile), which saves more storage space than the compiling and optimizing of the target application program in the compiling mode of speed-profile (have profile) in the preset stage (the stage of burning the operating system, the system application program and some three-party application programs of the electronic device). The volume of the baseline profile file is smaller than that of a compiling optimization file (the compiling optimization file obtained by compiling and optimizing a target application program in a speed-profile (have profile) compiling mode in a preset stage), so that the number of files preset by the electronic equipment can be reduced, and the storage space of the electronic equipment can be saved.
Based on the method provided by the embodiment of the application, in the scene of idle triggering and compiling of the electronic equipment, the scene of first starting/restoring factory setting of the electronic equipment and the scene of OTA upgrading of the electronic equipment, a baseline profile file (reference configuration file) of a target application program is obtained, and compiling of a speed-profile (have profile) compiling mode is carried out on a dex file of the target application program according to the baseline profile file to obtain a compiling optimization file. After compiling is completed, when the electronic equipment runs the target application program, the compiling optimization file can be directly called, the dex file of the target application program is not required to be compiled in time, the compiling time is saved, the executing efficiency of the electronic equipment on the application program is improved, the running of the application program is smoother, and the user experience can be improved.
Some embodiments of the application provide an electronic device that may include: a touch screen, a memory, and one or more processors. The touch screen, memory, and processor are coupled. The memory is for storing computer program code, the computer program code comprising computer instructions. When the processor executes the computer instructions, the electronic device may perform the various functions or steps performed by the electronic device in the method embodiments described above. The structure of the electronic device may refer to the structure of the electronic device 100 shown in fig. 2.
Embodiments of the present application also provide a system-on-a-chip (SoC) including at least one processor 1001 and at least one interface circuit 1002, as shown in fig. 10. The processor 1001 and the interface circuit 1002 may be interconnected by wires. For example, interface circuit 1002 may be used to receive signals from other devices (e.g., a memory of an electronic apparatus). For another example, the interface circuit 1002 may be used to send signals to other devices (e.g., the processor 1001 or a touch screen of an electronic apparatus). The interface circuit 1002 may, for example, read instructions stored in a memory and send the instructions to the processor 1001. The instructions, when executed by the processor 1001, may cause the electronic device to perform the various steps of the embodiments described above. Of course, the system-on-chip may also include other discrete devices, which are not particularly limited in accordance with embodiments of the present application.
Embodiments of the present application also provide a computer readable storage medium, where the computer readable storage medium includes computer instructions, which when executed on an electronic device, cause the electronic device to perform the functions or steps performed by the electronic device in the method embodiments described above.
The embodiment of the application also provides a computer program product, which when run on an electronic device, causes the electronic device to execute the functions or steps executed by the electronic device in the above-mentioned method embodiment.
It will be apparent to those skilled in the art from this description that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided by the present application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and the parts displayed as units may be one physical unit or a plurality of physical units, may be located in one place, or may be distributed in a plurality of different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a readable storage medium. Based on such understanding, the technical solution of the embodiments of the present application may be essentially or a part contributing to the prior art or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, including several instructions for causing a device (may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the method described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read Only Memory (ROM), a random access memory (random access memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of specific embodiments of the present application, but the scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present application should be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (8)

1. A method for compiling an application program, comprising:
under a target compiling scene, the electronic equipment determines whether an installation package of a target application program comprises a reference configuration file or not, wherein the reference configuration file is used for indicating a hot spot function in the installation package of the target application program; the target compiling scene comprises a scene that the electronic equipment triggers compiling in an idle state;
if the installation package of the target application program is determined to comprise the reference configuration file, the electronic equipment verifies the dex file in the installation package of the target application program based on a first compiling mode, and compiles the hot spot function indicated by the reference configuration file.
2. The method of claim 1, wherein the step of determining the position of the substrate comprises,
the target compiling scene further comprises a scene of triggering compiling when the electronic equipment is started for the first time and a scene of triggering compiling when the electronic equipment carries out over-the-air OTA upgrading.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
the electronic equipment records a hot spot function of the target application program when the target application program runs, and generates a first configuration file according to the recorded hot spot function;
the electronic device verifying the dex file in the installation package of the target application program based on a first compiling mode, and compiling the hotspot function indicated by the benchmark configuration file comprises the following steps:
and the electronic equipment verifies the dex file in the installation package of the target application program based on the first compiling mode, and compiles the hot spot function indicated by the reference configuration file and the hot spot function indicated by the first configuration file.
4. A method according to any of claims 1-3, wherein the electronic device determining whether the installation package of the target application includes a benchmark profile comprises:
the electronic equipment analyzes a manifest file in an installation package of the target application program, wherein a first zone bit is set in the manifest file and is used for indicating whether the installation package of the target application program contains the reference configuration file or not;
And reading the first flag bit, wherein if the first flag bit is true, the reference configuration file is contained in the installation package of the target application program, and if the first flag bit is false, the reference configuration file is not contained in the installation package of the target application program.
5. A method according to any of claims 1-3, wherein the electronic device determining whether the installation package of the target application includes a benchmark profile comprises:
the electronic device detects whether the reference configuration file exists in an installation catalog of the target application program.
6. The method of claim 1, wherein the electronic device verifies the dex file in the installation package of the target application based on the first compilation mode and before compiling the hotspot function in the installation package of the target application, the method further comprises:
the electronic equipment checks whether a first configuration catalog exists or not, and if the first configuration catalog does not exist, the first configuration catalog is created;
the electronic equipment moves the reference configuration file from an installation catalog to the first configuration catalog;
The electronic equipment sets and updates a second flag bit, the second flag bit is used for triggering the merging processing of the reference configuration files, and the electronic equipment moves the reference configuration files under the first configuration directory to the second configuration directory.
7. An electronic device, comprising a display screen, a processor, and a memory; the memory stores program instructions; the processor is configured to execute the program instructions stored in the memory, so that the electronic device performs the method according to any one of claims 1-6.
8. A computer readable storage medium, characterized in that the computer readable storage medium comprises program instructions which, when run on an electronic device, cause the electronic device to perform the method of any of claims 1-6.
CN202310141098.1A 2023-01-19 2023-01-19 Compiling method and device of application program Pending CN117130617A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310141098.1A CN117130617A (en) 2023-01-19 2023-01-19 Compiling method and device of application program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310141098.1A CN117130617A (en) 2023-01-19 2023-01-19 Compiling method and device of application program

Publications (1)

Publication Number Publication Date
CN117130617A true CN117130617A (en) 2023-11-28

Family

ID=88861634

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310141098.1A Pending CN117130617A (en) 2023-01-19 2023-01-19 Compiling method and device of application program

Country Status (1)

Country Link
CN (1) CN117130617A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7818729B1 (en) * 2003-09-15 2010-10-19 Thomas Plum Automated safe secure techniques for eliminating undefined behavior in computer software
CN112559088A (en) * 2020-12-29 2021-03-26 Oppo广东移动通信有限公司 Configuration file optimization method, device, server and storage medium
CN112596751A (en) * 2020-12-29 2021-04-02 Oppo广东移动通信有限公司 Compiling method, terminal, server and storage medium of application program installation package
CN112783501A (en) * 2019-11-08 2021-05-11 Oppo广东移动通信有限公司 Hot spot compiling unit determining method and device and server
CN112948026A (en) * 2019-11-26 2021-06-11 Oppo广东移动通信有限公司 Hotspot code processing method and device, server, electronic equipment and storage medium
CN113885870A (en) * 2021-08-27 2022-01-04 荣耀终端有限公司 Application program updating method, electronic equipment, terminal equipment and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7818729B1 (en) * 2003-09-15 2010-10-19 Thomas Plum Automated safe secure techniques for eliminating undefined behavior in computer software
CN112783501A (en) * 2019-11-08 2021-05-11 Oppo广东移动通信有限公司 Hot spot compiling unit determining method and device and server
CN112948026A (en) * 2019-11-26 2021-06-11 Oppo广东移动通信有限公司 Hotspot code processing method and device, server, electronic equipment and storage medium
CN112559088A (en) * 2020-12-29 2021-03-26 Oppo广东移动通信有限公司 Configuration file optimization method, device, server and storage medium
CN112596751A (en) * 2020-12-29 2021-04-02 Oppo广东移动通信有限公司 Compiling method, terminal, server and storage medium of application program installation package
CN113885870A (en) * 2021-08-27 2022-01-04 荣耀终端有限公司 Application program updating method, electronic equipment, terminal equipment and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
袁晓筱;罗森林;杨鹏;: "Android系统应用程序DEX文件保护方法研究", 信息网络安全, no. 07, 10 July 2020 (2020-07-10) *

Similar Documents

Publication Publication Date Title
US11947974B2 (en) Application start method and electronic device
CN110633090B (en) Patch method, related device and system
WO2021052167A1 (en) Method for realizing pluginization of application, and electronic apparatus
CN113568634A (en) Processing method and processing device for application optimization
CN113741993A (en) Method and device for compiling plug-in dex file
CN113656089B (en) Class verification method and device in application program
CN116483734B (en) Pile inserting method and system based on compiler and related electronic equipment
CN115309431B (en) Parameter updating method, readable medium and electronic equipment
CN116737243B (en) Screen parameter patch upgrading method and terminal equipment
CN116467221A (en) Pile inserting method and system based on interpreter and related electronic equipment
WO2022111664A1 (en) Patching method, related apparatus, and system
CN117130617A (en) Compiling method and device of application program
CN116795435A (en) Compatibility management and control method and related equipment
CN113885928B (en) Program updating method and electronic device
WO2021238376A1 (en) Function pack loading method and apparatus, and server and electronic device
CN116521180B (en) Compiling optimization method, electronic equipment and storage medium
CN116048629B (en) System service switching method, control device, electronic equipment and storage medium
CN116643778B (en) Application program optimization method and electronic equipment
CN116048544B (en) Processing method of popup advertisement, electronic equipment and readable storage medium
CN116048685B (en) Display method of magazine lock screen, graphical interface and electronic equipment
CN116048545B (en) Processing method of popup advertisement, electronic equipment and readable storage medium
CN114996078B (en) Method and device for compiling control of dex file
CN117009023B (en) Method for displaying notification information and related device
WO2024041367A1 (en) Advertisement display method, and terminal, server and system
CN117707563A (en) Application resource processing method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination