Application compilation control method and related equipment

By setting loose compilation conditions and a heartbeat time mechanism, the problem of applications in smart terminal devices being unable to complete pre-compilation when idle is solved, achieving more efficient compilation and lower system power consumption.

CN118069154BActive Publication Date: 2024-09-17HONOR DEVICE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410484096.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-22
Publication Date
2024-09-17
Estimated Expiration
2044-04-22

AI Technical Summary

Technical Problem

Applications in smart terminal devices cannot be pre-compiled when idle, resulting in compilation at runtime, which increases system power consumption and causes system lags.

Method used

By setting loose application compilation conditions, using the power and heartbeat time mechanism to wake up the device, and executing compilation tasks when the conditions are met, system power consumption is reduced and compilation efficiency is improved.

Benefits of technology

It improves the pre-compilation success rate of applications, reduces system power consumption and lagging, and optimizes the operating efficiency of the device.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069154B
    Figure CN118069154B
Patent Text Reader

Abstract

The embodiment of the present application provides an application compilation control method and related equipment, the method comprising: if the electronic device is in a screen-off charging state, obtaining the initial charging current and current power of the electronic device, and determining the moment when the power of the electronic device reaches a first preset value according to the initial charging current and current power of the electronic device; obtaining the next heartbeat moment, and determining the precise heartbeat moment according to the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment; waking up the electronic device at the precise heartbeat moment, and obtaining the real-time power of the electronic device; if the real-time power is greater than or equal to the first preset value, executing the first compilation task, and compiling multiple first preset application programs in the electronic device. The embodiment of the present application increases the execution probability of the first compilation task by setting a relatively loose application compilation condition, and can also wake up the electronic device at a precise time point to execute the first compilation task, effectively reducing system power consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of terminal equipment, and in particular to an application compilation control method and related equipment. Background Art

[0002] With the development of smart terminal technology, many applications are installed in terminal devices such as smart phones and personal computers. Application packages (Android Application Package, APK) are usually written in Java or Kotlin. When generating application packages, Java source code needs to be compiled into bytecode. When running the application, the bytecode of the application needs to be compiled into machine code, which is executed by the central processing unit CPU in the terminal device.

[0003] In related technologies, in order to improve the operating efficiency of applications, the bytecode of the application can be pre-compiled into machine code and stored when the terminal device is idle. However, in actual application, the application often cannot be pre-compiled when the terminal device is idle, and still needs to be compiled during runtime, which increases system power consumption and even causes system freezes. Summary of the invention

[0004] In view of the above, it is necessary to provide an application compilation control method and related equipment to solve the problem that the above-mentioned application cannot be pre-compiled when the electronic device is idle and needs to be compiled at runtime, which increases system power consumption and causes system freezes.

[0005] In a first aspect, the present application provides an application compilation control method, which is applied to an electronic device, and the method includes: if the electronic device is in a screen-off charging state, obtaining an initial charging current and a current power of the electronic device, and determining a moment when the power of the electronic device reaches a first preset value according to the initial charging current and the current power of the electronic device; obtaining the next heartbeat moment, and determining a precise heartbeat moment according to the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment; waking up the electronic device at the precise heartbeat moment, and obtaining the real-time power of the electronic device; if the real-time power is greater than or equal to the first preset value, executing a first compilation task to compile multiple first preset applications in the electronic device.

[0006] Based on the above technical solution, by setting relatively loose application compilation conditions, the execution probability of the first compilation task is improved, making it easier to pre-compile the application when the electronic device is idle. The electronic device can also be woken up at a precise time point to execute the first compilation task, thereby reducing the frequency of waking up the electronic device and effectively reducing system power consumption.

[0007] In one possible implementation, determining the precise heartbeat moment based on the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment includes: if the moment when the power of the electronic device reaches the first preset value is before the next heartbeat moment, and the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is greater than a first preset duration, setting the moment when the power of the electronic device reaches the first preset value as the precise heartbeat moment.

[0008] Based on the above technical solution, when the power of the electronic device reaches the first preset value within a long period of time before the next heartbeat, the frequency of waking up the electronic device is reduced by setting a precise time point to execute the first compilation task, thereby effectively reducing the system power consumption.

[0009] In one possible implementation, the method also includes: if the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration, waking up the electronic device at the next heartbeat moment, executing the first compilation task, and compiling the multiple first preset applications in the electronic device.

[0010] Based on the above technical solution, when the interval between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is short, the electronic device is directly awakened at the next heartbeat moment to execute the first compilation task without setting the precise heartbeat moment, thereby simplifying the execution process of the first compilation task.

[0011] In a possible implementation, the method also includes: after waking up the electronic device at the next heartbeat moment, obtaining the real-time power level of the electronic device, if the real-time power level is greater than or equal to the first preset value, executing the first compilation task to compile the multiple first preset applications in the electronic device.

[0012] Based on the above technical solution, after waking up the electronic device at the next heartbeat moment, it is monitored whether the power of the electronic device has indeed reached the first preset value to ensure that the electronic device executes the first compilation task when the conditions are met.

[0013] In a possible implementation, the method also includes: if the moment when the power of the electronic device reaches the first preset value is after the next heartbeat moment, and the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is greater than the first preset duration, waking up the electronic device at the next heartbeat moment, and updating the moment when the power of the electronic device reaches the first preset value.

[0014] Based on the above technical solution, when the moment when the power of the electronic device reaches the first preset value is a long time after the next heartbeat moment, the moment when the power of the electronic device reaches the first preset value is re-predicted to avoid the inaccuracy of the initial predicted moment when the power reaches the first preset value due to changes in the charging rate of the electronic device, which causes the electronic device to be unable to execute the first compilation task normally, and then causes the application to be unable to complete the pre-compilation in time.

[0015] In a possible implementation, the first compilation task is a daily idle-time compilation task, which is used to pre-compile the multiple first preset application programs in the electronic device when the electronic device is in an idle state on a one-day basis.

[0016] Based on the above technical solution, by executing daily idle compilation tasks, it can be ensured that the application programs in the electronic device can be pre-compiled without having to be compiled at runtime, thereby reducing system power consumption and reducing system freezes.

[0017] In one possible implementation, the multiple first preset applications include one or more of the following applications: all applications in the electronic device, applications in the electronic device whose configuration file change rate is greater than or equal to a preset percentage, and applications in the electronic device that generate version updates.

[0018] Based on the above technical solution, the application can be pre-compiled according to different needs by executing daily idle time compilation tasks.

[0019] In one possible implementation, compiling multiple first preset applications in the electronic device includes: obtaining hotspot functions of each first preset application according to a configuration file of each first preset application of the electronic device, and using a compilation optimization program to compile the bytecode corresponding to the hotspot function of each first preset application into machine code.

[0020] Based on the above technical solution, the hot functions of the application can be pre-compiled by executing daily off-peak compilation tasks, thereby improving the compilation efficiency of the application.

[0021] In a possible implementation, the method further includes: during the execution of the first compilation task, if it is monitored that the electronic device turns on the screen and / or stops charging, exiting the execution of the first compilation task.

[0022] Based on the above technical solution, when the state of the electronic device does not meet the execution condition of the first compilation task, the first compilation task can be interrupted in time to avoid the execution of the first compilation task affecting the normal use of the electronic device by the user.

[0023] In a possible implementation, the method further includes: if the electronic device is powered on for the first time after the operating system is updated and the state of the electronic device meets a preset condition, executing a second compilation task to pre-compile multiple second preset application programs in the electronic device.

[0024] Based on the above technical solution, when an electronic device is turned on for the first time after the operating system is updated and the state of the electronic device meets the preset conditions, the application in the electronic device can be pre-compiled by executing the second compilation task, so that the application does not need to be compiled during runtime, thereby effectively reducing system power consumption and reducing system lag.

[0025] In a possible implementation, the pre-compiling the plurality of second preset applications in the electronic device includes: acquiring a preset application list in the electronic device; and pre-compiling the plurality of second preset applications in the preset application list.

[0026] Based on the above technical solution, information of multiple second preset applications can be pre-recorded in the preset application list, so that when executing the second compilation task, multiple second preset applications can be quickly determined to improve the compilation efficiency of the application.

