Compilation optimization method, electronic equipment and storage medium

By flexibly adjusting the conditions and order of compilation optimization based on battery information and usage after electronic device system upgrades, the problem of compilation optimization being difficult to trigger in a timely manner is solved, thereby improving user experience and application running speed.

CN121918902APending Publication Date: 2026-04-24HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2024-10-23
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

After an electronic device system is upgraded, the compilation and optimization process may not be triggered in a timely manner, leading to a decline in user experience, especially when the user has not charged the device in time, which affects the smoothness of using the new system.

Method used

By assessing the battery information and usage status of electronic devices, the threshold for compilation optimization can be lowered without affecting normal user operation. This allows for timely initiation of compilation optimization tasks, including obtaining battery information and usage status, setting preset durations and conditions, and flexibly adjusting the goals and order of compilation optimization to avoid excessive power consumption caused by prolonged compilation.

Benefits of technology

This improved the user experience of the new system, ensuring that compilation optimizations are performed promptly when the battery is full and the system is idle, thus enhancing the startup speed and smoothness of applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121918902A_ABST
    Figure CN121918902A_ABST
Patent Text Reader

Abstract

The invention provides a compiling optimization method, electronic equipment and a storage medium, relates to the technical field of intelligent terminals, and is used for improving the fluency of running an application program after a system is upgraded. According to the scheme, after the electronic equipment completes system upgrading, battery information of the electronic equipment is obtained; the battery information comprises residual electric quantity and a charging state; and under the condition that the residual electric quantity is greater than or equal to the preset electric quantity and the charging state is non-charging, when the duration of the electronic equipment entering the screen-off state is greater than or equal to a first preset duration, compiling and optimizing an application program in the electronic equipment. Therefore, by judging the battery information and the use condition of the upgraded electronic equipment, on the premise that normal use of a user is not affected, the threshold of compilation optimization starting after system upgrading is lowered, and therefore the user experience when the user uses the application program is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart terminal technology, and in particular to a compilation optimization method, electronic device and storage medium. Background Technology

[0002] When an electronic device runs an application (APP), the application's code needs to be compiled before it can be executed. To improve the speed of application startup or runtime, electronic devices optimize the compilation of the application.

[0003] However, since the compilation and optimization process consumes the computing power and power consumption of electronic devices, in order not to affect the user experience, the relevant technologies usually start the compilation and optimization only when the electronic device is charged for the first time after the system upgrade. This can easily lead to the user feeling that the application runs sluggishly after the system upgrade if the user does not charge in time, thus affecting the user experience of the new system. Summary of the Invention

[0004] This application provides a compilation optimization method, an electronic device, and a storage medium. In this method, by determining the battery information and usage status of the upgraded electronic device, the threshold for compiling and optimizing the system after an upgrade is lowered without affecting normal user operation, thereby improving the user experience when using applications.

[0005] In a first aspect, this application provides a compilation optimization method, which includes: after the electronic device completes a system upgrade, obtaining the battery information of the electronic device; the battery information includes the remaining power and the charging status; when the remaining power is greater than or equal to a preset power and the charging status is not charging, when the duration of the electronic device entering the screen-off state is greater than or equal to a first preset duration, performing compilation optimization on the application in the electronic device.

[0006] Through the above solution, this application promptly obtains the battery information of the electronic device after the system upgrade is completed, in order to determine the remaining power and charging status of the electronic device after the system upgrade. Furthermore, if it is determined that the remaining power of the electronic device is sufficient and the electronic device is in an idle state, such as when the duration of the screen-off state is greater than or equal to a first preset duration, the compilation optimization task can be initiated even if the electronic device is not charging. Compared to related technologies that only initiate compilation optimization during the first charge after the electronic device's system upgrade, this application lowers the threshold for initiating compilation optimization after the system upgrade while ensuring the power of the electronic device and not affecting user use. This allows the upgraded electronic device to perform compilation optimization tasks in a timely manner, thereby enabling users to use applications more smoothly and improving the user experience of the new system.

[0007] In one possible implementation, the electronic device completing the system upgrade includes: the electronic device installing the system upgrade package and restarting, or the electronic device installing the system upgrade package but not restarting.

[0008] Understandably, the compilation optimization method provided in this application can be applied both after the electronic device has installed the system upgrade package and restarted, and without restarting. This ensures that compilation optimization tasks are executed promptly after a system upgrade, allowing users to experience the smooth application as soon as possible.

[0009] One possible implementation involves performing compilation optimizations on applications in an electronic device, including speed-profile level compilation optimizations on the applications in the electronic device.

[0010] Understandably, this application employs speed-profile level compilation optimization, which can improve compilation performance without slowing down the compilation speed.

[0011] One possible implementation involves performing compilation optimization on applications in an electronic device, including performing compilation optimization on all or part of the applications in the electronic device.

[0012] Understandably, this application allows for flexible setting of compilation optimization targets. It can perform compilation optimization on all applications in an electronic device to improve the coverage of edge optimization tasks, or it can perform compilation optimization on some applications in an electronic device to improve the time required to complete compilation optimization.

[0013] In one possible implementation, performing compilation optimization on an application in an electronic device includes: obtaining a list of compilation tasks; the list of compilation tasks includes at least one application to be compiled; and performing compilation optimization on the applications in the list of compilation tasks.

[0014] In one possible implementation, performing compilation optimization on the applications in the compilation task list includes: performing compilation optimization on each application sequentially according to the order of the applications in the compilation task list.

[0015] Understandably, this application performs compilation optimization on each application sequentially according to the order of the applications in the compilation task list, which facilitates the sorting of compilation optimization objects and makes the compilation optimization tasks proceed in an orderly manner.

[0016] In one possible implementation, the method further includes: obtaining the user's historical usage information; the historical usage information is used to reflect the user's records of using applications within a historical time period; based on the historical usage information, predicting the applications the user will use in a future preset time period; and adjusting the order of the applications to be used in the compilation task list to the top.

[0017] Understandably, a list of applications is created for each compilation task, and compilation is performed in the order of the list. This embodiment utilizes YOYO to predict applications that users might use within two hours and prioritizes the compilation of these applications. This avoids situations where task interruptions prevent these applications from being compiled.

[0018] In one possible implementation, performing compilation optimization on applications in an electronic device includes: recording a start timestamp when compilation optimization begins; determining the duration between the current timestamp and the start timestamp after each application's compilation optimization is completed; interrupting the compilation optimization task if the duration is greater than or equal to a second preset duration; and performing compilation optimization on the remaining applications if the duration is less than the second preset duration.

[0019] It is understandable to set a time limit for a single compilation optimization task. This way, each time a compilation optimization task is triggered, the electronic device will only execute the compilation optimization task within the limited time, avoiding excessive power consumption caused by excessively long edge optimization.

[0020] In one possible implementation, performing compilation optimization on an application in an electronic device includes interrupting the compilation optimization task upon receiving a screen-on signal.

