Method and electronic device for performing drawing operations by an application

JP7635859B2Active Publication Date: 2025-02-26HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2023558327
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-03-24
Filing Date
2022-03-21
Publication Date
2025-02-26
Estimated Expiration
2042-03-21

Smart Images

  • Figure 0007635859000002
    Figure 0007635859000002
  • Figure 0007635859000003
    Figure 0007635859000003
  • Figure 0007635859000004
    Figure 0007635859000004
Patent Text Reader

Abstract

The present invention provides a method and an electronic device for performing drawing operations by an application. The method for performing drawing operations by an application includes the steps of: determining a background drawing frequency of an application program; and, when the application program is switched to a background application, intercepting the drawing operations of the application program, so that the application program performs drawing operations at the background drawing frequency. This can reduce the frequency with which the background application performs invalid drawing operations. According to the method for performing drawing operations by an application provided in the present application, the occupation of system resources by background applications can be reduced, and the power consumption of the electronic device can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] [Related Applications] This application claims priority to Chinese Patent Application No. 202110316341.X, filed on March 24, 2021, entitled "METHOD FOR PERFORMING DRAWING OPERATION BY APPLICATION AND ELECTRONIC DEVICE," which is hereby incorporated by reference in its entirety.

[0002] [Technical field] The present application relates to the field of electronic technology, and more particularly to a method and electronic device for performing drawing operations by an application. [Background technology]

[0003] With the popularity of electronic devices such as smartphones, tablets, and wearable devices, users often unintentionally launch multiple or dozens of application programs when using electronic devices such as smartphones. During use, the screen of the smart device can only display a small number of application programs for users to view and operate. If the user does not completely close the application programs in the background in a timely manner, the user will experience obvious frame freezes, heat, and increased power consumption after a certain period of use.

[0004] This is because after an application program is changed from a foreground application to a background application, the application program still occupies the system resources of the electronic device, such as memory and CPU computation load, and performs drawing operations. In the case of a background application, the drawing operations are performed meaninglessly because the background application does not provide a visual interface or view to the user. However, the meaningless drawing operations continue to occupy the system resources of the electronic device. As a result, the power consumption of the electronic device increases and the system resources of the foreground application are occupied.

[0005] To reduce the occupation of system resources by background applications, the electronic device can proactively freeze the application when the application program becomes a background application or after a certain period of time to prevent the application from continuously occupying system resources.

[0006] However, a frozen application is usually awakened by a broadcast, a service, etc. Like any non-frozen background application, an awakened background application occupies system resources and performs pointless drawing operations. As a result, the background application occupies system resources of foreground applications, resulting in increased power consumption of the electronic device. Summary of the Invention

[0007] The embodiment of the present application provides a method for performing drawing operations by an application. The frequency with which a background application performs meaningless drawing operations is reduced by intercepting a vertical synchronization signal or a callback method in a choreographer, or deleting animation event tasks stored by the choreographer. This reduces the occupation of system resources by the background application and reduces the power consumption of the electronic device.

[0008] According to a first aspect, the present application provides a method of performing a drawing operation by an application, the method comprising: the electronic device launching a first application program; the electronic device performing drawing operations at a first frequency when the first application program is a foreground application, the drawing operations drawing a view for the first application program; the electronic device performing the drawing operation at a second frequency after the first application program is switched from the foreground application to a background application, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; Includes.

[0009] In the above embodiment, after determining that the application program is switched from a foreground application to a background application, the electronic device reduces the rendering frequency of the application program, and the rendering frequency is lower than the frequency at which the application program receives a vertical synchronization signal, thereby reducing the occupation of system resources by the background application and reducing the heat generation and power consumption of the electronic device.

[0010] With reference to some examples of the first aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, the electronic device instructs a choreographer of the first application program to respond to only N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0011] In the above embodiment, the electronic device instructs the choreographer of the application program to respond to only a portion of the received vertical synchronization signal, thereby reducing the frequency of performing drawing operations, and further reducing the occupation of system resources by background applications, heat generation and power consumption of the electronic device.

[0012] With reference to some examples of the first aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, the electronic device instructs a choreographer of the first application program to process only animation event tasks corresponding to N vertical synchronization signals out of the K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0013] In the above embodiment, the electronic device instructs the choreographer of the application program to process only animation event tasks corresponding to some of the received vertical synchronization signals, thereby reducing the frequency of performing drawing operations, and further reducing the occupation of system resources by background applications, and the heat and power consumption of the electronic device.

[0014] With reference to some examples of the first aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, the electronic device instructs a choreographer of the first application program to delete animation event tasks corresponding to KN vertical synchronization signals out of the K vertical synchronization signals received, so that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0015] In the above embodiment, the electronic device deletes the animation event task saved by the choreographer of the application program, so that the drawing operation performed by the background application becomes a null operation, thereby reducing the occupation of system resources by the background application and the heat and power consumption of the electronic device.

[0016] With reference to some embodiments of the first aspect, in some embodiments the ratio of N to K corresponds to the ratio of said second frequency to said first frequency.

[0017] With reference to some embodiments of the first aspect, in some embodiments, the ratio of N to K is equal to the ratio of the second frequency to the first frequency.

[0018] Referring to some embodiments of the first aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, when the application program does not receive a vertical synchronization signal at the first frequency but receives a vertical synchronization signal at a third frequency, the electronic device performs drawing operations at a frequency lower than a fourth frequency, where the third frequency is lower than the first frequency, and the fourth frequency is less than or equal to the third frequency and greater than 0.

[0019] In the above embodiment, the application program can perform drawing operations at a frequency not exceeding a certain value, thereby reducing the frequency of performing drawing operations, and further reducing the occupation of system resources by background applications, and the heat and power consumption of electronic devices.

[0020] Referring to some embodiments of the first aspect, in some embodiments, when the first application program receives a first vertical synchronization signal, the electronic device determines whether a time difference between a time when the first application program received the first vertical synchronization signal and a time when the first application program last performed the drawing operation is less than the reciprocal of the fourth frequency. If the time difference is less than the reciprocal, the electronic device intercepts the first drawing operation, the first drawing operation being a drawing operation performed by the first application program in response to the first vertical synchronization signal. If the time difference is not less than the reciprocal, the electronic device performs the first drawing operation.

[0021] In the above embodiment, when the application program executes the drawing operation for the purpose of not refreshing the interface, the application program can execute the drawing operation at a frequency that does not exceed a certain value, thereby reducing the frequency of executing the drawing operation, and further reducing the occupation of system resources by background applications, the heat generation and power consumption of electronic devices, and further achieving a dynamic balance between system stop and execution.

[0022] Referring to some embodiments of the first aspect, in some embodiments, the electronic device determines the second frequency according to a drawing frequency limit policy and the first application program.

[0023] In the above embodiment, the electronic device can determine the frequency of performing drawing operations by different application programs according to the drawing frequency limit policy, thereby simultaneously realizing differentiated allocation of system resources and reducing heat generation and power consumption of the electronic device.

[0024] With reference to some embodiments of the first aspect, in some embodiments, the electronic device determines whether the first application program is the foreground application or the background application based on an activity manager service and / or a cpuset parameter of the process of the first application program.

[0025] In the above embodiment, based on the activity manager service and / or cpuset parameters of the process of the application program, it can determine whether the application program has been switched from a foreground application to a background application, thereby improving the recognition accuracy of the background application, more accurately reducing the frequency at which the background application performs drawing operations, and further reducing the heat and power consumption of the electronic device.

[0026] With reference to some embodiments of the first aspect, in some embodiments N is equal to 0.

[0027] In the above embodiment, when the application program is a background application, the electronic device can instruct the application program not to perform drawing operations, allowing the application program to release system resources, thereby reducing heat generation and power consumption of the electronic device.

[0028] With reference to some embodiments of the first aspect, in some embodiments N is equal to K.

[0029] In the above embodiment, when the application program is a background application, when / after the application program receives a vertical synchronization signal, the animation event task stored by the application program can be deleted, so that all drawing operations performed by the application program become null operations, thereby releasing more system resources and further reducing the heat generation and power consumption of the electronic device.

[0030] According to a second aspect, the present application provides a method of performing a drawing operation by an application, the method comprising: the electronic device launching a first application program; the electronic device displaying an interface of the first application program, the electronic device performing drawing operations at a first frequency, the drawing operations drawing a view for the first application program; the electronic device closes the display of the interface of the first application program, and the electronic device executes the drawing operation at a second frequency, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; Includes.

[0031] In the above embodiment, when an application program closes the display of an interface, there is no need to perform a drawing operation to refresh the interface, which can reduce the frequency with which an application performs drawing operations, thereby reducing the occupation of system resources by background applications and reducing heat generation and power consumption of electronic devices.

[0032] With reference to some embodiments of the second aspect, in some embodiments, the electronic device closes the display of an interface of a first application program, where the first application program is a background application.

[0033] In the above embodiment, when the application program does not display an interface and is a background application, there is no need to perform drawing operations to refresh the interface, so that the electronic device can reduce the frequency with which the application performs drawing operations, thereby reducing the occupation of system resources by background applications and reducing heat generation and power consumption of the electronic device.

[0034] With reference to some examples of the second aspect, in some embodiments, the electronic device instructs a choreographer of the first application program to respond to only N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0035] In the above embodiment, the electronic device instructs a choreographer of the first application program to process only animation event tasks corresponding to N vertical synchronization signals out of the K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0036] With reference to some embodiments of the second aspect, in some embodiments, when the electronic device does not display an interface of the first application program, the electronic device instructs a choreographer of the first application program to process only animation event tasks corresponding to N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0037] In the above embodiment, the electronic device instructs the choreographer of the application program to process only animation event tasks corresponding to some of the received vertical synchronization signals, thereby reducing the frequency of performing drawing operations, and further reducing the occupation of system resources by background applications, and the heat and power consumption of the electronic device.

[0038] With reference to some embodiments of the second aspect, in some embodiments, the electronic device instructs a choreographer of the first application program to delete animation event tasks corresponding to KN vertical synchronization signals out of the K vertical synchronization signals received, such that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0039] In the above embodiment, the electronic device deletes the animation event task saved by the choreographer of the application program, so that the drawing operation performed by the background application becomes a null operation, thereby reducing the occupation of system resources by the background application and the heat and power consumption of the electronic device.

[0040] With reference to some embodiments of the second aspect, in some embodiments the ratio of N to K corresponds to the ratio of said second frequency to said first frequency.

[0041] With reference to some embodiments of the second aspect, in some embodiments the ratio of N to K is equal to the ratio of the second frequency to the first frequency.

[0042] Referring to some embodiments of the second aspect, in some embodiments, after the electronic device displays an interface of the first application program, when the application program does not receive a vertical synchronization signal at the first frequency but receives a vertical synchronization signal at a third frequency, the electronic device performs a drawing operation at a frequency lower than a fourth frequency, where the third frequency is lower than the first frequency, and the fourth frequency is less than or equal to the third frequency and greater than 0.

[0043] In the above embodiment, the application program can perform drawing operations at a frequency not exceeding a certain value, thereby reducing the frequency of performing drawing operations, and further reducing the occupation of system resources by background applications, and the heat and power consumption of electronic devices.

[0044] Referring to some embodiments of the second aspect, in some embodiments, when the first application program receives a first vertical synchronization signal, the electronic device determines whether a time difference between a time when the first application program received the first vertical synchronization signal and a time when the first application program last performed the drawing operation is less than the reciprocal of the fourth frequency. If the time difference is less than the reciprocal, the electronic device intercepts the first drawing operation, the first drawing operation being a drawing operation performed by the first application program in response to the first vertical synchronization signal. If the time difference is not less than the reciprocal, the electronic device performs the first drawing operation.

[0045] In the above embodiment, when the application program performs the drawing operation for the purpose of not refreshing the interface, the application program can perform the drawing operation at a frequency not exceeding a certain value, thereby reducing the frequency of performing the drawing operation, and further reducing the occupation of system resources by background applications, the heat generation and power consumption of the electronic device.

[0046] Referring to some embodiments of the second aspect, in some embodiments, the electronic device determines the second frequency according to a drawing frequency limit policy and the first application program.

[0047] In the above embodiment, the electronic device can determine the frequency of performing drawing operations by different application programs according to the drawing frequency limit policy, thereby simultaneously realizing differentiated allocation of system resources and reducing heat generation and power consumption of the electronic device.