[0027] In a possible implementation, the pre-compiling of the plurality of second preset applications in the preset application list includes: obtaining a dex file of the second preset application, and compiling the dex file of the second preset application using a compilation optimization program to obtain an odex file.

[0028] Based on the above technical solution, using a compilation optimization program to compile an application can effectively improve the compilation efficiency of the application.

[0029] In a possible implementation, the preset conditions include: the screen-off time of the electronic device is greater than or equal to a second preset duration, and the power of the electronic device is greater than or equal to a second preset value.

[0030] Based on the above technical solution, the execution condition of the second compilation task can be flexibly set according to different requirements, so that the second compilation task can be executed normally.

[0031] In a possible implementation, the preset conditions include: the screen-off time of the electronic device is greater than or equal to a third preset time length, and the electronic device is in a stationary state.

[0032] Based on the above technical solution, the execution condition of the second compilation task can be flexibly set according to different requirements, so that the second compilation task can be executed normally.

[0033] In a possible implementation, the plurality of second preset applications are applications whose usage rates in the electronic device are ranked in the top third preset values ​​or are applications preset by the user, and the second compilation task is a fast idle compilation task.

[0034] Based on the above technical solution, by executing the second compilation task, the user's frequently used or specified applications can be pre-compiled first, so that the electronic device does not need to compile the application when running the user's frequently used or specified applications, thereby improving the fluency of the application running process.

[0035] In a second aspect, an embodiment of the present application provides an application compilation control method, which is applied to an electronic device, and the method includes: after the operating system of the electronic device is updated and the state of the electronic device meets a preset condition, executing a second compilation task to compile multiple second preset applications in the electronic device; according to the above-mentioned application compilation control method, executing the first compilation task for other applications other than the multiple second preset applications in the electronic device.

[0036] Based on the above technical solution, after the operating system is updated, the electronic device first executes the second compilation task to prioritize the compilation of some applications in the electronic device, and then executes the first compilation task to compile the remaining applications in the electronic device, which effectively improves the compilation efficiency of the application and ensures the normal use of the application by the user.

[0037] In a possible implementation, the second compilation task is a fast idle compilation task, and the plurality of second preset applications are applications whose usage rates in the electronic device are ranked in the top third preset values ​​or applications preset by the user.

[0038] Based on the above technical solution, by executing the second compilation task, the user's frequently used or specified applications can be pre-compiled first, so that the electronic device does not need to compile the application when running the user's frequently used or specified applications, thereby improving the fluency of the application running process.

[0039] In a third aspect, the present application provides an electronic device, comprising 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 application compilation control method.

[0040] In a fourth aspect, the present application provides a chip coupled to a memory in an electronic device, wherein the chip is used to control a processor of the electronic device to execute the above-mentioned application compilation control method.

[0041] In a fifth aspect, the present application provides a computer storage medium storing program instructions, which, when executed on an electronic device, enables a processor of the electronic device to execute the above-mentioned application compilation control method.

[0042] In addition, the technical effects brought about by the third 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

[0043] Figure 1 It is an application compilation flow chart in the related technology.

[0044] Figure 2 It is an application compilation flow chart in another related technology.

[0045] Figure 3 It is a schematic diagram of the changes in the machine code of an application in the related art.

[0046] Figure 4 It is a schematic diagram of the relationship between the interpreted execution, JIT compilation and AOT compilation of an application in the related technology.

[0047] Figure 5 It is a processing flow chart of daily idle time compilation tasks in related technology.

[0048] Figure 6 It is a software architecture diagram of an electronic device provided in one embodiment of the present application.

[0049] Figure 7 It is a flowchart of an application compilation control method provided by an embodiment of the present application.

[0050] Figure 8 This is a schematic diagram of predicting the moment when the power of an electronic device reaches a first preset value provided by an embodiment of the present application.

[0051] Fig. 9 It is a partial flow chart of an application compilation control method provided by another embodiment of the present application.

[0052] Fig.10 This is another partial flow chart of the application compilation control method provided by another embodiment of the present application.

[0053] Fig.11 This is an operation flow chart of the task scheduler service provided in one embodiment of the present application.

[0054] Fig.12 It is a flowchart of an application compilation control method provided by another embodiment of the present application.

[0055] Fig.13This is a hardware architecture diagram of an electronic device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0056] The terms "first" and "second" involved in the embodiments of the present application are only used for descriptive purposes 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 features. In the description of the 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 the 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.

[0057] 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 this 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" refers to one or more. "Multiple" refers to 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. In the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other.

[0058] For ease of understanding, some concepts related to the embodiments of the present application are exemplarily described for reference:

[0059] ART: Android Runtime, Android runtime, is the operating environment or virtual machine of the Android operating system.

[0060] Dex: Dalvik Executable, bytecode file, an executable file format dedicated to the Android platform, used to store compiled code.

[0061] Odex: Optimized Dex, an optimized Dex file, is executable machine code.

[0062] Vdex: used to store verification information of Dex files.

[0063] APK: Android Application Package, application package, used to store Dex files, Manifest files, and application resource files.

[0064] Profile: Configuration file used to store the index of the hot function of the application. The hot function is the function that is frequently called during the execution of the application.

[0065] Boot.art: The file compiled from the Java Archive File (JAR) package, which is a machine code file.

[0066] Interpreter: A tool used to compile Dex code into machine code.

[0067] Interpreted execution: Interpreted execution means providing the source code as input to the interpreter and converting it into executable machine code through the interpreter.

[0068] JIT (Just-In-Time) compilation: Compiles bytecode or intermediate code into machine code while the application is running.

[0069] AOT (AHEAD OF TIME) compilation: compile bytecode or intermediate code into machine code before the application runs.

[0070] Dex2oat: Dalvik excutable file to optimized art file, compilation optimization program, is a program used to compile bytecode into machine code.

[0071] With the development of smart terminal technology, developers are developing more and more applications for smart terminal devices such as smartphones and personal computers, and there are also many applications installed in smart terminal devices. The application packages and Java archive file packages in smart terminal devices are usually written in Java language. When generating application packages or Java archive file packages, the Java source code needs to be compiled into bytecode, which can be recognized by ART virtual machines on different platforms. When running an application or file, after the ART virtual machine recognizes the bytecode, it needs to compile the bytecode into the machine code corresponding to the platform according to the platform where it is located. The compiled machine code is executed by the central processing unit CPU of the terminal device.

[0072] See also Figure 1The figure shows an application compilation flow chart in a related technology. S101, the Java source code (Java Code) of the application package is written in Java language. S102, when generating the application package, the developer compiles the Java source code into Dex bytecode. In the Android system platform, developers use Java language to write applications, and the Java code is first compiled into Java bytecode, and then these Java bytecodes are further compiled into Dex bytecode by the Dex compiler. In this way, the final application package only contains Dex bytecode, not Java bytecode. These Dex bytecodes are executed by the ART virtual machine on the Android device. S103, when the user terminal runs the application, the Dex bytecode is compiled into platform-adapted machine code through the ART virtual machine. S104, the compiled machine code is executed by the CPU.

[0073] In such Figure 1 In the related technology shown, each time an application is run, the Dex bytecode in the application package needs to be compiled into machine code, which increases system power consumption and causes device performance overhead.

[0074] See also Figure 2 As shown, it is an application compilation flow chart in another related technology. S201, write the Java source code of the application package in Java language. S202, when generating the application package, the developer compiles the Java source code into Dex bytecode. If the user terminal does not include the odex machine code of the application package, in S203, the Dex bytecode is pre-compiled into the platform-adapted machine code by the ART virtual machine when the user terminal is idle. S204, save the compilation result and obtain the odex machine code. S205, the CPU executes the compiled machine code.

[0075] If the user terminal includes the odex machine code of the application package, the odex machine code is obtained, and then S205 is executed, and the CPU executes the odex machine code.

[0076] In such Figure 2 In the related technologies shown, the application compilation adopts the AOT compilation mechanism. For example, all bytecodes or bytecodes of commonly used functions in the application package are compiled into machine code in advance and stored. In this way, the machine code can be run directly when the application is running, without performing compilation operations, so as to reduce system power consumption and improve the operation efficiency of the application. AOT compilation is usually performed when the electronic device is idle (for example, in sleep state or charging state). Due to factors such as the short idle time of the electronic device or the large number of applications that need to be compiled, AOT compilation often cannot be completed, resulting in some applications still needing to be compiled at runtime, resulting in increased system power consumption and even system freezes.

