Installation optimization method, electronic device, storage medium and computer program product

By estimating the compilation time and optimizing the upgrade progress information, the problem of low installation efficiency and poor user experience caused by the inability to call the jar package in the electronic device system upgrade is solved, and efficient installation and good user experience are achieved.

CN118519645BActive Publication Date: 2025-08-26HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410971536.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2025-08-26
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

When upgrading the electronic device system, the old odex file cannot call the jar package, causing the application to compile failure, affecting the installation efficiency of the installation package and poor user experience.

Method used

By estimating the compilation time of the application to be compiled, determine whether the compilation conditions are met. If not, end the compilation early and restart the device to avoid timeout of the compilation time, optimize the display of upgrade progress information, and ensure the installation efficiency and user experience of the installation package.

Benefits of technology

It improves the installation efficiency of the installation package, avoids the experience of users who mistakenly think that the upgrade failed, reduces the occurrence of application compilation failures, and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519645B_ABST
    Figure CN118519645B_ABST
Patent Text Reader

Abstract

The present application relates to an installation optimization method, an electronic device, a storage medium and a computer program product. The method is applied in an electronic device. The electronic device can start the upgrade of the operating system according to the upgrade installation package, and display the upgrade progress information on the upgrade interface according to the installation progress information. The electronic device also estimates the compilation time of the application to be compiled. If it is determined that the application to be compiled meets the compilation conditions based on the compilation time estimate and the total compilation time of the compiled applications, the electronic device compiles the application to be compiled and updates the upgrade progress information on the upgrade interface; if the application to be compiled does not meet the compilation conditions, the electronic device displays the preset upgrade progress information on the upgrade interface, and restarts the electronic device. The installation optimization method of the present application can solve the technical problem of low installation efficiency of the installation package.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an installation optimization method, an electronic device, a storage medium, and a computer program product. Background Art

[0002] When running an application, an electronic device needs to execute the corresponding code to provide the corresponding application services to the user. For example, an electronic device can compile the Android system's APK using dex2oat to generate an optimized executable file (odex) of the application. This compiled and optimized odex file enables the electronic device to execute more efficiently, achieve better performance, and reduce power consumption.

[0003] Typically, when installing and upgrading an electronic device's system, if the system's boot path (BootClassPath) changes, for example, if the jar package (java archive file) indicated by the BootClassPath changes, the old odex file will be unable to call the jar package, and the application will need to be recompiled to ensure better performance in executing the corresponding application on the electronic device. However, after installing the system upgrade package, when the electronic device compiles the application, it needs to complete the compilation and optimization of a portion of the TOP application within a reserved time. If the electronic device has not completed the compilation of the current application after the reserved time expires, the files of the uncompiled application will be discarded, affecting the installation efficiency of the installation package. Summary of the Invention

[0004] In view of the above, it is necessary to provide an installation optimization method, electronic device, storage medium and computer program product to solve the technical problem of low installation efficiency of the installation package.

[0005] In a first aspect, an embodiment of the present application provides an installation optimization method, which is applied to an electronic device, the method comprising: starting an upgrade of an operating system according to an upgrade installation package; displaying upgrade progress information on an upgrade interface according to the installation progress information; estimating a compilation time estimate of an application to be compiled; if, based on the compilation time estimate and the total compilation time of compiled applications, it is determined that the application to be compiled meets compilation conditions, compiling the application to be compiled, and updating the upgrade progress information on the upgrade interface; if the application to be compiled does not meet the compilation conditions, displaying preset upgrade progress information on the upgrade interface, and restarting the electronic device.

[0006] In the above technical solution, the electronic device can estimate the compilation time of the current application to be compiled. When it is determined that the application to be compiled does not meet the compilation conditions based on the estimated time and the compiled time, it can extract and end the compilation of the application to be compiled, thereby improving the installation efficiency of the installation package.

[0007] When the upgrade progress information does not display 100%, ART will instruct OUC to set the upgrade progress information to 100% on the upgrade interface according to ART's instructions, and notify OUC to trigger a device restart. This can avoid notifying the user to restart the electronic device when the upgrade progress information does not display 100%, which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, when the application to be compiled is determined to not meet the compilation conditions, the application will notify OUC to trigger a device restart to avoid the compilation time of the application exceeding the maximum time limit, resulting in the failure of the application compilation.

[0008] In one embodiment of the present application, if there are multiple applications to be compiled, determining whether the applications to be compiled meet the compilation conditions includes: determining a first total duration based on the estimated compilation duration of the Nth application, the estimated compilation duration of the N+1th application, and the total compilation duration of the compiled applications, where N is a natural number greater than or equal to 1; if the first total duration is less than the reserved duration, determining that the Nth application meets the compilation conditions. The above technical solution can accurately determine whether the Nth application meets the compilation conditions based on the estimated compilation durations of the Nth application to be compiled and the N+1th application, and the total compilation duration of the compiled applications.

[0009] In one embodiment of the present application, if N=1, estimating the compilation time estimates for the Nth application and the N+1th application includes: obtaining the file size of the Nth application and the file size of the N+1th application; obtaining the compilation time estimate for the Nth application based on a preset rate and the file size of the Nth application; and obtaining the compilation time estimate for the N+1th application based on the preset rate and the file size of the N+1th application. In the above technical solution, when the Nth application is the first application to be compiled, using the preset rate as the compilation rate for the Nth application and the N+1th application can improve the computational efficiency of the installation optimization method.

[0010] In one embodiment of the present application, if N is greater than 1, estimating the estimated compile time of the Nth application includes: obtaining the file size and compile time of the N-1th application, calculating the compile rate of the N-1th application, where the N-1th application is a compiled application; and estimating the estimated compile time of the Nth application based on the compile rate of the N-1th application. In the above technical solution, when the Nth application is not the first application to be compiled, the compile rate of the N-1th application is used as the compile rate of the Nth application, thereby setting the compile rate of the application to be compiled based on the compile rate of the compiled application, which can improve the accuracy of the estimated compile time of the Nth application.

[0011] In one embodiment of the present application, if N is greater than 1, estimating the estimated compile time of the N+1th application includes: obtaining the file size and compile time of the Nth application, calculating the compile rate of the Nth application, where the Nth application is a compiled application; and estimating the estimated compile time of the N+1th application based on the compile rate of the Nth application. In the above technical solution, when the Nth application is not the first application to be compiled, using the compile rate of the Nth application as the compile rate of the N+1th application can further improve the accuracy of the estimated compile time of the Nth application.

[0012] In one embodiment of the present application, the method further includes: if the first total duration is greater than or equal to the reserved duration, determining a second total duration based on the estimated compilation duration of the Nth application and the total compilation duration of the compiled applications; if the second total duration is less than or equal to the reserved duration, determining a third total duration based on the first total duration and the first preset duration; if the third total duration is greater than or equal to the reserved duration, compiling the Nth application as the last application to be compiled, and updating the upgrade progress information based on the estimated compilation duration of the Nth application. In the above technical solution, when the third total duration is greater than or equal to the reserved duration, compiling the Nth application as the last application to be compiled, and updating the upgrade progress information based on the estimated compilation duration of the Nth application, can avoid notifying the user to restart the electronic device when the upgrade progress information does not display a preset value (such as 100%), which may cause the user to mistakenly believe that the upgrade has failed, affecting the user experience. At the same time, it can avoid the occurrence of application compilation failure caused by the compilation time of the application exceeding the limit.

[0013] In one embodiment of the present application, the method further includes: if the third total duration is less than the reserved duration, compiling the Nth application, and recording the file size and compilation duration of the Nth application after compilation. In the above technical solution, if the third total duration is less than the reserved duration, the file size and compilation duration of the Nth application after compilation are recorded to facilitate subsequent setting of the compilation rate for the N+1th application.

[0014] In one embodiment of the present application, the file of the application to be compiled is an odex file.