[0048] With reference to some embodiments of the second aspect, in some embodiments, the electronic device determines whether the electronic device displays the first application program or whether the first application program is the foreground application or the background application based on an activity manager service and / or a cpuset parameter of the process of the first application program.

[0049] In the above embodiment, based on the activity manager service and / or cpuset parameters of the process of the application program, it can determine whether the application program has been switched from a foreground application to a background application, thereby improving the recognition accuracy of the background application, more accurately reducing the frequency at which the background application performs drawing operations, and further reducing the heat and power consumption of the electronic device.

[0050] With reference to some embodiments of the second aspect, in some embodiments N is equal to 0.

[0051] In the above embodiment, when the application program is a background application, the electronic device can instruct the application program not to perform drawing operations, allowing the application program to release system resources, thereby reducing heat generation and power consumption of the electronic device.

[0052] With reference to some embodiments of the second aspect, in some embodiments N is equal to K.

[0053] In the above embodiment, when the application program is a background application, when / after the application program receives a vertical synchronization signal, the animation event task stored by the application program can be deleted, so that all drawing operations performed by the application program become null operations, thereby releasing more system resources and further reducing the heat generation and power consumption of the electronic device.

[0054] According to a third aspect, an embodiment of the present application provides an electronic device, the electronic device including one or more processors and a memory, The memory is coupled to the one or more processors, the memory being configured to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the following operations: starting a first application program; performing drawing operations with a first frequency when the first application program is a foreground application, the drawing operations drawing a view of the first application program; performing the drawing operation at a second frequency after the first application program is switched from the foreground application to a background application, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; Execute.

[0055] With reference to some examples of the third aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, a choreographer of the first application program is instructed to respond to only N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0056] With reference to some embodiments of the third aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, a choreographer of the first application program is instructed to process only animation event tasks corresponding to N vertical synchronization signals out of the K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where N is a positive integer less than K.

[0057] With reference to some examples of the third aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, animation event tasks corresponding to KN vertical synchronization signals out of the K vertical synchronization signals received by the choreographer of the first application program are deleted, so that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0058] With reference to some embodiments of the third aspect, the ratio of N to K corresponds to the ratio of the second frequency to the first frequency.

[0059] With reference to some embodiments of the third aspect, the ratio of N to K is equal to the ratio of the second frequency to the first frequency.

[0060] Referring to some embodiments of the third aspect, in some embodiments, after the first application program is switched from the foreground application to the background application, when the application program does not receive a vertical synchronization signal at the first frequency but receives a vertical synchronization signal at a third frequency, the electronic device performs drawing operations at a frequency lower than a fourth frequency, where the third frequency is lower than the first frequency and the fourth frequency is less than or equal to the third frequency and greater than 0.

[0061] Referring to some embodiments of the third aspect, in some embodiments, when the first application program receives a first vertical synchronization signal, the electronic device determines whether a time difference between a time when the first application program received the first vertical synchronization signal and a time when the first application program last performed the drawing operation is less than the reciprocal of the fourth frequency. If the time difference is less than the reciprocal, the electronic device intercepts the first drawing operation, the first drawing operation being a drawing operation performed by the first application program in response to the first vertical synchronization signal. If the time difference is not less than the reciprocal, the electronic device performs the first drawing operation.

[0062] Referring to some embodiments of the third aspect, in some embodiments, the second frequency is determined according to a drawing frequency limit policy and the first application program.

[0063] With reference to some embodiments of the third aspect, in some embodiments, it is determined that the first application program is the foreground application or the background application based on an activity manager service and / or a cpuset parameter of the process of the first application program.

[0064] With reference to some embodiments of the third aspect, in some embodiments N is equal to 0.

[0065] With reference to some embodiments of the third aspect, in some embodiments N is equal to K.

[0066] According to a fourth aspect, an embodiment of the present application provides an electronic device, the electronic device including one or more processors and a memory, The memory is coupled to the one or more processors, the memory being configured to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the electronic device to perform the following operations: launching a first application program; displaying, by the electronic device, an interface of the first application program; performing drawing operations at a first frequency, the drawing operations rendering a view of the first application program; closing the display of the interface of the first application program and performing the drawing operation at a second frequency, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; Execute.

[0067] With reference to some embodiments of the fourth aspect, the electronic device closes a display of an interface of the first application program, and the first application program is a background application.

[0068] With reference to some embodiments of the fourth aspect, in some embodiments, when the electronic device does not display an interface of the first application program, a choreographer of the first application program is instructed to respond to only N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0069] With reference to some embodiments of the fourth aspect, in some embodiments, when the electronic device does not display an interface of the first application program, a choreographer of the first application program is instructed to process only animation event tasks corresponding to N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0070] With reference to some examples of the fourth aspect, in some embodiments, when the electronic device does not display an interface of the first application program, the drawing operation is performed at the second frequency, and the electronic device instructs a choreographer of the first application program to delete animation event tasks corresponding to KN vertical synchronization signals out of K vertical synchronization signals received, such that the electronic device performs the drawing operation at the second frequency, where K is a positive integer and N is a positive integer less than K.

[0071] With reference to some embodiments of the fourth aspect, in some embodiments the ratio of N to K corresponds to the ratio of the second frequency to the first frequency.

[0072] With reference to some embodiments of the fourth aspect, in some embodiments the ratio of N to K is equal to the ratio of the second frequency to the first frequency.

[0073] Referring to some embodiments of the fourth aspect, in some embodiments, after the display of the interface of the first application program is closed, when the application program does not receive a vertical synchronization signal at the first frequency but receives a vertical synchronization signal at a third frequency, the electronic device performs a drawing operation at a frequency lower than a fourth frequency, the third frequency being lower than the first frequency, and the fourth frequency being less than or equal to the third frequency and greater than 0.

[0074] Referring to some embodiments of the fourth aspect, in some embodiments, when the first application program receives a first vertical synchronization signal, the electronic device determines whether a time difference between a time when the first application program received the first vertical synchronization signal and a time when the first application program last performed the drawing operation is less than the reciprocal of the fourth frequency. If the time difference is less than the reciprocal, the electronic device intercepts the first drawing operation, the first drawing operation being a drawing operation performed by the first application program in response to the first vertical synchronization signal. If the time difference is not less than the reciprocal, the electronic device performs the first drawing operation.

[0075] Referring to some embodiments of the fourth aspect, in some embodiments, the second frequency is determined according to a drawing frequency limit policy and the first application program.

[0076] With reference to some embodiments of the fourth aspect, in some embodiments, it is determined whether the electronic device displays the first application program or whether the first application program is the foreground application or the background application based on an activity manager service and / or a cpuset parameter of the process of the first application program.

[0077] With reference to some embodiments of the fourth aspect, in some embodiments N is equal to 0.

[0078] With reference to some embodiments of the fourth aspect, in some embodiments N is equal to K.

[0079] According to a fifth aspect, an embodiment of the present application provides a chip system, said chip system being applied to an electronic device, said chip system comprising one or more processors, said processors invoking computer instructions such that said electronic device is configured to execute the method according to the first aspect or a possible implementation of the first aspect, or the method according to the second aspect or a possible implementation of the second aspect.

[0080] According to a sixth aspect, an embodiment of the present application provides a computer program product comprising instructions, which when executed on an electronic device, enable the electronic device to perform a method as described in the first aspect or any possible implementation of the first aspect, or the second aspect or any possible implementation of the second aspect.

[0081] According to a seventh aspect, an embodiment of the present application provides a computer readable storage medium comprising instructions which, when executed on an electronic device, enable the electronic device to perform a method as described in the first aspect or any possible implementation of the first aspect, or the second aspect or any possible implementation of the second aspect.

[0082] It is understood that the electronic device described in the third or fourth aspect, the chip system described in the fifth aspect, the computer program product described in the sixth aspect, and the computer storage medium described in the seventh aspect are all configured to execute the methods described in the embodiments of the present application. Therefore, for the advantageous effects that can be achieved, please refer to the advantageous effects in the corresponding methods. The details will not be described again here. [Brief description of the drawings]

[0083] [Figure 1] FIG. 2 is a schematic diagram of an example of conversion between foreground and background applications in the present application.

[0084] [Diagram 2] FIG. 2 is a schematic diagram of an example of the life cycle of an activity in the present application.

[0085] [Diagram 3] FIG. 2 is a schematic diagram of an example of a four event task in the present application.

[0086] [Figure 4] FIG. 2 is a schematic diagram of an example of a choreographer performing drawing operations according to the present application.

[0087] [Diagram 5] FIG. 2 is a schematic diagram of an example of drawing operations performed by foreground and background applications in the present application.

[0088] [Figure 6] 1 is a schematic diagram of an example of a system scheduling method for background applications in the present application;

[0089] [Figure 7] FIG. 2 is a schematic diagram of another example of a system scheduling method for background applications in the present application;

[0090] [Figure 8] 1 is a schematic diagram of the structure of an electronic device 100 according to an embodiment of the present application.

[0091] [Figure 9] 2 is a schematic diagram of another structure of the electronic device 100 according to an embodiment of the present application.

[0092] [Figure 10] 1 is a schematic block diagram of the software architecture of an electronic device 100 according to an embodiment of the present application.

[0093] [Figure 11] 2 is a schematic diagram of another software structure of the electronic device 100 according to an embodiment of the present application.

[0094] [Figure 12] 2 is a schematic diagram of an example of a method for performing drawing operations by an application in accordance with the present application;

[0095] [Figure 13A] 1 is a schematic diagram of an example of a drawing frequency limit policy interface according to the present application; [Figure 13B] 1 is a schematic diagram of an example of a drawing frequency limit policy interface according to the present application; [Figure 13C] 1 is a schematic diagram of an example of a drawing frequency limit policy interface according to the present application; [Figure 13D] 1 is a schematic diagram of an example of a drawing frequency limit policy interface according to the present application; [Figure 13E] 1 is a schematic diagram of an example of a drawing frequency limit policy interface according to the present application;

[0096] [Figure 14] FIG. 2 is a schematic diagram of an example of a method for a choreographer to intercept receiving a vertical synchronization signal according to an embodiment of the present application;

[0097] [Figure 15]2 is a schematic diagram of an example of how a choreographer intercepts processing an animation event task according to an embodiment of the present application;

[0098] [Figure 16] FIG. 2 is a schematic diagram of an example of intercepting a choreographer's drawing operations according to an embodiment of the present application;

[0099] [Figure 17] FIG. 2 is a schematic diagram of an example scenario for managing and controlling pointless drawing operations of background applications according to an embodiment of the present application;

[0100] [Figure 18] FIG. 2 is a schematic diagram of another example scenario of managing and controlling pointless drawing operations of background applications according to an embodiment of the present application; DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0101] The terms used in the following embodiments of the present application are merely intended to describe certain embodiments, but are not intended to limit the present application. As used in the present specification and the appended claims, the singular terms "a", "one", "the", "the foregoing", "this" and "the one" are intended to include the plural forms, unless otherwise clearly indicated in the context. It should be further understood that the term "and / or" as used herein indicates and includes any or all possible combinations of one or more of the listed items.

[0102] The terms "first" and "second" below are used for explanatory purposes only and should not be understood as an indication or suggestion of the relative importance or implied suggestion of the quantity of the technical features presented. Thus, a feature qualified by "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, unless otherwise specified, "plurality" means two or more than two.

[0103] For ease of understanding, the following describes relevant terms and concepts in the embodiments of the present application. The terms used in the description of the embodiments of the present invention are merely used to describe specific embodiments of the present invention, and are not intended to limit the present invention.

[0104] (1) Foreground and background applications

[0105] According to whether an application program can directly interact with a user, the application program can be classified into the following types: foreground applications and background applications. Foreground applications and background applications represent the running states of application programs. Foreground applications are application programs that are placed in the foreground by a user and can directly interact with each other, while background applications are application programs that are placed in the background by a user and cannot directly interact with each other.

[0106] In an embodiment of the present application, whether an application is a foreground application or a background application can be determined based on whether the application program is directly displayed, specifically, if the application program is visible, it is a foreground application, and if the application program is not visible, it is a background application.

[0107] For example, an application is a foreground application if its interface is displayed on the screen of an electronic device. An application is a foreground application if its interface is not displayed on the screen of an electronic device. An application's interface does not include the operating system's top status bar or notification bar.