[0021] For example, suppose there are three applications to be compiled and optimized on an electronic device: application A, application B, and application C. The second preset time is 5 minutes. After the compilation and optimization module completes the compilation and optimization of application A, it takes 25 seconds, which is less than 5 minutes. However, at this time, the electronic device is woken up by the user. In order not to affect the user's use and to provide the user with a compatibility with the compilation and optimization effect, the compilation and optimization module also interrupts the compilation and optimization task at this time.

[0022] In one possible implementation, after interrupting the compilation optimization task, the method further includes: continuing to perform compilation optimization on the remaining applications when the duration of the electronic device in the screen-off state is greater than or equal to a first preset duration; or, when the remaining battery power is greater than or equal to a preset battery power and the charging status is not charging, continuing to perform compilation optimization on the remaining applications when the duration of the electronic device in the screen-off state is greater than or equal to the first preset duration.

[0023] Understandably, in order to ensure the integrity of the compilation optimization task, if the electronic device meets the conditions for performing compilation optimization again after the compilation optimization task is interrupted, it will continue to perform compilation optimization on the remaining applications.

[0024] In one possible implementation, the second preset duration is associated with the time period in which the current time is located; when the current time is in the first time period, the second preset duration is the first duration; when the current time is in the second time period, the second preset duration is the second duration; the first time period and the second time period are used to describe different times, for example, the first time period is used to describe daytime, the second time period is used to describe nighttime, and the first duration is shorter than the second duration.

[0025] Understandably, electronic devices can be flexibly configured with different time limits for different time periods. Since users typically use electronic devices more frequently during the day than at night, this application can set a shorter time limit for the daytime, while users tend to rest at night, so this application can set a longer time limit for the daytime.

[0026] Secondly, this application provides a compiler optimization processing apparatus, which includes units / modules for performing the method described in the first aspect above. This apparatus can correspond to performing the method described in the first aspect above. For a brief description of the units / modules in this apparatus, please refer to the description in the first aspect above; for brevity, it will not be repeated here.

[0027] Thirdly, an electronic device is provided, including a processor coupled to a memory, the processor being configured to execute a computer program or instructions stored in the memory, such that the electronic device implements a compilation optimization method as described in any of the first aspects.

[0028] Fourthly, a chip is provided that is coupled to a memory for reading and executing a computer program stored in the memory to implement a compilation optimization method as described in any of the first aspects.

[0029] Fifthly, a computer-readable storage medium is provided that stores a computer program, which, when run on a terminal device, causes the terminal device to perform a compilation optimization method as described in any of the first aspects.

[0030] Sixthly, a computer program product is provided that, when the computer program product is run on a computer, causes the computer to perform a compilation optimization method as described in any of the first aspects.

[0031] It is understood that the beneficial effects of the second to sixth aspects mentioned above can be found in the relevant descriptions in the first aspect mentioned above, and will not be repeated here. Attached Figure Description

[0032] Figure 1 A comparative diagram of the JIT process provided in the embodiments of this application;

[0033] Figure 2 This is a schematic diagram illustrating one of the application scenarios of the compilation optimization method provided in the embodiments of this application;

[0034] Figure 3 A second schematic diagram illustrating an application scenario of the compilation optimization method provided in this application embodiment;

[0035] Figure 4 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application;

[0036] Figure 5 A schematic diagram of the software structure of the electronic device provided in the embodiments of this application;

[0037] Figure 6 One of the flowcharts illustrating the compilation optimization method provided in the embodiments of this application;

[0038] Figure 7 A second schematic flowchart illustrating the compilation optimization method provided in this application embodiment;

[0039] Figure 8 This is a schematic diagram of the compilation task list provided in an embodiment of this application;

[0040] Figure 9 This is a schematic diagram illustrating the adjustment of the compilation task list provided in an embodiment of this application;

[0041] Figure 10 This is a schematic diagram of the structure of the compiler optimization device provided in the embodiments of this application. Detailed Implementation

[0042] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.

[0044] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.

[0045] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0046] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.

[0047] For ease of understanding, the relevant technologies and technical terms involved in the embodiments of this application will be introduced below.

[0048] 1. Application source code: This is code data written by the application developers to support the implementation of various application services. The executable (dex) file of an electronic device contains the corresponding source code. When an application's installation package (Android application package, APK) is downloaded to an electronic device, the dex file containing the source code is written to the electronic device's data partition along with the application's APK.

[0049] When an electronic device runs an application, it needs to execute the application's source code to provide the user with the corresponding application services. Of course, the application's source code is code data that the electronic device cannot directly recognize. Currently, electronic devices mainly use methods such as interpreted execution and machine code execution to execute the application's source code.

[0050] 2. Interpreted Execution: During the execution of an application on an electronic device, an interpreter interprets the source code into binary code that the electronic device can recognize, and then executes that binary code. In this interpreted execution method, the electronic device interprets one line of source code before executing the corresponding line of binary code.

[0051] In scenarios where the source code is extensive, the application's source code execution efficiency is very low.

[0052] 3. Machine code execution: Also known as compiled execution, this refers to the process of translating source code into machine instructions using a compiler, such as binary code that electronic devices can directly recognize. Based on the compiled binary code, a corresponding optimized executable (odex) file is generated. When running an application, the electronic device can directly execute the binary code in the application's corresponding odex file to provide the user with the relevant application services.

[0053] As shown in Table 1, benchmark tests were performed on a virtual machine using both interpreted and machine code execution methods. The total execution time for the test items using interpreted execution was 3125745412 nanoseconds (ns), while the total execution time for the test items using machine code execution was 493084978 ns.

[0054] Table 1

[0055] Test Items Interpretation and execution Machine code execution Total execution time of test items 3125745412ns 493084978ns

[0056] As can be seen from the test results in Table 1, the execution time of interpreted execution is more than 6 times slower than that of machine code execution. In other words, the efficiency of interpreted execution is weaker than that of machine code execution. Therefore, completing the compilation as early as possible is one of the main optimization directions to improve application performance.

[0057] The main methods for compiling source code into machine instructions include: ahead-of-time (AOT) compilation and just-in-time (JIT) compilation.

[0058] In scenarios using AOT (Ahead-of-Time) compilation, the electronic device compiles the application's source code into machine code and generates the corresponding odex file before executing the application. This allows the application to start faster and run with better performance.

[0059] In a JIT (Just-In-Time) compilation scenario, during application execution, each line of source code is interpreted and its corresponding binary code is recorded. After all the source code has been interpreted once, an odex file containing the binary code of all the source code is obtained. Of course, when the application stops running, the electronic device destroys the corresponding odex file for that application.

[0060] In this embodiment, the scenario described is mainly based on AOT compilation. In subsequent embodiments, it can also be referred to as optimizing the compilation of the application.

[0061] For example, the odex file mentioned above may include the binary code of all the source code of the application. As another example, the odex file may also include the binary code corresponding to hot functions in the source code. Hot functions are code functions that rank highly in terms of the number of calls during application execution; typically, the application's configuration file can record the hot functions for that application.

[0062] Understandably, the binary code in an odex file is an instruction that the electronic device can directly recognize. When an electronic device runs an application, it executes the binary code in the odex file faster. Therefore, the application responds more quickly during operation.

[0063] As shown in Table 2, for application 1 in the electronic device, the startup time and startup power consumption of application 1 were tested with and without a corresponding odex file.