[0077] See also Figure 3 The figure shows a schematic diagram of the changes in the machine code of an application in the related art. When the operating system of an electronic device is updated by HOTA (Hotfix OTA, instant update), patch update, or COTA (Customer OTA, periodic update), if any Jar package of the operating system of the electronic device changes, the machine code contained in boot.art also changes, resulting in a failure in the verification of the odex file. In this case, all applications in the electronic device need to be recompiled, resulting in device power consumption and performance overhead. Among them, the odex file is an executable file extracted from the APK package of the application. It is a file format used in the Android system to optimize and improve program execution efficiency. The odex file reduces the loading time and memory usage when the program starts by pre-extracting and optimizing the DEX file.

[0078] See also Figure 4 As shown, it is a schematic diagram of the relationship between the interpreted execution, JIT compilation and AOT compilation of the application in the related technology. First, after the electronic device downloads the application package (for example, APK file): S301, after downloading the application package, install and decompress the application package. S302, compile the code of the application package into dex bytecode. S303, extract the dex bytecode and perform preliminary verification, and store it in the application installation directory, and then execute the vdex bytecode when the application is running. When the application is installed, first decompress the APK, extract the so library file and dex file of the APK, the so library file is the shared target file of the application, which is used to store the local code of the application, and then store the decompressed so library file in the lib folder of the application installation directory. The decompressed dex file is verified to generate a vdex file, which is stored in the oat / arm64 (or oat / arm) folder of the application installation directory. S304, run the application.

[0079] During the running process of the application, the corresponding compilation mode is selected according to different situations: S305, execute the Java method in the application, wherein executing the Java method means executing the code or function in the application to realize the corresponding function. S306, determine whether the Java method has been compiled. If the Java method has been compiled, the process executes S307; if the Java method has not been compiled, the process executes S310. S307, determine whether the Java method has been JIT compiled. If the Java method has not been JIT compiled, the process executes S308; if the application package has been JIT compiled, the process executes S309. S308, run odex machine code. Among them, when the Java method has not been JIT compiled, it means that it has been AOT compiled and odex machine code has been generated, so the odex machine code can be run. S309, run cache code codecache. Among them, when the Java method is JIT compiled, cache code is generated. S310, interpret and execute the Java method, wherein interpret and execute means providing the source code as input to the interpreter and converting it into executable machine instructions through the interpreter. S311, record the hot functions in the application package, which are functions that are frequently called during the execution of the application. S312, determine whether a function is a hot function, wherein each function is determined to be a hot function during the interpretation and execution process. If the function is not a hot function, the process returns to execute S310; if the function is a hot function, the process executes S313.

[0080] S313, determine whether the memory of the electronic device is sufficient. If the memory of the electronic device is sufficient, the process executes S314; if the memory of the electronic device is insufficient, the process executes S316. S314, JIT compiles the application package. S315, stores the compiled machine code into the cache code codecache, and then the process executes S309. S316, executes GC (Garbage Collection) memory recovery. S317, determine whether the memory of the electronic device is sufficient. If the memory of the electronic device is sufficient, the process executes S314; if the memory of the electronic device is insufficient, the process executes S318. S318, stops JIT compilation.

[0081] When the application package is downloaded to the electronic device and runs in the electronic device: S319, start loading the application package. S320, determine whether there is an odex machine code for the application package. If there is no odex machine code for the application package, the process executes S321; if there is an odex machine code for the application package, the process executes S323. S321, use dex2oat to compile the application package. S322, verify the compiled machine code, obtain vdex verification information, and store the verification information in the dex bytecode. S323, save the odex machine code to the disk.

[0082] In order to improve the running efficiency of the application, the application can be compiled in advance: S324, the application package is compiled in the background during daily idle time. S325, the application package is compiled using dex2oat, where the compilation mode is speed-profile. S326, the compiled odex machine code is saved to the ART virtual machine.

[0083] S327, when a function is a hot function, import the function index into the profile. S328, determine whether the change in the profile is greater than or equal to 2%. If the change in the profile is greater than or equal to 2%, the process executes S324.

[0084] During the process of installing or updating the application package, the configuration file is synchronized: S329, the application package is installed / updated. S330, the general configuration file is synchronized with the cloud, and the original configuration file is deleted. Then, the process executes S325.

[0085] The interpreted execution compilation and JIT compilation of the application package are usually performed during the running of the application. After a function is interpreted and executed multiple times, it can be identified as a hot function. After the application package is interpreted and compiled and JIT compiled, each function can be used directly and immediately, regardless of whether there is odex. However, the performance of interpreted execution compilation is poor and power-consuming. The compilation results are not written to the disk, and the application needs to be recompiled after restarting. AOT compilation can compile all hot functions recorded in the configuration file during daily idle time, and store the compilation results in the ROM memory. AOT compilation has good performance and saves power. However, AOT compilation is concentrated in idle time, which can easily cause the device to heat up, the compilation entry conditions are relatively restricted, and the compilation results need to occupy the storage space of the ROM memory.

[0086] See also Figure 5 As shown, it is a processing flow chart of daily idle time compilation task in the related technology.

[0087] S401, after the electronic device is started, a broadcast is sent to the task scheduler service, and a daily idle time compilation task is created through the task scheduler service.

[0088] S402, setting execution conditions of the daily idle time compilation task. For example, the execution conditions of the daily idle time compilation task can be set to include: the execution cycle is once a day, the electronic device is in a charging state, the power of the electronic device is greater than or equal to a preset power threshold (for example, 95%), and the duration of the electronic device being in an idle state is greater than or equal to a preset duration threshold (for example, 31 minutes).

[0089] S403, if the state of the electronic device meets the execution condition of the daily idle time compilation task, the daily idle time compilation task is executed in the background by the compilation optimization program dex2oat to fully compile the application program in the electronic device.

[0090] S404, if the daily idle time compilation task is completed, call onFinishJob and return true, indicating that the daily idle time compilation task is completed.

[0091] S405, if during the execution of the daily idle time compilation task, the state of the electronic device does not meet the execution condition of the daily idle time compilation task, the execution of the daily idle time compilation task is interrupted, and onStopJob is called to return true, indicating that the execution of the daily idle time compilation task is interrupted.

[0092] S406, reporting the execution status of the daily idle time compilation task. For example, reporting the execution status of the daily idle time compilation task to the task scheduler service.

[0093] Since the entry conditions of the daily idle compilation task are relatively harsh, the application often fails to complete the compilation during the fast charging process of the electronic device. For example, the entry conditions of the daily idle compilation task are that the device is in a charging state, the screen is off and idle for half an hour, and the power is greater than 95%, or the entry conditions of the daily idle compilation task are that the device is in a charging state and the screen is off and idle for half an hour. And due to the popularity of fast charging, the number of times electronic devices are charged has increased, but the time for a single charge has shortened. In addition, electronic devices often start charging from a higher initial power, resulting in a time threshold of charging to 95% of less than half an hour. In this way, the state of the electronic device is not easy to meet the entry conditions of idle compilation, and thus the idle compilation cannot be performed in time. In addition, in the night sleep mode, the number of heartbeat wake-ups of the electronic device is small. After the task scheduler service unifies the heartbeat cycle, the wake-up of the electronic device may be delayed by one heartbeat cycle, resulting in a delay in compilation. If the above entry conditions are not set, due to the high load of the electronic device during the application compilation process, the bright screen compilation will cause the foreground application to freeze, cause the device to heat up severely, and increase the power consumption of the device. Compiling during the charging process will increase the heating during the charging process and reduce the charging speed.

[0094] Based on the analysis of the above problems, in actual application, applications often cannot be pre-compiled when the electronic device is idle, and still need to be compiled at runtime, which will lead to an increase in system power consumption and even cause system freezes.