[0108] Optionally, in some embodiments of the present application, whether an application program is a foreground application or a background application can be determined based on whether the application program satisfies several conditions. Specifically, if the application program satisfies any of the following three conditions, the application program is a foreground application. Otherwise, the application program is a background application. The three conditions are as follows: the application has a visible activity, the application has a foreground service, and another foreground application is associated with the application. For the concept of activity, see the explanation of terminology (2) Activity, and details will not be explained here.

[0109] The electronic device can determine whether an application currently has visible activity, and further determine whether the application is a foreground application or a background application, in many ways, including but not limited to the above.

[0110] For example, whether an application program is a foreground application or a background application can be determined based on the life cycle of the main activity of the application program. Specifically, whether an application is a foreground application or a background application can be determined based on whether the main activity of the application program executes various methods such as the onStop method, the onResume method, and the topResumedActivityChangedItem method. After the activity of the application executes the onStop method, the application is considered to be a background application. After the activity of the application executes the onResume method and the topResumedActivityChangedItem method, the application is considered to be a foreground application. For the concepts of terms such as the onStop method, the onResume method, and the topResumedActivityChangedItem method, see the explanation of (2) Activity in the following glossary. Details will not be explained again here.

[0111] For example, whether an application program is a foreground application or a background application can be determined using the cpuset parameter. Specifically, if the cpuset parameter of the process corresponding to the application program is background or key-background, the application program is a background application. Therefore, if the cpuset parameter of the process corresponding to the application program is background or key-background, the application program is a foreground application.

[0112] In addition, an application program may be switched between a foreground application and a background application in response to a user operation.

[0113] Note that, from a user's perspective, an application is considered a foreground application if the user can see the application program's interface, and is considered a background application if the user does not display the application program's interface.

[0114] Next, using the contents shown in Figures 1(A) to 1(F) as an example, we will explain how to determine whether an application program is a foreground application or a background application based on whether the device displays the application program's interface.

[0115] 1(A) to 1(F) are schematic diagrams of examples of conversion between foreground and background applications in the present application.

[0116] As shown in FIG. 1(A), when the current user launches Music to listen to music, the interface displayed on the mobile phone is the interface of Music. In this case, Music is the foreground application. Referring to the content shown in FIG. 1(B), the user can open the multitasking bar and know that three application programs: Music, Gallery, and Browser are currently running on the mobile phone. In the scenario shown in FIG. 1(A), the electronic device does not display the interfaces of Gallery and Browser. In this case, Gallery and Browser are background applications. As shown in FIG. 1(C), according to the user's operation, the user switches Music to the background and Gallery to the foreground, and the electronic device displays the interface of Gallery. In this case, Gallery is the foreground application, and Music and Browser are background applications. As shown in FIG. 1(D), according to the user's operation, the user can open a small window of the browser based on FIG. 1(C) to browse web pages and photos at the same time, and the mobile phone displays the interfaces of Browser and Gallery at the same time. In this case, Gallery and Browser are foreground applications, and Music is a background application.

[0117] When a user opens a video application, the user can switch the application to the background after enabling the small window mode, as shown in Fig. 1(E). The electronic device displays the desktop and a small window of the video application, as shown in Fig. 1(F). In this case, the video application is the foreground application.