[0015] In one embodiment of the present application, the method further includes: if the second total time is greater than the reserved time, determining whether the second total time is greater than the limit time; if the second total time is greater than the limit time, terminating the compilation of the Nth application, setting the upgrade progress information to a preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart. In the above technical solution, when the second total time is greater than the reserved time, if the second total time is greater than the limit time, terminating the compilation of the Nth application, setting the upgrade progress information to a preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart, it can avoid notifying the user to restart the electronic device when the upgrade progress information does not display the preset value, which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, it can avoid the compilation time of the application exceeding the limit time, resulting in the occurrence of application compilation failure.

[0016] In one embodiment of the present application, the method further includes: if the second total time is less than or equal to the limit time, determining a fourth total time based on the second total time and the second preset time; if the fourth total time is greater than the reserved time, terminating the compilation of the Nth application, setting the upgrade progress information to the preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart. In the above technical solution, when the second total time is less than or equal to the limit time, if the fourth total time is greater than the reserved time, terminating the compilation of the Nth application, setting the upgrade progress information to the preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart, it can avoid notifying the user to restart the electronic device when the upgrade progress information does not display the preset value, which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, it can avoid the compilation time of the application exceeding the limit time, resulting in the occurrence of application compilation failure.

[0017] In one embodiment of the present application, the method further includes: if the fourth total duration is less than or equal to the reserved duration, compiling the Nth application as the last application to be compiled, and updating the upgrade progress information based on the estimated compilation duration of the Nth application. In the above technical solution, when the second total duration is less than or equal to the limit time, if the fourth total duration is less than or equal to the reserved duration, compiling the Nth application as the last application to be compiled, and updating the upgrade progress information based on the estimated compilation duration of the Nth application, can avoid notifying the user to restart the electronic device when the upgrade progress information does not display the preset value, which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, it can avoid the compilation time of the application exceeding the limit time, resulting in the occurrence of application compilation failure.

[0018] In one embodiment of the present application, restarting the electronic device includes: exiting the operating system and cutting off the power supply of the device; turning on the power supply of the device again and starting the operating system corresponding to the version of the upgrade installation package.

[0019] In one embodiment of the present application, restarting the electronic device includes: displaying a pop-up window on the upgrade interface, the pop-up window including a restart control for restarting the electronic device; and controlling the electronic device to restart in response to a user's operation on the restart control.

[0020] In one embodiment of the present application, the method further includes obtaining a compilation time for the application to be compiled, and if the compilation time reaches a time limit, terminating the compilation of the application to be compiled, setting the upgrade progress information to a preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart. The above technical solution can prevent the application compilation time from exceeding the time limit, resulting in application compilation failure.

[0021] On the second aspect, some embodiments of the present application provide an electronic device, which includes a memory and a processor: wherein the memory is used to store program instructions; the processor is used to read and execute the program instructions stored in the memory, and when the program instructions are executed by the processor, the electronic device executes the above-mentioned installation optimization method.

[0022] On the third aspect, some embodiments of the present application provide a chip including a processor and a memory; wherein the processor is connected to the memory; the memory is used to store program instructions; and the processor is used to read the program instructions stored in the memory to implement the above-mentioned installation optimization method.

[0023] In a fourth aspect, some embodiments of the present application provide a computer storage medium storing program instructions. When the program instructions are executed on an electronic device, the electronic device executes the above-mentioned installation optimization method.

[0024] In a fifth aspect, some embodiments of the present application provide a computer program product, including computer program instructions, which implement the above-mentioned installation optimization method when executed by a processor.

[0025] In addition, the technical effects brought about by the second to fifth aspects can be found in the descriptions of the methods of each design in the above method section, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 Schematic diagram of the OTA package installation process in the related art.

[0027] Figure 2 This is a schematic diagram of the OTA package installation process in one embodiment of the present application.

[0028] Figure 3 This is a schematic diagram of an upgrade interface in one embodiment of the present application.

[0029] Figure 4 This is a schematic diagram of an upgrade interface in another embodiment of the present application.

[0030] Figure 5 Schematic diagram of the hardware structure of an electronic device in one embodiment of the present application.

[0031] Figure 6 This is a software structure block diagram of an electronic device in one embodiment of the present application.

[0032] Figure 7 This is a flowchart of an installation optimization method in another embodiment of the present application.

[0033] Figure 8 This is a flowchart of installing an upgrade installation package in one embodiment of the present application.

[0034] Figure 9 This is a schematic diagram of an upgrade interface in one embodiment of the present application.

[0035] Figure 10 This is a flowchart of updating upgrade progress information in one embodiment of the present application.

[0036] Figure 11 A schematic diagram of an upgrade interface in another embodiment of the present application.

[0037] Figure 12 This is a schematic diagram of an upgrade interface in another embodiment of the present application.

[0038] Figure 13 This is a schematic diagram of a pop-up window in one embodiment of the present application.

[0039] Figure 14 This is a flow chart of a method for compiling an application in another embodiment of the present application.

[0040] Figure 15 This is a schematic diagram of the upgrade progress during OTA package installation in another embodiment of the present application. DETAILED DESCRIPTION

[0041] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of such features. In the description of some embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in some embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.

[0042] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can mean A or B. "And / or" in some embodiments of this application is merely a way to describe the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can mean: a, b, c, a and b, a and c, b and c, a, b and c.

[0043] To facilitate understanding, the technical terms involved in the embodiments of this application are first introduced below.

[0044] 1. Application source code: Code data written by the application developer to support the implementation of various application services of the application. The executable (dex) file of the electronic device contains the corresponding source code. TM When an application package (apk) is created, the dex file containing the source code is written into the data partition of the electronic device along with the application package (apk).

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

[0046] 2. Interpreted execution: When an electronic device runs an application, it uses an interpreter to convert the source code into binary code that the electronic device can recognize, and then executes the binary code. In this way, when running an application, the electronic device interprets each line of source code and then executes the corresponding binary code.

[0047] In a scenario where the amount of code in a source file is large, the source code execution efficiency of the application is very low.

[0048] 3. Machine code execution: Also known as compiled execution, this refers to the translation of source code into machine instructions, such as binary code, directly readable by electronic devices, by a compiler. 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 corresponding odex file, providing the corresponding application services to the user.

[0049] The above-mentioned method of compiling source code into machine instructions may include: ahead of time (AOT) compilation and just-in-time (JIT) compilation.

[0050] In AOT compilation, the application source code is compiled into machine code and a corresponding odex file is generated before the application is executed. This can make the application start faster and have better performance.

[0051] In a JIT compilation scenario, while the application is running, each source code line is interpreted and the corresponding binary code is recorded. After all source code has been interpreted, an odex file containing the binary code of all source code is generated. After the application stops running, the electronic device destroys the corresponding odex file. The above two compilation methods each have advantages and disadvantages. In the embodiments of this application, the description is mainly based on the scenario of AOT compilation. In subsequent embodiments, it can also be referred to as optimized compilation of the application.

[0052] Exemplarily, the odex file may include the binary code of all the source code of the application. Furthermore, the odex file may include the binary code corresponding to hot functions in the source code. A hot function is a code function that ranks before a specified number of calls during the application's execution. Typically, the application's configuration file (or profile file) records the hot functions corresponding to the application.

[0053] It is understandable that the binary code in the odex file is a direct instruction that the electronic device can recognize. When the electronic device runs an application, the binary code in the odex file is executed more quickly. This results in a faster response time during application execution. However, the odex file for an application is not included with the application's APK. The electronic device needs to use the application for a period of time before generating the corresponding odex file. The odex file in the above embodiment is used for illustration only. In other embodiments, files compiled by the electronic device may also include exe files and obj files, and this application does not limit this.

[0054] Before the odex file of the application is generated, the electronic device cannot execute the application in machine code because the odex file of the application is not in the electronic device. In this scenario, the application can only be run in an interpreted execution mode.

[0055] It can be seen that the prerequisite for enabling machine code execution is to generate the corresponding odex file.

[0056] Furthermore, the odex file is compiled based on the operating system's BootClassPath. The odex file also records the BootClassPath it relies on and the size of the underlying file package (e.g., a jar file (Java archive file)) stored in the location indicated by the BootClassPath. This allows electronic devices to call various jar files according to the BootClassPath when executing the odex file.