[0095] In order to prevent an application from being unable to complete pre-compilation when an electronic device is idle, an embodiment of the present application provides an application compilation control method. By setting a looser compilation entry condition, the state of the electronic device is more likely to meet the compilation entry condition, thereby increasing the probability of the electronic device performing idle compilation, and ensuring that the application completes pre-compilation of the application when the electronic device is idle, without having to compile when the application is running, thereby effectively reducing system power consumption and system freezes. In addition, a heartbeat wake-up mechanism is used to wake up the electronic device to perform idle compilation when the conditions are met, which can shorten the time the electronic device is in the wake-up state and further reduce system power consumption. The application compilation control method is applied to an electronic device, and the following text will be combined with the following text. Figure 5 A diagram illustrating the software architecture of an electronic device.

[0096] See also Figure 6 As shown, it is a software architecture diagram of the electronic device provided in the embodiment of the present application. The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. For example, the Android system is divided into four layers, from top to bottom, namely, the application layer 101, the framework layer 102, the Android runtime (Androidruntime) and the system library 103, the hardware abstraction layer 104, the kernel layer 105, and the hardware layer 106.

[0097] The application layer 101 may include a series of application packages, such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, device control service and other applications.

[0098] The framework layer 102 provides an application programming interface (API) and a programming framework for the application programs of the application layer. The application framework layer includes some predefined functions. For example, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc.

[0099] Among them, the window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for electronic devices. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify the completion of downloads, message reminders, etc. The notification manager can also be a notification that appears in the top status bar of the system in the form of an icon or scroll bar text, such as a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is prompted in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.

[0100] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library contains two parts: one is the function that the Java language needs to call, and the other is the Android core library.

[0101] The application layer 101 and the framework layer 102 run in a virtual machine. The virtual machine executes the Java files of the application layer and the 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.

[0102] The system library 103 may include multiple functional modules, such as a surface manager, a media library, a 3D graphics processing library (eg, OpenGL ES), a 2D graphics engine (eg, SGL), and the like.

[0103] Among them, the surface manager 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 multiple commonly used audio and video formats, as well as static image files. The media library can support multiple 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. The 2D graphics engine is a drawing engine for 2D drawing.

[0104] The hardware abstraction layer 104 runs in the user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer.

[0105] The kernel layer 105 is a layer between hardware and software. The kernel layer 105 at least includes a display driver, a camera driver, an audio driver, and a sensor driver.

[0106] The kernel layer 105 is the core of the operating system of the electronic device. It is the first layer of software expansion based on hardware, provides the most basic functions of the operating system, is the basis of the operating system, is responsible for managing the system's processes, memory, device drivers, files and network systems, and determines the performance and stability of the system. For example, the kernel can determine the operating time of an application on a certain part of the hardware.

[0107] The kernel layer 105 includes programs closely related to the hardware, such as interrupt handlers, device drivers, etc., and also includes basic, common, and high-frequency modules, such as clock management modules, process scheduling modules, etc., and also includes key data structures. The kernel layer can be set in the processor or solidified in the internal memory.

[0108] The hardware layer 106 includes the hardware of the electronic device, such as a display screen, buttons, a camera, etc.

[0109] In order to better understand the application compilation control method provided by the embodiment of the present application, the application compilation control method provided by the embodiment of the present application is described below with reference to the accompanying drawings.

[0110] See also Figure 7 FIG. 1 is a flowchart of an application compilation control method provided by an embodiment of the present application. The method is applied in an electronic device, and the application compilation control method includes:

[0111] S501, determine whether the electronic device is in the screen-off charging state. If the electronic device is in the screen-off charging state, the process executes S502; if the electronic device is not in the screen-off charging state, the process continues to execute S501.

[0112] In one embodiment of the present application, an electronic device is installed with a power saving wizard application for monitoring the screen on / off state and the charging state of the electronic device. The task scheduler service (JobSchedulerService) of the electronic device registers a listener with the power saving wizard application to monitor the screen on / off state and the charging state of the electronic device monitored by the power saving wizard application. If the power saving wizard application monitors that the electronic device is in the screen off state and the charging state at the same time, a broadcast notification can be sent to the task scheduler service. If the task scheduler service receives a broadcast sent by the power saving wizard application that the electronic device is in the screen off state and the charging state at the same time, it determines that the electronic device is in the screen off and charging state. If the task scheduler service does not receive a broadcast sent by the power saving wizard application that the electronic device is in the screen off state and the charging state at the same time, it determines that the electronic device is not in the screen off and charging state.

[0113] In one embodiment of the present application, when the electronic device is in a screen-off charging state (that is, a dormant state), the electronic device is periodically awakened based on a heartbeat mechanism through a timed reminder service (AlarmService) to process an event or message, and the electronic device continues to enter the dormant state after processing the event or message. The moment of waking up the electronic device is the heartbeat moment, and the period of waking up the electronic device is the heartbeat period. For example, the heartbeat period is 10 seconds, 12 seconds, 15 seconds or other time.

[0114] S502, obtaining an initial charging current and a current power of the electronic device, and determining a time when the power of the electronic device reaches a first preset value according to the initial charging current and the current power of the electronic device.

[0115] In one embodiment of the present application, if the electronic device is in a screen-off charging state, the electronic device is awakened by the power saving wizard application, and the task scheduler service schedules the first compilation task, for example, adding the first compilation task to the task queue, and determining whether the electronic device meets the execution condition of the first compilation task. The first compilation task is a daily idle compilation task, which is used to pre-compile the hotspot functions of all applications in the electronic device when the electronic device is idle.

[0116] In one embodiment of the present application, the initial charging current of the electronic device is determined according to the preset charging strategy of the electronic device. Among them, the preset charging strategy includes the corresponding relationship between multiple preset power percentage ranges of the electronic device and the charging current. For example, the charging current corresponding to the preset power percentage range of 0-20% is 3.5A, the charging current corresponding to the preset power percentage range of 20%-60% is 2.5A, and the charging current corresponding to the preset power percentage range of 60%-100% is 2A. The current power of the electronic device is the power percentage, and the preset power percentage range into which the current power falls is determined, and the corresponding initial charging current is determined according to the preset charging strategy and the preset power percentage range into which the current power falls. In other embodiments of the present application, the electronic device is installed with maintenance and testing software for collecting the real-time charging current of the electronic device through the charging current monitoring interface, so the initial charging current can be obtained from the maintenance and testing software. In one embodiment of the application, the first preset value is 95%, 96%, 97% or other percentage values.

[0117] In one embodiment of the present application, the time Δt=(P1-P2)*C / I required for the power of the electronic device to reach the first preset value is calculated based on the initial charging current and the current power of the electronic device, where P1 is the first preset value, P2 is the current power percentage, I is the initial charging current, and C is the rated power of the electronic device. The moment when the power of the electronic device reaches the first preset value is T1=T0+Δt, where T0 is the current moment. For example, P1 is 95%, P2 is 50%, C is 5500mAh (milliampere-hours), and the initial charging current is 2.5A, then the Δt calculated according to the above calculation formula is 0.99h (hours).

[0118] S503, obtaining the next heartbeat time.

[0119] In one embodiment of the present application, the timing reminder service periodically wakes up the electronic device and obtains the next heartbeat time, that is, obtains the time when the timing reminder service wakes up the electronic device next time.

[0120] S504, determine whether the moment when the electronic device's power reaches the first preset value is before the next heartbeat moment, and determine whether the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration. If the moment when the electronic device's power reaches the first preset value is before the next heartbeat moment, and the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration, the process executes S505; if the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration, the process executes S509; if the moment when the electronic device's power reaches the first preset value is after the next heartbeat moment, and the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration, the process executes S510. Among them, the first preset duration is greater than a single heartbeat cycle and less than two heartbeat cycles. For example, the first preset duration can be 12 seconds, 14 seconds, 18 seconds or other times. To facilitate Figure 7 The judgment conditions involved are clearly described in the flowchart shown, with T1 representing the moment when the battery reaches the first preset value, T2 representing the next heartbeat moment, ΔT representing the difference between the moment when the battery reaches the first preset value and the next heartbeat moment, the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is represented as |ΔT|, and T3 representing the first preset duration. "T1<T2" means that the moment when the battery reaches the first preset value is before the next heartbeat moment, "T1>T2" means that the moment when the battery reaches the first preset value is after the next heartbeat moment, "|ΔT|>T3" means that the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is greater than the first preset duration, and "|ΔT|≤T3" means that the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration.

[0121] S505: Setting the time when the power of the electronic device reaches a first preset value as the precise heartbeat time.