[0118] It should be noted that in this embodiment of the present application, an application is considered a foreground application if the user has switched the application's main interface to the background but the device still displays the application's small window interface (either the application's main interface or another interface).

[0119] It should be noted that in some embodiments of the present application, if the electronic device closes some of the interface displays of an application program, the electronic device is considered not to have closed the interface display of the application program.Thus, if the electronic device closes all of the interface displays of an application program, the electronic device is considered to have closed the interface display of the application program.

[0120] In the scenario shown in FIG. 1(A), the user can see the Music interface displayed by the electronic device. Therefore, Music is the foreground application. In the scenario shown in FIG. 1(B), the user can see the Gallery interface displayed by the electronic device. Therefore, Gallery is the foreground application. In the scenario shown in FIG. 1(D), the user can see the Gallery and Browser interfaces displayed by the electronic device. In this case, Gallery and Browser are the foreground applications. In the scenarios shown in FIG. 1(E) and FIG. 1(F), the user can see the Video interface displayed by the electronic device. Therefore, the video software is the foreground application.

[0121] (2) Activities

[0122] An activity is one of the basic components of the Android operating system that an application program can use to present an interactive interface or view to the user. An application program can have multiple activities, and an application loads activities using a task stack. The activity at the top of the task stack is the activity that the user can directly interact with.

[0123] Activities have a life cycle. The life cycle of the main activity of an application program is determined to determine whether the application is a foreground application or a background application. The main activity is an activity designated by the developer when developing the application, and may be used to handle the main interface of the application program.

[0124] FIG. 2 is a schematic diagram of an example of the life cycle of an activity in this application.

[0125] As shown in Figure 2, application program developers need to implement at least seven callback methods when developing an activity of an application program. A callback method is also called a callback function and can be called to implement a specific function. The seven callback methods are the onCreate callback method, the onStart callback method, the onResume callback method, onPause These are the onStop callback method, the onDestroy callback method, and the onRestart callback method. An activity can implement its life cycle by invoking the seven callback methods mentioned above.

[0126] Specifically, when an activity is first created, it calls the onCreate callback method to initialize the activity. When the activity changes from hidden to visible, it calls the onStart callback method. When the activity is ready to interact with the user, it calls the onResume callback method. When the activity is removed from the top of the task stack, it calls the onPause callback method to save key data and release resources. When the activity is completely hidden, it calls the onStart callback method. Before the activity destroys itself, it calls the onDestroy callback method to release resources. When the activity changes from a stopped state to a running state, it calls the onRestart callback method.

[0127] You can refer to the activity life cycle to determine whether the application program to which an activity belongs is a foreground application or a background application. You can think of an application as becoming a background application after its main activity executes its onStop callback method. Correspondingly, you can think of an application as becoming a foreground application after its main activity executes its onResume callback method.

[0128] Note that in some cases, when an application program resumes to the foreground, the application program's main activity executes the TopResumedActivityChangeItem callback method. Therefore, you can determine whether the application program's main activity has executed the TopResumedActivityChangeItem callback method to determine whether the current application will become the foreground application.

[0129] In an embodiment of the present application, an Activity Manager Service (AMS) provided by the operating system is used to monitor the life cycle of the main activity of a currently executing application program, and the Activity Manager Service can be used to determine whether the application program is currently a foreground or background application.

[0130] Optionally, in some embodiments of the present application, when developing an application program, the developer of the application program can add an interface to the life cycle of the main activity to transfer information to the choreographer or other module or object of the application program to determine whether the application program is a foreground application or a background application.

[0131] (3) Choreographer and drawing operations

[0132] The choreographer is a class in the operating system to request a vertical sync signal and perform drawing operations in response to the requested vertical sync signal. The class is a data structure that defines the state and behavior of an object. The vertical sync signal is a signal provided by the operating system to coordinate and synchronize choreographer and SurfaceFlinger operations.

[0133] When an application program is launched, the choreographer is initialized. The process of initializing the choreographer is as follows: An activity creates a choreographer object instantiated based on the choreographer class. The choreographer can perform drawing operations. The drawing operations include: The choreographer handles input event tasks, animation event tasks, layout event tasks, and submission event tasks. After performing the drawing operations, the choreographer can submit the results of the drawing operations to another module of the application program to display a refreshed interface or view on the screen of the electronic device.

[0134] The following describes the detailed creation of the choreographer and the trigger conditions for the choreographer to perform drawing operations.

[0135] After each application program is launched by a user, at least one choreographer belonging to the application program is generated when the application program needs to display a visual interface or view for the first time. The number of choreographers can be related to the number of threads used by the application program. A thread is the minimum resource scheduled by the operating system. For example, the UI thread of an application program generates a choreographer bound to the thread. The UI thread is sometimes called the main thread and is mainly used to carry the computation overhead for implementing functions such as displaying, updating, and controlling interactions of the interface.

[0136] When an application program needs to refresh an interface or view, the choreographer requests a vertical synchronization signal (Vsync) from SurfaceFlinger to find the appropriate timing to perform drawing operations. After receiving the vertical synchronization signal sent by SurfaceFlinger, the choreographer starts performing drawing operations. The choreographer receives the vertical synchronization signal using the OnVsync callback method. The OnVsync callback method is a callback method provided by the choreographer's internal class FrameDisplayEventReceiver. When the choreographer successfully receives the vertical synchronization signal using the OnVsync callback method, the choreographer is notified that it can start drawing operations.

[0137] If the application program is a foreground application / background application, the frequency at which the choreographer requests a vertical synchronization signal from SurfaceFlinger remains unchanged.

[0138] SurfaceFlinger is a service provided at the lowest layer of an operating system, configured to receive requests from choreographers of different application programs and deliver a vertical synchronization signal to the application programs according to the requests. The vertical synchronization signal may be generated through software simulation or may be generated by the hardware of an electronic device. For example, the vertical synchronization signal may be generated by a Hardware Composer (HWC). After generating the vertical synchronization signal, the HWC may send the vertical synchronization signal to SurfaceFlinger using a callback method. Thus, SurfaceFlinger can forward the vertical synchronization signal to the choreographer. After receiving the vertical synchronization signal sent from SurfaceFlinger, the choreographer starts to execute the drawing operation.

[0139] The frequency at which the electronic device generates the vertical synchronization signal may be related to the refresh rate of the screen of the electronic device. For example, when the frequency at which the electronic device generates the vertical synchronization signal is 90 Hz, the refresh rate of the screen of the electronic device may be 90 Hz.

[0140] The following describes what is included in the drawing operation.

[0141] Specifically, after the choreographer is generated, the application program saves four event tasks in chronological order in four one-way linked lists (CallbackQueue) set in the choreographer. After receiving a vertical synchronization signal, the choreographer uses the doFrame callback method to process the four corresponding event tasks that correspond to the current time. The four event tasks are CALLBACK_INPUT, CALLBACK_ANIMATION, CALLBACK_TRAVERSAL, and CALLBACK_COMMIT.

[0142] The doFrame callback method contains four doCallBacks callback methods that are used respectively to handle the four event tasks mentioned above.

[0143] CALLBACK_INPUT is an input event task, and the input event task is data for the application program to encapsulate an input event and deliver it to the choreographer. The input event may be an interaction between a user and the application program received by the application program. For example, the input event may be a user tap on an interactive control of the application program, or a user swipe (e.g., swipe up and down or slide left and right) in the application program. This is not limited here. After determining the input event, the application program preliminarily processes the input event, generates an input event task corresponding to the input event, and transfers the input event task to the choreographer.

[0144] CALLBACK_ANIMATION is an animation event task, and an animation event task is data that an application program needs to calculate animations. Animations include view animations, frame animations (Drawable Animations), property animations, etc.

[0145] CALLBACK_TRAVERSAL is a layout event task that is used by the choreographer to calculate the drawing data of a view or interface. The calculated and determined drawing data is sent to another module of the application program to determine the width, height, position, shape, etc. of the content to be displayed in the view.

[0146] CALLBACK_COMMIT is a submission event task that indicates that the choreographer has completed the drawing operations corresponding to the vertical synchronization signal.

[0147] Next, the above four event tasks will be explained in detail again using the content shown in FIG. 3 as an example.

[0148] FIG. 3 is a schematic diagram of an example of a four event task in this application.

[0149] The main interface of the application program is shown in FIG. 3(A). The main interface includes three rectangular controls: a first rectangular control 301, a second rectangular control 302, and a third rectangular control 303. The first rectangular control 301 and the second rectangular control 302 may correspond to a user's tap operation, and the third rectangular control 303 may display a current numerical value to the user. When the user taps the first rectangular control 301, the numerical value displayed in the third rectangular control 303 increases by 1. When the user taps the second rectangular control 302, the numerical value displayed in the third rectangular control 303 decreases by 1. In addition, when the user taps the first rectangular control 301 or the second rectangular control 302, the rectangular control that the user tapped displays a gradual gray animation to notify the user that the tap was successful.

[0150] The content shown in Fig. 3B is the interface that is displayed after the user taps the second rectangular control 302. Compared to the interface of the application program shown in Fig. 3A, the second rectangular control 302 turns gray, and the number displayed in the third rectangular control 303 changes from 4 to 3.

[0151] In the content shown in FIG. 3, a tap event of the first rectangle control 301 or the second rectangle control 302 can be considered as an input event. After obtaining the input event, the screen of the electronic device reports the input event to the corresponding driver and delivers the input event to the corresponding application program. After obtaining the input event, the application program packages the event into an input event task and delivers the task to the choreographer. Similarly, the animation of the gradient gray that needs to be displayed is an animation event, which is packaged as an animation event task and delivered to the choreographer. Similarly, the layout event task is used to determine the position, size, and shape of the second rectangle control 302 in the view. Similarly, the submission event task is used to determine the completion of the drawing operation.

[0152] Finally, we use the content shown in FIG. 4 as an example to explain the data processing in which the choreographer performs drawing operations.

[0153] FIG. 4 is a schematic diagram of an example of a choreographer performing drawing operations according to the present application.

[0154] As shown in Figure 4, after an application program is first launched, the main activity of the application program executes callback methods such as the onStart callback method and the onResume callback method based on the life cycle of the activity. After the application program executes the onResume callback method, if it needs to display a visual interface or view, it can use the Activity.makeVisible callback method to draw the interface or view. While the activity is drawing the interface or view using the Activity.makeVisible callback method, the choreographer is initialized.

[0155] After the choreographer is initialized, when the application program needs to refresh the view, a drawing request is sent to the choreographer using the scheduleTraversals callback method. The choreographer, awakened by the scheduleTraversals callback method, receives event tasks continuously in chronological order and uses various one-way linked lists to store the corresponding event tasks.

[0156] Furthermore, after receiving the drawing request, the choreographer requests a vertical synchronization signal from SurfaceFlinger. After receiving the vertical synchronization signal sent by SurfaceFlinger, the choreographer can perform drawing operations using the doFrame callback method. Specifically, input event tasks, animation event tasks, layout event tasks, and submission event tasks are processed using the doFrame callback method.

[0157] The following describes a scenario relevant to this application.

[0158] The operating system does not provide a callback method for determining whether an application requesting a vertical sync signal really needs to perform a drawing operation. After an application program requests a vertical sync signal from SurfaceFlinger, the vertical sync signal is delivered. When using an electronic device such as a smartphone, a user can launch multiple application programs. However, due to the limitations of the screen size of the electronic device, at a particular moment, the user can only display one or a few applications on the screen for interaction (e.g., split screen), and other application programs are converted into background applications. In the case of a background application, the background application is not discarded and still holds the choreographer, so that when some operations are performed in the background, the background application triggers the choreographer to perform drawing operations.

[0159] First, because the background application has no view or interface that it can use to present to the user, the results of drawing operations performed by the background application are not visible to the user, and second, because only animation event tasks are delivered to the background application's choreographer, the background application actually only processes animation event tasks when it performs drawing operations.

[0160] For these two reasons, drawing operations performed by background applications can be considered meaningless drawing operations.

[0161] Note that for any application program, if the application program is a foreground application, the input event tasks, animation event tasks, layout event tasks, and submission event tasks are delivered to the choreographer of the application program, whereas if the application program is a background application, the input event tasks, layout event tasks, and submission event tasks are not delivered to the application program because the application program does not provide an interface or view that can interact with each other.

[0162] For the user, when the electronic device displays the interface of the application program, the application program needs to perform drawing operations to refresh the interface, but after the electronic device finishes displaying the interface of the application program, the drawing operations performed by the application program to refresh the interface until the electronic device displays the interface of the application program again waste resources of the operating system and increase heat generation and power consumption of the electronic device.

[0163] FIG. 5 is a schematic diagram of an example of drawing operations performed by foreground and background applications in the present application.

[0164] As shown in Fig. 5, multiple application programs including Gallery, Music, and Browser run on the electronic device. When Gallery is a foreground application, Music and Browser are background applications. The choreographers of Gallery, Music, and Browser each receive a vertical synchronization signal, and in response to the vertical synchronization signal, the choreographers of Gallery, Music, and Browser each perform a drawing operation. The computational resources for the drawing operations performed by the choreographers are provided by the UI thread.

[0165] It is understood that when background applications perform meaningless drawing operations, the system resources of the foreground applications are occupied, which increases the heat and power consumption of the electronic device, thereby causing frame freezes in the electronic device and degrading the user experience.

[0166] The following describes two system scheduling methods for background applications in this application.

[0167] 5, even after an application program is converted to a background application, the application program still retains the choreographer, so the choreographer of the application still receives the vertical synchronization signal sent from SurfaceFlinger and performs meaningless drawing operations. To reduce meaningless drawing operations performed by background applications, there are two main system scheduling methods for background applications.

[0168] The first system scheduling method related to background applications is to allocate system resources to foreground applications and background applications in different ways, mainly with reference to the characteristics of the hardware architecture of the CPU of the electronic device.

[0169] FIG. 6 is a schematic diagram of an example of a system scheduling method for background applications in the present application.

[0170] As shown in FIG. 6, the CPU Kirin9000 is used as an example. Kirin9000 includes one large core of A77 architecture, three medium cores of A77 architecture, and four small cores of A55 architecture. Referring to the hardware architecture characteristics of the CPU of the electronic device, when an application program is a foreground application, the large core is preferentially used to support the computational resources of the application. When the application program is a background application, the medium core and the small core are preferentially used to support the computational resources of the application.

[0171] It can be understood that when an application program performs a drawing operation, the CPU's computing resources will be consumed. Therefore, allocating system resources to foreground applications and background applications in different ways helps reduce the occupation of the computing resources of foreground applications by background applications. However, when a user launches a large number of applications, or when the foreground application currently used by the user needs to occupy a large amount of system resources, i.e., when the medium or small cores of the CPU need to provide some computing resources, the meaningless drawing operations of the background applications will occupy the computing resources of the system. As a result, frame freeze will occur in the foreground application, resulting in a poor user experience. Furthermore, taking the CPU as an example, since different electronic devices have different hardware capabilities, the system scheduling method cannot adapt to different models of CPUs from different manufacturers.

[0172] It can be understood that the above-mentioned system scheduling method for background applications refers to the hardware capabilities of the electronic device to perform different scheduling, so as to reserve system resources for foreground applications as much as possible.

[0173] However, system scheduling methods do not prevent background applications from performing pointless drawing operations, which waste system resources and increase the power consumption of the electronic device.

[0174] The second system scheduling method related to background applications involves freezing the background applications in a timely manner to prevent the background applications from occupying system resources.

[0175] FIG. 7 is a schematic diagram of another example of a system scheduling method for background applications in the present application.

[0176] When an application program is converted from a foreground application to a background application, the electronic device can freeze the application program. Although the application program needs to request system resources from the electronic device to perform drawing operations, the electronic device does not allocate system resources to the frozen application program. Thus, the frozen application program does not perform meaningless drawing operations. However, the frozen background application is often awakened by broadcasts, services, etc. The awakened background application still performs meaningless drawing operations, occupies system resources, and increases the power consumption of the electronic device.

[0177] As shown in FIG. 7, when the browser application is switched to the background, the Browser application freezes. The frozen browser application cannot occupy the system resources of the electronic device and therefore cannot perform drawing operations. However, the frozen browser application is often awakened by broadcasts or services from the operating system or other applications, and the awakened browser application still performs meaningless drawing operations.

[0178] It will be appreciated that background applications can be frozen so that they cannot perform pointless drawing operations.

[0179] However, the frozen background application will be woken up frequently, and the woken background application can still perform meaningless drawing operations, occupying system resources and increasing the power consumption of the electronic device.

[0180] The present application provides a method for performing drawing operations by an application and an electronic device, so as to prevent a background application from performing meaningless drawing operations, thereby reducing the occupation of system resources and reducing the power consumption of the electronic device. When an application program is changed from a foreground application to a background application, the application program determines a background drawing frequency according to a drawing frequency limiting policy, and intercepts a vertical synchronization signal or intercepts a choreographer processing an animation event task based on the determined background drawing frequency, thereby effectively reducing meaningless drawing operations performed by the background application, further reducing the occupation of system resources by the background application, and reducing the power consumption of the electronic device.

[0181] The following describes the electronic device provided in this application.

[0182] In the embodiment of the present application, the electronic device may be a mobile electronic device such as a mobile phone or a tablet computer, or may be a device such as a smart TV or a personal computer (PC), which is not limited herein.

[0183] For example, FIG. 8 is a schematic diagram of the structure of an electronic device 100 according to an embodiment of the present application.

[0184] In the following, the present embodiment will be described in detail using the electronic device 100 as an example. It should be noted that the electronic device 100 may have more or less components than those shown in the figure, may combine two or more components, or may have different components. The various components shown in the figure may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.

[0185] 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, a headset jack 170D, a sensor module 180, keys 190, a motor 191, an indicator 192, a camera 193, a display 194, a subscriber identification module (SIM) card interface 195, and the like. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, an optical proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.

[0186] It may be understood that the structure shown in this embodiment of the invention does not constitute a specific limitation for the electronic device 100. In some other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown, or some components may be combined, or some components may be separated, or different component arrangements may be used. The components in the figures may be implemented by hardware, software, or a combination of software and hardware.

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

[0188] The controller may be the brain and command center of the electronic device 100. The control unit can generate operation control signals based on instruction operation codes and time sequence signals to provide complete control of instruction fetching and instruction execution.

[0189] The memory may also be located within the processor 110 and is configured to store instructions and data. In some embodiments, the memory within the processor 110 is a cache. The memory may store instructions or data that are used immediately or periodically by the processor 110. When the processor 110 needs to use the instructions or data again, the processor may recall the instructions or data directly from the memory. This avoids repeated accesses and reduces the latency of the processor 110, thereby improving system efficiency.

[0190] In some embodiments, the processor 110 may include one or more interfaces, including 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, a universal serial bus (USB) interface, and the like.

[0191] The I2C interface is a bidirectional synchronous serial bus and includes one serial data line (SDA) and one serial clock line (SCL). In some embodiments, the processor 110 can include multiple groups of I2C buses. The processor 110 can be individually 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, and the processor 110 can communicate with the touch sensor 180K through the I2C bus interface to realize the touch function of the electronic device 100.

[0192] The I2S interface can be configured to perform audio communication. In some embodiments, the processor 110 can include multiple groups of I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S buses to realize communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can send audio signals to the wireless communication module 160 via the I2S interface to realize a function of answering a call via a Bluetooth headset.

[0193] The PCM interface may also be used to perform audio communication, and to sample, quantize, and encode analog signals. In some embodiments, audio module 170 may be coupled to wireless communication module 160 via a PCM bus interface. In some embodiments, audio module 170 may also send audio signals to wireless communication module 160 via the PCM interface to implement the functionality of answering a call via a Bluetooth headset. Both the I2S interface and the PCM interface may be used for audio communication.

[0194] The UART interface is a universal serial data bus and is configured to perform asynchronous communication. The bus may be a bidirectional communication bus. The bus converts the transmitted data between serial and parallel communication. In some embodiments, the UART interface is generally configured to connect the processor 110 to the wireless communication module 160. For example, the processor 110 communicates with a Bluetooth module in the wireless communication module 160 via the UART interface to implement a Bluetooth function. In some embodiments, the audio module 170 can send an audio signal to the wireless communication module 160 via the UART interface to realize a function of playing music via a Bluetooth headset.

[0195] The MIPI interface can be configured to connect the processor 110 to peripheral components such as a display 194 or a camera 193. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 110 communicates with the camera 193 via the CSI to realize the capture function of the electronic device 100. The processor 110 communicates with the display 194 via the DSI to realize the display function of the electronic device 100.

[0196] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be configured to connect the processor 110 to a camera 193, a display 194, a wireless communication module 160, an audio module 170, a 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.

[0197] The SIM interface can be used to communicate with a SIM card interface 195 to realize the function of sending data to the SIM card or reading data in the SIM card.

[0198] The USB interface 130 is an interface that complies with the USB standard specification, and may specifically be a mini USB interface, a micro USB interface, a USB Type-C interface, etc. The USB interface 130 may be configured to connect to a charger to charge the electronic device 100, or may be configured to transmit data between the electronic device 100 and a peripheral device. Alternatively, the USB interface may be configured to connect to a headset to play audio through the headset. The interface may further be configured to connect to another electronic device, such as an AR device.

[0199] It should be understood that the interface connection relationships between modules shown in this embodiment of the present invention are merely examples for the purpose of explanation, and do not limit the structure of the electronic device 100. In some other embodiments of the present application, the electronic device 100 may use an interface connection method different from that in the above embodiment, or may use a combination of multiple interface connection methods.

[0200] The charging management module 140 is configured to receive a charging input from a charger, which may be a wireless charger or a wired charger.

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

[0202] The wireless communication function of the electronic device 100 can be realized via an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, a modem processor, a baseband processor, and so on.

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

[0204] The mobile communication module 150 can provide wireless communication solutions, including 2G / 3G / 4G, 5G, etc., that are applied to the electronic device 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via the antenna 1, process the received electromagnetic waves, such as filtering or amplifying, and send the electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can further amplify the modulated signal by the modem processor and convert the signal to an electromagnetic wave for emission via the antenna 1. In some embodiments, at least some of the functional modules in the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 and at least some of the modules of the processor 110 may be disposed in the same device.

[0205] The modem processor may include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium and high-frequency signal. The demodulator is configured to demodulate a received electromagnetic signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal is transmitted to the application processor after being processed by the baseband processor. The application processor outputs a sound signal through an audio device (such as, but not limited to, speaker 170A, receiver 170B, etc.) or displays an image or video through a display 194. In some embodiments, the modem processor may be an independent component. In some other embodiments, the modem processor may be separate from the processor 110 and may be located in the same device as the mobile communication module 150 or other functional modules.

[0206] The wireless communication module 160 can provide wireless communication solutions applied to the electronic device 100, including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC) technology, infrared (IR) technology, etc. 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, performs frequency modulation and filtering on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 can further receive signals to be transmitted from the processor 110, perform frequency modulation and amplification on the signals, and convert the processed signals into electromagnetic waves for emission via the antenna 2.

