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

By estimating and judging the application compilation time, the compilation failure problem caused by odex file failure during electronic device system upgrades is solved, and the installation efficiency and user experience of the installation package are improved.

CN118519645AActive Publication Date: 2024-08-20HONOR DEVICE CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

During the system upgrade process of electronic equipment, the old odex file becomes invalid due to changes in the system boot path, causing application compilation to fail and affecting the installation efficiency of the installation package.

Method used

By estimating the compilation time of the application to be compiled, it is determined whether the compilation conditions are met, and the progress information is updated on the upgrade interface to avoid installation package discarding and user misunderstanding of upgrade failure caused by incomplete compilation.

Benefits of technology

It improves the installation efficiency of installation packages, avoids user misunderstandings and application compilation failures, and ensures the accuracy of upgrade progress information and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118519645A_ABST
    Figure CN118519645A_ABST
Patent Text Reader

Abstract

The invention relates to an installation optimization method, electronic equipment, a storage medium and a computer program product. The method is applied to the electronic equipment. And the electronic equipment can start upgrading of the operating system according to the upgrading installation package and display upgrading progress information on an upgrading interface according to the installation progress information. And the electronic equipment also estimates the compiling duration estimation value of the to-be-compiled application program. If it is determined that the to-be-compiled application program meets a compiling condition based on the compiling duration estimated value and the total compiling duration of the compiled application program, the electronic device compiles the to-be-compiled application program and updates upgrading progress information on the upgrading interface; if the to-be-compiled application program does not meet the compiling condition, the electronic equipment displays preset upgrading progress information on an upgrading interface, and the electronic equipment is restarted. According to the installation optimization method, the technical problem of low installation efficiency of the installation package can be solved.
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 an electronic device runs an application, it needs to execute the code corresponding to the application to provide the corresponding application service to the user. For example, the electronic device can compile the APK of the Android system to dex2oat to generate an optimized executable file (odex) of the application. The compiled and optimized odex file makes the electronic device more efficient, with better performance and lower power consumption.

[0003] Usually, when the system of an electronic device is installed and upgraded, if the boot path (BootClassPath) that depends on the system changes, for example, the jar package (java archive file) indicated by BootClassPath changes, the old odex file cannot call the jar package, and the application needs to be recompiled so that the electronic device can execute the corresponding application with better performance. However, after installing the system upgrade installation package, when the electronic device compiles the application, it needs to complete the compilation optimization of a part of the TOP application within the reserved time. If the electronic device has not completed the compilation of the current application after the reserved time is reached, 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, an electronic device, a storage medium and a 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, and the method includes: 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 it is determined that the application to be compiled meets compilation conditions based on the compilation time estimate and the total compilation time of compiled applications, 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, which 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 notifies OUC to trigger a device restart to avoid the compilation time of the application exceeding the 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, the estimation of the compilation time estimates of the Nth application and the N+1th application includes: obtaining the file size of the Nth application and the file size of the N+1 application; obtaining the compilation time estimate of the Nth application according to the preset rate and the file size of the Nth application; and obtaining the compilation time estimate of the N+1 application according to 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, the preset rate is used as the compilation rate of the Nth application and the N+1th application, which can improve the computational efficiency of the installation optimization method.

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

[0011] In one embodiment of the present application, if N is greater than 1, the estimation of the compilation time estimate of the N+1th application includes: obtaining the file size and compilation time of the Nth application, calculating the compilation rate of the Nth application, and the Nth application is a compiled application; based on the compilation rate of the Nth application, estimating the compilation time estimate of the N+1th application. In the above technical solution, when the Nth application is not the first application to be compiled, the compilation rate of the Nth application is used as the compilation rate of the N+1th application, which can further improve the accuracy of the compilation time estimate 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, based on the estimated compilation duration of the Nth application and the total compilation duration of the compiled applications, determining the second total duration; if the second total duration is less than or equal to the reserved duration, based on the first total duration and the first preset duration, determining the third total 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 the preset value (such as 100%), which may cause the user to mistakenly believe that the upgrade has failed, affecting the user's experience, and at the same time, it can avoid the compilation time of the application exceeding the limit duration, resulting in the occurrence of application compilation failure.