[0122] In one embodiment of the present application, if the moment when the power of the electronic device reaches a first preset value is before the next heartbeat moment, and the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is greater than the first preset duration, indicating that the moment when the power of the electronic device reaches the first preset value is before the next heartbeat moment and the interval time between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is relatively long, the moment when the power of the electronic device reaches the first preset value is set as the precise heartbeat moment, wherein the precise heartbeat moment is the moment when the electronic device is woken up next time.

[0123] S506, when the current time reaches the precise heartbeat time, wake up the electronic device.

[0124] S507, obtaining the real-time power of the electronic device and determining whether the real-time power is greater than or equal to a first preset value. If the real-time power is greater than or equal to the first preset value, the process proceeds to S508; if the real-time power is less than the first preset value, the process returns to S502.

[0125] See also Figure 8 As shown, a schematic diagram of predicting the moment when the power of an electronic device reaches a first preset value provided by an embodiment of the present application. In an embodiment of the present application, at the first heartbeat moment, it is determined whether the electronic device is in a screen-off charging state, and when the electronic device is in a screen-off charging state, the moment when the power of the electronic device reaches the first preset value is predicted. At the next heartbeat moment or the precise heartbeat moment, if the power of the electronic device does not actually reach the first preset value, the moment when the power of the electronic device reaches the first preset value is predicted again based on the charging current and current power of the electronic device, or the moment when the power of the electronic device reaches the first preset value is predicted again based on the power increment between two adjacent heartbeat moments, thereby correcting the moment when the power of the electronic device initially predicted to reach the first preset value. Repeat the above steps until the power of the electronic device reaches the first preset value at a heartbeat moment or a precise heartbeat moment, triggering the execution of the first compilation task, for example, triggering the execution of the daily idle time compilation task.

[0126] Since electronic devices usually generate heat during the charging process, the charging rate may change, such as becoming slower, or the charging rate of some electronic devices may slow down as the power level increases. Therefore, at the moment of a heartbeat, if the actual power level of the electronic device has not reached the first preset value, the moment when the power level of the electronic device reaches the first preset value needs to be updated and corrected.

[0127] S508, executing a first compiling task to compile a plurality of first preset application programs in the electronic device.

[0128] In one embodiment of the present application, when the current moment reaches the precise heartbeat moment and the electronic device is awakened, when it is determined that the power of the electronic device is greater than or equal to the first preset value, an application compilation process is created through the ART virtual machine, and a first compilation task is executed to compile multiple first preset applications in the electronic device. Among them, the multiple first preset applications can be all applications in the electronic device, applications whose configuration file change rate is greater than or equal to a preset percentage, or applications that generate version updates. The configuration file change rate is the ratio between the number of newly added hotspot functions in the configuration file and the total number of hotspot functions. For example, the preset percentage can be 1%, 2%, or other percentage values.

[0129] In one embodiment of the present application, in order of usage from high to low, the hotspot functions of each first preset application are obtained according to the configuration file of each first preset application, and dex2oat is used to compile the bytecode corresponding to the hotspot function of each first preset application into machine code.

[0130] In one embodiment of the present application, the usage rate of an application is determined based on the number of times it is opened and / or the running time within a preset time period. For example, the preset time period is one week, ten days, one month, or other time period. In some embodiments, the electronic device counts the number of times each application is opened within the preset time period, and sorts the usage rates of all applications based on the number of times they are opened, for example, sorting them in order from most to least number of times they are opened. In other embodiments, the electronic device counts the running time of each application within the preset time period, and sorts the usage rates of all applications based on the running time, for example, sorting them in order from longest to shortest running time.

[0131] In another embodiment of the present application, the hotspot function of any first preset application may be randomly obtained according to the configuration file of the first preset application, and the bytecode corresponding to the hotspot function may be compiled into machine code using dex2oat.

[0132] In another embodiment of the present application, when executing the first compilation task, dex2oat may also be used to compile all bytecodes of each first preset application into machine code.

[0133] S509, when the current time reaches the next heartbeat time, wake up the electronic device, execute the first compilation task, and compile multiple first preset application programs in the electronic device.

[0134] In one embodiment of the present application, regardless of whether the moment when the power of the electronic device reaches the first preset value is before or after the next heartbeat moment, if the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration, it indicates that the moment when the power of the electronic device reaches the first preset value is basically consistent with the next heartbeat moment. At this time, there is no need to set the precise heartbeat moment. The electronic device is woken up at the next heartbeat moment, the first compilation task is executed, and multiple first preset applications in the electronic device are compiled.

[0135] S510, when the current time reaches the next heartbeat time, wake up the electronic device and update the time when the power of the electronic device reaches the first preset value. Then, the process jumps to S503 to obtain the next heartbeat time.

[0136] In one embodiment of the present application, if the moment when the power of the electronic device reaches a first preset value is after the next heartbeat moment, and the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is greater than a first preset duration, the current power of the electronic device is obtained, and when the current moment reaches the next heartbeat moment, the electronic device is woken up, and the moment when the power of the electronic device reaches the first preset value is recalculated based on the power increment of the electronic device between two adjacent heartbeat moments to update the moment when the power of the electronic device reaches the first preset value.

[0137] In one embodiment of the present application, the difference between the current power of the electronic device and the power last obtained is calculated to obtain the power increment of the electronic device between two adjacent heartbeat moments, and the moment when the power of the electronic device reaches the first preset value is recalculated according to the difference between the first preset value and the current power and the interval time between two adjacent heartbeat moments. For example, if the current power is 60%, and the power last obtained is 50%, then the power increment of the electronic device between two adjacent heartbeat moments is 10%. If the interval time between two adjacent heartbeat moments is 5 minutes, the first preset value is 95%, and the difference between the first preset value and the current power is 35%, then it takes 17.5 minutes for the electronic device to charge from the current power to the first preset value power. By adding 17.5 minutes to the current moment, the moment when the power of the electronic device reaches the first preset value can be recalculated.

[0138] The above-mentioned embodiments of the present application determine the precise time point when the electronic device is charged to a preset percentage of power based on the heartbeat mechanism, and wake up the electronic device at the precise time point to perform the daily idle compilation task, and pre-compile the application in the electronic device so that the application does not need to be compiled during operation. The precise time point when the electronic device is charged to a preset percentage of power can also be updated and corrected based on the heartbeat mechanism and real-time power, thereby reducing the frequency of waking up the electronic device during the screen-off charging process and effectively reducing system power consumption.

[0139] In another embodiment of the present application, between S501 and S502, the method further includes: determining whether the first compilation task of the day has been completed; if the first compilation task of the day has been completed, exiting the execution of the first compilation task; if the first compilation task of the day has not been completed, the process executes S502.

[0140] In another embodiment of the present application, S503 can be replaced by: obtaining the next heartbeat moment, and determining whether the next heartbeat moment is obtained within the preset time. If the next heartbeat moment is obtained within the preset time, the process executes S504; if the next heartbeat moment is not obtained within the preset time, the next heartbeat moment is set to infinity, or set to a moment that is more than 24 hours away from the current moment, and then the process executes S504 again.

[0141] In another embodiment of the present application, after S507, the method includes: if the real-time power is less than the first preset value, determining whether the real-time power is less than the second preset value, if the real-time power is greater than or equal to the second preset value, waiting with lock, and continuing to charge the electronic device, and then the process returns to execute S507 to monitor the real-time power of the electronic device; if the real-time power is less than the second preset value, the process returns to execute S502. In another embodiment of the present application, waiting with lock means that the power saving wizard application obtains the wake-up lock of the electronic device, so that the electronic device remains in the awake state and prevents the electronic device from entering the dormant state. When the real-time power of the electronic device is less than the first preset value and greater than or equal to the second preset value, it indicates that the real-time power of the electronic device is about to reach the first preset value. At this time, the power saving wizard application can wait with lock, and execute the first compilation task when the power of the electronic device reaches the first preset value, without re-predicting the moment when the power of the electronic device reaches the first preset value. In another embodiment of the present application, the second preset value is less than the first preset value, for example, the second preset value is 94%, 95%, 96% or other percentage values.