[0207] In some embodiments, antenna 1 is coupled to mobile communication module 150 and antenna 2 is coupled to wireless communication module 160 in electronic device 100, allowing electronic device 100 to communicate with networks and other devices by using wireless communication technologies, including 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, IR technologies, etc. 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 satellite based augmentation systems (SBAS).

[0208] The electronic device 100 implements display functionality through a GPU, a display 194, an application processor, etc. The GPU is a microprocessor for image processing and is connected to the display 194 and the application processor. The GPU is configured to perform mathematical and geometric calculations and render images. The processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0209] The display 194 is configured to display images, videos, etc. The display 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0210] The electronic device 100 can achieve photographic functionality via a camera 193, an ISP, a video codec, a GPU, a display 194, an application processor, and the like.

[0211] The ISP is configured to process data fed back by the camera 193. For example, during shooting, the shutter is pressed and light is sent through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then sent to the camera's photosensitive element for processing by the ISP, which converts the electrical signal into a visible image. The ISP can further perform algorithmic optimization on image noise, brightness, and complexion. The ISP can further optimize parameters such as exposure and color temperature for the shooting scenario. In some embodiments, the ISP may be located in the camera 193.

[0212] The camera 193 is configured to capture still images or videos. An optical image of an object is generated through a lens and projected onto a photoreceptor. The photoreceptor may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photoreceptor converts the optical signal into an electrical signal, which is then sent 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 format, such as RGB or YUV. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0213] The digital signal processor is configured to process digital signals and may process other digital signals in addition to the digital image signal. For example, once the electronic device 100 selects a frequency, the digital signal processor is configured to perform a Fourier transform on the frequency energy.

[0214] A video codec is configured to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 may play or record video in multiple coding formats, such as moving picture experts group (MPEG)-1, MPEG-2, MPEG-3, and MPEG-4.

[0215] The NPU is a neural-network (NN) calculation processor. The NPU quickly processes input information by referring to the structure of a biological neural network, for example, by referring to the transmission pattern between neurons in the human brain, and continuously performs self-learning. Through the NPU, applications such as intelligent recognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

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

[0217] The 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, e.g., fifth generation DDR SDRAM is commonly referred to as DDR5 SDRAM), and the like.

[0218] Non-volatile memory can include magnetic disk storage and flash memory.

[0219] Flash memory can be divided according to the operating principle, which can include NOR FLASH, NAND FLASH, 3D NAND FLASH, etc.; divided according to the potential level of the storage unit, which can include single-level storage unit (SLC), multi-level storage unit (MLC), triple-level storage unit (TLC), quad-level storage unit (QLC), etc.; or divided according to the storage specification, which can include universal flash storage (UFS), embedded multi media card (eMMC), etc.

[0220] The random access memory may be directly read by and written to by the processor 110 and may be configured to store executable programs (e.g., machine instructions) for the operating system or other running programs, and may also be configured to store data, such as user and application programs.

[0221] The non-volatile memory may also store executable programs, user data, application program data, and the like that may previously be loaded into the random access memory so as to be directly read and written by the processor 110 .

[0222] The external memory interface 120 can be configured 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 via the external memory interface 120 to provide data storage functionality. For example, files such as music and videos are stored in the external non-volatile memory.

[0223] The electronic device 100 can realize audio functions, such as music playback and recording, through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, an application processor, etc., and can realize music playback and recording functions.

[0224] Audio module 170 is configured to convert digital audio information to analog audio signals for output, and to convert analog audio input to digital audio signals. Audio module 170 may further be configured to code and decode audio signals. In some implementations, audio module 170 is located within processor 110, or some functional modules within audio module 170 are located within processor 110.

[0225] The speaker 170A, also called a "loudspeaker," is configured to convert audio electrical signals into voice signals. With the speaker 170A, the electronic device 100 may be used for listening to music or for answering calls in a hands-free mode.

[0226] Receiver 170B, also referred to as an "earpiece," is configured to convert electrical audio signals into speech signals such that when answering a call or receiving voice information via electronic device 100, receiver 170B can be held close to a human ear to hear the speech.

[0227] The microphone 170C, also called a "microphone" or "mic", is configured to convert a voice signal into an electrical signal. When making a call or sending a voice message, a user may generate a voice near the microphone 170C through the user's mouth to input the voice signal into the microphone 170C. At least one microphone 170C may be disposed in the electronic device 100. In some other embodiments, two microphones 170C may be disposed in the electronic device 100 to collect voice signals and realize a noise reduction function. In some other embodiments, alternatively, three, four or more microphones 170C may be disposed in the electronic device 100 to collect voice signals, realize noise reduction, identify sound sources, realize directional recording functions, etc.

[0228] Headset jack 170D is configured to connect to a wired headset and may be a USB interface 130, a 3.5 mm open mobile terminal platform (OMTP) standard interface, or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0229] The pressure sensor 180A is configured to sense a pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display 194. There are many types of pressure sensor 180A, such as resistive pressure sensor, inductive pressure sensor, and capacitive pressure sensor. The capacitive pressure sensor may include at least two parallel plates made of a conductive material. When a force is applied to the pressure sensor 180A, a capacitance between the electrodes changes. The electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is performed on the display 194, the electronic device 100 detects the intensity of the touch operation via the pressure sensor 180A. The electronic device 100 may also calculate a touch position based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations performed at the same touch position but with different touch operation intensities may correspond to different operation commands. For example, when a touch operation is performed on an SMS message application icon with a touch operation intensity less than a first pressure threshold, an instruction to view SMS messages is executed. When a touch is performed over the SMS message application icon with a touch strength equal to or greater than a first pressure threshold, instructions are executed to compose a new SMS message.

[0230] The gyro sensor 180B may be configured to determine the motion attitude of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., axes x, y, and z) may be determined via the gyro sensor 180B. The gyro sensor 180B may be configured to correct camera shake during shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle at which the electronic device 100 jitters, calculates the distance that the lens module needs to compensate based on the angle, and the lens cancels the jitter of the electronic device 100 with an inverse motion to perform camera shake correction. The gyro sensor 180B can also be used for navigation and motion control game scenarios.

[0231] The air pressure sensor 180C is configured to measure air pressure, in some embodiments, the electronic device 100 calculates altitude through the air pressure measured by the air pressure sensor 180C to aid in positioning and navigation.

[0232] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can detect whether the flip cover is open or closed by using the magnetic sensor 180D. In some embodiments, when the electronic device 100 is a clamshell phone, the electronic device 100 can detect whether the flip cover is open or closed based on the magnetic sensor 180D. In addition, the function of automatically unlocking the flip cover is set based on the detected open or closed state of the leather case or the detected open or closed state of the flip cover.

[0233] The acceleration sensor 180E can detect acceleration in various directions (typically, three axes) of the electronic device 100. When the electronic device 100 is stationary, it can detect the magnitude and direction of gravity. The acceleration sensor 180E can also be configured to identify the orientation of the electronic device, which can be used in applications such as switching between landscape and portrait modes or as a pedometer.

[0234] The distance sensor 180F is configured to measure distance. The electronic device 100 may measure distance in an infrared or laser manner. In some embodiments, in a photography scenario, the electronic device 100 may measure distance through the distance sensor 180F to achieve fast focusing.

[0235] The optical proximity sensor 180G may include, for example, a light emitting diode (LED) and an optical detector, for example, a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light through the light emitting diode. The electronic device 100 detects infrared reflected light from a nearby object through the photodiode. If sufficient reflected light is detected, it may be determined that an object is present near the electronic device 100. If insufficient reflected light is detected, the electronic device 100 may determine that no object is present near the electronic device 100. By using the optical proximity sensor 180G, the electronic device 100 can detect when a user holds the electronic device 100 close to the ear for a call and automatically turn off the screen to save power. The optical proximity sensor 180G may also be used in a smart cover mode or a pocket mode to automatically unlock or lock the screen.

[0236] The ambient light sensor 180L is configured to sense the brightness of the ambient light. The electronic device 100 can adaptively adjust the brightness of the display 194 based on the sensed brightness of the ambient light. The ambient light sensor 180L may also be configured to automatically adjust the white balance during shooting. The ambient light sensor 180L may also cooperate with the optical proximity sensor 180G to detect whether the electronic device 100 is in a pocket to avoid accidental contact.

[0237] The fingerprint sensor 180H is configured to collect a fingerprint, and the electronic device 100 can use the collected fingerprint characteristics to perform fingerprint-based unlocking, application lock access, fingerprint-based photography, fingerprint-based call answering, and the like.

[0238] The temperature sensor 180J is configured to detect temperature. In some embodiments, the electronic device 100 executes a temperature handling policy through the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor in the vicinity of the temperature sensor 180J to reduce power consumption for thermal protection. In some other embodiments, when the temperature is below another threshold, the electronic device 100 heats the battery 142 to prevent the power supply of the electronic device 100 from abnormally shutting down due to low temperature. In some other embodiments, when the temperature is below yet another threshold, the electronic device 100 increases the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.

[0239] The touch sensor 180K is also referred to as a "touch panel." The touch sensor 180K may be disposed on the display 194, and the touch sensor 180K and the display 194 form a touch screen, also referred to as a "touch screen." The touch sensor 180K is configured to detect touch operations performed on or near the touch sensor. The touch sensor may forward the detected touch operations to an application processor to determine the type of touch event. A visual output associated with the touch operation may be provided via the display 194. In some other embodiments, the touch sensor 180K may be disposed on the surface of the electronic device 100 at a location different from the surface of the display 194.

[0240] The keys 190 include a power key, a volume key, etc. The keys 190 may be mechanical keys or touch keys. The electronic device 100 can receive key inputs and generate signal inputs related to user settings and function control of the electronic device 100.

[0241] The motor 191 can generate a vibration prompt. The motor 191 can be configured to provide an incoming call vibration prompt or touch vibration feedback. For example, touch operations performed in different applications (e.g., taking pictures and playing audio) may correspond to different vibration feedback effects. The motor 191 may also correspond to different vibration feedback effects for touch operations performed in different regions of the display 194. Different application scenarios (e.g., time reminder, information reception, alarm clock, games) may also correspond to different vibration feedback effects. The touch vibration feedback effects can be further customized.

[0242] The indicator 192 may be an indicator light and may be configured to indicate charging status and power changes, or may be configured to indicate messages, missed calls, notifications, and the like.