[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 the compilation is completed. 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 the compilation is completed are recorded to facilitate the subsequent setting of the compilation rate of 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 duration is greater than the reserved duration, determining whether the second total duration is greater than the limit time; if the second total duration 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 scheme, when the second total duration is greater than the reserved duration, if the second total duration 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 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, 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 scheme, when the second total duration is less than or equal to the limit time, if the fourth total duration is greater than the reserved duration, 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 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 scheme, 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 of the device; turning on the power 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; responding to the user's operation on the restart control, controlling the electronic device to restart.

[0020] In one embodiment of the present application, the method further includes: obtaining the compilation time for compiling the application to be compiled, and 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. The above technical solution can prevent the compilation time of the application from exceeding the limit time, resulting in the occurrence of application compilation failure.

[0021] In a 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, which, when executed on an electronic device, enables the electronic device to execute 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 related to the methods of each design in the above method part, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 It is a schematic diagram of the installation process of the OTA package in the related art.

[0027] Figure 2 A schematic diagram of the installation process of an OTA package in an embodiment of the present application.

[0028] Figure 3 It 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 It 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 an embodiment of the present application.

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

[0035] Fig.10 This is a schematic diagram of the process of updating the upgrade progress information in one embodiment of the present application.

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

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

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

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

[0040] Fig.15 This is a schematic diagram of the upgrade progress when installing an OTA package 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 should not be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the 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 designs. 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 those generally understood by technicians in the technical field in this application. The terms used in the specification of this application are only for the purpose of describing specific embodiments 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 represent A or B. "And / or" in some embodiments of the present application is only a description of the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: 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 represent: a, b, c, a and b, a and c, b and c, a, b and c seven situations.

[0043] To facilitate understanding, the technical terms involved in the embodiments of the present 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 source code of the application to provide the corresponding application service to the user. The source code of the application is code data that cannot be directly recognized by the electronic device. At present, electronic devices mainly use interpreted execution and machine code execution to execute the source code of the application.

[0046] 2. Interpretation and execution: When an electronic device runs an application, it uses an interpreter to interpret the source code into binary code that the electronic device can recognize, and then executes the binary code. In this way, when the application is running, the electronic device interprets a sentence of source code and then executes a corresponding sentence of 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: It can also be called compiled execution, which means translating source code into machine instructions through a compiler, such as translating into binary code that can be directly recognized by electronic devices. 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 odex file corresponding to the application and provide corresponding application services to users.

[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 the scenario of AOT compilation, the source code of the application is compiled into machine code and the corresponding odex file is generated before the application is executed. This can make the application start faster and have better running performance.

[0051] In the scenario of JIT compilation, during the running of the application, a sentence of source code is interpreted and a corresponding binary code is recorded. After all the source codes are interpreted once, an odex file containing the binary code of all the source codes can be obtained. After the application stops running, the electronic device will destroy the odex file corresponding to the application. The above two compilation methods have their own advantages and disadvantages. In the embodiments of the present application, the scenario of AOT compilation is mainly described, and the subsequent embodiments may also be referred to as optimizing the compilation of the application.

[0052] Exemplarily, the above odex file may include binary codes of all source codes of the application. Exemplarily, the above odex file may also include binary codes corresponding to hot functions in the source code. The hot functions may be code functions whose call counts are ranked before a specified ranking during the running of the application. Usually, the configuration file (or profile file) of the application may record the hot functions corresponding to the application.

[0053] It can be understood that the binary code in the odex file is an instruction that can be directly recognized by the electronic device. When the electronic device runs the application, the binary code in the odex file is executed faster. In this way, the response speed of the application is faster during operation. However, the odex file of the application is not a file that comes with the apk of the application. The electronic device needs to use the application for a period of time before the corresponding odex file can be generated. In the above embodiment, the odex file is only used for illustration. In other embodiments, the files compiled by the electronic device also include exe files and obj files, which are not limited in this application.

[0054] Before the odex file of the application is generated, the electronic device cannot use machine code to execute because there is no odex file of the application 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] In addition, the odex file is a file compiled based on the BootClassPath provided by the operating system. The odex file also records the BootClassPath it relies on and the size of the basic file package (for example, jar package (java archive file)) stored in the location indicated by BootClassPath. In this way, when the electronic device executes the odex file, it can call various types of jar packages according to the BootClassPath.

[0057] After the BootClassPath of the operating system changes, the odex file will become invalid, causing the electronic device to be unable to continue to enable machine code execution. Usually, after the operating system of an electronic device is upgraded, the BootClassPath in the electronic device may change, for example, the address changes, 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. Operating system upgrade based on over the air (OTA) technology: refers to the software upgrade of electronic devices through the air interface of mobile communications. The electronic device corresponds to a server for publishing the upgrade installation package of the operating system. The electronic device can obtain the latest upgrade installation package from the server and use the upgrade installation package to upgrade the electronic 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 the electronic device runs an application, it can check whether the application corresponds to an odex file. In the case where it is determined that the application corresponds to an odex file, it is detected whether the corresponding odex file 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, it is determined that the odex file is valid. If the addresses are different or the corresponding jar package sizes are different, it is determined that the odex file is 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 odex file of the application has expired (for example, the electronic device updated the BootClassPath during the OTA operating system upgrade process), the electronic device needs to compile the application and generate the corresponding odex file when it is idle and has sufficient power.

[0065] After the electronic device upgrades the operating system according to the upgrade installation package (such as OTA package), the upgraded operating system takes effect by restarting the device. The restart process after the upgrade includes: restarting and powering on the electronic device; mounting data (data partition). The data partition is the storage area for storing application apk. After mounting the data partition, the apk can be scanned and optimized accordingly.

[0066] like Figure 1 As shown, the installation process of the OTA package by the electronic device includes two time periods, namely time period 1 and time period 2, where time period 1 is the installation time of the OTA package, and time period 2 is the time for compiling applications (such as third-party applications). In time period 1, the electronic device can complete the download and installation of the OTA package, and in time period 2, the electronic device can compile the third-party application, such as compiling the hotspot function corresponding to the third-party application. Among them, the third-party application refers to the application developed by a third party.

[0067] Exemplarily, during the restart process after the upgrade, the electronic device displays an interface indicating application optimization, and then classifies and performs different optimization processes on the application programs in the electronic device. For example, the system application is 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 compiled in advance.

[0068] refer to Figure 2 After the otapreopt of the electronic device completes the installation of the OTA package, it will compile the application and generate the odex file of the application. 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 needs to complete the installation of the OTA package and the compilation of the application within the reserved time. If the electronic device has not completed the compilation of the current application after the reserved time is reached, the files 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 increasing the reserved time. However, the increased reserved time will increase the time required for OTA package installation. At the same time, the increase in the 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 to compile 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, where 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 an upgrade interface in an 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] In order to improve the above problems, the embodiment of the present application provides an installation optimization method, which can be applied to electronic devices. Among them, the electronic device can compile the applications in sequence before upgrading and restarting, and estimate the compilation time of the current application to be compiled, and judge whether the current application needs to be compiled according to 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 may be a hot application in the electronic device. It is understandable that the hot application may be an application with a high activity ranking in the electronic device. For example, the activity ranking of the application may be performed based on the user's usage time and frequency of each application in the electronic device, and the activity ranking of the application may also be determined based on the user's personal preference settings. In this way, it is possible to meet the user's use needs for the electronic device before the odex files of all applications are generated.