[0142] In another embodiment of the present application, S509 can be replaced by: when the current moment reaches the next heartbeat moment, wake up the electronic device, obtain the real-time power of the electronic device, and determine whether the real-time power is greater than or equal to the first preset value. If the real-time power is greater than or equal to the first preset value, execute the first compilation task to compile multiple first preset applications in the electronic device; if the real-time power is less than the first preset value, determine whether the real-time power is less than the second preset value. If the real-time power is greater than or equal to the second preset value, hold the lock and wait, continue to charge the electronic device, and then the process returns to execute S507 to monitor the real-time power of the electronic device; if the real-time power is less than the second preset value, the process returns to execute S502.

[0143] In another embodiment of the present application, after S508 and S509, the method further includes: during the execution of the first compilation task, monitoring whether the electronic device turns on the screen or stops charging, if the electronic device is monitored to turn on the screen and / or stop charging, exiting the execution of the first compilation task; if the electronic device is not monitored to turn on the screen and is not monitored to stop charging, continuing to execute the first compilation task.

[0144] In another embodiment of the present application, the method also includes: monitoring whether the electronic device is in a charging state; if the electronic device is in a charging state, listening to the power broadcast of the electronic device, determining whether the power of the electronic device is greater than or equal to a first preset value; if the power of the electronic device is greater than or equal to the first preset value, triggering the execution of a first compilation task.

[0145] In another embodiment of the present application, for the scenario where the electronic device is charging and not in sleep mode, the power saving wizard application is in operation and monitors the power of the electronic device in real time. The task scheduler service can register a listener with the power saving wizard application to monitor the power broadcast. When the power of the electronic device is charged to a first preset value, the power saving wizard application sends a power broadcast to the task scheduler service. After receiving the power broadcast, the task scheduler service sends a directional broadcast to the ART virtual machine. The ART virtual machine creates a daily idle compilation process to execute the daily idle compilation task to compile multiple first preset applications in the electronic device.

[0146] See also Figure 9-10 FIG. 1 is a flowchart of an application compilation control method provided by another embodiment of the present application. The method is applied in an electronic device, and the application compilation control method includes:

[0147] S601, after the electronic device is turned on, determine whether the current boot is the first boot after the operating system is updated. If the current boot is the first boot after the operating system is updated, the process executes S602; if the current boot is not the first boot after the operating system is updated, the process executes S604.

[0148] S602, monitoring whether the state of the electronic device meets the preset condition. If the state of the electronic device meets the preset condition, the process executes S603; if the state of the electronic device does not meet the preset condition, the process continues to execute S602.

[0149] In one embodiment of the present application, if the electronic device is powered on for the first time after the operating system is updated, the flag mlsHasFastIdle is set to true. When it is detected that the flag mlsHasFastIdle is set to true, the state of the electronic device is monitored to see whether it meets a preset condition.

[0150] In one embodiment of the present application, the preset conditions include but are not limited to: the screen off time of the electronic device is greater than or equal to the second preset time, and the power of the electronic device is greater than or equal to the third preset value. The second preset time can be 30 minutes, 31 minutes, 32 minutes or other time, and the third preset value is 30%, 40%, 50% or other percentage values.

[0151] S603, executing a second compiling task to compile a plurality of second preset application programs in the electronic device.

[0152] In one embodiment of the present application, if the current boot is the first boot after the operating system is updated, the task scheduler service creates a second compilation task and monitors whether the state of the electronic device meets the preset conditions for executing the second compilation task. If the state of the electronic device meets the preset conditions for executing the second compilation task, a broadcast notification is sent to the ART virtual machine to create an application compilation thread to execute the second compilation task. The second compilation task is a fast idle compilation task, and the multiple second preset applications can be multiple commonly used applications in the electronic device or multiple applications preset by the user. The electronic device implements the pre-compilation of applications after the first boot after the operating system is updated by executing the second compilation task.

[0153] In one embodiment of the present application, the electronic device includes a preset application list for recording multiple second preset applications in the electronic device. Among them, the multiple second preset applications can be applications with a usage rate ranked in the top fourth preset value among all applications of the electronic device or all third-party applications. Among them, the application with a usage rate ranked in the top fourth preset value refers to multiple applications with a higher usage rate corresponding to the fourth preset value within a preset time period. The fourth preset value is 10, 12, 15 or other values. In one embodiment of the present application, the usage rate of the application is determined according to the number of openings and / or running time within a preset time period. For example, the preset time period is a week, ten days, a month or other time period. In some embodiments, the electronic device counts the number of times each third-party application is opened within the preset time period, and adds the name of the application with the number of openings ranked in the top fourth preset value to the preset application list. In other embodiments, the electronic device counts the running time of each third-party application within the preset time period, and adds the name of the application with the running time ranked in the top fourth preset value to the preset application list.

[0154] In one embodiment of the present application, the dex file of the second preset application in the preset application list is obtained according to the order of usage from high to low, and the dex file of the second preset application is compiled using dex2oat to obtain the corresponding odex file. In other embodiments, the second preset application in the preset application list can also be compiled according to a random order.

[0155] S604, determine whether the electronic device is in the screen-off charging state. If the electronic device is in the screen-off charging state, the process executes S605; if the electronic device is not in the screen-off charging state, the process continues to execute S604.

[0156] S605, obtaining an initial charging current and a current power of the electronic device, and determining a time when the power of the electronic device reaches a first preset value according to the initial charging current and the current power of the electronic device.

[0157] S606, obtaining the next heartbeat time.

[0158] S607, determine whether the moment when the electronic device's power reaches the first preset value is before the next heartbeat moment, and determine whether the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration. If the moment when the electronic device's power reaches the first preset value is before the next heartbeat moment, and the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration, the process executes S609; if the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration, the process executes S610; if the moment when the electronic device's power reaches the first preset value is after the next heartbeat moment, and the absolute value of the difference between the moment when the electronic device's power reaches the first preset value and the next heartbeat moment is greater than the first preset duration, the process executes S611. Among them, the first preset time can be 1 second, 2 seconds, 3 seconds or other time. To facilitate Fig.10 The judgment conditions involved are clearly described in the flowchart shown, with T1 representing the moment when the battery reaches the first preset value, T2 representing the next heartbeat moment, ΔT representing the difference between the moment when the battery reaches the first preset value and the next heartbeat moment, the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is represented as |ΔT|, and T3 representing the first preset duration. "T1<T2" means that the moment when the battery reaches the first preset value is before the next heartbeat moment, "T1>T2" means that the moment when the battery reaches the first preset value is after the next heartbeat moment, "|ΔT|>T3" means that the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is greater than the first preset duration, and "|ΔT|≤T3" means that the absolute value of the difference between the moment when the battery reaches the first preset value and the next heartbeat moment is less than or equal to the first preset duration.

[0159] S608: Set the time when the power of the electronic device reaches a first preset value as the precise heartbeat time.

[0160] S609, when the current time reaches the precise heartbeat time, wake up the electronic device.

[0161] S610, obtaining the real-time power of the electronic device and determining whether the real-time power is greater than or equal to a first preset value. If the real-time power is greater than or equal to the first preset value, the process proceeds to S611; if the real-time power is less than the first preset value, the process returns to S605.

[0162] S611, executing a first compiling task to compile a plurality of first preset application programs in the electronic device.

[0163] In one embodiment of the present application, if the current boot is not the first boot after the operating system is updated, the task scheduler service creates a first compilation task and monitors whether the state of the electronic device meets the preset conditions for executing the first compilation task. If the state of the electronic device meets the preset conditions for executing the first compilation task, a broadcast notification is sent to the ART virtual machine to create an application compilation thread to execute the first compilation task.

[0164] S612, when the current time reaches the next heartbeat time, wake up the electronic device, execute the first compilation task, and compile multiple first preset application programs in the electronic device.

[0165] S613, when the current time reaches the next heartbeat time, wake up the electronic device and update the time when the power of the electronic device reaches the first preset value. Then, the process jumps to S606 to obtain the next heartbeat time.

[0166] The specific implementation of S604-S613 is the same as above Figure 7 The specific implementation methods of the processes S501 - S510 are the same and will not be described in detail here.

[0167] The above-mentioned embodiment of the present application can execute the second compilation task first after the electronic device is turned on for the first time after the operating system is updated, and pre-compile the applications commonly used by users in the electronic device, so that the commonly used applications do not need to be compiled during operation, effectively reducing system power consumption and avoiding system freezes. If the current startup of the electronic device is not the first startup after the operating system is updated, the first compilation task is executed to fully compile the applications in the electronic device.