[0064] Table 2

[0065] Application Name odex file Startup time Startup power consumption Application 1 have 0.5 seconds (s) 740 mA Application 1 none 1 second (s) 725 mA

[0066] As can be seen from the test results in Table 2, compared to Application 1 which has no corresponding odex file, Application 1 with a corresponding odex file has a shorter startup time and lower startup power consumption.

[0067] like Figure 1 The diagram illustrates the JIT process of an electronic device when application 1 with a corresponding odex file is launched, and when application 1 without a corresponding odex file is launched. Figure 1 As can be seen, when launching application 1 without a corresponding odex file, the JIT process executes more frequently because the electronic device needs to continuously identify hot functions and perform JIT compilation. However, when launching application 1 with a corresponding odex file, the JIT process executes less frequently. This also explains why application 1 consumes less power when it is launched with a corresponding odex file.

[0068] Additionally, as shown in Table 3, electronic devices of the same model are categorized into Electronic Device 1, Electronic Device 2, and Electronic Device 3. Electronic Device 1 uses a 1.0 system and its applications have corresponding odex files; Electronic Device 2 uses a 2.0 system and its applications do not have odex files; Electronic Device 3 uses a 2.0 system and its applications have corresponding odex files. The 2.0 system is an upgraded version of the 1.0 system. With all devices at 100% battery and all other conditions remaining the same, battery life tests were conducted on Electronic Device 1, Electronic Device 2, and Electronic Device 3 respectively.

[0069] Table 3

[0070] Electronic device name Battery life Electronic device 1 10.01 hours (h) Electronic devices 2 9.70 hours (h) Electronic devices 3 10.04 hours (h)

[0071] As can be seen from the test results in Table 3, the battery life of electronic devices 1 and 3 with odex files is similar, and both are significantly longer than that of electronic device 2 without odex files.

[0072] However, the odex file of an application is not included in the application's APK; electronic devices require tools to generate the corresponding odex file. To solve this problem, dex2oat (dalvik excutable fileto optimized art file) was developed. dex2oat can pre-compile the application's bytecode into machine code, allowing direct execution of the machine code during runtime, thus significantly improving the application's efficiency.

[0073] dex2oat includes several different build modes, ranked by application performance. Common build modes include: speed, speed-profile, and verify. The speed build mode optimizes all application code, resulting in high-performance output, but it generates large files, takes a long time, and consumes a lot of phone storage. The speed-profile build mode relies on a profile file and can optimize hot functions of the application. The verify build mode only verifies the application's dex file. The verify build mode generally performs worse compilation performance than the speed-profile build mode.

[0074] Additionally, odex files are compiled based on the boot classpath provided by the operating system. These odex files also record the dependent boot classpaths and the size of the underlying file packages (e.g., JAR files, Java archive files) stored at the location indicated by the boot classpath. This allows electronic devices to call various types of JAR files according to the boot classpath during the execution of the odex file.

[0075] When the operating system's BootClassPath changes, the odex file becomes invalid, preventing the electronic device from continuing to execute machine code. Typically, after an operating system upgrade, the BootClassPath on an electronic device may change; for example, the address may change, or the size of JAR files in the storage location indicated by the BootClassPath may change.

[0076] For example, the above-mentioned operating system upgrade can be an operating system upgrade based on over-the-air (OTA) download technology.

[0077] 4. Operating system upgrades based on over-the-air (OTA) technology: This refers to software upgrades of electronic devices via the air interface of mobile communication. The electronic device has a server that distributes operating system upgrade packages. The electronic device can obtain the latest upgrade package from the server and use it to upgrade itself.

[0078] During an operating system upgrade, electronic devices may update their BootClassPath. After the BootClassPath is updated, the odex files of all applications on the electronic device will become invalid.

[0079] In some embodiments, before an electronic device runs an application, it can check whether the application corresponds to an odex file. If it is determined that the application corresponds to an odex file, the validity of the corresponding odex file is checked. For example, the BootClassPath recorded in the odex file is compared with the actual BootClassPath in the operating system. If the addresses are the same and the corresponding JAR file sizes are the same, the odex file is determined to be valid. If the addresses are different or the corresponding JAR file sizes are different, the odex file is determined to be invalid.

[0080] If the electronic device determines that the application has a corresponding odex file and that the odex file is valid, it will run the application using machine code execution.

[0081] If it is determined that the application does not have a corresponding odex file, or that the odex file is invalid, the electronic device will run the application using interpreted execution.

[0082] Additionally, if the application does not yet have a corresponding odex file (for example, the electronic device has just installed the application), or if the application's odex file is invalid (for example, the electronic device updated its BootClassPath during an OTA operating system upgrade), the electronic device needs to compile the application to generate the corresponding odex file.

[0083] However, since the compilation process consumes computing power and generates power consumption of electronic devices, in order not to affect the normal use of users, the relevant technologies do not directly compile the application after the electronic device system is upgraded. Instead, the compilation optimization task is usually started when the electronic device is charged for the first time after the system upgrade to compile the application and generate the corresponding odex file.

[0084] For example, in the native system rules of an electronic device, the condition for starting a compilation optimization task could be: the electronic device is off and charging.

[0085] However, as users become increasingly reliant on electronic devices, using them more frequently and for longer periods, scenarios that trigger application compilation under native rules are becoming increasingly rare. These native rules can be rules built into the operating system.

[0086] For example, if a user doesn't charge their device immediately after upgrading the system, even if the device is idle during this time, compilation optimizations for the application won't be triggered. Similarly, if a user frequently checks information on their device while it's charging, compilation optimizations for the application will still be difficult to trigger during charging.

[0087] For example, Table 4 shows the charging habits of 2,000 users on the day of system upgrade. Among them, 53.35% of users did not charge on the day of upgrade, 19.20% of users charged briefly on the day of upgrade, and 27.45% of users charged for a long time on the day of upgrade.

[0088] Table 4

[0089] Charging time percentage User habits Not charged 53.35% No charging required on the day of upgrade 0.1-0.5h 19.20% Brief charging on the day of upgrade other 27.45% Long charging time on the day of upgrade

[0090] As can be seen from the statistics in Table 4, the vast majority of users do not charge their devices or only charge them briefly on the day of the upgrade. Therefore, for the vast majority of users, the compilation optimization conditions for the relevant technologies are unlikely to be triggered on the day of the upgrade.

[0091] Furthermore, in some related technologies, after a system upgrade of an electronic device, even if compilation optimization conditions are triggered, the level of compilation optimization will be reduced to verify. Since the verify compilation mode only verifies the application's dex file, the application's performance will still decrease compared to before the system upgrade, even if compilation optimization conditions are triggered.

[0092] In summary, because the relevant technologies are difficult to trigger or have a low level of compilation optimization after system upgrades, electronic devices cannot promptly compile and optimize applications after system upgrades. As a result, users often experience increased application startup time and lag after system upgrades, which in turn affects the user experience of the new system.