[0073] Exemplarily, 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: 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.

[0075] 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.

[0076] It is to 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 in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0077] 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 processor (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), etc. Different processing units may be independent devices or integrated into one or more processors.

[0078] 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.

[0079] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0080] In some embodiments, the processor 110 may include one or more interfaces. The interface 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, etc.

[0081] It is understandable that the interface connection relationship between the modules shown in this embodiment is only a schematic 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 in the above embodiments, or a combination of multiple interface connection methods.

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

[0083] The display screen 194 is used to display images, videos, etc. The 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc.

[0084] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0085] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element (image sensor) through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.

[0086] 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.

[0087] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0088] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0089] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. NPU can realize applications such as intelligent cognition of electronic device 100, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0090] The software system of the electronic device can adopt a layered architecture, an event-driven architecture, a micro-core 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.

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

[0092] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the operating system of the electronic device can be divided into multiple layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (ART) and the system library, and the kernel layer.

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

[0094] like Figure 6 As shown in the figure, 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, Call, Memo, Contacts, Camera, Gallery, Calendar, Maps, Bluetooth, etc.

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

[0096] 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.

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

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

[0099] Exemplarily, the compilation optimization service module is used to determine the application programs that need to be compiled and the compilation order between the application programs. For example, hot applications can be determined as the application programs that need to be compiled.

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