[0057] After the operating system's BootClassPath changes, the odex file becomes invalid, causing the electronic device to no longer enable machine code execution. Typically, after an electronic device's operating system is upgraded, the BootClassPath in the electronic device may change, for example, the address changes, or the size of the JAR package in the storage location indicated by the BootClassPath changes.

[0058] Exemplarily, the above operating system upgrade may be an operating system upgrade based on over-the-air download technology.

[0059] 4. Over-the-air (OTA) operating system upgrades: This refers to software upgrades for electronic devices via the mobile communications air interface. The electronic device is associated with 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 the device.

[0060] During the operating system upgrade process, the electronic device may update the BootClassPath. After the BootClassPath is updated, the odex files of all applications in the electronic device will become invalid.

[0061] In some embodiments, before running an application, the electronic device may check whether an odex file corresponds to the application. If it is determined that an odex file corresponds to the application, the corresponding odex file is checked to see if it is valid. 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 package sizes are the same, the odex file is determined to be valid. If the addresses are different or the corresponding jar package sizes are different, the odex file is determined to be invalid.

[0062] When it is determined that there is an odex file corresponding to the application and the odex file is valid, the electronic device runs the application in a machine code execution manner.

[0063] When it is determined that the application has no corresponding odex file or the odex file is invalid, the electronic device runs the application in an interpreted execution manner.

[0064] In addition, if the application does not have a corresponding odex file (for example, the electronic device has just installed the application), or the application's odex file has expired (for example, the electronic device updated the BootClassPath during an OTA operating system upgrade), the electronic device needs to compile the application and generate the corresponding odex file when it is idle and has sufficient power.

[0065] After an electronic device upgrades its operating system using an upgrade package (such as an OTA package), it reboots the device to make the updated operating system take effect. The reboot process includes: powering on the electronic device and mounting data (the data partition). The data partition is the storage area for application program APKs. After mounting the data partition, APKs can be scanned and optimized accordingly.

[0066] like Figure 1 As shown, the OTA package installation process for an electronic device consists of two time periods: Time Period 1 and Time Period 2. Time Period 1 is the time for installing the OTA package, and Time Period 2 is the time for compiling applications (such as third-party applications). During Time Period 1, the electronic device can complete the download and installation of the OTA package. During Time Period 2, the electronic device can compile third-party applications, such as compiling hotspot functions corresponding to third-party applications. Third-party applications are applications developed by third parties.

[0067] Exemplarily, during the reboot process after the upgrade, the electronic device displays an interface indicating application optimization, and then performs different optimization processes on the applications in the electronic device according to categories. For example, system applications are processed in a speed-profile mode: the executable file (dex) in the system application is verified, and then the hot function methods listed in the configuration file of the system application are pre-compiled.

[0068] refer to Figure 2 After the OTA package is installed, the electronic device's otapreopt will compile the application and generate the application's odex file. Usually, the reserved time for otapreopt to install the OTA package and compile the application is the first preset time (usually 5 minutes), and the maximum time for otapreopt to install the OTA package and compile the application is the second preset time (usually 10 minutes). Usually, otapreopt's installation of the OTA package and compilation of the application need to be completed within the reserved time. If the electronic device has not completed the compilation of the current application after the reserved time is reached, the file of the uncompiled application will be discarded, which will inevitably affect the installation efficiency of the OTA package.

[0069] In order to increase the number of TOP applications compiled during OTA package installation, the compilation time can be increased to optimize the performance of the electronic device after upgrading and restarting and reduce power consumption. For example, otapreopt increases the number of TOP applications compiled by lengthening the reserved time. However, the extended reserved time will increase the time required to install the OTA package. At the same time, the extended reserved time may also cause otapreopt to reach the maximum time when compiling the last application, causing the electronic device to stop compiling and display a restart interface to instruct the user to restart. At this time, the unfinished compiled file of the last application will be discarded, resulting in a waste of time compiling the last application.

[0070] otapreopt will display the upgrade progress of the OTA package when installing the OTA package and compiling the application. The upgrade progress of the OTA package includes the installation progress of the OTA package and the compilation progress of the application, wherein the installation process of the OTA package precedes the compilation process of the application. In one embodiment of the present application, the installation progress of the OTA package and the compilation progress of the application can be displayed through the upgrade interface. Figure 3 , which is a schematic diagram of the upgrade interface in one embodiment of the present application. otapreopt displays a circular progress bar 802 on the upgrade interface 801. The circular progress bar 802 is used to indicate the upgrade progress information, that is, to indicate the installation progress and compilation progress of the OTA package. Figure 4 , which is a schematic diagram showing an upgrade interface in another embodiment of the present application. otapreopt displays an upgrade interface 803 on the message interface (notification bar) of the electronic device, and a long progress bar 804 is displayed on the upgrade interface 803 to indicate the upgrade progress information.

[0071] To improve the above-mentioned problems, embodiments of the present application provide an installation optimization method that can be applied to electronic devices. Prior to upgrading and restarting, the electronic device can compile applications sequentially, estimate the compilation time of the current application to be compiled, and determine whether the current application needs to be compiled based on the estimated time and the compiled time, thereby optimizing the time consumption of OTA package installation.

[0072] In some embodiments, before upgrading and restarting, the compiled application can be a hot application in the electronic device. It is understandable that the hot application can be an application with a high activity ranking in the electronic device. For example, the activity ranking of the application can be based on the user's usage time and frequency of each application in the electronic device. The activity ranking of the application can also be determined based on the user's personal preferences. In this way, it is possible to meet the user's usage needs for the electronic device before the odex files of all applications are generated.

[0073] For example, the electronic device in the embodiments of the present application may be a portable computer (such as a mobile phone), a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), a media player, etc. The embodiments of the present application do not impose any special restrictions on the specific form of the electronic device.

[0074] Please refer to Figure 5 , Figure 5 A possible hardware structure diagram of an electronic device is shown below:

[0075] like Figure 5As 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, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0076] Among them, the above-mentioned sensor module 180 may include sensors such as pressure sensor, gyroscope sensor, air pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor and bone conduction sensor.

[0077] It should be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0078] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0079] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0080] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0081] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuits sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0082] It is understood that the interface connection relationship between the modules illustrated in this embodiment is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

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

[0084] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLED, or a quantum dot light-emitting diode (QLED).

[0085] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.

[0086] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light passes through the lens to the camera's photosensitive element (image sensor). The light signal is converted into an electrical signal, which is then passed to the ISP for processing and transformed into a visible image. The ISP can also perform algorithmic optimization for image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.

[0087] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. 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, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include N cameras 193, where N is a positive integer greater than 1.

[0088] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0089] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.

[0090] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU enables intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, voice recognition, and text comprehension.

[0091] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to illustrate the software structure of the electronic device.

[0092] Figure 6 It is a software structure block diagram of the electronic device according to an embodiment of the present application.

[0093] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other via software interfaces. In some embodiments, the operating system of an electronic device can be divided into multiple layers: from top to bottom, the application layer, the application framework layer, the Android runtime (ART) and system libraries, and the kernel layer.

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

[0095] like Figure 6 As shown, the application layer can be installed with online update client (OUC), chat application, payment application, music application, video application, game application, browser, etc. Of course, the application layer also includes Figure 6 Applications not shown include, for example, Calls, Memos, Contacts, Camera, Gallery, Calendar, Maps, Bluetooth, etc.

[0096] The OUC is used to obtain the latest upgrade installation package from the server that serves the upgrade installation package.

[0097] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0098] like Figure 6 As shown, the application framework layer can include an update engine, a compilation optimization service module (dexopt service), an OTA upgrade management service (otapreopt service), etc. In addition, it can also include Figure 6 Services and modules not shown in the figure, such as window manager, resource manager, view system, etc.

[0099] Exemplarily, the update engine is used to drive the upgrade of the operating system.

[0100] For example, the compilation optimization service module is used to determine the applications that need to be compiled and the compilation order of the applications. For example, hot applications can be determined as the applications that need to be compiled.