[0243] The SIM card interface 195 is configured to connect to a SIM card. The SIM card may be inserted into or removed from the SIM card interface 195 to achieve contact with or separation from the electronic device 100. The electronic device 100 may support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 may support a nano-SIM card, a micro-SIM card, a SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The multiple cards may be of the same type or different types. The SIM card interface 195 may be compatible with different types of SIM cards. The SIM card interface 195 is also compatible with an external storage card. The electronic device 100 interacts with a network through the SIM card to achieve functions such as conversation and data communication.

[0244] In the present embodiment of the present application, the processor 110 invokes computer instructions stored in the internal memory 121 to enable the electronic device 100 to execute a method for performing drawing operations by an application in the present embodiment of the present application.

[0245] For example, FIG. 9 is a schematic diagram of another structure of an electronic device 100 according to an embodiment of the present application.

[0246] The electronic device 100 includes: an input device 201, an output device 202, a processor 203, and a memory 204 (wherein there may be one or more processors 203 in the electronic device 100, and one processor 203 is used as an example in FIG. 9 ). In some embodiments of the present application, the input device 201, the output device 202, the processor 203, and the memory 204 may be connected by a bus or in another manner.

[0247] The processor 203 invokes operating instructions stored in the memory 204 to enable the electronic device 200 to execute a method for performing drawing operations by an application in an embodiment of the present application.

[0248] For example, FIG. 10 is a schematic block diagram of the software architecture of an electronic device 100 according to an embodiment of the present application.

[0249] In a layered architecture, software is divided into layers, with each layer having a distinct role and task. The layers communicate with each other through software interfaces. In some embodiments, the system is divided into four layers from top to bottom: application program layer, application program framework layer, runtime, system libraries, and kernel layer.

[0250] The application program layer may include a series of application packages.

[0251] As shown in FIG. 10, the application package may include application programs (or called applications) such as Camera, Gallery, Calendar, Phone, Maps, Navigation, WLAN, Bluetooth, Music, Videos, and Messages.

[0252] The application program layer may further include a performance optimization application. The performance optimization application may or may not provide a visual interface or view. After the electronic device is started, the performance optimization application may be automatically started without user interaction. The performance optimization application stores a drawing rate limiting policy used to determine the correspondence between the application program and the background drawing frequency. After starting, the performance optimization application may access a server via a network to determine the parameters in the drawing rate limiting policy, or may read a local configuration file of the operating system to determine the parameters in the drawing rate limiting policy. The performance optimization application is provided with an interface, and another application may access the performance optimization application via the interface to determine the background drawing frequency of the application.

[0253] Alternatively, after being launched, the application program generates a drawing frequency limiting module that reads a local configuration file of the system to obtain a drawing frequency limiting policy, and determines the background drawing frequency of the application program according to the drawing frequency limiting policy.

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

[0255] As shown in FIG. 10, the application program framework layer may include a window manager, a content provider, a view system, a telephone manager, a resource manager, a notification manager, a Local Profile Assistant (LPA), and the like.

[0256] A window manager is configured to manage window programs. A window manager can get the size of the display, determine if there is a status bar, lock the screen, and capture the screen.

[0257] Content providers are configured to store and retrieve data and make the data accessible by applications. Data may include video, images, audio, calls made and received, browsing history, bookmarks, address books, and the like.

[0258] The telephone manager is configured to provide communication functions for the electronic device 100, such as call state management (including call connection and termination).

[0259] The resource manager provides various resources, such as localized strings, icons, pictures, layout files, and video files, to application programs.

[0260] The notification manager allows application programs to display notification information in the status bar and can be configured to convey notification messages. The displayed notification information may disappear without user interaction after a short pause. For example, the notification manager is configured to notify of download completion, message reminders, etc. Alternatively, the notification manager may be a notification that appears in the form of a chart or scrollbar text on top of the system status bar, e.g., a notification that an application program is running in the background, or a notification that appears on the screen in the form of a dialog interface. For example, text information may be prompted in the status bar, a prompt sound may be played, the electronic device may vibrate, or an indicator light may flash.

[0261] The view system includes visual controls, such as a control for displaying text and a control for displaying pictures. The view system can be used to build application programs. A display interface may be formed by one or more views. For example, a display interface that includes a short message notification icon may include a view for displaying text and a view for displaying an image.

[0262] The application program framework layer further includes a performance optimization system, and the drawing frequency limit policy can be stored in the performance optimization system. After the application program is started, the performance optimization system can be directly accessed using a callback method provided by the operating system to determine the background drawing frequency of the application program.

[0263] The runtime contains the core libraries and the virtual machine, and is responsible for scheduling and managing the Android system.

[0264] The core library contains two parts: one part is the functional functions that the Java language needs to call, and the other part is the core library.

[0265] The application program layer and the application frame program work layer run in a virtual machine. The virtual machine executes the Java files of the application program layer and the application frame program work layer as binary files. The virtual machine is configured to implement functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0266] The system library may include multiple functional modules, for example, a surface manager, a media library, a three-dimensional graphics processing library (eg, OpenGL ES), and a two-dimensional graphics engine (eg, SGL).

[0267] The surface manager is configured to manage the display subsystem and provides a blend of two-dimensional (2D) and three-dimensional (3D) layers for multiple application programs.

[0268] The media library supports the playback and recording of multiple commonly used audio and video formats, still image files, etc. The media library supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.

[0269] The 3D graphics processing library is configured to realize 3D graphics drawing, image rendering, compositing, and layer processing.

[0270] A 2D graphics engine is a drawing engine for 2D drawing.

[0271] The kernel layer is a layer between the hardware and the software, and includes at least a display driver, a camera driver, an audio driver, a sensor driver, and a virtual card driver.

[0272] The choreographer in this application can be placed in the view system of the application program framework layer. When the application program needs to refresh the interface, the application program calls the choreographer in the view system, generates a choreographer object specific to the application program, and performs a drawing operation. When performing a drawing operation, the choreographer can use a callback method to perform the drawing operation using a surface manager, a two-dimensional graphic engine, etc. in the core library.

[0273] Note that when the operating system version is updated, the server can update the configuration file in the new version of the file to update the rendering rate limiting policy.

[0274] For example, FIG. 11 is a schematic block diagram of another software architecture of the electronic device 100 according to an embodiment of the present application.

[0275] In some embodiments, the system is divided into four layers from top to bottom: an application layer, a framework layer, a system services library, and a kernel layer.

[0276] The application layer includes system applications and third-party non-system applications.

[0277] The system applications may include a performance optimization application. The performance optimization application may or may not provide a visual interface or view. After booting of the electronic device, the performance optimization application may be automatically launched without user interaction. The performance optimization application stores a drawing rate limiting policy used to determine a correspondence between an application program and a background drawing frequency. After launching, the performance optimization application may access a server over a network to determine parameters in the drawing rate limiting policy, or may read a local configuration file of the operating system to determine parameters in the drawing rate limiting policy. The performance optimization application is provided with an interface through which another application may access the performance optimization application to determine the background drawing frequency of the application.

[0278] Alternatively, after being launched, the application program generates a drawing frequency limiting module that reads a local configuration file of the system to obtain a drawing frequency limiting policy, and determines the background drawing frequency of the application program according to the drawing frequency limiting policy.

[0279] The framework layer provides JAVA / C / C++ / JS and other multi-language user program frameworks and function frameworks for application programs in the application layer, and multi-language framework APIs open to the outside for various software and hardware services.

[0280] The system service layer includes a system basic functional subsystem set, a basic software service subsystem set, an extended software service subsystem set, and a hardware service subsystem set.

[0281] The system basic functional subsystem set supports the operation of the operating system on multiple devices, such as operation, scheduling, migration, etc. The system basic functional subsystem set can include a distributed soft bus, a distributed data management, a distributed task scheduling, and a common basic subsystem. The system service layer and the framework layer jointly implement a multi-mode input subsystem, a graphics subsystem, etc. The drawing frequency limit policy can be stored in the graphics subsystem. After an application program starts, it can directly access the graphics subsystem using a callback method provided by the operating system to determine the background drawing frequency of the application program. The choreographer of the present application can be placed in the graphics subsystem. When an application program needs to refresh an interface, the application program calls the choreographer in the view system, generates a choreographer object specific to the application program, and performs the drawing operation.

[0282] The base software service subsystem set provides common software services common to operating systems and may include an event notification subsystem, a multimedia subsystem, and the like.

[0283] The extended set of software service subsystems provides differentiated software services for different devices and can include an IoT dedicated service subsystem.

[0284] The hardware service subsystem set provides hardware services to the operating system and may include an IoT-specific hardware service subsystem.

[0285] It is noted that based on the deployment environments of different device forms, the basic functional subsystem set, the basic software service subsystem set, the extended software service subsystem set, and the hardware service subsystem set of the system may be subdivided according to other functional granularity.

[0286] The kernel layer includes a kernel abstraction layer and a driver subsystem. The kernel abstraction layer includes multiple kernels and provides basic kernel functions of the upper layers by shielding the differences between the multiple kernels, such as thread / process management, memory management, file system, and network management. The driver subsystem provides a unified peripheral access function and a driver development and management framework for software developers.

[0287] However, depending on different operating systems and possible future upgrades, the software structure of the electronic device may be divided in other ways depending on the operating system.

[0288] The following describes how to perform drawing operations with the application provided herein.

[0289] FIG. 12 is a schematic diagram of an example of a method for performing drawing operations by an application in accordance with the present application.

[0290] As shown in FIG. 12, the method for performing a drawing operation by an application provided in the present application may include the following steps.

[0291] S1201: The application program determines the background drawing frequency based on the frequency restriction policy.

[0292] When an application program is converted from a foreground application to a background application, the application program determines the background drawing frequency based on the rate limiting policy.

[0293] Specifically, it is first necessary to determine when an application program is converted from a foreground application to a background application. The operating system provides a drawing frequency limiting module configured to determine whether an application program is a foreground application or a background application. The drawing frequency limiting module can directly listen to the life cycle of the main activity of the application program via a configuration interface, and can further determine the running state of the application program, i.e., whether the application program is a foreground application or a background application. Alternatively, the drawing frequency limiting module can use an activity manager service to determine the running state of the application program, i.e., whether the application program is a foreground application or a background application.

[0294] Then, when it is determined that the application program has been converted from a foreground application to a background application, the application program can determine a background drawing frequency of the application program according to the drawing frequency limit policy, where the background drawing frequency is a frequency at which a choreographer of the application program performs drawing operations after the application program becomes a background application.

[0295] In this embodiment of the present application, the drawing frequency limit policy is preset and is for setting the background drawing frequency when a different application becomes a background application.

[0296] The drawing frequency limit policy may be set in a drawing frequency limit module, which may communicate with a choreographer of an application program via an interface. Specifically, the drawing frequency limit module may be pre-set by an operating system. Specifically, the drawing frequency limit module may be set inside each application program. Alternatively, the drawing frequency limit module may be set within a service of the operating system and / or within another application that maintains an execution state. The application program may access the drawing frequency limit module via an interface to determine the background drawing frequency of the application program.

[0297] The background drawing frequency determined by the application program is less than the frequency at which the vertical synchronization signal is generated (or the screen refresh rate).

[0298] It is considered that the developer of the application program needs to transfer some parameters to the activity of the application program or other modules through the drawing operation executed by the choreographer when developing the application program. That is, the application program executes the drawing operation for the purpose of not refreshing the interface. In this case, if the application program is a background application, the frequency at which the background application requests a vertical synchronization signal is less than the generation frequency of the vertical synchronization signal (or the screen refresh rate). In this case, the background drawing frequency determined by the application program in step S1201 may be less than or equal to the generation frequency of the vertical synchronization signal (or the screen refresh rate).

[0299] Optionally, in some embodiments of the present application, if the frequency at which an application program requests a vertical synchronization signal is less than the frequency at which the vertical synchronization signal is generated (or the screen refresh rate), the background drawing frequency determined by the application program based on the frequency limiting policy may be equal to the frequency at which the vertical synchronization signal is generated (or the screen refresh rate).

[0300] Optionally, in some embodiments of the present application, the background drawing frequency of an application program may be determined when the application program is launched or after the application program is launched.

[0301] Optionally, in some embodiments of the present application, the drawing rate limiting module may provide an interface for an application program to change the background drawing rate of the application program, and the application program may configure the background drawing rate of the application program via the interface.