[0101] 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 provide 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.

[0102] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system. The encoder (dalvik excutable file to optimized art file, dex2oat) and optimization compilation (dexopt) modules run in the virtual machine of the above Android Runtime. Among them, dexopt can be used to convert the dex file containing source code into an odex file containing binary code. For example, dexopt can call dex2oat to translate the source code of the application, and generate the odex file corresponding to the application according to the translation result of dex2oat.

[0103] 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.

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

[0105] The kernel layer is a layer between hardware and software. The kernel layer at least includes a camera driver, an audio driver, a sensor driver, etc., and the present application embodiment does not impose any restrictions on this.

[0106] 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.

[0107] In some embodiments, the developer can store the written upgrade installation package on the 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.

[0108] In an embodiment of the present application, in addition to the data used to update the operating system, the above-mentioned upgrade installation package also includes a final installation (PostInstall) file. Among them, the above-mentioned PostInstall file can indicate the process to be executed after the upgrade installation package is installed and verified. The above-mentioned PostInstall file can 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 installing and verifying the upgrade installation package, 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 installing and verifying the upgrade installation package, the PostInstall file is executed to compile part of the application program in the target operating system, and the electronic device indicated activates the target operating system, wherein the target operating system is the upgraded operating system in the A / B operating system.

[0109] 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 an example, and the order of the steps can be changed. Without departing from the content disclosed in the present application, additional steps can be added or steps can be reduced. The method specifically includes the following steps.

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

[0111] S701, the OUC in the electronic device searches and downloads an upgrade installation package from a server.

[0112] In one embodiment of the present application, the electronic device can periodically initiate a package search request to the server through the OUC, and 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 whether there is 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 there is an upgrade installation package of a newer version, 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.

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

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

[0115] In the embodiments of the present application, Figure 1 As shown, upgrading the operating system of the electronic device may include two stages. In the first stage (time period 1), the electronic device may install and verify the upgrade installation package. In the second stage (time period 2), the electronic device may perform AOT compilation for the first number of applications in sequence according to the PostInstall file in the upgrade installation package to generate corresponding odex files.

[0116] As an implementation method, the OUC may download and save the upgrade installation package to the user data partition (Userdata). Afterwards, the OUC instructs the start of the update engine, which executes the first stage of upgrading the operating system, see S702 to S704 for details.

[0117] S702, OUC instructs the update engine to start upgrading the operating system.

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

[0119] After that, OUC obtains the status of the update engine through binder communication. After OUC confirms that the update engine has been successfully started, OUC passes the upgrade parameters to the update engine (for example, the above upgrade parameters can indicate whether the current upgrade operation is a file update operation or a file storage operation), triggering the update engine to enter the upgrade process. The file storage operation usually means the process of writing data in the memory to a persistent storage device (such as a hard disk).

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

[0121] In some embodiments, the update engine can confirm whether the upgrade installation package is a legitimate upgrade package by verifying whether the META-INF (ie, digital signature) in the upgrade installation package is legitimate. If the META-INF in the upgrade installation package is legitimate, the update engine can confirm that the upgrade installation package is a legitimate upgrade package.