[0101] For example, the OTA upgrade management service is used to manage operating system upgrades. For example, for an electronic device using a virtual A / B operating system, the target operating system to be upgraded can be determined. For example, if the electronic device runs on operating system A, the target operating system to be upgraded is operating system B.

[0102] like Figure 6 As shown, the system library can include multiple functional modules. For example: layer integrator (SurfaceFlinger), media library (Media Libraries), 3D graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL), etc. Surface Flinger is used to manage the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc. The 2D graphics engine is a drawing engine for 2D drawing.

[0103] The Android Runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and management of the Android system. The Android Runtime's virtual machine runs the Dalvik executable file to optimized art file (dex2oat) encoder and the optimization compiler (dexopt) module. Dexopt can be used to convert a dex file containing source code into an odex file containing binary code. For example, dexopt can call dex2oat to translate an application's source code and generate the corresponding odex file based on the dex2oat translation results.

[0104] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0105] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0106] The kernel layer is the layer between hardware and software. The kernel layer includes at least camera driver, audio driver, sensor driver, etc., which are not limited in this embodiment of the application.

[0107] The following describes the implementation details of an installation optimization method provided by an embodiment of the present application in conjunction with the accompanying drawings.

[0108] In some embodiments, a developer can store the compiled upgrade installation package on a server and publish the upgrade installation package through the server. The upgrade installation package is a data package used to upgrade the operating system to the latest version. In some embodiments, the upgrade installation package can be a full upgrade package or an incremental upgrade package, which is not specifically limited in the embodiments of the present application.

[0109] In an embodiment of the present application, in addition to the data used to update the operating system, the upgrade installation package also includes a final installation (PostInstall) file. The PostInstall file may indicate the process to be executed after the upgrade installation package is installed and verified. The PostInstall file may be the last file executed by the update engine in the process of performing an operating system upgrade according to the upgrade installation package. For example, after the upgrade installation package is installed and verified, the PostInstall file is executed to compile part of the application program. For another example, when the electronic device enables the virtual A / B operating system, after the upgrade installation package is installed and verified, the PostInstall file is executed to compile part of the application program in the target operating system, and the electronic device is instructed to activate the target operating system, wherein the target operating system is the upgraded operating system in the A / B operating system.

[0110] In some embodiments, the electronic device obtains the upgrade installation package and can upgrade the operating system of the electronic device based on the upgrade installation package. Figure 7 , shown is a flow chart of the installation optimization method in one embodiment of the present application. Figure 7 The method of the example includes one or more steps, but does not constitute a limitation of the present application. In addition, the order of the steps of the method is only for example, and the order of the steps can be changed. Additional steps can be added or steps can be reduced without departing from the content disclosed in the application. The method specifically includes the following steps.

[0111] As an implementation method, the above process of obtaining the upgrade installation package and installing the upgrade installation package can be referred to Figure 7 S701~S705 in.

[0112] S701: The OUC in the electronic device searches for and downloads an upgrade installation package from a server.

[0113] In one embodiment of the present application, the electronic device can periodically initiate a package search request to the server through the OUC. The package search request includes the version number of the operating system currently running on the electronic device (for example, version 1.1, which is an old version). The server searches for an upgrade installation package with a newer version number (for example, version 1.2, which is a newer version) based on the operating system version number in the package search request. When an upgrade installation package with a newer version number exists, the server feeds back the download address of the upgrade installation package (for example, a full upgrade installation package of version 1.2) to the electronic device. The electronic device downloads the upgrade installation package according to the download address.

[0114] In another embodiment of the present application, the server may also proactively push the new version of the upgrade installation package to the electronic device after obtaining it.

[0115] In some embodiments, after the electronic device obtains the upgrade installation package, it has the ability to upgrade the operating system.

[0116] In the embodiments of this application, Figure 1 As shown, upgrading the operating system of an electronic device can include two phases. In the first phase (time period 1), the electronic device can install and verify the upgrade installation package. In the second phase (time period 2), the electronic device can sequentially perform AOT compilation on a first number of applications according to the PostInstall file in the upgrade installation package to generate corresponding odex files.

[0117] As an implementation method, the OUC can download and save the upgrade installation package to the user data partition (Userdata). Afterwards, the OUC instructs the update engine to start, and the update engine performs the first stage of upgrading the operating system, as shown in S702 to S704.

[0118] S702: OUC instructs the update engine to start upgrading the operating system.

[0119] As an implementation method, the OUC can set the update engine's startup attribute by sending an upgrade instruction to the update engine, for example, setting its corresponding startup attribute to true. In addition, a service manager, a service resident in the operating system background of the electronic device, monitors the update engine's startup attribute. When the service manager detects that the update engine's startup attribute is true, it starts the update engine.

[0120] The OUC then obtains the update engine's status through binder communication. After the OUC confirms the update engine has successfully started, it passes upgrade parameters to the update engine (for example, these parameters may indicate whether the current upgrade operation is a file update or a file write operation), triggering the update engine to begin the upgrade process. A file write operation typically involves writing data from memory to a persistent storage device (such as a hard drive).

[0121] S703, the update engine is installed according to the upgrade installation package and instructs the OUC to display the upgrade interface.

[0122] In some embodiments, the update engine can verify whether the upgrade package is a legitimate upgrade package by verifying whether the META-INF (i.e., the digital signature) in the upgrade package is valid. If the META-INF in the upgrade package is valid, the update engine can confirm that the upgrade package is a legitimate upgrade package.

[0123] After confirming that the upgrade package has passed verification, the update engine can parse the upgrade package to obtain the upgrade data used to update the operating system. The update engine can then write the upgrade data to the operating system's corresponding storage partition in the memory (static partition or dynamic partition, etc.).

[0124] Taking the upgrade of an electronic device that enables a virtual A / B operating system and runs on an A operating system as an example, the implementation of the above S703 is as follows: Figure 8 The method flow shown.

[0125] S801, the update engine reads the saved upgrade installation package from the user data partition (User data), and writes the upgrade data for the static partition in the upgrade installation package into the static partition (B), so as to upgrade the static partition.

[0126] For example, if a system upgrade package contains data for the static partition of version 1.2, that is, upgrade data for the static partition, the update engine parses the upgrade package and overwrites the static partition data (that is, the data for the static partition of version 1.2) in the upgrade package to the static partition (B).

[0127] S802: The update engine creates a virtual dynamic partition in the user data partition (User data), and writes the data for the dynamic partition in the upgrade data into the virtual dynamic partition.

[0128] For example, the upgrade installation package includes data of the dynamic partition of version 1.2. After the data of the dynamic partition of version 1.2 is parsed from the upgrade installation package, the data of the dynamic partition of version 1.2 (Super) is written into the virtual dynamic partition.

[0129] S704, the OUC obtains the installation progress information of the OTA package and displays the upgrade progress information on the upgrade interface.

[0130] refer to Figure 9 The figure is a schematic diagram of the upgrade interface in one embodiment of the present application. The OUC displays a circular progress bar 802 on the upgrade interface 801, and indicates the upgrade progress information through the circular progress bar 802. The upgrade progress information may include graphics, text and other information, for example, Figure 8 As shown, the progress ratio is displayed in a preset graphic, for example, 10%, 20%. In one embodiment of the present application, after executing S803, that is, after the installation package is installed, the circular progress bar 8022 of the upgrade interface 801 displays a first ratio, for example, the first ratio is 80%.

[0131] S705: The update engine performs verification after the upgrade.

[0132] In some embodiments, after installing the upgrade package, the update engine verifies whether the upgraded B operating system (data in static partition B and virtual dynamic partition) is valid. If valid, the update engine determines that the installation and verification are complete and executes the PostInstall file in the upgrade installation package.

[0133] Subsequently, the second stage of the operating system upgrade begins. In this second stage, the electronic device can optimize and compile the first number of applications to obtain corresponding odex files. For example, after installing the upgrade installation package, the electronic device can optimize and compile the applications. For example, after executing S701-S704 above, if the upgrade passes the post-upgrade verification, the optimized compilation of the applications can be performed. For another example, after executing S701-S705, if the upgrade data has been written to the first storage partition (e.g., to the static partition (B) and the virtual dynamic partition), the optimized compilation of the applications can be performed.