[0302] For example, as shown in Table 1, Table 1 is a schematic table of a drawing frequency restriction policy according to an embodiment of the present application. [Table 1] [Table 1]

[0303] As shown in Table 1, when Music is switched to a background application, its background rendering frequency is set to 1 / 6 of the vertical sync frequency, in accordance with the rendering frequency limiting policy. When the Gallery is switched to a background application, its background rendering frequency is set to 0, in accordance with the rendering frequency limiting policy.

[0304] It is understood that different background drawing frequencies can be configured according to drawing frequency limiting policies of different applications or different types of applications (social applications, game applications, and other applications), which helps to properly allocate system resources and reduce power consumption of electronic devices.

[0305] Optionally, as shown in the following contents of Figures 13A to 13E, in some embodiments of the present application, a user can personalize parameters of the drawing frequency limit policy with reference to the performance and usage requirements of the electronic device.

[0306] 13A-13E are schematic diagrams of example interfaces for drawing frequency limiting policies according to the present application.

[0307] As shown in FIG. 13A, a user can select an application program on the main interface of the electronic device by touching and holding, for example, selecting "Huawei AppGallery". Furthermore, as shown in FIG. 13B, after a user touches and holds to select an application program, the user can select an information option by tapping. Furthermore, as shown in FIG. 13C, after a user selects the information option, the user can view the related information of the application, which includes a power-saving management option responsible for scheduling the application program. Furthermore, as shown in FIG. 13D, a user can set a drawing limit frequency corresponding to an application program in the drawing frequency limit policy by setting a specific parameter in the power-saving management option. Furthermore, as shown in FIG. 13E, a user can specifically set a background drawing frequency when an application program is converted into a background application.

[0308] As shown in FIG. 13(D), when the user selects intelligent power saving, the application program determines the background drawing frequency of the application program based on parameters preset in the drawing frequency restriction policy.

[0309] For the concepts of terms such as foreground application, background application, choreographer, and main activity, please refer to the text explanations of (1) foreground application and background application, (2) activity, and (3) choreographer and drawing operation in the above terminology explanation. The details will not be explained again here.

[0310] S1202: The application program performs a drawing operation based on the background drawing frequency.

[0311] Specifically, after determining the background drawing frequency, the choreographer of the application program intercepts a vertical synchronization signal based on the background drawing frequency, or intercepts the choreographer's drawing operation and performs a meaningless drawing operation based on the background drawing frequency.

[0312] For the concepts of terms such as meaningless drawing operations, please refer to the text explanations of Choreographer and Drawing Operations (3) in the Terminology Explanation. The details will not be explained again here.

[0313] Next, referring to the contents shown in Figure 12, and taking the contents shown in Figures 14 and 15 as examples, a method of intercepting a vertical synchronization signal based on the background drawing frequency and a method of intercepting a choreographer's drawing operations based on the background drawing frequency will be explained in detail.

[0314] FIG. 14 is a schematic diagram of an example of how a choreographer intercepts receiving a vertical synchronization signal according to an embodiment of the present application.

[0315] As shown in (A) of FIG. 14, after receiving a vertical sync signal through the OnVsync callback method, the choreographer of the application program first determines whether the application program to which the choreographer belongs is a foreground application or a background application. If the application program is a foreground application, a default drawing operation is performed. If the application program is a background application, after the application program is switched to the background application, the vertical sync signal is recorded as the Kth vertical sync signal, and the value of K and the first threshold are determined. If K is less than the first threshold, the default drawing operation is skipped. Alternatively, if K is equal to the first threshold, K is cleared, recounted, and the default drawing operation is performed. Skipping the default drawing operation may indicate that the choreographer does not call the doFrame callback method to intercept the drawing operation.

[0316] The electronic device may determine a background drawing frequency or a first threshold of the application program according to the drawing frequency limit policy. After determining the background drawing frequency of the application program according to the drawing frequency limit policy, the electronic device may determine the first threshold corresponding to the background drawing frequency. After determining the first threshold of the application program according to the drawing frequency limit policy, the electronic device may determine the background drawing frequency corresponding to the first threshold.

[0317] For example, if both the frequency of occurrence of the vertical synchronization signal and the screen refresh rate of the electronic device are 90 Hz, and the application program determines the background drawing frequency to be 18 Hz according to the drawing frequency limit policy, the electronic device may determine a first threshold value corresponding to a background drawing frequency of 18 Hz. The first threshold value may be the frequency of occurrence of the vertical synchronization signal (or the screen refresh rate) divided by the background application drawing frequency of the application program. That is, the first threshold value is 5. In this case, when the application program becomes a background application, the choreographer of the application program executes the default drawing operation only once every five vertical synchronization signals are received.

[0318] As another example, if an application program determines that a first threshold for the application program is 5 according to a drawing frequency limiting policy, the electronic device may determine that the background drawing frequency corresponding to the first threshold of 5 is 18 Hz.

[0319] In addition, when the background drawing frequency is 0, the first threshold value is, for example, 2 10 Alternatively, the content shown in FIG. 14A may be changed. K is cleared so that the application program does not perform the default drawing operation after the application program receives the vertical synchronization signal. Alternatively, after the application program receives the vertical synchronization signal, K is always equal to 0 because the application program does not count the vertical synchronization signal, and the application program does not perform the default drawing operation.

[0320] Specifically, as shown in (B) of FIG. 14, when the application program is a foreground application, the interval at which the application program performs a drawing operation is 1 / 90 seconds. That is, the application program performs a drawing operation after receiving a vertical synchronization signal. When the application program is a background application, the interval at which the application program performs a drawing operation is 5 / 90 seconds. That is, the application program performs a default drawing operation only after receiving five vertical synchronization signals. For example, starting from 0 seconds, the choreographer of the application program requests a vertical synchronization signal every 1 / 90 seconds. If the application program becomes a background application at 0 seconds, 1 / 90 seconds, 2 / 90 seconds, 3 / 90 seconds, and 4 / 90 seconds, the drawing operation of the choreographer of the application program is intercepted because K is less than 5. At 5 / 90 seconds, the choreographer of the application program receives a vertical synchronization signal. In this case, K=5. Therefore, the drawing operation of the application program is not intercepted, and the default drawing operation is executed once. The drawing operation executed when the application program is a background application is a meaningless drawing operation.

[0321] Note that the time consumed by each drawing operation performed by the choreographer may be different or the same, this is not a limitation of this application.

[0322] FIG. 15 is a schematic diagram of an example of how a choreographer intercepts processing an animation event task according to an embodiment of the present application.

[0323] As shown in Figure 15, the choreographer of the application program receives the vertical synchronization signal using the OnVsync callback method and then starts to perform drawing operations. The drawing operations include processing input event tasks, animation event tasks, layout event tasks, and submission event tasks. The choreographer of the background application processes input event tasks, layout event tasks, and Submission This is because the choreographer does not get the event task, so the choreographer is intercepted from processing the animation event task, and as a result, the execution of meaningless drawing operations is intercepted.

[0324] Specifically, after receiving a vertical synchronization signal and before starting a drawing operation, the application program determines whether the application program to which the choreographer belongs is a background application. If the application program to which the choreographer belongs is a foreground application, the default drawing operation can be continued. If the application program to which the choreographer belongs is a background application, the doFrame callback method can skip the processing of the animation event task or directly end the drawing operation, thereby preventing the choreographer from performing meaningless drawing operations.

[0325] For example, when the background drawing frequency is 0, at the start of the choreographer's doFrame callback method, it may be determined whether the application program to which the choreographer belongs is a foreground application or a background application. If the determination result is a background application, the choreographer can skip the execution of the doCallbacks callback method for processing animation event tasks in the doFrame callback method. In this case, the choreographer still invokes the doCallbacks callback method to process input event tasks, layout event tasks, and submission event tasks, but the input event tasks, layout event tasks, and submission event tasks are empty. Therefore, the animation event tasks processed by the choreographer can be skipped to intercept the choreographer from performing meaningless drawing operations.

[0326] If the determination is that it is the foreground application, then default drawing operations are performed.

[0327] In addition, when the background drawing frequency is greater than 0, the choreographer can intercept the processing of the animation event task, thereby reducing the frequency of meaningless drawing operations by the background application, as shown in FIG. 14B. For example, before the doCallbacks callback method is called to process the animation event task, it is determined that the vertical synchronization signal received by the choreographer is the Kth vertical synchronization signal. If K is less than the first threshold, the choreographer skips processing the animation event task. If K is equal to the first threshold, the choreographer is allowed to process the animation event task, and K is cleared and then counted again.

[0328] It can be appreciated that by intercepting the choreographer's receipt of a vertical synchronization signal or by intercepting the choreographer's processing of animation event tasks, the frequency with which background applications perform meaningless drawing operations can be reduced.

[0329] If the background drawing frequency determined in step S1201 is equal to the vertical synchronization signal generation frequency (or screen refresh rate), that is, if the application program does not perform drawing operations for the purpose of refreshing the interface, a minimum time interval T1 can be determined based on the background drawing frequency. According to T1, the drawing operations that need to be intercepted are determined, and according to T1, the drawing operations that can be performed are determined.

[0330] Specifically, after an application program is switched to a background application, if the frequency at which the choreographer of the application program requests a vertical synchronization signal is less than the frequency at which the vertical synchronization signal occurs (or the screen refresh rate), the application can be considered to be performing a drawing operation for the purpose of not refreshing the interface. In this case, when the choreographer of the application program receives a first vertical synchronization signal, a default drawing operation is performed. When a vertical synchronization signal other than the first is received, the application program may determine a time interval between the vertical synchronization signal and the previous vertical synchronization signal. If the time interval is less than the time interval threshold corresponding to the background drawing frequency, the drawing operation corresponding to the vertical synchronization signal is intercepted. If the time interval is greater than the time interval threshold corresponding to the background drawing frequency, the drawing operation corresponding to the vertical synchronization signal is performed.

[0331] Next, using the content shown in FIG. 16 as an example, it will be specifically described how meaningless drawing operations are intercepted when an application program performs drawing operations with the purpose of not refreshing the interface.

[0332] FIG. 16 is a schematic diagram of an example of intercepting a choreographer's drawing operations according to an embodiment of the present application.

[0333] When the background drawing frequency of the application program is 30 Hz, the parameter T1 is 3 / 90 seconds. As shown in FIG. 16A, the choreographer of the application program requests and receives a vertical synchronization signal transmitted from SurfaceFlinger every 1 / 90 seconds. Therefore, in the case shown in FIG. 16A, the application program performs a drawing operation for the purpose of refreshing the interface. If the application program performs a meaningless drawing operation at 2 / 90 seconds, the next meaningless drawing operation will be performed at 5 / 90 seconds.

[0334] Unlike the content shown in (A) of Figure 16, as shown in (B) of Figure 16, the application program choreographer requests and receives vertical synchronization signal 1 at 2 / 90 seconds, requests and receives vertical synchronization signal 2 at 6 / 90 seconds, and requests and receives vertical synchronization signal 3 at 7 / 90 seconds.

[0335] There may be several ways for an application program to determine whether or not a drawing operation is required without refreshing the interface.

[0336] For example, in the case shown in (B) of Fig. 16, between 0 and 8 / 90 seconds, the frequency at which the application program requests a vertical synchronization signal from SurfaceFlinger is 4 / 15 Hz, which is lower than the frequency at which the vertical synchronization signal occurs (90 Hz or the screen refresh rate), and therefore the application program performs drawing operations in order not to refresh the interface. The frequency at which an application program requests a vertical synchronization signal is the number of times the application program requests a vertical synchronization signal per unit time.

[0337] As another example, if an application program receives a vertical sync signal at 2 / 90ths of a second, and then does not receive a vertical sync signal at 3 / 90ths of a second, it may determine that the application program has requested to perform a drawing operation with the intent of not refreshing the interface.