[0122] After determining that the upgrade installation package passes the inspection, the update engine can parse the upgrade installation package to obtain the upgrade data for updating the operating system. Then, the update engine can write the upgrade data to the storage partition (static partition or dynamic partition, etc.) corresponding to the operating system in the memory.

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

[0124] 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.

[0125] For example, the system upgrade package contains the data of the static partition of version 1.2, that is, the upgrade data for the static partition. After the update engine parses the upgrade installation package, it overwrites the data of the static partition carried in the upgrade installation package (that is, the static partition data of version 1.2) into the static partition (B).

[0126] 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.

[0127] 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 (Super) of version 1.2 is written into the virtual dynamic partition.

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

[0129] refer to Fig. 9 The figure is a schematic diagram of the upgrade interface in an 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 S803 is executed, that is, after the installation package is installed, the annular progress bar 8022 of the upgrade interface 801 displays a first ratio, for example, the first ratio is 80%.

[0130] S705, the update engine performs verification after the upgrade.

[0131] In some embodiments, after installing the upgrade data package, the update engine verifies whether the upgraded B operating system (data in static partition B and virtual dynamic partition) is valid. If valid, it is determined that the installation and verification have been completed, and the PostInstall file in the upgrade installation package is executed.

[0132] Then, the second stage of the operating system upgrade is entered. In the second stage, the electronic device can optimize and compile the first number of applications to obtain corresponding odex files. Exemplarily, the electronic device can optimize and compile the application after installing the upgrade installation package. For example, after executing the aforementioned S701~S704, if the verification after the upgrade is passed, the application is optimized and compiled. For another example, after executing S701~S705, if the upgrade data has been written into the first storage partition (such as written into the static partition (B) and the virtual dynamic partition), the application can be optimized and compiled.

[0133] As an implementation method, the process of optimizing compilation can be referred to Figure 7 S706~S714 in: S706, the update engine instructs ART to compile a first number of application programs.

[0134] In some embodiments, a first number may be configured in the PostInstall file. In this way, 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, and the update engine executing the PostInstall file may instruct ART to compile 5 applications in the electronic device through the compiler. Exemplarily, the above first number may be less than the total number of applications in the electronic device.

[0135] When the electronic device uses a virtual A / B operating system, the application can be optimized and compiled through the ART of the target operating system. In this way, the compiled odex file is generated based on the BootClassPath of the target operating system. After the above optimization compilation, when the electronic device switches from running the original operating system to running the target operating system, the compiled application can be run in the form of machine code execution.

[0136] It can be understood that when the 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.

[0137] The above update will not affect the system data corresponding to the A operating system. In this way, before the electronic device activates the B operating system, the BootClassPath in the A operating system remains unchanged, and the odex file compiled based on the A operating system before the upgrade is still valid. During the operation of the A operating system, the electronic device can run the application in the way of machine code execution.

[0138] 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, which is used to distinguish from the original odex file of the application (the odex file compiled based on the A operating system) 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 in the execution of the machine code.

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

[0140] In other embodiments, a first duration may be configured in the PostInstall file, so that the update engine may instruct ART to compile the applications in sequence 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 in sequence 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.

[0141] 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 function is translated into binary code, and the corresponding odex file is generated. It can be understood that the hotspot function is related to the activity level (or calling frequency) of each function called in the source code, and is related to the user's habit of using the application and the operating rules of the application. In the process of using the application by the electronic device, the hotspot function in the configuration file can also be updated according to the activity level of the function.

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

[0143] The first condition may include one or more of the following combinations: (1) The first application is an application ranked in the top N positions in terms of activity level among the applications of the electronic device, where N is a positive integer. For example, if N is 5, the first application may be an application ranked in the top 5 in terms of activity level among the applications of the electronic device. The activity level is the activity level of the application evaluated based on the application running records (foreground running, background running, etc.) and the application download volume.

[0144] 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. Exemplarily, the user's application operation records for each application can be obtained to evaluate a first score indicating the 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.

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