[0168] In another embodiment of the present application, after S603, the process jumps to S604, and compiles other applications other than the plurality of second preset applications in the electronic device by executing the second compilation task.

[0169] In another embodiment of the present application, the preset conditions include but are not limited to: the screen off time of the electronic device is greater than or equal to the second preset time, and the electronic device is in a charging state. In another embodiment of the present application, after the electronic device completes the HOTA upgrade and the jar package of the application, application service, or system file changes, if the screen off time of the electronic device is greater than or equal to the second preset time, and the electronic device is in a charging state, the user's commonly used applications in the electronic device can be pre-compiled by executing the second compilation task.

[0170] In another embodiment of the present application, the preset conditions include but are not limited to: the screen-off time of the electronic device is greater than or equal to the third preset duration, and the electronic device is in a stationary state. For example, the third preset duration is 3 minutes, 4 minutes, 5 minutes or other time. The electronic device being in a stationary state means that when the electronic device is in a screen-off state, the electronic device is awakened by periodically sending heartbeat information, and after the electronic device is awakened, the activity recognition service (ActivityRecognition) detects that the electronic device is in a stationary state. If the activity recognition service detects that the electronic device is moving or the screen is on, the execution of the second compilation task is interrupted.

[0171] See also Fig.11 The figure shows an operation flow chart of the task scheduler service provided in one embodiment of the present application.

[0172] S701, when the system starts, start the task scheduler service (JobSchedulerService).

[0173] S702, register a listener.

[0174] In one embodiment of the present application, the listener includes a battery charging status listener, a power level listener, an idle status listener, a timed reminder listener, and the like.

[0175] S703: When a specified event is generated, a corresponding event broadcast is received.

[0176] In one embodiment of the present application, the specified event includes the time when the electronic device enters the idle state reaches a preset time, the electronic device enters or exits the charging state, the battery power is greater than or equal to a preset percentage, etc. It can be determined whether the specified time occurs according to the corresponding event flag bit, for example, if the time when the electronic device enters the idle state reaches a preset time, the flag bit indicating that the electronic device is idle changes from false to true; if the electronic device enters the charging state, the flag bit indicating that the electronic device is in the charging state changes from false to true; if the electronic device exits the charging state, the flag bit indicating that the electronic device is in the charging state changes from true to false; if the battery power is greater than or equal to a preset percentage, the flag bit notlow indicating that the electronic device has sufficient power changes from false to true.

[0177] S704, traverse the tasks to be processed according to the specified event.

[0178] S705, if there is a task to be processed, determine whether the triggering condition of the task to be processed is met. If the triggering condition of the task to be processed is met, the process executes S706; if the triggering condition of the task to be processed is not met, the process executes S711.

[0179] S706, if the task to be processed is a periodic task, determine whether the task to be processed meets the period. If the task to be processed meets the period, the process executes S707; if the task to be processed does not meet the period, the process executes S711.

[0180] S707, asynchronously executing the task through the child thread.

[0181] In one embodiment of the present application, during the execution of a task, the task scheduler service traverses the tasks to be processed. The traversal process at this time is asynchronously executed, and the child thread holds the task lock to prevent the electronic device from entering a sleep state.

[0182] S708: If the task is completed, set a task completion flag.

[0183] S709: If the triggering condition of the task is not met during the execution of the task, the current task is interrupted and the task processing progress is recorded.

[0184] S710: Report the task execution result.

[0185] S711: Do not execute the pending task. Then, the process returns to execute S704.

[0186] S712: If there is no pending task, this traversal is completed.

[0187] According to the above-mentioned embodiment of the present application, after the electronic device is turned on, the task scheduler service is turned on. The task scheduler service monitors the changes of system events by registering a listener. After the system event changes, the listener sends a broadcast to the task scheduler service. The task scheduler service traverses all tasks and checks the tasks that can be executed. When it traverses to the tasks that can be executed after the state changes, it starts the child thread to asynchronously execute the task and holds the wakelock of the task. When it traverses to the tasks that do not meet the running conditions after the state changes, it stops the running of the task, records the current progress and waits for the next time the conditions are met to continue, and waits for the next broadcast after the traversal ends. If a task is completed, the completion Flag is set. If it is a periodic task, the task will not be scheduled before the next cycle.

[0188] See also Fig.12 , which is a flowchart of an application compilation control method provided by another embodiment of the present application.

[0189] S801, electronic equipment is turned on.

[0190] S802, if the electronic device is powered on for the first time after the operating system is updated, the task scheduler service creates a fast idle compilation task and sets the execution conditions of the fast idle compilation task. For example, the execution conditions of the fast idle compilation task include: the power of the electronic device is greater than or equal to the third preset value, and the screen off time of the electronic device is greater than or equal to the second preset duration.

[0191] S803, if the electronic device is not turned on for the first time after the operating system is updated, the task scheduler service creates a daily idle compilation task and sets the execution conditions of the daily idle compilation task. For example, the execution conditions of the daily idle compilation task include: the electronic device is in a charging state, the screen off time of the electronic device is greater than or equal to the second preset time, and the power of the electronic device is greater than or equal to the first preset value.

[0192] S804, determine whether the screen off time of the electronic device is greater than or equal to the second preset time. If the screen off time of the electronic device is greater than or equal to the second preset time, the process executes S805; if the screen off time of the electronic device is less than the second preset time, the process continues to execute S804.

[0193] S805, determining whether the electronic device is in a charging state. If the electronic device is in a charging state, the process proceeds to S806; if the electronic device is not in a charging state, the process proceeds to S809.

[0194] S806, determine whether the power of the electronic device is greater than or equal to a first preset value. If the power of the electronic device is greater than or equal to the first preset value, the process proceeds to S807; if the power of the electronic device is less than the first preset value, the process continues to proceed to S806.

[0195] S807, executing the daily idle time compilation task to compile all the applications in the electronic device, for example, compiling the hot functions of all the applications in the electronic device.

[0196] S808, if there is a fast idle compile task, delete the fast idle compile task, and recreate and set the fast idle compile task when the computer is powered on for the first time after the next operating system update.

[0197] S809, determining whether the power level of the electronic device is greater than or equal to a third preset value. If the power level of the electronic device is greater than or equal to the third preset value, the process proceeds to S810; if the power level of the electronic device is less than the third preset value, the process continues to proceed to S809.

[0198] S810, executing a fast idle time compilation task to compile commonly used applications in the electronic device, for example, compiling the top 15 applications in the electronic device in terms of usage rate.

[0199] The present application also provides an electronic device 100. Fig.13 As shown, the electronic device 100 can be 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), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, a vehicle-mounted device, a smart home device and / or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the electronic device 100.

[0200] 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. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0201] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, 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.

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

[0203] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.

[0204] The processor 110 may also be provided with a memory for storing instructions and data. In one embodiment of the present application, 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 instructions 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.

[0205] In one embodiment of the present application, the processor 110 may include one or more interfaces. The interface may include an Inter-integrated Circuit (I2C) interface, an Inter-integrated Circuit 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.

[0206] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In one embodiment of the present application, the processor 110 may include multiple groups of I2C buses. The processor 110 can be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces. For example: the processor 110 can be coupled to the touch sensor 180K through the I2C interface, so that the processor 110 communicates with the touch sensor 180K through the I2C bus interface to realize the touch function of the electronic device 100.

[0207] The I2S interface can be used for audio communication. In one embodiment of the present application, the processor 110 may include multiple I2S buses. The processor 110 may be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170. In one embodiment of the present application, the audio module 170 may transmit an audio signal to the wireless communication module 160 via the I2S interface to achieve the function of answering a call via a Bluetooth headset.

[0208] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In one embodiment of the present application, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In one embodiment of the present application, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface to realize the function of answering a call via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0209] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In one embodiment of the present application, the UART interface is generally used to connect the processor 110 and the wireless communication module 160. For example: the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface to implement the Bluetooth function. In one embodiment of the present application, the audio module 170 can transmit an audio signal to the wireless communication module 160 through the UART interface to implement the function of playing music through a Bluetooth headset.