[0134] As an implementation method, the process of optimizing compilation can be referred to Figure 7 S706~S714 in:

[0135] S706 , the update engine instructs ART to compile a first number of application programs.

[0136] In some embodiments, a first number may be configured in the PostInstall file. Thus, the update engine may instruct ART to compile the first number of applications through the compiler. For example, the first number may be configured as 5 in the PostInstall file. When the update engine executes the PostInstall file, it may instruct ART to compile 5 applications in the electronic device through the compiler. Exemplarily, the first number may be less than the total number of applications in the electronic device.

[0137] When an electronic device uses a virtual A / B operating system, the target operating system's ART can be used to optimize and compile applications. The resulting odex file is generated based on the target operating system's BootClassPath. After this optimized compilation, once the electronic device switches from running the original operating system to running the target operating system, the compiled application can be executed using machine code.

[0138] It can be understood that when an electronic device runs on operating system A (the original operating system, or the first operating system), when upgrading operating system B (the target operating system, or the second operating system), only the data in the storage partition corresponding to operating system B (such as the first storage partition) is updated. For example, the first storage partition includes the static partition of operating system B, as well as the virtual dynamic partition created for operating system B, etc.

[0139] The above update will not affect the system data corresponding to operating system A. In this way, before the electronic device activates operating system B, the BootClassPath in operating system A remains unchanged, and the odex files compiled based on operating system A before the upgrade remain valid. While running operating system A, the electronic device can run applications in the same way as machine code execution.

[0140] After the data in the first storage partition of the B operating system is updated, the BootClassPath in the B operating system changes. In order to ensure that the first number of applications in the B operating system can be executed using machine code after switching to enable the B operating system, the odex files of the first number of applications can be compiled in the B operating system before switching to the B operating system, and the odex files compiled in the B operating system are assigned a target identifier. The target identifier is used to distinguish it from the original odex file of the application (the odex file compiled based on the A operating system), so as to avoid the electronic device from mistakenly loading the odex file compiled based on the B operating system during the operation of the A operating system, resulting in a failure of machine code execution.

[0141] For example, if the target operating system is operating system B, the file name of the odex file compiled in the ART of operating system B can carry the identifier of operating system B, for example, the suffix of the file name includes "b", which serves as the corresponding target identifier. In addition, the above is only an example of target identifier and does not limit the target identifier.

[0142] In other embodiments, the PostInstall file may be configured with a first duration, so that the update engine may instruct ART to compile the applications sequentially through the compiler within the first duration. It is understandable that the number of applications actually compiled within the first duration is the first number. For example, the first duration may be configured as 3 minutes in the PostInstall file, and the update engine executing the PostInstall file may instruct ART to compile the applications sequentially through the compiler, and stop compiling after the compilation time reaches 3 minutes. In this example, if 5 applications are compiled within 3 minutes, the corresponding first number is 5.

[0143] In some embodiments, ART can compile the applications one by one during the process of compiling the first number of applications. During the compilation process, the hotspot functions recorded in the configuration file of the application can be obtained, and then the source code of the hotspot functions can be translated into binary code, and a corresponding odex file can be generated. It can be understood that the hotspot functions are related to the activity level (or call frequency) of each function in the source code, and are related to the user's habit of using the application and the operating rules of the application. In the process of using the application on the electronic device, the hotspot functions in the configuration file can also be updated according to the activity level of the function.

[0144] In some embodiments, the compiled application program may be the first application in the electronic device that meets the first condition.

[0145] The first condition may include one or more of the following:

[0146] (1) The first application is the application ranked in the top N in terms of activity level among the applications in the electronic device, where N is a positive integer. For example, if N is 5, the first application may be the application ranked in the top 5 in terms of activity level in the electronic device. The activity level is the activity level of the application evaluated based on the application operation records (foreground operation, background operation, etc.) and the application download volume.

[0147] It is understandable that the activity level of each application in the electronic device can be evaluated based on information such as user usage habits (indicated by application operation records), application download volume, etc. For example, the user's application operation records for each application can be obtained to evaluate a first score indicating usage habits. Then, the application download volume is quantified into a second score. Based on the first score and the second score, an activity score is fitted based on the weights corresponding to the user's usage habits and the application download volume. Then, the activity levels are divided according to the activity scores. The higher the activity score, the higher the corresponding activity level, and the lower the activity score, the lower the corresponding activity level. Arrange from high to low according to the activity level, and the applications arranged in front are more popular than the applications arranged in the back.

[0148] (2) The first application belongs to a first set, which is a set of application programs that provide a specified type of service.

[0149] For example, the first set (also referred to as an application set) includes multiple applications, each of which is a preselected type of application. A preselected type of application is an application that can provide a specified application service. Furthermore, one or more preselected types may be set, and this is not specifically limited in this embodiment of the present application.

[0150] For example, the pre-selected type of application is an application that provides communication services (such as an instant messaging application), and the electronic device may have installed chat applications, payment applications, transportation card applications, short message applications, video applications, work communication applications, etc. In this scenario, the application set (first set) may be a set consisting of chat applications, short message applications, work communication applications, etc.

[0151] Exemplarily, the process of ART compiling the first number of applications may include: randomly selecting the first number of applications to be compiled from the application collection, and then sequentially optimizing and compiling the applications to be compiled. Furthermore, illustratively, the process of ART compiling the first number of applications may include: randomly selecting one application from the application collection for optimization compilation, and after completing optimization compilation for the one application, randomly selecting another non-optimized application from the application collection, and continuing to optimize and compile the application until a termination condition is met. The termination condition may be that the total time taken for ART to compile the applications reaches a preset time.

[0152] Exemplarily, the process of ART compiling the first number of applications may also include: sorting the applications in the electronic device according to the activity level, selecting the first number of applications from the applications ranked in the top N in terms of activity as applications to be compiled, and performing optimized compilation. Wherein, N is a positive integer, or a natural number greater than 1. As another example, the process of ART compiling the first number of applications may also be: sorting the applications in the electronic device according to the activity level, selecting the application ranked first for optimized compilation, and completing the optimized compilation for one application. Then, according to the activity level, from high to low, rearrange the applications that have not been optimized and compiled, select the application ranked first in terms of activity level to continue to perform optimized compilation, and repeat the above process until the termination condition is met. Wherein, the termination condition may be that the total time for ART to optimize and compile the application reaches the reserved time.

[0153] S707 , ART estimates the compilation time of the application to be compiled, and records the total compilation time of the compiled application.

[0154] It should be noted that the installation process of the OTA package of the present application is performed in an older version of the operating system. The electronic device stores odex files of various applications compiled under the older version of the operating system. In one embodiment of the present application, ART obtains the odex file size of the Nth application to be compiled and the odex file size of the N+1th application from the odex files stored in the electronic device. For example, when N=1, the Nth application is the Top1 application, and the N+1th application is the Top2 application. When compiling the first application (such as the Top1 application), ART uses the preset compilation rate as the compilation rate of the Nth application and the N+1th application, estimates the compilation time estimate of the Nth application based on the odex file size of the Nth application and the compilation rate of the Nth application, and estimates the compilation time estimate of the N+1th application based on the odex file size of the N+1th application and the compilation rate of the N+1th application. For example, the odex file size of the Nth application can be divided by the compilation rate of the Nth application to obtain the compilation time estimate of the Nth application. Similarly, the odex file size of the N+1th application can be divided by the compilation rate of the N+1th application to obtain the compilation time estimate of the Nth application.

[0155] When N is greater than 1, the Nth application is not the first application compiled. The compilation rate of the N-1th application is calculated based on the odex file and compilation time of the N-1th application that has been compiled before it. The compilation rate of the N-1th application that has been compiled before it is used as the compilation rate of the Nth application. The estimated compilation time of the Nth application is then determined based on the odex file size of the Nth application and the compilation rate of the N-1th application. For example, when ART compiles the next application after the Top1 application (i.e., the Top2 application), the compilation rate of the Top1 application is calculated based on the odex file of the Top1 application that has been compiled before it and the compilation time of the Top1 application. The compilation rate of the Top1 application is used as the compilation rate of the Top2 application to be compiled. The estimated compilation time of the Top2 application is then divided by the odex file size of the Top2 application and the compilation rate of the Top1 application.