[0338] At 2 / 90 seconds, the choreographer of the application program receives vertical synchronization signal 1, and before 2 / 90 seconds, the choreographer of the application program does not receive any other vertical synchronization signal. Therefore, the choreographer can perform a drawing operation corresponding to vertical synchronization signal 1 at 2 / 90 seconds. At 6 / 90 seconds, the choreographer of the application program receives vertical synchronization signal 2. The choreographer of the application program finally receives vertical synchronization signal 1 at 6 / 90 seconds. The time interval is 4 / 90 seconds, which is greater than T1. Therefore, the choreographer can perform a drawing operation corresponding to vertical synchronization signal 1 at 6 / 90 seconds. At 7 / 90 seconds, the choreographer of the application program receives vertical synchronization signal 3. The choreographer of the application program finally receives vertical synchronization signal 1 at 6 / 90 seconds. The time interval is 1 / 90 seconds, which is less than T1. Therefore, the drawing operation of the application program is intercepted.

[0339] Optionally, in some embodiments of the present application, see the contents shown in Figures 13A to 13E and 14. In / before the OnVsync method, the choreographer receives a vertical synchronization signal, thereby reducing the frequency of performing meaningless drawing operations after the application program becomes a background application.

[0340] Optionally, in some embodiments of the present application, see the contents shown in Figures 13A to 13E and 14. Because the choreographer intercepts requests for vertical synchronization signals from SurfaceFlinger, the frequency of performing meaningless drawing operations after an application program becomes a background application is reduced.

[0341] Note that if the choreographer is intercepted from requesting a vertical sync signal from SurfaceFlinger, or if the choreographer is intercepted from receiving a vertical sync signal before the OnVsync method, the choreographer must be isolated, thereby preventing the choreographer from only performing drawing operations, without affecting the normal operation of the choreographer's other functionality.

[0342] Optionally, in some embodiments of the present application, see the contents shown in Figures 13A to 13E and 14. Since data in the one-way linked list storing animation event tasks is deleted, the frequency of meaningless drawing operations after the application program becomes a background application is reduced.

[0343] Next, with reference to the method of performing a drawing operation by an application shown in FIG. 12, the method of performing a drawing operation by an application in an embodiment of the present application will be described below using the contents shown in FIG. 16 and FIG. 17 as an example.

[0344] FIG. 17 is a schematic diagram of an example scenario for managing and controlling pointless drawing operations of background applications according to an embodiment of the present application.

[0345] As shown in Fig. 17, when a user launches an application program, the activity manager service can obtain registration information of the application program. The registration information uniquely identifies the application program. For example, the registration information may be a package name of the application program or a process name of the application program. This is not limited here.

[0346] After a user launches an application program, the application program initializes at least one choreographer and at least one drawing frequency limiting module.

[0347] After a user launches an application program, the application program initializes a choreographer and a drawing frequency restriction module. The drawing frequency restriction module can call back a method of the activity manager service through an interface to determine the running state of the application program, i.e., whether the application program is a foreground application or a background application. The drawing frequency restriction module can also use the activity manager service to obtain registration information of the application program. The registration information uniquely identifies the application program. For example, the registration information may be a package name of the application program, or the registration information may be a process name corresponding to the application program. This is not limited here.

[0348] If the application program is a foreground application, the choreographer may execute the default drawing operation. Alternatively, before executing the default drawing operation, the choreographer may request from the drawing frequency limiting module whether to allow the current drawing. Before receiving the background application identifier, the drawing frequency limiting module always allows the choreographer to execute the default drawing operation.

[0349] When the application program is switched to a background application, the activity manager service determines that the application program is switched to a background application when the main activity of the application program executes an onStop method, or / and detects that the cpuset parameter of the process of the application program is background or key-background. The activity manager service notifies the drawing rate limiting module that the application program will become a background application. After determining that the application program is a background application, the activity manager service sends a background application identifier to the drawing rate limiting module. The background application identifier may include registration information of the application program. After receiving the background application identifier, the drawing rate limiting module can determine the background drawing frequency according to the drawing rate limiting policy.

[0350] When the application program becomes a background application, the application program's choreographer sends a request for a vertical sync signal to SurfaceFlinger because the application program is not frozen. In response to the application program's request, SurfaceFlinger sends a vertical sync signal to the application program's choreographer.

[0351] After receiving a vertical synchronization signal and before executing a drawing operation, the choreographer of the application program sends a request for drawing information to the drawing frequency limiting module. If the choreographer receives a drawing permission request from the drawing frequency limiting module, the choreographer continues to execute the current meaningless drawing operation. However, if the choreographer does not receive a drawing permission request from the drawing frequency limiting module, the choreographer directly ends the meaningless drawing operation. For the drawing frequency limiting module to determine whether to allow the choreographer to perform the current meaningless drawing operation based on the background drawing frequency, see the contents shown in FIG. 12. Details will not be described again here.

[0352] It should be noted that the drawing rate limiting module may be located within an application's choreographer or within an operating system service.

[0353] With reference to the contents of FIG. 12 and the drawing frequency restriction policy shown in Table 1, the scenario shown in FIG. 17 will be specifically explained using an application program such as Music as an example.

[0354] When a user launches Music, the activity manager service can get the music package name com.android.mediacenter and the process name HWMusic. The activity manager server sends the Music package name and / or process name to the rendering rate limiting module. The rendering rate limiting module determines that Music's background rendering rate should be 10Hz based on the current vertical sync frequency (60Hz) and Music's registration information.

[0355] When the user switches Music to the background, the activity manager server sends the background application identifier to the drawing frequency limiting module. In this case, after the Music choreographer receives a vertical synchronization signal, the choreographer requests drawing from the drawing frequency limiting module. The drawing frequency limiting module allows the choreographer to perform one drawing operation for every five drawing requests received by the choreographer, and reduces the frequency of meaningless drawing operations by the Music choreographer to 10Hz.

[0356] When the user switches Music from the background to the foreground, the activity manager server notifies the drawing rate limiting module, which then runs the choreographer and performs drawing operations whenever it receives a drawing request from the choreographer.

[0357] FIG. 18 is a schematic diagram of another example scenario of managing and controlling pointless drawing operations of background applications according to an embodiment of the present application.

[0358] As shown in Fig. 18, similar to the contents shown in Fig. 17, after starting an application program, a user initializes a choreographer of the application program, and initializes a drawing frequency limiting module in the choreographer in the initialization process of the choreographer. After the drawing frequency limiting module is initialized, the drawing frequency limiting module determines the background drawing frequency of the application program according to the drawing frequency limiting policy.

[0359] If the application program is the foreground application, the application program's choreographer performs default drawing operations.

[0360] When the application program is switched to a background application, the activity manager service sends a background application identifier to the drawing frequency limiting module. After receiving the background application identifier, the drawing frequency limiting module determines that the application program is a background application.

[0361] After the application program is switched to the background application, the choreographer requests and receives a vertical synchronization signal, and then uses the doFrame method to perform drawing operations. The drawing frequency limiting module can intercept the choreographer from processing an animation event task, so that the choreographer does not actually perform the current meaningless drawing operations.

[0362] After the application program is switched from a background application to a foreground application, the activity manager service sends a foreground application identifier to the choreographer of the application program. After receiving the foreground application identifier, the drawing frequency restriction module determines that the application program to which the choreographer belongs is switched to a foreground application, and therefore does not intercept the choreographer from processing the animation event task, so that the choreographer can perform default drawing operations.

[0363] Depending on the context, the term "when" as used in the above embodiments may be interpreted to mean "when," "after," "in response to determining," or "in response to detecting." Similarly, depending on the context, the phrase "upon determining that" or "when (a described condition or event) is detected" may be interpreted to mean "upon determining that" or "in response to determining" or "when (a described condition or event) is detected" or "in response to detecting (a described condition or event)."

[0364] All or part of the above-mentioned embodiments can be implemented by software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the procedures or functions according to the embodiments of the present application are generated completely or partially. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or another programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from the computer-readable storage medium to another computer-readable storage medium. For example, computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, or digital subscriber line) or wireless (e.g., infrared, radio, or microwave) methods. A computer-readable storage medium may be any available medium accessible by a computer, or a data storage device such as a server or a data center that incorporates one or more available media. The available medium may be magnetic media (e.g., floppy disks, hard disks, or magnetic tapes), optical media (e.g., DVDs), semiconductor media (e.g., solid state drives), etc.

[0365] Those skilled in the art may understand that all or part of the process of the method in the above embodiment may be implemented by a computer program that instructs relevant hardware. The program may be stored in a computer-readable storage medium. When the program is executed, the process of the method in the above embodiment is performed. The above storage medium may include any medium that can store program code, such as a ROM, a random access memory RAM, a magnetic disk, or an optical disk.

Claims

1. 1. A method for performing a drawing operation by an application, comprising: launching a first application program by the electronic device; performing, by the electronic device, drawing operations at a first frequency when the first application program is a foreground application, the drawing operations drawing a view for the first application program; performing, by the electronic device, the drawing operation at a second frequency after the first application program is switched from the foreground application to a background application, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; The method includes:

2. The step of performing the drawing operation at a second frequency by the electronic device after the first application program is switched from the foreground application to the background application specifically includes:

2. The method of claim 1, further comprising the step of: after the first application program is switched from the foreground application to the background application, instructing, by the electronic device, a choreographer of the first application program to respond to only N of the K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

3. The step of performing the drawing operation at a second frequency by the electronic device after the first application program is switched from the foreground application to the background application specifically includes:

2. The method of claim 1, further comprising: after the first application program is switched from the foreground application to the background application, instructing, by the electronic device, a choreographer of the first application program to process only animation event tasks corresponding to N vertical synchronization signals out of the K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where N is a positive integer less than K.

4. The step of performing the drawing operation at a second frequency by the electronic device after the first application program is switched from the foreground application to the background application specifically includes:

2. The method of claim 1, further comprising: after the first application program is switched from the foreground application to the background application, deleting, by the electronic device, animation event tasks corresponding to K-N vertical synchronization signals among the K vertical synchronization signals received by a choreographer of the first application program, so that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

5. 5. The method of claim 2, wherein the ratio of N to K corresponds to the ratio of the second frequency to the first frequency.

6. After the step of launching the first application program by the electronic device, the method further comprises: determining, by the electronic device, the second frequency according to a drawing frequency limit policy and the first application program; The method of any one of claims 1 to 5, further comprising:

7. After the step of launching the first application program by the electronic device, the method further comprises: determining, by the electronic device, that the first application program is the foreground application or the background application based on an activity manager service and / or a cpuset parameter of the process of the first application program; The method of any one of claims 1 to 6, further comprising:

8. 1. A method for performing a drawing operation by an application, comprising: launching a first application program by the electronic device; displaying, by the electronic device, an interface of the first application program and performing, by the electronic device, drawing operations at a first frequency, the drawing operations drawing a view for the first application program; closing, by the electronic device, a display of the interface of the first application program; and executing, by the electronic device, the drawing operation at a second frequency, the second frequency being less than the first frequency, the first frequency being a frequency at which the first application program receives a vertical synchronization signal; The method includes:

9. The step of performing the drawing operation at a second frequency by the electronic device specifically includes:

9. The method of claim 8, further comprising the step of instructing, by the electronic device, a choreographer of the first application program to respond to only N of K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

10. The step of performing the drawing operation at a second frequency by the electronic device specifically includes:

9. The method of claim 8, further comprising: instructing, by the electronic device, a choreographer of the first application program to process only animation event tasks corresponding to N vertical synchronization signals out of K received vertical synchronization signals, such that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

11. The step of performing the drawing operation at a second frequency by the electronic device specifically includes:

9. The method of claim 8, further comprising: deleting, by the electronic device, animation event tasks corresponding to KN vertical synchronization signals among the K vertical synchronization signals received by a choreographer of the first application program, so that the electronic device performs the drawing operations at the second frequency, where K is a positive integer and N is a positive integer less than K.

12. 12. The method of claim 9, wherein the ratio of N to K corresponds to the ratio of the second frequency to the first frequency.

13. An electronic device, the electronic device including one or more processors and a memory; An electronic device, wherein the memory is configured to store instructions, and wherein the one or more processors invoke the instructions to enable the electronic device to perform the method of any one of claims 1 to 12.

14. A computer program comprising instructions, when said computer program is executed on an electronic device, enabling said electronic device to carry out the method according to any one of claims 1 to 12.

Citation Information

Patent Citations

  • Frame rate adjustment method and device, storage medium and intelligent terminal

    CN108646906A

  • Screen refreshing method and related equipment

    CN110928396A

  • Terminal power saving method, terminal and readable storage medium

    CN111787602A

  • Display method and program

    JP2019153883A

  • Drive device and display device

    WO2013125405A1