[0210] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In one embodiment of the present application, the processor 110 and the camera 193 communicate via the CSI interface to realize the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the DSI interface to realize the display function of the electronic device 100.

[0211] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In one embodiment of the present application, the GPIO interface can be used to connect the processor 110 with the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0212] The USB interface 130 is an interface that complies with the USB standard specification, and can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transfer data between the electronic device 100 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices 100, such as AR devices, etc.

[0213] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0214] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device 100 through the power management module 141.

[0215] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

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

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

[0218] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (Low Noise Amplifier, LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In one embodiment of the present application, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In one embodiment of the present application, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0219] The modem processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to a speaker 170A, a receiver 170B, etc.), or displays an image or video through a display screen 194. In one embodiment of the present application, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be arranged in the same device as the mobile communication module 150 or other functional modules.

[0220] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0221] In one embodiment of the present application, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include Global System For Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a Global Positioning System (GPS), a Global Navigation Satellite System (GLONASS), a Beidou Navigation Satellite System (BDS), a Quasi-Zenith Satellite System (QZSS) and / or a Satellite Based Augmentation System (SBAS).

[0222] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor controlled by application compilation, connecting 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.

[0223] 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. In one embodiment of the present application, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.

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

[0225] 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 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 one embodiment of the present application, ISP can be set in camera 193.

[0226] 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 optical 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 one embodiment of the present application, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

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

[0228] The video codec is used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0229] 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. Through NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0230] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).

[0231] Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation DDR SDRAM is generally called DDR5 SDRAM), etc.;

[0232] Non-volatile memory may include disk storage devices and flash memory.

[0233] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle. It can be divided into single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage unit potential level. It can be divided into universal flash storage (UFS), embedded Multi Media Card (eMMC), etc. according to the storage specification.

[0234] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.

[0235] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .

[0236] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 through the external memory interface 120 to implement a data storage function. For example, files such as music and videos are stored in the external non-volatile memory.

[0237] The internal memory 121 or the external memory interface 120 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 110. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 110, the screen display detection method executed on the electronic device 100 in the above embodiment can be implemented to implement the screen display detection function of the electronic device 100.

[0238] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0239] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In one embodiment of the present application, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0240] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0241] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0242] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

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

[0244] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.

[0245] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0246] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power changes, messages, missed calls, notifications, etc.

[0247] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In one embodiment of the present application, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100. The embodiment of the present application also provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on the electronic device 100, the electronic device 100 executes the above-mentioned related method steps to implement the application compilation control method in the above-mentioned embodiment.

[0248] The embodiment of the present application also provides a computer program product. When the computer program product is run on a computer, the computer is caused to execute the above-mentioned related steps to implement the application compilation control method in the above-mentioned embodiment.

[0249] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer execution instructions, and when the device is running, the processor can execute the computer execution instructions stored in the memory so that the chip executes the application compilation control method in the above-mentioned method embodiments.

[0250] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above and will not be repeated here.

[0251] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0252] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0253] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0254] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0255] 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 readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program code.

[0256] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present application and are not intended to limit it. Although the present application has been described in detail with reference to the preferred embodiments, a person of ordinary skill in the art should understand that the technical solution of the present application may be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present application.

Claims

1. An application compilation control method, applied to electronic equipment, characterized in that: The method comprises: If the electronic device is in a screen-off charging state, obtaining an initial charging current and a current power of the electronic device, and determining a time when the power of the electronic device reaches a first preset value according to the initial charging current and the current power of the electronic device; Obtaining the next heartbeat time, if the time when the power of the electronic device reaches the first preset value is before the next heartbeat time, and the absolute value of the difference between the time when the power of the electronic device reaches the first preset value and the next heartbeat time is greater than a first preset duration, setting the time when the power of the electronic device reaches the first preset value as the precise heartbeat time; Waking up the electronic device at the precise heartbeat moment and acquiring the real-time power level of the electronic device; If the real-time power level is greater than or equal to the first preset value, executing a first compiling task to compile a plurality of first preset application programs in the electronic device; If the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the moment of the next heartbeat is less than or equal to the first preset duration, waking up the electronic device at the next heartbeat moment, executing the first compiling task, and compiling the multiple first preset applications in the electronic device; If the moment when the power of the electronic device reaches the first preset value is after the next heartbeat moment, and the absolute value of the difference between the moment when the power of the electronic device reaches the first preset value and the next heartbeat moment is greater than the first preset duration, the electronic device is woken up at the next heartbeat moment, and the moment when the power of the electronic device reaches the first preset value is updated.

2. The application compilation control method according to claim 1, characterized in that: The method further comprises: After waking up the electronic device at the next heartbeat moment, the real-time power level of the electronic device is obtained. If the real-time power level is greater than or equal to the first preset value, the first compilation task is executed to compile the multiple first preset applications in the electronic device.

3. The application compilation control method according to claim 1, characterized in that: The first compilation task is a daily idle-time compilation task, which is used to pre-compile the multiple first preset application programs in the electronic device when the electronic device is in an idle state with one day as a cycle.

4. The application compilation control method according to claim 3, characterized in that: The multiple first preset applications include one or more of the following applications: all applications in the electronic device, applications in the electronic device with a configuration file change rate greater than or equal to a preset percentage, and applications in the electronic device that have generated version updates.

5. The application compilation control method according to claim 3, characterized in that: The compiling of a plurality of first preset application programs in the electronic device includes: The hotspot functions of each first preset application are obtained according to the configuration file of each first preset application of the electronic device, and the bytecode corresponding to the hotspot function of each first preset application is compiled into machine code using a compilation optimization program.

6. The application compilation control method according to claim 1, characterized in that: The method further comprises: During the execution of the first compiling task, if it is detected that the electronic device turns on the screen and / or stops charging, the execution of the first compiling task is exited.

7. The application compilation control method according to claim 1, characterized in that: The method further comprises: If the electronic device is powered on for the first time after the operating system is updated and the state of the electronic device meets a preset condition, a second compilation task is executed to pre-compile a plurality of second preset application programs in the electronic device.

8. The application compilation control method according to claim 7, characterized in that: The pre-compiling of a plurality of second preset application programs in the electronic device comprises: Obtaining a list of preset applications in the electronic device; Pre-compile a plurality of second preset application programs in the preset application program list.

9. The application compilation control method according to claim 8, characterized in that: The pre-compiling of the plurality of second preset applications in the preset application list comprises: The dex file of the second preset application is obtained, and the dex file of the second preset application is compiled using a compilation optimization program to obtain an odex file.

10. The application compilation control method according to claim 7, characterized in that: The preset conditions include: the screen-off time of the electronic device is greater than or equal to a second preset duration, and the power of the electronic device is greater than or equal to a second preset value.

11. The application compilation control method according to claim 7, characterized in that: The preset conditions include: the screen-off time of the electronic device is greater than or equal to a third preset time length, and the electronic device is in a stationary state.

12. The application compilation control method according to any one of claims 7 to 11, characterized in that: The plurality of second preset application programs are application programs with usage rates in the electronic device ranked in the top third preset value or application programs preset by the user, and the second compilation task is a fast idle compilation task.

13. An application compilation control method, applied to electronic equipment, characterized in that: The method comprises: After the operating system of the electronic device is updated and the state of the electronic device meets a preset condition, executing a second compiling task to compile a plurality of second preset application programs in the electronic device; According to the application compilation control method according to any one of claims 1 to 6, a first compilation task is performed on other application programs in the electronic device other than the plurality of second preset application programs.

14. The application compilation control method according to claim 13, characterized in that: The second compilation task is a fast idle compilation task, and the plurality of second preset applications are applications whose usage rates in the electronic device are ranked in the top third preset value or applications preset by the user.

15. An electronic device, characterized in that: The electronic device comprises 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. When the program instructions are executed by the processor, the electronic device executes the application compilation control method according to 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, a processor of the electronic device executes the application compilation control method according to any one of claims 1 to 14.

Citation Information

Patent Citations

  • Application optimization method and device and electronic equipment

    CN115185652A

  • Compiling method and device

    CN115268921A

  • Application program optimization method and electronic equipment

    CN116643778A

  • Method and device for compiling application program

    CN117130617A

  • Application program pre-compilation method and apparatus, server and storage medium

    WO2021115178A1