[0093] In view of the above problems, this application provides a compilation optimization method. By judging the battery information and usage of the upgraded electronic device, the method lowers the threshold for starting compilation optimization after system upgrade without affecting the user's normal use. This allows the electronic device to trigger compilation optimization tasks as early as possible after system upgrade, improves the performance of applications in the new system, and thus improves the user's experience with the new system.

[0094] The compilation optimization method provided in this application can be applied to electronic devices such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). This application does not impose any restrictions on the specific type of electronic device.

[0095] The following describes several scenarios of the compilation optimization method used in this application.

[0096] In an exemplary application scenario, such as Figure 2 As shown, the system upgrade of an electronic device can be divided into a new system configuration stage, a new system download and installation stage, and a post-upgrade stage. The new system configuration stage mainly includes configuring relevant configuration files for the new system so that the electronic device can successfully load and execute the new system. The new system download and installation stage mainly includes downloading the new system package, installing the new system package, and restarting. The post-upgrade stage includes both the post-upgrade charging state and the post-upgrade non-charging state. The compilation optimization method of this application embodiment can perform compilation optimization in the post-upgrade non-charging state.

[0097] Specifically, during the new system development process, developers can configure relevant configuration files for the new system during the configuration phase to ensure that electronic devices can successfully load and execute the new system. After the new system development is complete, users can receive the new system version pushed to their electronic devices and choose to download it. In response to the user's choice to download the new system, the electronic device can download the new system package via OTA technology. After downloading, the electronic device installs the new system package and prompts the user to restart. After the user confirms the restart, the electronic device restarts, thus completing the system upgrade. If the user does not charge the device promptly after restarting (i.e., the device is in a post-upgrade non-charging state), the electronic device performs the compilation optimization task described in this application, also known as timely compilation or fast compilation. If the user charges the device promptly after restarting (i.e., the device is in a post-upgrade charging state), the electronic device performs a normal compilation optimization task.

[0098] The specific details of the compilation optimization tasks performed by the electronic device in the upgraded, non-charging state can be found in the following embodiments, and will not be repeated here. When the electronic device is in the upgraded, charging state, the ordinary compilation optimization tasks performed by the electronic device can be in the verify compilation mode.

[0099] In another exemplary application scenario, such as Figure 3 As shown, the system upgrade of an electronic device can be divided into a new system configuration stage, a new system download and installation stage, and a post-upgrade stage. The new system configuration stage mainly includes configuring relevant configuration files for the new system so that the electronic device can successfully load and execute the new system. The new system download and installation stage mainly includes downloading the new system package, installing the new system package, and restarting. The post-upgrade stage includes the charging state and the non-charging state after the upgrade. The compilation optimization method of this application embodiment can perform compilation optimization during the new system download and installation stage.

[0100] Specifically, after the electronic device completes the installation of the new system package, it prompts the user to restart. If the user chooses not to restart, the electronic device will not restart, and the user can continue to use it. The compilation optimization method in this application embodiment can perform the compilation optimization task before the electronic device completes the installation of the new system package and restarts.

[0101] If the user chooses not to restart, the electronic device will perform the compilation optimization task of this application, also known as just-in-time compilation or fast compilation. After the electronic device restarts, if the user does not charge the device in time and the just-in-time compilation task has not been completed, just-in-time compilation can continue; if the user charges the device in time, that is, while the electronic device is in the upgraded charging state, the electronic device can perform the normal compilation optimization task.

[0102] Of course, this application can also perform compilation optimization tasks in other scenarios, such as when an electronic device is restored to factory settings or when an electronic device is powered on for the first time. This application does not limit this to other scenarios.

[0103] The following is combined with Figure 4 The hardware structure of electronic devices will be introduced.

[0104] Figure 4 A schematic diagram of the hardware structure of the electronic device provided in an embodiment of this application is shown.

[0105] like Figure 4 As shown, the electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, 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, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, accelerometers, temperature sensors, motion sensors, barometric pressure sensors, magnetic sensors, distance sensors, proximity sensors, fingerprint sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.

[0106] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0107] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of instruction fetching and execution.

[0108] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.

[0109] USB port 130 is a USB standard compliant interface, specifically a Mini USB port, Micro USB port, USB Type-C port, etc. USB port 130 can be used to connect a charger to charge electronic device 100, and can also be used for data transfer between electronic device 100 and peripheral devices. It can also be used to connect headphones for audio playback. This interface can also be used to connect other electronic devices, such as AR devices.

[0110] The charging management module 140 receives charging input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 receives charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 receives wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device via the power management module 141.

[0111] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display 194, camera 193, and wireless communication module 160, etc.

[0112] The wireless communication function of electronic device 100 can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor, and baseband processor.

[0113] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with a tuning switch.

[0114] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.

[0115] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc.

[0116] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.

[0117] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0118] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.

[0119] Electronic device 100 can perform shooting functions through ISP, camera 193, video codec, GPU, display 194 and application processor.

[0120] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard RGB, YUV, or other formats. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0121] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to perform data storage functions.

[0122] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121, such as causing electronic device 100 to implement the compilation method in the embodiments of this application. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0123] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.

[0124] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.

[0125] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A. In some embodiments, the electronic device 100 may be equipped with multiple speakers 170A.

[0126] The receiver 170B, also known as the "earpiece," is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a telephone call or voice message, the receiver 170B can be brought close to the ear to listen to the voice.

[0127] Microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. When making a phone call or sending a voice message, the user can speak by bringing their mouth close to microphone 170C, inputting the sound signal into microphone 170C. Electronic device 100 may have at least one microphone 170C. In some embodiments, electronic device 100 may have two microphones 170C, which, in addition to collecting sound signals, can also perform noise reduction. In other embodiments, electronic device 100 may also have three, four, or more microphones 170C, which can collect sound signals, reduce noise, identify the sound source, and perform directional recording, etc.

[0128] The 170D headphone jack is used to connect wired headphones. The 170D headphone jack can be a USB 130 interface or a 3.5mm Open Mobile Terminal Platform (OMTP) standard interface, a CTIA (Cellular Telecommunications Industry Association of the USA) standard interface.

[0129] A pressure sensor is used to sense pressure signals and can convert these signals into electrical signals. In some embodiments, the pressure sensor may be located on the display screen 194. The electronic device 100 may also calculate the position of a touch based on the detection signal from the pressure sensor.

[0130] A gyroscope sensor can be used to determine the motion attitude of an electronic device 100. In some embodiments, the angular velocity of the electronic device 100 about three axes (i.e., the x, y, and z axes) can be determined by the gyroscope sensor.

[0131] An accelerometer can detect the magnitude of acceleration of an electronic device 100 in various directions (typically three axes). When the electronic device 100 is stationary, the accelerometer can detect the magnitude and direction of gravity. Accelerometers can also be used to identify the posture of electronic devices, and are applied in applications such as screen orientation switching and pedometers.

[0132] A touch sensor, also known as a "touch panel," can be located on the display screen 194. The touch sensor and display screen 194 together form a touchscreen, also called a "touch screen." The touch sensor detects touch operations applied to or near it. It then transmits the detected touch operation to the application processor to determine the type of touch event.

[0133] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch-sensitive buttons. Electronic device 100 can receive button input and generate key signal inputs related to user settings and function control of electronic device 100.