[0156] At step S708, ART determines whether the application to be compiled meets the compilation conditions based on the estimated compilation time of the application to be compiled and the total compilation time of the compiled applications. In one embodiment of the present application, if it is determined that the application to be compiled meets the compilation conditions, step S709 is executed; if it is determined that the application to be compiled does not meet the compilation conditions, step S711 is executed.

[0157] In one embodiment of the present application, ART sums the estimated compile time of the Nth application, the estimated compile time of the N+1th application, and the total compile time of the compiled applications to obtain a total compile time, and determines whether the total compile time is greater than or equal to a reserved time (e.g., 5 minutes). If the total compile time is less than the reserved time, the Nth application is determined to meet the preset conditions; if the total compile time is greater than or equal to the reserved time, the Nth application is determined to not meet the preset conditions.

[0158] In one embodiment of the present application, in order to increase the number of applications that an electronic device completes compilation within the reserved duration, when compiling the Nth application, if the total duration has reached the reserved duration, but the Nth application has not yet completed compilation, ART may allow the Nth application to continue compiling. In one embodiment of the present application, ART extends the reserved duration by a preset duration, and determines whether the total duration is greater than or equal to the extended reserved duration. If the total duration is less than the extended reserved duration, it is determined that the first application meets the preset conditions; if the total duration is greater than or equal to the extended reserved duration, it is determined that the first application does not meet the preset conditions. In one embodiment of the present application, the extended reserved duration is less than the limit duration (for example, 10 minutes).

[0159] S709, ART compiles the applications to be compiled in sequence, and instructs OUC to update the upgrade progress information on the upgrade interface, and obtains the compile time of the applications to be compiled, and updates the total compile time according to the obtained compile time.

[0160] In one embodiment of the present application, after the OTA package is installed, ART compiles the applications to be compiled in order from the top 1 application according to the activity level of the applications within the reserved time.

[0161] In one embodiment of the present application, when ART compiles an application to be compiled, the upgrade engine instructs the OUC to update the upgrade progress information on the upgrade interface and to perform timing. When the compilation of the application to be compiled is completed, the compilation time of the application to be compiled is obtained, and the obtained compilation time is summed with the total compilation time, and the sum is used as the new total compilation time.

[0162] S710: The OUC obtains the compilation progress of the application to be compiled, and updates the upgrade progress information according to the compilation progress.

[0163] In one embodiment of the present application, after the OTA package is installed, the upgrade progress information displayed on the upgrade interface by the OUC is a first proportion (e.g., 80%). The upgrade progress information after the first proportion on the upgrade interface (e.g., 85%, 90%, 100%) is used to indicate the compilation progress information of the application.

[0164] refer to Figure 10 The figure shows a flow chart of the OUC updating upgrade progress information in one embodiment of the present application. The OUC first launches the upgrade compilation script file hn_otapreopt_script.sh to perform compilation preprocessing. When compiling the application to be compiled, the OUC prints compilation progress information through the update_progress() function at preset intervals (e.g., 5 seconds) and obtains the compilation time from the compilation progress information. The compilation time is divided by the reserved duration, and the result of the division is multiplied by the remaining progress to obtain the compilation progress. The compilation progress is added to the first ratio to obtain the upgrade progress, wherein the percentage ratio can be subtracted from the first ratio to obtain the remaining progress. The upgrade progress information corresponding to the upgrade progress is displayed on the upgrade interface.

[0165] The following example illustrates this. If the first ratio is 80%, then based on the difference between the percentage ratio and 80%, the remaining progress is 20%. If OUC prints the compilation progress of the application through the update_progress() function after an interval of 5 seconds, and the compilation time obtained from the compilation progress is 1 minute, then the compilation time of 1 minute is divided by the reserved time of 5 minutes, and the result of the division is multiplied by the remaining progress of 20%, resulting in a compilation progress of 4%. After adding 4% to 80%, the upgrade progress is 84%. For reference, Figure 11 , the upgrade progress information with a value of 84% is displayed on the upgrade interface.

[0166] S711, ART instructs the OUC to set the upgrade progress information to a preset value on the upgrade interface, finish the compilation of the application to be compiled, and notify the upgrade engine to restart.

[0167] In one embodiment of the present application, if it is determined that the application to be compiled does not meet the compilation conditions, ART instructs OUC through the upgrade engine to set the upgrade progress information on the upgrade interface to a preset value, such as 100%, to end the compilation of the application to be compiled, and notify the update engine to restart.

[0168] S712, the OUC sets the upgrade progress information to a preset value on the upgrade interface.

[0169] In one embodiment of the present application, reference Figure 12 , OUC sets the upgrade progress information on the upgrade interface to 100% according to the instruction information sent by ART to indicate to the user that the operating system corresponding to the OTA package has been updated.

[0170] S713: The update engine instructs the OUC to trigger a device restart.

[0171] S714, the OUC displays a pop-up window on the upgrade interface and receives a restart operation input by the user in the pop-up window to restart the electronic device.

[0172] refer to Figure 13 , which shows a schematic diagram of a pop-up window in one embodiment of the present application. Pop-up window 20 includes a restart control 201. The OUC receives a user click on restart control 201 and controls the electronic device to restart. In one embodiment of the present application, controlling the electronic device to restart includes: exiting the current old version of the operating system (e.g., operating system A), powering off the device, powering on the device again, and launching a new version of the operating system (e.g., operating system B).

[0173] In an embodiment of the present application, if it is determined that the application to be compiled does not meet the compilation conditions, ART terminates the compilation of the application to be compiled. When the upgrade progress information does not display 100%, ART will instruct OUC to set the upgrade progress information to 100% on the upgrade interface according to ART's instructions, and notify OUC to trigger a device restart. This can avoid notifying the user to restart the electronic device when the upgrade progress information does not display 100% (such as displaying 95%), which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, when the present application determines that the application to be compiled does not meet the compilation conditions, it notifies OUC to trigger a device restart, avoiding the compilation time of the application exceeding the maximum time limit, resulting in the failure of the application compilation.

[0174] In S707 and S708 of the above-described embodiment, when ART compiles an application, it determines whether the application to be compiled meets the compilation conditions based on the compilation time estimates of the two applications to be compiled (i.e., the compilation time estimates of the Nth application and the N+1th application), the total compilation time of the compiled applications, and the reserved time. In other embodiments of the present application, it is also possible to determine whether the application to be compiled meets the compilation conditions based on the compilation time estimate of one application to be compiled (e.g., the compilation time estimate of the Nth application), the total compilation time of the compiled applications, and the reserved time. For example, ART sums the compilation time estimate of the Nth application and the total compilation time of the compiled applications to obtain a total time, and determines whether the total time is greater than or equal to the reserved time or the extended reserved time. If the total time is greater than or equal to the reserved time or the extended reserved time, it is determined that the application to be compiled does not meet the compilation conditions; if the total time is less than the reserved time or the extended reserved time, it is determined that the application to be compiled meets the compilation conditions.

[0175] refer to Figure 14 , which is a flow chart of a method for compiling an application in another embodiment of the present application. The method includes the following steps.

[0176] S1401: ART instructs the OUC to update upgrade progress information based on the first ratio and the reserved time.

[0177] In one embodiment of the present application, after the installation of the OTA package is completed, the OUC updates the upgrade progress information based on the first ratio and the reserved time according to the instruction of the ART. In one embodiment of the present application, the OUC displays the first ratio on the upgrade interface, calculates the difference between the percentage ratio and the first ratio to obtain the remaining progress, divides the remaining progress by the reserved time to obtain the progress update rate, and updates the upgrade progress information according to the progress update rate. An example is as follows: Figure 15The first ratio is 80%, and the reserved duration is 5 minutes. The OUC calculates the difference between the first ratio (80%) and the percentage, resulting in a remaining progress of 20%. The remaining progress of 20% is divided by the reserved duration of 5 minutes to obtain a progress update rate of 4% / minute. The OUC updates the upgrade progress information at this progress update rate. Based on the progress update rate, the OUC updates the upgrade progress at preset intervals (for example, 15 seconds).