[0146] Exemplarily, the first set (also referred to as an application set) includes multiple applications, and each application is an application of a pre-selected type. An application of a pre-selected type is an application that can provide a specified application service. In addition, one pre-selected type or multiple pre-selected types may be set, and this embodiment of the present application does not specifically limit this.

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

[0148] Exemplarily, the process of ART compiling a first number of applications may include: randomly selecting a first number of applications to be compiled from an application set, and then optimizing and compiling the applications to be compiled in sequence. In another exemplary embodiment, the process of ART compiling a first number of applications may include: randomly extracting an application from the application set for optimization compilation, after completing the optimization compilation for the application, randomly extracting another non-optimized compiled application from the application set, and continuing to optimize and compile the application until a termination condition is met. The termination condition may be that the total time for ART to compile the application reaches a preset time.

[0149] 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 the applications to be compiled, and optimizing the 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 in the first place for optimization compilation, and completing the optimization 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 in the first place in terms of activity level to continue to optimize the compilation, and repeat the above process until the termination condition is met. Wherein, the termination condition may be that the total duration of ART's optimization compilation of the application reaches the reserved duration.

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

[0151] It should be noted that the installation process of the OTA package of the present application is carried out in the old version of the operating system. The electronic device stores the odex files of various applications compiled under the old 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 file 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 ART compiles the first application (such as the Top1 application), it 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 estimated compilation time 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 estimated compilation time of the Nth application.

[0152] When N is greater than 1, the Nth application is not the first application to be 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 the Nth application. The compilation rate of the N-1th application that is before the Nth application is used as the compilation rate of the Nth application, and the compilation time estimate of the Nth application is determined based on the odex file size of the Nth application and the compilation rate of the N-1 application. An example is as follows: 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 the Top2 application 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, and the compilation time estimate of the Top2 application is obtained by dividing the odex file size of the Top2 application and the compilation rate of the Top1 application.

[0153] S708, ART determines whether the application to be compiled meets the compilation conditions based on the compilation time estimation 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, S709 is executed, and if it is determined that the application to be compiled does not meet the compilation conditions, S711 is executed.

[0154] 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 the total time, and determines whether the total time is greater than or equal to the reserved time (for example, 5 minutes). If the total time is less than the reserved time, it is determined that the Nth application meets the preset condition; if the total time is greater than or equal to the reserved time, it is determined that the Nth application does not meet the preset condition.

[0155] In one embodiment of the present application, in order to increase the number of applications that the 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).

[0156] S709, ART compiles the application programs 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 application programs to be compiled, and updates the total compile time according to the obtained compile time.

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

[0158] In one embodiment of the present application, when ART compiles the application to be compiled, the upgrade engine instructs the OUC to update the upgrade progress information on the upgrade interface and 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.

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

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

[0161] refer to Fig.10 As shown, it is a flow chart of OUC updating upgrade progress information in one embodiment of the present application. OUC first pulls up the upgrade compilation script file hn_otapreopt_script.sh for compilation preprocessing; when compiling the application to be compiled, OUC prints the compilation progress information through the update_progress() function at intervals of a preset time period (such as 5s), and obtains the compilation time from the compilation progress information; divides the compilation time by the reserved time, and multiplies the result of the division by the remaining progress to obtain the compilation progress, and adds the compilation progress 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; and displays the upgrade progress information corresponding to the upgrade progress on the upgrade interface.

[0162] The following is an example. If the first ratio is 80%, then based on the difference between the percentage 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 divide the 1-minute compilation time by the 5-minute reserved time, and multiply the result of the division by the remaining progress of 20%, and get a compilation progress of 4%. Add 4% and 80% to get an upgrade progress of 84%. Refer to Fig.11 , the upgrade progress information showing a value of 84% is displayed on the upgrade interface.

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

[0164] 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%, ends the compilation of the application to be compiled, and notifies the update engine to restart.

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

[0166] In one embodiment of the present application, reference Fig.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.

[0167] S713, the update engine instructs the OUC to trigger a device restart.

[0168] 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.