[0134] Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, different vibration feedback effects can be corresponding to touch operations applied to different applications (such as taking photos, playing audio, etc.).

[0135] Indicator 192 can be an indicator light, used to indicate charging status, power changes, or to indicate messages, missed calls, notifications, etc.

[0136] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0137] The following is combined with Figure 5 The software architecture of electronic devices will be introduced.

[0138] Figure 5 This is a schematic diagram of the software structure of an electronic device provided in an embodiment of this application.

[0139] like Figure 5 As shown, electronic devices can adopt a layered architecture, dividing the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the software layers of the software structure are divided from top to bottom as follows: application layer, application framework layer, Android Runtime and system libraries, and kernel layer.

[0140] The application layer can include a series of application packages.

[0141] like Figure 5As shown, the application layer can accommodate online update clients (OUC), chat applications, payment applications, music applications, video applications, game applications, browsers, and more. Of course, the application layer also includes... Figure 5 Applications not shown include, for example, calling, memos, contacts, camera, gallery, calendar, maps, Bluetooth, etc.

[0142] OUC is used to obtain the latest upgrade package from the server that provides the service upgrade package.

[0143] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0144] like Figure 5 As shown, the application framework layer can include an update engine, a compilation optimization and control module, and an OTA (Over-The-Air) upgrade management service. Of course, it can also include... Figure 5 Services and modules not shown in the diagram, such as window manager, resource manager, view system, etc.

[0145] For example, the update engine described above is used to drive and perform operating system upgrades.

[0146] For example, the aforementioned compilation optimization control module is used to determine whether an electronic device meets the compilation optimization conditions, and if the electronic device meets the compilation optimization conditions, instructs the compilation optimization module to perform compilation optimization on the applications in the electronic device. The compilation optimization control module can also be used to determine the applications that need to be compiled, and to determine the compilation order among the applications. For example, it can identify frequently used applications as those that need to be compiled.

[0147] For example, the aforementioned OTA upgrade management service is used to manage matters related to operating system upgrades. Taking an electronic device using a virtual A / B operating system as an example, the target operating system to be upgraded can be determined. For instance, if the electronic device runs on operating system A, the target operating system to be upgraded is operating system B.

[0148] like Figure 5As shown, the system library can include multiple functional modules. For example: a layer integrator (SurfaceFlinger), media libraries, 3D graphics processing libraries (e.g., OpenGL ES), and 2D graphics engines (e.g., SGL). SurfaceFlinger manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media libraries support playback and recording of various common audio and video formats, as well as still image files. The media libraries support various audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG. The 3D graphics processing libraries are used to implement 3D graphics drawing, image rendering, compositing, and layer processing. The 2D graphics engine is the drawing engine for 2D graphics.

[0149] The Android Runtime comprises core libraries and a virtual machine. The Android Runtime is responsible for scheduling and managing the Android system. Within the Android Runtime's virtual machine, there run an encoder (dalvik excutable file tooptimized art file, dex2oat) and a compilation optimization module (dexopt). The compilation optimization module is used to compile applications in electronic devices; specifically, it converts dex files containing source code into odex files containing binary code. For example, dexopt can call dex2oat to translate the application's source code and generate the corresponding odex file based on the translation results.

[0150] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0151] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0152] The kernel layer is the layer between hardware and software. The kernel layer includes at least camera drivers, audio drivers, and sensor drivers, but this application embodiment does not impose any limitations on this.

[0153] It should be noted that, Figure 5The layers and components within each layer of the illustrated software architecture do not constitute a specific limitation on the electronic device. In other embodiments, the electronic device may include more layers than illustrated, such as a system library (FWK LIB) layer and a kernel layer. Each layer may include more or fewer components than illustrated. Furthermore, the aforementioned functional modules may be combined into a single functional module, and the layers may be combined into a single layer; for example, a compiler optimization and control module may include a compiler optimization module, and a media middleware framework layer may be located within an application framework layer.

[0154] It is understood that, in order to implement the compilation optimization method in the embodiments of this application, the electronic device includes hardware and / or software modules that perform various functions. Based on the algorithm steps of the examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments.

[0155] The following section takes the execution body of the compiler optimization method as an example. Figure 5 Using the modules shown in the software structure diagram as examples, the compilation optimization method provided in this application embodiment will be illustrated by way of example.

[0156] Figure 6 This is a schematic diagram illustrating the overall flow of the compilation optimization method provided in this application embodiment. This method can be applied to, for example... Figures 2-3 In the compiler optimization scenario shown, such as... Figure 6 As shown, the method may include the following steps S201-S210.

[0157] S201. Upgrade clients in electronic devices can search for and download upgrade installation packages from the server.

[0158] In one feasible implementation, the electronic device can periodically send packet search requests to the server via OUC. These requests include the version number of the operating system currently running on the electronic device (e.g., version 1.1). Based on the operating system version number in the packet search request, the server checks if an upgrade package for a newer version (e.g., version 1.2) exists. When an upgrade package for a newer version exists, the server provides the electronic device with a download address for the upgrade package (e.g., a full upgrade package for version 1.2). The electronic device then downloads the upgrade package from the provided address.

[0159] In another feasible implementation, the server can also proactively push the new version upgrade installation package to electronic devices after receiving it.

[0160] In some embodiments, after receiving an upgrade installation package, the electronic device has the ability to upgrade its operating system. In some embodiments, the electronic device can automatically upgrade based on the upgrade installation package when idle. In other embodiments, the electronic device can upgrade based on the upgrade installation package in response to a user's upgrade instruction.

[0161] S202, the upgrade client instructs the upgrade engine to initiate an upgrade for the operating system.

[0162] As one implementation, OUC can set the update engine's startup attributes to true by sending upgrade commands to the update engine. Additionally, a service manager running in the background of the operating system monitors the update engine's startup attributes. When the service manager detects that the update engine's startup attribute is true, it starts the update engine.

[0163] Afterwards, the OUC obtains the status of the update engine through binder communication. Once the OUC confirms that the update engine has started successfully, the OUC passes upgrade parameters to the update engine (for example, the upgrade parameters can indicate whether the current upgrade operation is a file update operation or a file write operation), triggering the update engine to enter the upgrade process.

[0164] S203, the engine upgrade is installed according to the upgrade installation package.

[0165] In some embodiments, the update engine may verify the validity of the META-INF (i.e., digital signature) in the upgrade package to confirm whether the upgrade package is a legitimate upgrade package. For specific implementation details, please refer to relevant technologies, which will not be elaborated upon here.

[0166] After verifying that the upgrade package has passed inspection, the update engine can parse the package to obtain the upgrade data used to update the operating system. Then, the update engine can write the upgrade data to the corresponding storage partition (static or dynamic partition, etc.) of the operating system in memory, and the electronic device completes the system upgrade.

[0167] Furthermore, after the upgrade engine completes the installation of the upgrade package, it can send a notification message to the compilation optimization and management module to notify the module that the system upgrade has been completed.

[0168] S204. After confirming that the electronic device has completed the system upgrade, the compilation optimization and control module obtains the battery information of the electronic device.