[0178] S1402, obtaining the odex file size of the Nth application to be compiled and the odex file size of the N+1th application.

[0179] In one embodiment of the present application, ART compiles the applications sequentially starting from the top 1 application according to the activity level of the applications within the reserved time. In one embodiment of the present application, ART obtains the odex file size of the Nth application and the odex file size of the N+1th application from the odex file stored in the electronic device.

[0180] S1403: Determine whether the odex file size of the Nth application is greater than or equal to a first threshold, where the first threshold is 2% of the APK file size of the Nth application. If the odex file size of the Nth application is less than the first threshold, execute S1404; if the odex file size of the Nth application is greater than or equal to the first threshold, execute S1405.

[0181] S1404: Estimate the size of the odex file of the first application program based on the total number of hotspot functions recorded in the configuration file of the Nth application program.

[0182] In one embodiment of the present application, if the odex file size of the Nth application is less than a first threshold, it indicates that the Nth application is a newly installed application or an application with a newly updated APK. The original configuration file and odex file recording the hotspot functions are invalidated and deleted. When the Nth application is updated or a new version is installed, the application market will only send a configuration file containing only the hotspot functions for the startup scenario, resulting in a relatively small odex file compiled by the Nth application during installation. Therefore, the Nth application needs to be used for a period of time and then re-collect the hotspot functions and record them in the configuration file. In one embodiment of the present application, functions that are used more than a preset number of times (for example, 40,000 times) can be used as hotspot functions.

[0183] In an embodiment of the present application, when the odex file size of the Nth application is less than a first threshold, ART may use the file size occupied by all hotspot functions recorded in the configuration file of the Nth application as the size of the odex file of the Nth application.

[0184] S1405: Determine whether the odex file size of the N+1th application is greater than or equal to a second threshold, where the second threshold is 2% of the APK file size of the N+1th application. If the odex file size of the N+1th application is less than the second threshold, execute S1406; if the odex file size of the N+1th application is greater than or equal to the second threshold, execute S1407.

[0185] S1406 , estimating the size of the odex file of the N+1th application program based on the total number of hotspot functions recorded in the configuration file of the N+1th application program.

[0186] In one embodiment of the present application, ART uses the file size occupied by all hotspot functions recorded in the configuration file of the N+1th application as the size of the odex file of the N+1th application.

[0187] S1407: Set the compilation rate of the Nth application and the compilation rate of the N+1th application.

[0188] In one embodiment of the present application, when N=1, that is, when the Nth application is the first application to be compiled, ART uses the preset compilation rate as the compilation rate for the Nth application and the N+1th application. When N is greater than 1, that is, when the Nth application is not the first application to be compiled, ART uses the compilation rate of the N-1th application as the compilation rate for the Nth application, and uses the compilation rate of the Nth application as the compilation rate for the N-1th application. In some embodiments, the rate at which the electronic device background compiles applications is substantially fixed, and the rate at which the electronic device background compiles applications can be used as the preset compilation rate.

[0189] S1408, determine the estimated compilation time T1 of the Nth application based on the odex file size and compilation rate of the Nth application, and determine the estimated compilation time T2 of the N+1th application based on the odex file size and compilation rate of the N+1th application.

[0190] In one embodiment of the present application, ART divides the odex file size of the Nth application by the compilation rate of the Nth application to obtain the compilation time estimate T1 of the Nth application, and divides the odex file size of the N+1th application to be compiled by the compilation rate of the N+1th application to obtain the compilation time estimate T2 of the N+1th application.

[0191] S1409 , summing the estimated compile time of the Nth application, the estimated compile time of the N+1th application, and the total compile time of compiled applications to obtain a first total time.

[0192] In one embodiment of the present application, when the top 1 application is used as the Nth application, the total compile time of the compiled applications is zero; when a non-top 1 application is used as the Nth application, the total compile time of the compiled applications is the sum of the compile times of all applications before the Nth application. ART sums the estimated compile time of the Nth application, the estimated compile time of the N+1th application, and the total compile time of the compiled applications to obtain the first total time.

[0193] S1410: Determine whether the first total duration is less than the reserved duration. If the first total duration is less than the reserved duration, execute S1411. If the first total duration is greater than or equal to the reserved duration, execute S1412.

[0194] In one embodiment of the present application, if the total duration is less than the reserved duration, it means that ART can still compile the N+1th application when the reserved duration expires. If the first total duration is greater than or equal to the reserved duration, it means that ART cannot compile the N+1th application when the reserved duration expires.

[0195] S1411, compile the Nth application, record the compile time and the odex file size of the Nth application when the compilation is completed, and update the total compile time according to the recorded compile time. Then, after S1411 is completed, continue to execute S1402.

[0196] In one embodiment of the present application, ART sums the recorded compilation time with the total compilation time, and uses the sum as the new total compilation time to update the total compilation time.

[0197] At step S1412, the estimated compilation time of the Nth application is summed with the total compilation time of the compiled applications to obtain a second total compilation time, and a determination is made as to whether the second total compilation time is greater than the reserved compilation time. If the second total compilation time is less than or equal to the reserved compilation time, step S1413 is executed; if the second total compilation time is greater than the reserved compilation time, step S1417 is executed.

[0198] S1413: Subtract the first total duration from the first preset duration to obtain a third total duration, and determine whether the third total duration is greater than the reserved duration. If the third total duration is greater than the reserved duration, execute S1414. If the third total duration is less than or equal to the reserved duration, execute S1411.

[0199] In one embodiment of the present application, the first preset duration is less than the difference between the limit duration (e.g., 10 minutes) and the reserved duration, for example, the first preset duration is 10 seconds. In one embodiment of the present application, the third total duration being greater than the reserved duration indicates that ART cannot compile the N+1th application when the reserved duration expires.

[0200] S1414 , taking the Nth application as the last application to be compiled, sending the estimated compilation time T1 of the Nth application to the OUC, and instructing the OUC to update the upgrade progress information based on the estimated compilation time T1.

[0201] In one embodiment of the present application, OUC calculates the difference between the percentage and the currently displayed upgrade progress to obtain the remaining progress, divides the remaining progress by the estimated compilation time T1 of the application to be compiled to obtain the progress update rate, and updates the upgrade progress information according to the progress update rate. Figure 15 The currently displayed upgrade progress is 95%, and the estimated compilation time T1 of the Nth application is 1 minute. OUC calculates the difference between the percentage and 95% to obtain a remaining progress value of 5%. The remaining progress value of 5% is divided by the reserved time value of 1 minute to obtain a progress update rate of 5% / minute. The upgrade progress information is updated according to the progress update rate of 5% / minute.

[0202] S1415: Compile the Nth application program.

[0203] Compiling an application to be compiled using ART is a well-known technical means in the art and will not be described in detail here.

[0204] S1416 , ending the compilation, instructing the OUC to set the upgrade progress information to a preset value, and instructing the OUC to display a pop-up window to remind the user to restart.

[0205] In one embodiment of the present application, the OUC sets the upgrade progress information to 100% on the upgrade interface according to the instructions sent by the ART to indicate to the user that the operating system corresponding to the OTA package has been updated; and displays a pop-up window and receives the restart operation entered by the user in the pop-up window to restart the electronic device.

[0206] S1417: Determine whether the second total duration is greater than the limit duration. If the second total duration is greater than the limit duration, execute S1416; if the second total duration is less than or equal to the limit duration, execute S1418.

[0207] S1418: Subtract the second total duration from the second preset duration to obtain a fourth total duration, and determine whether the fourth total duration is less than or equal to the reserved duration. If the fourth total duration is less than or equal to the reserved duration, execute S1414; if the fourth total duration is greater than the reserved duration, execute S1416.

[0208] In one embodiment of the present application, the second preset duration is smaller than the difference between the limit duration and the reserved duration. For example, the second preset duration may be set to 10s.