[0169] refer to Fig.13 , which is a schematic diagram of a pop-up window in an embodiment of the present application. The pop-up window 20 includes a restart control 201. The OUC receives an operation of the user clicking the restart control 201 to control the electronic device to restart. In an embodiment of the present application, controlling the electronic device to restart includes: exiting the current old version of the operating system (for example, operating system A), cutting off the power of the device, turning on the power of the device again, and starting the new version of the operating system (for example, operating system B).

[0170] In the embodiment of the present application, if it is determined 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 show 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, which can avoid notifying the user to restart the electronic device when the upgrade progress information does not show 100% (such as showing 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 it is determined that the application to be compiled does not meet the compilation conditions, the present application notifies OUC to trigger the device restart, avoiding the compilation time of the application exceeding the limit time, resulting in the failure of the application compilation.

[0171] In S707 and S708 of the above-mentioned embodiments, 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 (such as the compilation time estimate of the Nth application), the total compilation time of the compiled applications, and the reserved time. For example, ART sums up the compilation time estimate of the Nth application and the total compilation time of the compiled applications to obtain the 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 current 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 current application to be compiled meets the compilation conditions.

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

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

[0174] 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: Fig.15, the first ratio is 80%, the reserved time is 5 minutes, OUC calculates the difference between the percentage ratio and the first ratio of 80% to obtain the remaining progress value of 20%; divides the remaining progress of 20% by the reserved time of 5 minutes to obtain the progress update rate of 4% / minute, and updates the upgrade progress information according to the progress update rate of 4% / minute. OUC can update the upgrade progress according to the progress of each preset time period (such as 15 seconds) according to the progress update rate.

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

[0176] In one embodiment of the present application, ART compiles the applications in order 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.

[0177] 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.

[0178] 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.

[0179] In one embodiment of the present application, if the odex file size of the Nth application is less than the first threshold, it means that the Nth application is a newly installed application or a newly updated apk application, and the original configuration file and odex file recording the hotspot function are invalid 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 function of the startup scene, 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.

[0180] 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.

[0181] 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.

[0182] 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.

[0183] 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.

[0184] S1407, setting the compilation rate of the Nth application and the compilation rate of the N+1th application.

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

[0186] 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.

[0187] 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 an estimated compilation time T1 for 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 an estimated compilation time T2 for the N+1th application.

[0188] S1409: sum up 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.

[0189] In one embodiment of the present application, when the Top1 application is taken as the Nth application, the total compilation time of the compiled applications is zero; when the non-Top1 application is taken as the Nth application, the total compilation time of the compiled applications is the sum of the compilation times of all applications before the Nth application. ART sums the compilation time estimate of the Nth application, the compilation time estimate of the N+1th application, and the total compilation time of the compiled applications to obtain the first total time.

[0190] 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.

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

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

[0193] 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.

[0194] S1412, summing the estimated compilation time of the Nth application and the total compilation time of the compiled applications to obtain a second total time, and determining whether the second total time is greater than the reserved time. If the second total time is less than or equal to the reserved time, execute S1413; if the second total time is greater than the reserved time, execute S1417.

[0195] 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.

[0196] 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 is greater than the reserved duration, indicating that ART cannot compile the N+1th application when the reserved duration is reached.

[0197] S1414: The Nth application is taken as the last application to be compiled, and the estimated compilation time T1 of the Nth application is sent to the OUC, instructing the OUC to update the upgrade progress information based on the estimated compilation time T1.

[0198] 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. Fig.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 the remaining progress value of 5%; the remaining progress value of 5% is divided by the reserved time value of 1 minute to obtain the progress update rate of 5% / minute, and the upgrade progress information is updated according to the progress update rate of 5% / minute.

[0199] S1415, compile the Nth application program.

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

[0201] 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.

[0202] In one embodiment of the present application, OUC sets the upgrade progress information to 100% on the upgrade interface according to the instructions sent by 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.

[0203] 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.

[0204] S1418, subtract the second total duration from the second preset duration to obtain a fourth total duration, and determine whether the fourth 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 duration is greater than the reserved duration, execute S1416.

[0205] 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.

[0206] 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.

[0207] In an embodiment of the present application, the electronic device can estimate the compilation time of the current application to be compiled before upgrading and restarting. 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, ART ends the compilation of the application to be compiled. When the upgrade progress information does not show 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, which can avoid notifying the user to restart the electronic device when the upgrade progress information does not show 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 it is determined that the application to be compiled does not meet the compilation conditions, the present application notifies OUC to trigger the device restart, so as to avoid the compilation time of the application exceeding the limit time, resulting in the failure of the application compilation.

[0208] The embodiment of the present application also provides an electronic device, which may include: a memory and one or more processors. The memory is coupled to the processor. The memory is used to store computer program code, and the computer program code includes computer instructions. When the processor executes the computer instructions, the electronic device can execute 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.

[0209] The embodiment of the present application also provides a chip system, which 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 above-mentioned electronic device. The processor and the interface circuit can be interconnected through a line. The processor can receive and execute computer instructions from the memory of the above-mentioned electronic device through the interface circuit. When the computer instructions are executed by the processor, the electronic device can execute the various steps in the above-mentioned embodiment. Of course, the chip system can also include other discrete devices, which are not specifically limited in the embodiment of the present application.

[0210] In some embodiments, through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity 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 is 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.

[0211] Each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units.

[0212] 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 is essentially 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, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk.

[0213] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the embodiment of the present application should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope 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; Display the upgrade progress information on the upgrade interface according to the installation progress information; Estimate the compilation time of the application to be compiled; If it is determined that the application to be compiled meets the compilation condition based on the compilation time estimation and the total compilation time of the compiled applications, 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 condition, 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, characterized in that: If there are multiple applications to be compiled, determining that the applications to be compiled meet the compilation condition includes: Determine a first total duration according to 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, where N is a natural number greater than or equal to 1; If the first total duration is less than the reserved duration, it is determined that the Nth application meets the compilation condition.

3. The installation optimization method according to claim 2, characterized in that: If N=1, the estimated compilation time of 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 an estimated compilation time of the Nth application program according to a preset rate and a file size of the Nth application program; and According to the preset rate and the file size of the N+1th application, an estimated compilation time of the N+1 application is obtained.

4. The installation optimization method according to claim 2, characterized in that: If N is greater than 1, the estimated compilation time of the Nth application includes: Obtaining a file size and a compile time of an N-1th application, and calculating a compile rate of the N-1th application, where the N-1th application is a compiled application; Based on the compilation rate of the N-1th application, an estimated compilation time of the Nth application is estimated.

5. The installation optimization method according to claim 2, characterized in that: If N is greater than 1, the estimated compilation time of the N+1th application includes: Obtaining a file size and a compile time of an Nth application, and calculating a compile 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.

6. The installation optimization method according to claim 2, characterized in that: The method further comprises: 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, the Nth application is compiled as the last application to be compiled, and the upgrade progress information is updated based on the estimated compilation duration of the Nth application.

7. The installation optimization method according to claim 6, 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 the compilation is completed are recorded.

8. The installation optimization method according to any one of claims 3 to 7, characterized in that: The file of the application to be compiled is an odex file.

9. The installation optimization method according to claim 6, characterized in that: The method further comprises: 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 duration 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.

10. The installation optimization method according to claim 6, characterized in that: The method further comprises: 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.

11. The installation optimization method according to claim 10, characterized in that: 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.

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

13. The installation optimization method according to claim 1, characterized in that: 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.

14. The installation optimization method according to claim 1, characterized in that: The method further comprises: Obtain the compilation time for compiling the application to be compiled. If the compilation time reaches a limit time, 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.

15. 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 used 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 as described in any one of claims 1 to 14.

16. 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 14.

17. 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 14 is implemented.

Citation Information

Patent Citations

  • Data processing system, data processing method and electronic equipment

    CN114661321A

  • Application program optimization method and electronic equipment

    CN116643778A

  • Adaptive interpretation and compilation of database queries

    US11055331B1

  • Bounded installation time optimization of applications

    US8972975B1