[0169] The battery information includes the remaining power and the charging status, which can be divided into charging and not charging.

[0170] In one feasible implementation, upon receiving a notification message from the upgrade engine, the compilation optimization and control module determines that the electronic device has completed the system upgrade. The compilation optimization and control module can obtain the electronic device's battery information through the battery management module, thereby determining the remaining battery power and charging status.

[0171] S205. The compilation optimization and control module determines whether the remaining power of the electronic device is greater than or equal to the preset power.

[0172] The preset battery level can be flexibly set according to actual needs. For example, considering that compilation and optimization tasks consume power in electronic devices, the preset battery level can be set to 30% to ensure sufficient power for the user.

[0173] For example, after the compilation optimization and control module obtains the battery information of the electronic device, it can determine whether the remaining power is greater than or equal to 30%.

[0174] S206. If the remaining power of the electronic device is greater than or equal to the preset power, the compilation optimization and control module determines whether the electronic device is in a charging state.

[0175] In one feasible implementation, if the remaining battery power of the electronic device is determined to be greater than or equal to a preset battery power, the compilation optimization and control module continues to determine whether the electronic device is in a charging state. If the remaining battery power of the electronic device is determined to be less than the preset battery power, the compilation optimization and control module terminates the current process and continues execution of the current process after the remaining battery power of the electronic device is greater than or equal to the preset battery power.

[0176] S207. If the electronic device is not charging, the compilation optimization and control module obtains the screen-off status information of the electronic device.

[0177] Among them, the screen-off status information is used to reflect whether the electronic device is currently in a screen-off state. If the electronic device is currently in a screen-off state, the screen-off status information can also reflect the duration of the electronic device's screen-off state.

[0178] In some embodiments, the screen detection module in the electronic device can detect the screen state of the electronic device in real time. When it detects that the screen of the electronic device is off, the screen detection module starts timing. The screen detection module can record the screen state of the electronic device and the duration of entering the screen-off state in the screen-off state information.

[0179] If the remaining battery power of the electronic device is greater than or equal to the preset battery power and the electronic device is not charging, the compilation optimization and control module can obtain the screen-off status information of the electronic device from the screen detection module.

[0180] It should be noted that the order in which the remaining power and charging status are determined in this application embodiment is not limited. The compilation optimization and control module may determine the remaining power of the electronic device first and then the charging status of the electronic device, or it may determine the charging status of the electronic device first and then the remaining power of the electronic device, or it may determine both the remaining power and the charging status of the electronic device at the same time.

[0181] S208. When the electronic device enters the screen-off state, the compilation optimization and control module determines whether the duration of the electronic device entering the screen-off state is greater than or equal to the first preset duration.

[0182] The first preset duration can be flexibly set according to actual conditions. For example, considering that compilation and optimization tasks consume the computing power of electronic devices, in order not to affect user use, compilation should be performed when the electronic device is idle (i.e., when the user is not using it). For example, the first preset duration of the electronic device can be set to 5 minutes, that is, when the electronic device has been in screen-off state for more than five minutes, it can be determined that the user will not use the electronic device for the time being.

[0183] As one possible implementation, after obtaining the screen-off state information of the electronic device, if the screen-off state information shows that the electronic device is currently in a screen-off state, the compilation optimization and control module compares the duration of the electronic device entering the screen-off state with a first preset duration to determine whether the duration of the electronic device entering the screen-off state is greater than or equal to the first preset duration.

[0184] S209. If the duration of the electronic device in the screen-off state is greater than or equal to the first preset duration, the compilation optimization control module sends a compilation start command to the compilation optimization module.

[0185] The compilation start instruction is used to indicate the start of the compilation optimization task.

[0186] S210. In response to the compilation start instruction, the compilation optimization module performs compilation optimization on the application in the electronic device.

[0187] As one possible implementation, after receiving the compilation start instruction sent by the compilation optimization control module, the compilation optimization module can perform compilation optimization on all applications in the electronic device.

[0188] As another possible implementation, after receiving the compilation start instruction sent by the compilation optimization control module, the compilation optimization module can perform compilation optimization on some applications in the electronic device.

[0189] For example, the compilation optimization module can perform compilation optimization for applications that are frequently used by users on electronic devices (such as applications that rank in the top 15 most frequently used applications).

[0190] For any application to be compiled and optimized, the compilation optimization module can use any of the various compilation optimization modes shown in Table 5 when compiling it.

[0191] Table 5

[0192]

[0193] Among them, the speed compilation mode: In this compilation mode, dex2oat can perform AOT compilation on all function code in the dex file to obtain the corresponding compilation products: odex and vdex. The speed compilation mode optimizes all program code, resulting in high-performance products, but the generated files are large, the time taken, and the consumption of more mobile phone storage space.

[0194] Speed-profile compilation mode: In this mode, dex2oat not only verifies the dex file to obtain the corresponding odex file, but also performs AOT compilation on the function code specified in the profile file within the application's dex file, producing the corresponding ART file. The profile file contains information about hot functions (also known as hot code). This ART file contains the addresses of these specified function codes, facilitating function lookup. These specified function codes are the code for functions frequently used by the application. Therefore, during application execution, after loading the ART file into memory, the electronic device can quickly address and execute the found code, resulting in smoother application operation.

[0195] The verify compilation mode: In this mode, dex2oat verifies the dex file to obtain the corresponding odex file. Since verifying only the dex file and does not involve AOT compilation or dex instruction optimization, verifying has a shorter compilation time than speed-profile. However, verifying's compilation performance is worse than speed-profile.

[0196] In some embodiments, the compilation optimization module can perform speed-profile level compilation optimizations on applications in the electronic device.

[0197] In other embodiments, when the remaining battery power is greater than or equal to a preset battery power and the charging status is not charging, when the duration of the electronic device in the screen-off state is greater than or equal to a first preset duration, the compilation optimization module can adjust the compilation optimization level from the verify level to the speed-profile level.

[0198] Through the above solution, this application promptly obtains the battery information of the electronic device after the system upgrade is completed, in order to determine the remaining power and charging status of the electronic device after the system upgrade. Furthermore, if it is determined that the remaining power of the electronic device is sufficient and the electronic device is in an idle state, such as when the duration of the screen-off state is greater than or equal to a first preset duration, the compilation optimization task can be initiated even if the electronic device is not charging. Compared to related technologies that only initiate compilation optimization during the first charge after the electronic device's system upgrade, this application lowers the threshold for initiating compilation optimization after the system upgrade while ensuring the power of the electronic device and not affecting user use. This allows the upgraded electronic device to perform compilation optimization tasks in a timely manner, thereby enabling users to use applications more smoothly and improving the user experience of the new system.

[0199] The following describes the specific process by which the compiler optimization module performs compiler optimization tasks.

[0200] In some embodiments, such as Figure 7 As shown, the specific process by which the compiler optimization module performs compiler optimization tasks may include:

[0201] S301. When the compilation optimization task starts, the compilation optimization module records the start timestamp.