[0209] In one embodiment of the present application, the method also includes: obtaining the compilation time of the application to be compiled starting from the ART compilation application, if the compilation time reaches the limit time, ending the compilation of the application to be compiled, setting the upgrade progress information to a preset value, and displaying a pop-up window on the upgrade interface to remind the user to restart.

[0210] In an embodiment of the present application, the electronic device can estimate the compilation time of the current application to be compiled before the upgrade and restart. When it is determined based on the estimated time and the compiled time that the application to be compiled does not meet the compilation conditions, ART ends the compilation of the application to be compiled. When the upgrade progress information does not display 100%, ART will instruct OUC to set the upgrade progress information to 100% on the upgrade interface according to ART's instructions, and notify OUC to trigger the device restart. This can avoid notifying the user to restart the electronic device when the upgrade progress information does not display 100%, which may easily cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience. At the same time, when the present application determines that the application to be compiled does not meet the compilation conditions, it notifies OUC to trigger the device restart, avoiding the compilation time of the application exceeding the limit, resulting in the failure of the application compilation.

[0211] An embodiment of the present application further provides an electronic device, which may include: a memory and one or more processors. The memory and processor are coupled. The memory is used to store computer program code, which includes computer instructions. When the processor executes the computer instructions, the electronic device performs the various steps performed by the electronic device in the above embodiment. Of course, the electronic device includes but is not limited to the above memory and one or more processors.

[0212] The present application also provides a chip system that can be applied to the electronic device in the aforementioned embodiment. The chip system includes at least one processor and at least one interface circuit. The processor can be the processor in the aforementioned electronic device. The processor and the interface circuit can be interconnected via a line. The processor can receive and execute computer instructions from the memory of the aforementioned electronic device via the interface circuit. When the computer instructions are executed by the processor, the electronic device can perform the various steps in the aforementioned embodiment. Of course, the chip system can also include other discrete components, which are not specifically limited in the present application.

[0213] In some embodiments, through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of description, 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. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.

[0214] The functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0215] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk, and other media that can store program code.

[0216] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present invention should be included in the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.

Claims

1. An installation optimization method, applied to electronic equipment, characterized in that: The method comprises: Start the operating system upgrade according to the upgrade installation package; Displaying the upgrade progress information on the upgrade interface according to the installation progress information of the upgrade installation package; Obtain the odex file size of the Nth application to be compiled and the odex file size of the N+1th application, where N is a natural number greater than or equal to 1; If the odex file size of the Nth application is smaller than a first preset value of the APK file of the Nth application, estimating the size of the odex file of the Nth application according to the total number of hotspot functions recorded in the configuration file of the Nth application; If the Nth application is the first compiled application, the compilation rate of the Nth application and the N+1th application is set to the preset compilation rate; if the Nth application is not the first compiled application, the compilation rate of the compiled N-1th application is used as the compilation rate of the Nth application; Determining an estimated compile time of the Nth application based on the odex file size of the Nth application and the compile rate of the Nth application; and determining an estimated compile time of the N+1th application based on the odex file size of the N+1th application and the compile rate of the N+1th application; Determining a first total duration based on the estimated compile duration of the Nth application, the estimated compile duration of the N+1th application, and the total compile duration of compiled applications; if the first total duration is less than the reserved duration, determining that the Nth application to be compiled meets the compilation condition, and compiling the Nth application to be compiled; If the first total duration is greater than or equal to the reserved duration, it is determined that the Nth application to be compiled does not meet the compilation condition, and the compilation duration estimate of the Nth application is summed with the total compilation duration of the compiled applications to obtain a second total duration. If the second total duration is less than or equal to the reserved duration, the first total duration is subtracted from the first preset duration to obtain a third total duration. If the third total duration is greater than the reserved duration, the Nth application is compiled as the last application to be compiled, and the difference between the percentage ratio and the currently displayed upgrade progress is calculated to obtain the remaining progress. The remaining progress is divided by the compilation duration estimate of the Nth application to obtain a progress update rate. The upgrade progress information is updated according to the progress update rate, and when the Nth application completes compilation, the preset upgrade progress information is displayed on the upgrade interface; and the electronic device is restarted.

2. The installation optimization method according to claim 1, wherein: If N is greater than 1, the estimated compilation time of the Nth application includes: Obtaining the file size and compilation time of the N-1th application, and calculating the compilation rate of the N-1th application, where the N-1th application is a compiled application; An estimated compilation time of the Nth application is estimated based on the compilation rate of the N-1th application.

3. The installation optimization method according to claim 1, wherein: If N is greater than 1, the estimated compilation time of the N+1th application includes: Obtaining a file size and a compilation time of an Nth application, and calculating a compilation rate of the Nth application, where the Nth application is a compiled application; Based on the compilation rate of the Nth application, an estimated compilation time of the N+1th application is estimated.

4. The installation optimization method according to claim 1, wherein: Compiling the Nth application as the last application to be compiled includes: Determining a second total compile time based on the estimated compile time of the Nth application and the total compile time of the compiled applications; If the second total duration is less than or equal to the reserved duration, determining a third total duration based on the first total duration and the first preset duration; If the third total duration is greater than or equal to the reserved duration, the Nth application is compiled as the last application to be compiled.

5. The installation optimization method according to claim 4, characterized in that: The method further comprises: If the third total duration is less than the reserved duration, the Nth application is compiled, and the file size and compilation duration of the Nth application after compilation are recorded.

6. The installation optimization method according to claim 4, characterized in that: When the Nth application is compiled, displaying preset upgrade progress information on the upgrade interface further includes: If the second total duration is greater than the reserved duration, determining whether the second total duration is greater than a limit time; If the second total time is greater than the limit time, the compilation of the Nth application is terminated, the upgrade progress information is set to a preset value, and a pop-up window is displayed on the upgrade interface to remind the user to restart.

7. The installation optimization method according to claim 4, characterized in that: When the Nth application is compiled, displaying preset upgrade progress information on the upgrade interface includes: If the second total duration is less than or equal to the limit time, determining a fourth total duration based on the second total duration and the second preset duration; If the fourth total duration is greater than the reserved duration, the compilation of the Nth application is terminated, the upgrade progress information is set to a preset value, and a pop-up window is displayed on the upgrade interface to remind the user to restart.

8. The installation optimization method according to claim 7, wherein: The method further comprises: If the fourth total duration is less than or equal to the reserved duration, compile the Nth application as the last application to be compiled, and update the upgrade progress information based on the estimated compilation duration of the Nth application.

9. The installation optimization method according to claim 1, wherein: Restarting the electronic device includes: Exit the operating system and cut off the power supply of the device; Turn on the device power again and start the operating system corresponding to the version of the upgrade installation package.

10. The installation optimization method according to claim 1, wherein: Restarting the electronic device includes: Displaying a pop-up window on the upgrade interface, wherein the pop-up window includes a restart control for restarting the electronic device; In response to a user's operation on the restart control, the electronic device is controlled to restart.

11. The installation optimization method according to claim 1, wherein: The method further comprises: Obtain the compilation time for compiling the application to be compiled. If the compilation time reaches a limit, terminate the compilation of the application to be compiled, set the upgrade progress information to a preset value, and display a pop-up window on the upgrade interface to remind the user to restart.

12. An electronic device, characterized in that: The electronic device comprises a memory and a processor: The memory is used to store program instructions; The processor is configured to read and execute the program instructions stored in the memory. When the program instructions are executed by the processor, the electronic device executes the installation optimization method according to any one of claims 1 to 11.

13. A computer storage medium, characterized in that The computer storage medium stores program instructions, and when the program instructions are executed on an electronic device, the electronic device executes the installation optimization method according to any one of claims 1 to 11.

14. A computer program product comprising computer program instructions, characterized in that When the computer program instructions are executed by a processor, the installation optimization method according to any one of claims 1 to 11 is implemented.

Citation Information

Patent Citations

  • Data processing system, data processing method and electronic equipment

    CN114661321A

  • Application program optimization method and electronic equipment

    CN116643778A