[0202] As one possible approach, when the remaining battery power is greater than or equal to the preset battery power and the charging status is not charging, when the duration of the electronic device in the screen-off state is greater than or equal to the first preset duration, the compilation optimization module starts to execute the compilation optimization task and records the start timestamp.

[0203] S302. After each application's compilation optimization is completed, the compilation optimization module determines the duration between the current timestamp and the start timestamp to obtain the current compilation duration.

[0204] As one possible approach, after each application's compilation optimization is completed, the compilation optimization module compares the current timestamp with the start timestamp, calculates the time difference between the current timestamp and the start timestamp, and uses this time difference as the current compilation time.

[0205] For example, the electronic device contains three applications to be compiled and optimized: Application A, Application B, and Application C. The compilation optimization module performs compilation optimization on Application A, Application B, and Application C sequentially. Assuming the compilation optimization task starts at 6:00:00 and the compilation optimization of Application A is completed at 6:00:25, then after completing the compilation optimization of Application A, the current compilation time determined by the compilation optimization module is: 6:00:25 minus 6:00:00, which is 25 seconds.

[0206] S303. The compilation optimization module determines whether the current compilation time is greater than or equal to the second preset time.

[0207] The second preset duration is associated with the time period in which the current time is located; when the current time is in the first time period, the second preset duration is the first duration; when the current time is in the second time period, the second preset duration is the second duration; the first time period is used to reflect daytime, the second time period is used to reflect nighttime, and the first duration is shorter than the second duration.

[0208] Understandably, electronic devices can be flexibly configured with different time limits for different time periods. Since users typically use electronic devices more frequently during the day than at night, this application can set a shorter time limit for the daytime, while users tend to rest at night, so this application can set a longer time limit for the daytime.

[0209] For example, if the current time is nighttime (e.g., 0:00-6:00), the second preset duration can be set to 10 minutes. If it is not nighttime, the second preset duration can be set to 5 minutes.

[0210] As one possible implementation, the compiler optimization module can compare the current compilation time with the second preset time to determine whether the current compilation time is greater than or equal to the second preset time.

[0211] S304. If the duration is less than the second preset duration, perform compilation optimization on the next application.

[0212] For example, suppose the electronic device contains three applications to be compiled and optimized: application A, application B, and application C. The second preset time is 5 minutes. After the compilation optimization module completes the compilation optimization of application A, the time taken is 25 seconds, which is less than 5 minutes. Therefore, it can continue to perform compilation optimization on application B.

[0213] S305. If the duration is greater than or equal to the second preset duration, the compilation optimization module interrupts the compilation optimization task.

[0214] For example, suppose there are three applications to be compiled and optimized in an electronic device: application A, application B, and application C. The second preset time is 5 minutes. After the compilation and optimization module completes the compilation and optimization of application B, if the total time taken reaches 5 minutes and 1 second, which is greater than 5 minutes, the compilation and optimization module will interrupt the compilation and optimization task, that is, it will temporarily not perform the compilation and optimization task for application C.

[0215] It is understandable to set a time limit for a single compilation optimization task. This way, each time a compilation optimization task is triggered, the electronic device will only execute the compilation optimization task within the limited time, avoiding excessive power consumption caused by excessively long edge optimization.

[0216] In other embodiments, if a screen-on signal is received during the compilation optimization process of the compilation optimization module on the application in the electronic device, the compilation optimization module will also interrupt the compilation optimization task.

[0217] For example, suppose there are three applications to be compiled and optimized on an electronic device: application A, application B, and application C. The second preset time is 5 minutes. After the compilation and optimization module completes the compilation and optimization of application A, it takes 25 seconds, which is less than 5 minutes. However, at this time, the electronic device is woken up by the user. In order not to affect the user's use and to provide the user with a compatibility with the compilation and optimization effect, the compilation and optimization module also interrupts the compilation and optimization task at this time.

[0218] In some embodiments, in order to ensure that compilation optimization is performed on all applications to be compiled and optimized, after the compilation optimization module interrupts the compilation optimization task, when the electronic device reaches the screen-off state again for a duration greater than or equal to a first preset duration, the compilation optimization module continues to perform compilation optimization on the remaining applications.

[0219] For example, suppose the electronic device contains three applications to be compiled and optimized: Application A, Application B, and Application C. The second preset time is 5 minutes. After the compilation and optimization module completes the compilation and optimization of Application A, it takes 25 seconds, less than 5 minutes. However, at this time, the electronic device is woken up by the user. In order not to affect the user's use and to provide the user with a seamless compilation and optimization effect, the compilation and optimization module also interrupts the compilation and optimization task at this time. After a period of time, the electronic device enters the screen-off state for another 5 minutes, at which point the compilation and optimization module continues to perform compilation and optimization on Application B.

[0220] As another example, suppose the electronic device contains three applications to be compiled and optimized: application A, application B, and application C. The second preset time is 5 minutes. After the compilation and optimization module completes the compilation and optimization of application B, the cumulative time taken reaches 5 minutes and 1 second, which is greater than 5 minutes. Therefore, the compilation and optimization module interrupts the compilation and optimization task, that is, it temporarily suspends the compilation and optimization task for application C. After a period of time, when the electronic device enters the screen-off state for another 5 minutes, the compilation and optimization module resumes the compilation and optimization of application C.

[0221] In other embodiments, when the remaining battery power is greater than or equal to a preset battery power and the charging status is not charging, when the duration of the electronic device entering the screen-off state again is greater than or equal to a first preset duration, the compilation optimization module continues to perform compilation optimization on the remaining application.

[0222] For example, suppose the electronic device contains three applications to be compiled and optimized: Application A, Application B, and Application C. The second preset duration is 5 minutes. After the compilation and optimization module completes the compilation and optimization of Application A, the time taken is 25 seconds, less than 5 minutes. However, at this time, the electronic device is woken up by the user. In order not to affect the user's use and to provide the user with a seamless compilation and optimization effect, the compilation and optimization module also interrupts the compilation and optimization task at this time. After a period of time, the electronic device enters a screen-off state. If the electronic device meets the following conditions again: the remaining battery power is greater than or equal to the preset battery power, the charging status is not charging, and the duration of entering the screen-off state is greater than or equal to the first preset duration, then the compilation and optimization module continues to perform compilation and optimization on Application B.

[0223] As another example, suppose the electronic device contains applications A, B, and C to be compiled and optimized, and the second preset duration is 5 minutes. After the compilation and optimization module completes the compilation and optimization of application B, if the cumulative time taken reaches 5 minutes and 1 second, which is greater than 5 minutes, the compilation and optimization module will interrupt the compilation and optimization task, that is, it will temporarily not perform the compilation and optimization task for application C. After a period of time, the electronic device enters a screen-off state. If the electronic device again meets the conditions: the remaining battery power is greater than or equal to the preset battery power, the charging status is not charging, and the duration of entering the screen-off state is greater than or equal to the first preset duration, then the compilation and optimization module will continue to perform compilation and optimization for application C.

[0224] In some embodiments, such as Figure 8 As shown, before the compilation optimization module executes compilation optimization tasks, the electronic device pre-creates a list of compilation tasks. This list contains one or more applications to be compiled, such as... Figure 8 The list includes applications A, B, C, and D. The applications in the list can be sorted by frequency of use or by other orders; this embodiment does not limit the sorting.

[0225] When an electronic device meets the conditions for executing a compilation optimization task (i.e., the remaining battery power is greater than or equal to the preset battery power, the charging status is not charging, and the screen-off state duration is greater than or equal to), the compilation optimization module can obtain the above compilation task list and perform compilation optimization on the applications in the compilation task list.

[0226] For example, the compilation optimization module can perform compilation optimization on each application sequentially according to the order of the applications in the compilation task list.

[0227] For example, the compiler optimization module can also randomly perform compiler optimizations on applications in the compiler task list.

[0228] As one possible implementation, when compilation optimization begins, the compilation optimization module records a start timestamp. After completing the compilation optimization of each application, the compilation optimization module determines the duration between the current timestamp and the start timestamp. If the duration is greater than or equal to a second preset duration, the compilation optimization module interrupts the current compilation optimization task; if the duration is less than the second preset duration, the compilation optimization module performs compilation optimization on the next application in the compilation task list.

[0229] As another possible implementation, after interrupting the current compilation optimization task, when the electronic device returns to the screen-off state for a duration greater than or equal to a first preset duration, the compilation optimization module continues to perform compilation optimization on applications that have not been compiled in the compilation task list.

[0230] In other embodiments, the electronic device can also adjust the order of applications to be compiled in the compilation task list. Specifically, the electronic device can first obtain the user's historical usage information. This historical usage information reflects the user's records of using applications within a historical time period. Further, based on the historical usage information, the electronic device can predict the applications the user will use in a preset future time period, and then adjust the order of these applications in the compilation task list to the top.

[0231] For example, electronic devices can use a built-in AI assistant (such as YOYO Assistant) to predict which applications a user might use in the next two hours and move those applications to the top of the build task list.

[0232] like Figure 9As shown, the original compilation task list listed applications A, B, C, and D in descending order of video frequency. After the electronic device connected the original compilation task list to YOYO Assistant, YOYO Assistant predicted that the user might use application D within the next two hours. Therefore, the electronic device moved application D to the top of the column in the original compilation task list, resulting in the current compilation task list. In the current compilation task list, application D is ranked first. When the compilation optimization module starts executing compilation optimization tasks, application D can be compiled first.

[0233] Understandably, a list of applications is created for each compilation task, and compilation is performed in the order of the list. This embodiment utilizes YOYO to predict applications that users might use within two hours and prioritizes the compilation of these applications. This avoids situations where task interruptions prevent these applications from being compiled.

[0234] It is understood that, in order to achieve the above-mentioned functions, electronic devices include hardware structures or software modules, or a combination of both, corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in a hardware-driven or software-driven manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0235] This application embodiment can divide an electronic device into functional modules based on the above method example. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation. The following description uses the example of dividing each functional module according to each function.

[0236] Figure 10 This is a schematic diagram of a compiler optimization device provided in an embodiment of this application. Figure 10 As shown, the device may include an acquisition unit 401 and a compilation unit 402.

[0237] The acquisition unit 401 is used to acquire the battery information of the electronic device after the electronic device has completed the system upgrade; the battery information includes the remaining power and the charging status.

[0238] The compilation unit 402 is used to perform compilation optimization on the application in the electronic device when the remaining battery power is greater than or equal to the preset battery power and the charging state is not charging, and the duration of the electronic device entering the screen-off state is greater than or equal to the first preset duration.

[0239] This embodiment also provides a computer storage medium storing computer instructions. When the computer instructions are executed on an electronic device, the electronic device performs the aforementioned related method steps to implement the compilation optimization method in the above embodiment.

[0240] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the compilation optimization method in the above embodiment.

[0241] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the compilation optimization methods in the above method embodiments.

[0242] In this embodiment, the electronic devices (such as mobile phones), computer storage media, computer program products or chips are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0243] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0244] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0245] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.

Claims

1. A compiler optimization method, characterized in that, include: After the electronic device completes the system upgrade, the battery information of the electronic device is obtained, including the remaining power and charging status. When the remaining battery power is greater than or equal to a preset battery power and the charging state is not charging, when the duration of the electronic device in the screen-off state is greater than or equal to a first preset duration, the application in the electronic device is compiled and optimized.

2. The method according to claim 1, characterized in that, The electronic device completing the system upgrade includes: the electronic device installing the system upgrade package and restarting, or the electronic device installing the system upgrade package but not restarting.

3. The method according to claim 1, characterized in that, The process of performing compilation optimization on the application in the electronic device includes: Speed-profile level compilation optimizations are performed on applications in the electronic device.

4. The method according to claim 1 or 3, characterized in that, The process of performing compilation optimization on the application in the electronic device includes: Perform compilation optimization on all or part of the applications in the electronic device.

5. The method according to claim 1, characterized in that, The process of performing compilation optimization on the application in the electronic device includes: Obtain a list of compilation tasks, which includes at least one application to be compiled; Perform compilation optimizations on the applications in the compilation task list.

6. The method according to claim 5, characterized in that, The process of performing compilation optimization on the applications in the compilation task list includes: Compilation optimizations are performed on each application sequentially according to the order of the applications in the compilation task list.

7. The method according to claim 6, characterized in that, The method further includes: Obtain the user's historical usage information, which reflects the user's record of using the application within a historical time period; Based on the historical usage information, predict the applications that the user will use in a future preset time period; The order of the application to be used in the compilation task list is adjusted to the first position, which is the column header of the compilation task list.

8. The method according to claim 1, characterized in that, The process of performing compilation optimization on the application in the electronic device includes: When compilation optimization begins, record the start timestamp; After each application's compilation optimization is completed, determine the duration between the current timestamp and the start timestamp; If the duration is greater than or equal to the second preset duration, the compilation optimization task is interrupted. If the duration is less than the second preset duration, perform compilation optimization on the remaining application.

9. The method according to claim 1, characterized in that, The process of performing compilation optimization on the application in the electronic device includes: If a screen light-up signal is received, the compilation and optimization task is interrupted.

10. The method according to claim 8 or 9, characterized in that, After interrupting the compilation optimization task, the method further includes: When the duration of the electronic device in screen-off state is greater than or equal to the first preset duration, the remaining application continues to be compiled and optimized. Alternatively, if the remaining battery power is greater than or equal to a preset battery power and the charging state is not charging, when the duration of the electronic device in the screen-off state is greater than or equal to a first preset duration, the remaining application continues to be compiled and optimized.

11. The method according to claim 8, characterized in that, The second preset duration is associated with the time period in which the current time is located; when the current time is in the first time period, the second preset duration is the first duration; when the current time is in the second time period, the second preset duration is the second duration; the first time period and the second time period are used to describe different times, and the first duration is shorter than the second duration.

12. An electronic device, characterized in that, include: One or more processors; Memory; And one or more computer programs, wherein the one or more computer programs are stored on the memory, and when the computer programs are executed by the one or more processors, cause the electronic device to perform the compilation optimization method as described in any one of claims 1-1.

13. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, it causes the electronic device to perform the compilation optimization method as described in any one of claims 1-11.