Method and device for reducing power consumption
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2026-03-10
AI Technical Summary
Applications running in electronic devices still apply for vertical synchronous signals to draw image frames after entering the background, resulting in excessive power consumption.
When detecting that there is no visible window in the foreground, the frame rate of the application is reduced, and by setting the frame rate of the first application to the second frame rate, the power consumption waste caused by the background application applying for the vsync signal is alleviated.
It effectively reduces the power consumption of electronic devices, reduces the resource waste caused by background application image frame drawing, and improves the operation efficiency of the device.
Smart Images

Figure CN121646743A_ABST
Abstract
Description
Method and device for reducing power consumption
[0001] This application claims priority to the Chinese patent application filed with the China Patent Office on September 28, 2023, with application number 202311290211.9 and application name “Method and Device for Reducing Power Consumption”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of terminal technology, and in particular to a power consumption reduction device. Background Art
[0003] With the popularization and development of the Internet, people's demands for the functions of electronic devices are becoming more and more diverse. For example, in order to improve users' demand for electronic devices, electronic devices can support the download of various types of applications, which can be system applications or third-party applications.
[0004] However, running more applications on an electronic device can lead to excessive power consumption. For example, an application running on an electronic device may request a vertical synchronization (VSync) signal to render an image, thereby triggering the rendering process of the image frame. Performing these actions requires a certain amount of power consumption.
[0005] Summary of the Invention
[0006] The embodiment of the present application provides a power consumption reduction device, which enables an electronic device to reduce the frame rate when it detects that there is no visible window in the foreground, thereby alleviating the power consumption waste caused by some applications still requesting vsync signals to draw image frames after entering the background.
[0007] In a first aspect, an embodiment of the present application provides a method for reducing power consumption, the method comprising: an electronic device displays a first interface of a first application, wherein the first application is at a first frame rate; in response to a first operation, the electronic device displays a second interface, and the second interface does not include any window of the first application; wherein the first application issues a drawing request to draw in the first window, the electronic device sets the frame rate of the first application to a second frame rate, the second frame rate is less than the first frame rate, and the first window is invisible.
[0008] The first interface may be an interface displayed when the first application is in the foreground, and the first operation is an operation of switching the first application from the foreground to the background. The second interface may display the desktop or the interface of other applications.
[0009] In this way, when the first application switches from the foreground to the background, the electronic device can reduce the frame rate of the first application, thereby alleviating the power consumption waste caused by the first application still applying for the vsync signal to draw image frames after entering the background.
[0010] In one possible implementation, the electronic device sets the frame rate of the first application to the second frame rate, including: when the first application is in the first list, the electronic device sets the frame rate of the first application to the second frame rate, and the first list includes applications that are allowed to apply for vertical synchronization vsync signals in the background.
[0011] In this way, the electronic device can configure the first list to perform frame reduction processing on applications that are allowed to apply for vsync signals in the background when switching to the background, thereby reducing power consumption waste caused by image drawing at a high frame rate.
[0012] Among them, the first list can be the first control list described in the embodiment of this application.
[0013] In one possible implementation, the method also includes: the electronic device displays a third interface of the second application, wherein the second application is at a first frame rate; in response to the second operation, the electronic device displays a fourth interface, and the fourth interface does not include any window of the second application; wherein the second application issues a drawing request to draw in the second window, and the electronic device maintains the second application at the first frame rate, wherein the second window is not visible and the second application does not belong to the first list.
[0014] The third interface may be an interface displayed when the second application is in the foreground, and the second operation is an operation of switching the first application from the foreground to the background. The fourth interface may display the desktop or the interface of other applications.
[0015] In this way, when the second application switches from the foreground to the background, since the second application does not belong to the first list, the second application will not apply for the vsync signal in the background, and the electronic device does not need to perform frame reduction processing for the second application, and the second application can maintain the first frame rate.
[0016] In one possible implementation, after the electronic device sets the frame rate of the first application to the second frame rate, the method further includes: the electronic device adds the first application to the second list to obtain a third list, the second list includes: applications with a frame rate of the second frame rate, and the third list includes the first application.
[0017] Both the second list and the third list can be the second control list described in the embodiments of the present application.
[0018] In this way, the electronic device can perform real-time control on the frame reduction application through the setting of the second control list.
[0019] In one possible implementation, a first thread is run in an electronic device, and when the electronic device receives a first vsync signal request sent by a first application at a first moment, the first vsync signal is distributed to the first application at a second moment through the first thread; when the electronic device receives a second vsync signal request sent by the first application at a third moment, the second vsync signal is distributed to the first application at a fourth moment through the first thread, and the second vsync signal request is the next vsync signal request of the first vsync signal request, and the time interval between the fourth moment and the second moment is determined by the electronic device based on the second frame rate.
[0020] In this way, the electronic device can delay the distribution of the vsync signal requested by the background application through the first thread, thereby reducing the power consumption waste caused by the background application when drawing the screen.
[0021] In one possible implementation, when the electronic device receives a second vsync signal request sent by the first application at a third moment, the second vsync signal is distributed to the first application through the first thread at a fourth moment, including: when the electronic device receives a second vsync signal request sent by the first application through the second thread at the third moment, and when it is determined that the first application is in the third list, the first thread is woken up, wherein the first thread starts a timer, and the timer notifies the first thread to distribute the second vsync signal to the first application at the fourth moment.
[0022] In this way, the electronic switching device can wake up the first thread, and the first thread can implement delayed distribution of the vsync signal, thereby reducing power consumption waste caused by background applications drawing pictures.
[0023] In one possible implementation, the electronic device runs a third application in the foreground, and a second thread is also running in the electronic device. When the electronic device receives a third vsync signal request sent by the third application, the electronic device distributes the third vsync signal to the third application through the second thread, and the electronic device distributes the first vsync signal to the first application at the second moment through the first thread.
[0024] In this way, the electronic device can control the distribution of different vsync signals through two threads, and ensure the delayed distribution of vsync signals of background applications without affecting the foreground application's request for vsync signals for screen drawing, thereby maintaining the normal operation of foreground and background applications.
[0025] In one possible implementation, a fourth application is also running in the electronic device, the fourth application belongs to the first list, and the fourth application belongs to the third list. Between the third moment and the fourth moment, the electronic device receives a fourth vsync signal request sent by the fourth application. The method also includes: the electronic device distributes the second vsync signal to the first application at the fourth moment through the first thread, and distributes the fourth vsync signal to the fourth application at the fourth moment.
[0026] In this way, when the fourth application also belongs to the third list, the electronic device can control the distribution of the vacancy signals of the two applications through one thread, ensuring that the background applications can all draw pictures at the first frame rate.
[0027] In a possible implementation, the electronic device is configured with a display composition system, which runs an event thread, the second thread is a main thread in the event thread, and the first thread is a delay thread in the event thread.
[0028] In one possible implementation, the method further includes: in response to an operation of closing the first application, when the first application is in the first list, the electronic device sets the frame rate of the first application to the first frame rate; and the electronic device removes the first application from the third list.
[0029] In this way, when the first application is closed, the electronic device can restore the frame rate of the first application to the first frame rate, so that when the first application is subsequently started, the electronic device can continue to use the first frame rate to draw the screen of the first application.
[0030] In one possible implementation, an electronic device is configured with: an active task manager service and a display synthesis system, and the electronic device sets the frame rate of a first application to a second frame rate, including: the task manager service sends a first message to the display synthesis system, the first message including: the package name of the first application, information indicating that the frame reduction feature is enabled, and information indicating that the first application is in the background; the display synthesis system obtains the second frame rate based on the information indicating that the frame reduction feature is enabled; and the display synthesis system sets the frame rate of the first application to the second frame rate.
[0031] In this way, the task manager can initiate a frame reduction process by sending a first message to the display composition system, so that the display composition system can delay the distribution of the vsync signal requested by the first application based on the second frame rate, thereby alleviating the power consumption waste caused by the first application still applying for the vsync signal to draw image frames after entering the background.
[0032] In a possible implementation, the first message further includes: a user identifier UID of the first application.
[0033] In this way, since some applications in electronic devices can support the application clone function, and the application package name cannot distinguish the two applications in the clone, the electronic device can use the package name of the first application and the UID of the first application to distinguish the specific running applications in the application clone scenario to improve the accuracy of the power consumption reduction method.
[0034] In one possible implementation, the method also includes: after the electronic device adds the first application to the second list and obtains the third list, the method also includes: in response to the third operation, the electronic device applies for the window of the first application to be visible; when the first application belongs to the first list, the electronic device sets the frame rate of the first application to the first frame rate; the electronic device removes the first application from the third list.
[0035] In this way, the electronic device can restore the first frame rate of the first application when detecting that the first application switches from the background to the foreground, so that the first application can maintain the first frame rate to draw the screen in the foreground, avoiding screen freezes in the first application.
[0036] The third operation may be an operation of switching the first application from the background to the foreground.
[0037] In one possible implementation, before the electronic device sets the frame rate of the first application to the first frame rate, the method also includes: when the electronic device receives the first frame data from the first application and the electronic device determines that the first application belongs to the third list, the electronic device sets the frame rate of the first application to the first frame rate, and the frame data is data obtained by layer rendering when the first application receives a vsync signal; the electronic device removes the first application from the third list.
[0038] In this way, in order to prevent the display synthesis system from not receiving the first frame rate in the second message when the first application receives frame data for the first time, resulting in frame rate abnormalities in the foreground application and page freezes, the display synthesis system can restore to the first frame rate in advance when it detects that the first application is in the foreground and receives the first frame data.
[0039] In one possible implementation, the electronic device is configured with: a window manager, an active task manager service, and a display synthesis system, and the electronic device applies for the window of the first application to be visible, including: the window manager applies for the window of the first application to be visible; the window manager sends a second message to the active task manager service, and the second message is used to instruct the first application to return to the foreground; when the first application belongs to the first list, the electronic device sets the frame rate of the first application to the first frame rate, including: in response to the second message, when the active task manager service determines that the first application belongs to the first list, the active task manager service sends a third message to the display synthesis system, and the third message includes: the package name of the first application, information indicating that the frame reduction feature is turned off, and information indicating that the first application is in the foreground; the display synthesis system obtains the first frame rate based on the information indicating that the frame reduction feature is turned off; the display synthesis system sets the frame rate of the first application to the first frame rate.
[0040] In this way, the task manager can initiate the frame rate recovery process by sending a second message to the display composition system, so that the display composition system can normally distribute the vsync signal requested by the first application in the foreground based on the first frame rate, thereby ensuring the normal operation of the foreground application.
[0041] In a possible implementation, the second message further includes: a user identifier UID of the first application.
[0042] In this way, since some applications in electronic devices can support the application clone function, and the application package name cannot distinguish the two applications in the clone, the electronic device can use the package name of the first application and the UID of the first application to distinguish the specific running applications in the application clone scenario to improve the accuracy of the power consumption reduction method.
[0043] In a third aspect, an embodiment of the present application provides a display device, which includes a display unit and a processing unit. The display unit is used to process the steps of displaying data in the display device, and the processing unit is used to process the steps of processing data in the display device.
[0044] In a possible implementation, the display device may further include a storage unit. The storage unit may include one or more memories. The memory may be a device in one or more devices or circuits for storing programs or data.
[0045] In a second aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store code instructions; the processor is used to run the code instructions so that the electronic device executes the method described in the first aspect or any implementation of the first aspect.
[0046] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores instructions. When the instructions are executed, the computer executes the method described in the first aspect or any implementation of the first aspect.
[0047] In a fourth aspect, a computer program product includes a computer program, which, when executed, causes a computer to execute the method described in the first aspect or any one of the implementations of the first aspect.
[0048] It should be understood that the second to fourth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] FIG1 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;
[0050] FIG2 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0051] FIG3 is a flow chart of a method for reducing power consumption provided in an embodiment of the present application;
[0052] FIG4 is a flow chart of another method for reducing power consumption provided in an embodiment of the present application;
[0053] FIG5 is a schematic diagram of a process for restoring a frame rate according to an embodiment of the present application;
[0054] FIG6 is a schematic diagram of an interface for switching application states provided in an embodiment of the present application;
[0055] FIG7 is a schematic diagram of a vsync signal distribution process provided by an embodiment of the present application;
[0056] FIG8 is a schematic diagram of a vsync signal distribution process provided by an embodiment of the present application;
[0057] FIG9 is a schematic diagram of a process for obtaining a first control list according to an embodiment of the present application;
[0058] FIG10 is a schematic diagram of another process for obtaining a first control list according to an embodiment of the present application;
[0059] FIG11 is a schematic structural diagram of a power consumption reduction device provided in an embodiment of the present application;
[0060] FIG12 is a schematic diagram of the hardware structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0061] In order to clearly describe the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. For example, the first value and the second value are merely used to distinguish different values and do not limit their order. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit different values.
[0062] It should be noted that, in this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0063] In this application, "at least one" means one or more, and "more" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can mean: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c can be single or multiple.
[0064] Typically, applications running in the foreground of an electronic device can request a vsync signal to trigger the drawing and rendering process of an image frame, while applications running in the background of an electronic device do not need to request a vsync signal. However, some applications that are not developed in a standardized manner still request a vsync signal to draw image frames after entering the background. These applications running in the background may even repeatedly request a vsync signal indefinitely, wasting central processing unit (CPU) resources and device power consumption.
[0065] In view of this, an embodiment of the present application provides a method for reducing power consumption, so that the electronic device can reduce the frame rate when it detects that there is no visible window in the foreground, thereby alleviating the power consumption waste caused by some applications still requesting vsync signals to draw image frames after entering the background.
[0066] It is understandable that the above-mentioned electronic devices may also be referred to as terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. The electronic devices may be mobile phones with touch screens, smart TVs, wearable devices, tablet computers (Pads), computers with wireless transceiver functions, virtual reality (VR) electronic devices, augmented reality (AR) electronic devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc. The embodiments of the present application do not limit the specific technologies and specific device forms adopted by the electronic devices.
[0067] Therefore, in order to better understand the embodiments of the present application, the structure of the electronic device according to the embodiments of the present application is introduced below.
[0068] The electronic device 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, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, an indicator 192, a camera 193, and a display screen 194, etc.
[0069] Among them, the sensor module 180 may include one or more of the following: pressure sensor, gyroscope sensor, air pressure sensor, magnetic sensor, acceleration sensor, distance sensor, proximity light sensor, fingerprint sensor, temperature sensor, touch sensor, ambient light sensor, or bone conduction sensor, etc., which is not specifically limited in the embodiments of the present application.
[0070] It is understood that the structures illustrated in the embodiments of the present application do not constitute specific limitations on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0071] The processor 110 may include one or more processing units. The different processing units may be independent devices or integrated into one or more processors. The processor 110 may also be provided with a memory for storing instructions and data.
[0072] USB port 130 is an interface that complies with USB standards and may be a Mini USB port, a Micro USB port, a USB Type-C port, or the like. USB port 130 can be used to connect a charger to charge an electronic device, transfer data between the electronic device and peripherals, connect headphones to play audio, and connect other electronic devices, such as augmented reality devices.
[0073] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. The power management module 141 is used to connect the charging management module 140 to the processor 110.
[0074] The wireless communication function of the electronic device can be implemented through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor.
[0075] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Antennas in electronic devices can be used to cover single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
[0076] Mobile communication module 150 can provide wireless communication solutions for electronic devices, including 2G / 3G / 4G / 5G. It can include at least one filter, switch, power amplifier, and low-noise amplifier (LNA). Mobile communication module 150 receives electromagnetic waves from antenna 1, filters and amplifies the received electromagnetic waves, and transmits them to a modem processor for demodulation.
[0077] The wireless communication module 160 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), etc.
[0078] The electronic device implements display functions through a GPU, display screen 194, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering.
[0079] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device may include one or N display screens 194, where N is a positive integer greater than one.
[0080] The electronic device can realize the shooting function through the ISP, camera 193, video codec, GPU, display 194 and application processor.
[0081] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0082] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0083] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 can include a program storage area and a data storage area.
[0084] The electronic device can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0085] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. Speaker 170A, also called "speaker", is used to convert audio electrical signals into sound signals. The electronic device can listen to music or listen to hands-free calls through speaker 170A. Receiver 170B, also called "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device answers a call or voice message, the voice can be heard by placing the receiver 170B close to the human ear. The headphone jack 170D is used to connect wired headphones. Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. In an embodiment of the present application, the electronic device may have a microphone 170C.
[0086] The pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor can be set on the display screen 194. The gyroscope sensor can be used to determine the motion posture of the electronic device. The air pressure sensor is used to measure the air pressure. The magnetic sensor includes a Hall sensor. The acceleration sensor can detect the magnitude of the acceleration of the electronic device in various directions (generally three axes). The distance sensor is used to measure the distance. The proximity light sensor can include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor is used to sense the brightness of the ambient light. The fingerprint sensor is used to collect fingerprints. The temperature sensor is used to detect the temperature. The touch sensor is also called a "touch device". The bone conduction sensor can obtain vibration signals.
[0087] A touch sensor can be provided on display screen 194, and the touch sensor and display screen 194 form a touch screen, or "touch screen." In embodiments of the present application, the touch screen can include a grid of capacitive sensing nodes (hereinafter referred to as a capacitive sensor). When the electronic device determines that the capacitance value of at least one grid cell received by the capacitive sensor exceeds a capacitance threshold, it can determine that a touch operation has occurred. Furthermore, the electronic device can determine the touch area corresponding to the touch operation based on the area occupied by the at least one grid cell that exceeds the capacitance threshold.
[0088] Keys 190 include a power button, volume button, and other buttons. Keys 190 can be mechanical or touch-sensitive. The electronic device can receive key inputs and generate key signal inputs related to user settings and function control of the electronic device. Indicator 192 can be an indicator light that can be used to indicate charging status, battery level changes, messages, missed calls, notifications, and the like.
[0089] The software system of the electronic device can adopt a layered architecture, event-driven architecture, micro-kernel architecture, microservice architecture, or cloud architecture, etc., which will not be described here.
[0090] For example, FIG2 is a schematic diagram of the software structure of an electronic device provided in an embodiment of the present application. As shown in FIG2, the layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into multiple layers, including, from top to bottom, the application (APP) layer, the application framework (framework) layer, the hardware abstraction layer (HAL), and the kernel layer (kernel), etc., which are not limited in the embodiments of the present application.
[0091] The application layer may include a series of application packages. The application layer may include one or more of the following: settings, Bluetooth, calendar, health, or phone, etc., which are not limited in the embodiments of the present application.
[0092] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined interfaces. The application framework layer may include one or more of the following: activity task manager service (ATMS), window manager (WMS), display composition system (surface flinger), window manager, content provider, resource manager, view system, or notification manager.
[0093] The Active Task Manager service is used to determine whether to reduce the application's frame rate based on the frequency reduction optimization switch and whether there is a visible foreground window.
[0094] The window manager is used to manage window programs. For example, the window manager can be used to request the foreground window, obtain the display size, determine whether there is a status bar, lock the screen, touch the screen, drag the screen, take screenshots, etc.
[0095] The display synthesis system is used to switch frame rates and synthesize layers.
[0096] Content providers are used to store and retrieve data and make it accessible to applications. Data can include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, the display interface including the SMS notification icon can include a view for displaying text and a view for displaying images. The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0097] The purpose of the hardware abstraction layer is to abstract the hardware. It can provide a unified interface for querying hardware devices for upper-layer applications, or it can also provide data storage services for upper-layer applications. The hardware abstraction layer can include modules such as the hardware composer (HWC).
[0098] The kernel layer is the layer between hardware and software. It drives the hardware to function. This layer can include one or more of the following: display drivers, camera drivers, or sensor drivers.
[0099] In the embodiments of the present application, no specific limitation is imposed on the software layers involved in the software architecture, the modules contained in the layers, and the functions of the modules.
[0100] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be implemented independently or in combination with each other. For the same or similar concepts or processes, some embodiments may not be described in detail.
[0101] For example, Figure 3 is a flowchart of a method for reducing power consumption provided by an embodiment of the present application. In the embodiment corresponding to Figure 3, the electronic device may include modules such as an activity task manager service and a display composition system.
[0102] As shown in FIG3 , the method for reducing power consumption may include the following steps:
[0103] S301: When the activity task manager service determines that the first application exits the foreground, the activity task manager service determines whether a preset switch is turned on.
[0104] The preset switch can be understood as a switch for implementing the power consumption reduction method provided in the embodiment of the present application. The preset switch may also be referred to as a background application frequency reduction optimization switch. The preset switch may be pre-set in the electronic device. For example, the preset switch may be set before the electronic device leaves the factory, or the preset switch may be set after the electronic device undergoes a system upgrade. Alternatively, the preset switch may be turned on or off based on a user operation, which is not limited in the embodiment of the present application.
[0105] When the active task manager service determines that the preset switch is on, the active task manager service may execute the step shown in S302; or when the active task manager service determines that the preset switch is off, the active task manager service may not process the frame rate of the first application.
[0106] For example, Figure 6 is a schematic diagram of an interface for switching application states provided in an embodiment of the present application. In the embodiment corresponding to Figure 6, an example is given in which the electronic device is a mobile phone and the first application is a video application. This example does not constitute a limitation on the embodiment of the present application.
[0107] The electronic device displays an interface as shown in a in FIG6 , which may be an interface displayed by a video application, and may display the video content being played, etc.
[0108] In the interface shown in a in Figure 6, in response to the user sliding upward along the bottom of the display screen, the activity task manager service can detect the interface status of the first application, that is, when it detects that the activity of the first application is in a paused (stop) state, it determines that the first application has exited the foreground. At this time, the electronic device can display the interface shown in b in Figure 6 or the interface shown in c in Figure 6.
[0109] The interface shown in b in FIG. 6 may display the content on the desktop, for example, at least one application icon.
[0110] In a possible implementation, in response to the first application exiting the foreground, the electronic device may also display the interface shown in c in Figure 6, which may include: a floating window 600 corresponding to the video application. Alternatively, in response to the first application exiting the foreground, the electronic device may also display the interface of another application in the foreground, which is not limited in the embodiments of the present application.
[0111] In a possible implementation, the electronic device may also enable the preset switch by default or not set the preset switch (or be understood as supporting the power consumption reduction method provided in the embodiment of the present application by default). In this scenario, the electronic device may not determine whether the preset switch is enabled, that is, when the active task manager service determines that the first application exits the foreground, the step shown in S302 is executed.
[0112] In a possible implementation, when the electronic device determines that the first application exits the foreground, when the electronic device detects that the first application in the background requests a vsync signal, the electronic device can also determine whether to set the frame rate of the first application to the second frame rate based on S301-S307.
[0113] S302: The activity task manager service determines whether there is a visible window of the first application.
[0114] A visible window can be understood as an application window with a window attribute of visible, or can also be understood as an application window displayed in the foreground of an electronic device. The visible window can be displayed in the foreground full screen or in a foreground floating window. The window displayed in the foreground floating window can include: an interactive floating window and a non-interactive floating window. The non-interactive floating window can also be called a mini window.
[0115] For example, referring to the embodiment corresponding to FIG6 , when the first application is a video application and a video is in a playback state, in response to the video application exiting the foreground, the electronic device can display a floating window of the video application in the foreground. The video content can continue to be played in the floating window, avoiding interruption of the video playback in the video application. The floating window can be referred to as floating window 600 in the interface shown in FIG6 c.
[0116] It is understandable that in the scenario where the visible window is still displayed in the foreground after the first application enters the background, in order to avoid triggering the electronic device to perform frame reduction processing after the first application enters the background, so that the low frame rate affects the normal operation of the visible window in the foreground, the electronic device can detect the visible window of the first application and perform subsequent frame reduction processing while ensuring that there is no visible window in the foreground.
[0117] When the active task manager service determines that the first application has no visible window, the step shown in S303 is executed. Alternatively, when the active task manager service determines that the first application has a visible window, the frame rate of the first application is not processed.
[0118] Exemplarily, the activity task manager service may determine whether a visible window of the first application exists based on a user identifier (UID) of the first application. For example, the activity task manager service queries the visible window corresponding to the UID of the first application, that is, the activity task manager service queries the visible window by calling the visiblewindow(getUID()) method.
[0119] The active task manager service can locally call an interface to query visible windows. For example, when the window manager detects a window change, it can set the window state in the application visible window map (appvisiblewindowMAP). The active task manager service can then query the visible windows of the first application from the appvisiblewindowMAP by calling a method.
[0120] Alternatively, the active task manager service may determine whether the first application has a visible window by exchanging information with the window manager. For example, the active task manager service may send a message to the window manager to query the visible windows of the first application. The window manager may query the visible windows of the first application from the appvisiblewindowMAP and return the message to the active task manager service.
[0121] Optionally, S303 , the active task manager service determines whether the method call satisfies the system call.
[0122] Exemplarily, the active task manager service obtains the caller's UID by calling getCallingUid(). The caller may be the UID of the active task manager service, ie, the system UID (system_UID), to determine whether the method call satisfies the system call.
[0123] When the active task manager service determines that the method call satisfies the system call, the step shown in S304 is executed; or when the active task manager service determines that the method call does not satisfy the system call, the frame rate of the first application is not processed.
[0124] It is understandable that the active task manager service can prevent illegal business calls and improve system security by determining whether the current call is a system call.
[0125] Optionally, S304 , the activity task manager service determines whether the package name of the first application passes parameter validity verification.
[0126] Exemplarily, the activity task manager service determines whether the package name of the first application is legal by calling the parameter legality verification method TextUtils.isEmpty(packageName), where the packageName in the parameter legality verification method may be the package name of the first application.
[0127] When the active task manager service determines that the package name of the first application passes the parameter validity check, the step shown in S305 is executed; or when the active task manager service determines that the package name of the first application fails the parameter validity check, the frame rate of the first application is not processed.
[0128] It is understandable that both S303 and S304 are steps for improving system security, and the electronic device may also use other steps to verify system security, which is not limited in the embodiments of the present application.
[0129] S305: The activity task manager service determines whether the first application is in the first control list.
[0130] The first control list is used to store the package names of applications that are allowed to apply for vsync signals in the background. The first control list is set in the memory for easy query at any time.
[0131] Among them, the first control list can be obtained by loading a configuration file when the electronic device is restarted, or the first control list can also be obtained by loading an updated configuration file after the electronic device performs a software update. The specific acquisition method can refer to the embodiment corresponding to Figure 7, and this is not limited in the embodiments of the present application.
[0132] When the active task manager service determines that the package name of the first application is included in the first control list, the step shown in S306 is executed; or when the active task manager service determines that the package name of the first application is not in the first control list, the frame rate of the first application is not processed.
[0133] It is understandable that the embodiment of the present application does not specifically limit the order of any step S301-S305.
[0134] S306: The activity task manager service sends a first message to the display composition system.
[0135] The first message is used to instruct the first application to reduce its frame rate. The first message may include: the package name of the first application, information indicating that the frame rate reduction feature is enabled, and information indicating that the first application is in the background. For example, the first message may include: package name (packagename), true (true), and background type (type_background), where true indicates that the frame rate reduction feature is enabled.
[0136] When the display composition system determines that the frame reduction feature is enabled based on the first message, the display composition system may call an interface from the active task manager service to determine that the frame rate when the frame reduction feature is enabled is the second frame rate.
[0137] The first frame rate is greater than the second frame rate. The first frame rate may be a value such as 120 Hz (or 90 Hz), and the second frame rate may be a value such as 15 Hz (or 30 Hz).
[0138] In a possible implementation, the first message may include: the package name of the first application, the UID of the first application, information indicating that the frame reduction feature is enabled, and information indicating that the first application is in the background.
[0139] It is understandable that since some applications in electronic devices can support the application clone function, and the application package name cannot distinguish between the two applications in the clone, the electronic device can use the package name of the first application and the UID of the first application to distinguish the specific applications running in the application clone scenario to improve the accuracy of the power consumption reduction method.
[0140] S307: The display synthesis system sets the frame rate of the first application to the second frame rate, and then adds the first application to the second control list.
[0141] The second control list may include: the application package name, or the application package name + application UID.
[0142] Furthermore, after the electronic device adds the application to the second control list, the electronic device can use the second control list to control the application that has been reduced in frame rate. The specific steps of the second control list can be referred to the steps shown in S506-S507, which will not be repeated here.
[0143] Exemplarily, when the display synthesis system determines from the first message that the first application is in the background, it can add the package name of the first application (or the package name of the first application + the UID of the first application) to the second control list and set the frame rate of the first application to the second frame rate.
[0144] After the display composition system sets the frame rate to the second frame rate, the display composition system may subsequently receive a vsync signal requested by the first application and process the distribution of the vsync signal based on the second frame rate when determining that the first application is in the second control list.
[0145] Based on this, the electronic device can reduce the frame rate when it detects that the first application exits the foreground and there is no visible window currently, thereby reducing the number of times the first application applies for vsync signals in the background, thereby alleviating the waste of resources caused by the first application applying for vsync signals in the background.
[0146] In a possible implementation, after S307, when the first application is in the background and in the first control list, in response to the user closing the first application, the electronic device may perform the steps of restoring the first application's first frame rate, thereby removing the first application from the second control list. In this scenario, when the first application is restarted, since the first application has already restored to the first frame rate, the first application can display the interface of the first application based on the first frame rate after applying for a visible window.
[0147] Alternatively, after S307, in response to the user closing the first application, the electronic device may not execute the step of setting the first application to the first frame rate and removing the first application from the second control list. In this scenario, when the first application is started again, the electronic device may execute the step of setting the first application to the first frame rate when the application window is visible, and removing the first application from the second control list. This allows the interface of the first application to be displayed normally in the foreground based on the first frame rate.
[0148] Based on the embodiment corresponding to FIG3 , the electronic device may also restore the first frame rate when detecting that the first application returns to the foreground from the background, and the first application is not closed during the process of returning to the foreground from the background. It is understandable that the first application described in FIG4 may be an application determined to be at the second frame rate after the judgment between S301 and S307, and the first application is an application on the second control list.
[0149] For example, Figure 4 is a flowchart of another method for reducing power consumption provided by an embodiment of the present application. In the embodiment corresponding to Figure 4, the electronic device may include: a window manager, an activity task manager service, and a display composition system.
[0150] As shown in FIG4 , the method for reducing power consumption may include the following steps:
[0151] S401: When the window manager determines that the first application returns to the foreground, the window manager applies for the application window to be visible.
[0152] The window application makes the application window visible, that is, the window manager can set the property of the application window to visible, and the application window can be displayed in the foreground.
[0153] For example, the window manager may detect the interface state of the first application, and in response to the user sliding upward along the bottom of the interface shown in b in FIG6 , the electronic device may display a background multitasking interface (not shown in FIG6 ), which may include a thumbnail of the first application. In response to a click operation on the thumbnail of the first application, the window manager may determine that the first application has returned to the foreground when detecting that the active activity of the first application is in the resume state. At this time, the electronic device may display the interface shown in a in FIG6 . The first application may return to the foreground by a cold start or a hot start.
[0154] S402: The window manager sends a message to the active task manager service to instruct the first application to exit the foreground.
[0155] Adaptively, the active task manager service may execute the step shown in S403 when determining that the first application exits the foreground.
[0156] The window manager may execute the step shown in S402 when detecting that any application requests a visible window.
[0157] S403: The activity task manager service determines whether the preset switch is turned on.
[0158] The meaning of the preset switch and the method for obtaining the preset switch can be found in the step shown in S301, and will not be repeated here.
[0159] When the active task manager service determines that the preset switch is on, the step shown in S404 is executed; or when the active task manager service determines that the preset switch is off, the frame rate of the first application is not processed.
[0160] Optionally, S404 , the active task manager service determines whether the method call satisfies the system call.
[0161] The way in which the active task manager service determines whether the method call satisfies the system call can be found in step S303 , which will not be described in detail here.
[0162] When the active task manager service determines that the method call satisfies the system call, the step shown in S405 is executed; or when the active task manager service determines that the method call does not satisfy the system call, the frame rate of the first application is not processed.
[0163] Optionally, S405 , the activity task manager service determines whether the package name of the first application passes parameter validity verification.
[0164] The way in which the activity task manager service determines whether the package name of the first application passes the parameter validity check can be referred to the step shown in S304, which will not be repeated here.
[0165] When the active task manager service determines that the package name of the first application passes the parameter validity check, the step shown in S406 is executed; or when the active task manager service determines that the package name of the first application fails the parameter validity check, the step shown in S407 is executed.
[0166] S406: The activity task manager service determines whether the first application is in the first control list.
[0167] The meaning and usage of the first control list can be found in the step shown in S305 and will not be repeated here.
[0168] When the active task manager service determines that the package name of the first application is included in the first control list, the step shown in S407 is executed; or when the active task manager service determines that the package name of the first application is not in the first control list, the frame rate of the first application is not processed.
[0169] In a possible implementation, the active task manager can determine whether to restore the frame rate of all applications that have been restored from the background to the foreground based on steps S403-S406. Alternatively, the active task manager can determine whether the first application is on the second control list based on the package name of the first application. For example, if the task manager determines that the first application is on the second control list, it executes steps S407-S408.
[0170] S407: The activity task manager service sends a second message to the display composition system.
[0171] The second message is used to restore the frame rate of the first application. The second message may include: the package name of the first application, information indicating that the frame rate reduction feature is disabled, and information indicating that the first application is in the foreground. For example, the second message may include: packagename, false, and foreground type (type_foreground), where false indicates that the frame rate reduction feature is disabled.
[0172] When the display composition system determines that the frame reduction feature is disabled based on the first message, the display composition system may call an interface from the active task manager service to determine that the frame rate when the frame reduction feature is disabled is the first frame rate.
[0173] In a possible implementation, the second message may further include: the UID of the first application.
[0174] S408: The display composition system sets the frame rate of the first application to the first frame rate, and then removes the first application from the second control list.
[0175] The meaning of the second control list can be found in the step shown in S307 above, and will not be repeated here.
[0176] For example, when the display synthesis system determines from the second message that the first application is in the foreground, it can set the frame rate to the first frame rate, and then remove the package name of the first application (or the package name of the first application + the UID of the first application) from the second control list.
[0177] Based on this, the electronic device can restore to the first frame rate when detecting that the first application returns to the foreground, to avoid affecting the normal operation of the first application in the foreground when the frame rate drops to the second frame rate.
[0178] Based on the embodiment corresponding to FIG4 , the embodiment of the present application can provide a guarantee mechanism for detecting that the frame rate has not been restored when the first frame is displayed. For example, when the electronic device receives the first frame data of the first application after S401 and before S408 , the electronic device can restore the first frame rate based on the embodiment corresponding to FIG5 , avoiding the situation where the display synthesis system has not yet received the first frame rate in the second message when the first application first receives the frame data, resulting in an abnormal foreground frame rate of the first application.
[0179] In a possible implementation, when the electronic device receives the first frame data of the first application after S408, the electronic device may process the first frame data based on the first frame rate, and the first application will not have a frame rate abnormality.
[0180] For example, FIG5 is a flowchart of a frame rate recovery process provided in an embodiment of the present application.
[0181] As shown in FIG5 , the method includes the following steps:
[0182] S501: A first application requests a first vsync signal from a display composition system.
[0183] The first application described in S501 may be an application determined to perform frame reduction based on the embodiment corresponding to FIG3 , and the first application belongs to the second control list.
[0184] Exemplarily, the first application may send a message for obtaining a first vsync signal to the display composition system.
[0185] The vsync signal can be a periodic signal, and the vsync signal period can be set according to the frame rate. When the frame rate is 120 Hz, the vsync signal period can be approximately 8.4 ms. When the frame rate is 15 Hz, the vsync signal period can be approximately 66.6 ms.
[0186] S502: The display composition system returns a first vsync signal to the first application.
[0187] S503: The first application performs layer drawing and rendering upon receiving the first vsync signal to generate a first frame of data.
[0188] S504: The first application sends a first frame of data to the display composition system.
[0189] The first frame data may carry layer information, the layer information may include a layer name, and the layer name may include the package name of the first application.
[0190] In the step shown in S504, the first frame data can be the first frame layer data received by the display synthesis system. For example, after S401, the first frame data generated by the first application can be physically displayed after layer synthesis by the display synthesis system. Therefore, it can be understood that when the display synthesis system detects that the first application has layer data (i.e., the first frame data) that needs to be synthesized for the first time based on the layer information, it indicates that the application needs to restore the foreground visibility and display the first frame. Then, the display synthesis system can execute the steps shown in S505-S507 to restore the frame rate of the first application to avoid affecting the display of the first application in the foreground.
[0191] S505: The display synthesis system determines whether the preset switch is turned on.
[0192] The meaning of the preset switch and the method for obtaining the preset switch can be found in the step shown in S301, and will not be repeated here.
[0193] When the display composition system determines that the preset switch is on, the step shown in S506 is executed; or when the display composition system determines that the preset switch is off, the frame rate of the first application is not processed.
[0194] S506: The display synthesis system determines whether the first application is on the second control list.
[0195] When the display composition system determines that the second control list includes the package name of the first application, the step shown in S507 is executed; or, when the display composition system determines that the second control list does not include the package name of the first application, the frame rate of the first application is not processed.
[0196] S507: The display composition system sets the frame rate of the first application to the first frame rate, and then removes the first application from the second control list.
[0197] Exemplarily, after the display composition system recovers to the first frame rate and removes the first application from the second control list, the display composition system may distribute a vsync signal to the first application at the first frame rate.
[0198] Based on this, in order to prevent the display synthesis system from not receiving the first frame rate in the second message when the first application receives frame data for the first time, resulting in frame rate abnormalities in the foreground application and page freezes, the display synthesis system can restore to the first frame rate in advance when it detects that the first application is in the foreground and receives the first frame data.
[0199] In conjunction with the embodiments corresponding to Figures 4 and 5 , after the display composition system pre-restores the first frame rate of the first application based on the embodiment corresponding to Figure 5 , the display composition system receives the second message in S407 . Alternatively, the display composition system may execute step S408 upon receiving the second message. Since the first application is no longer on the second control list at this point, the result of executing S408 by the display composition system is that the frame rate of the first application is not processed. Alternatively, the display composition system may determine whether the first application is on the second control list upon receiving the second message, and if it determines that the first application is not on the second control list, it may not execute step S408.
[0200] Based on the embodiments corresponding to FIG. 3 to FIG. 5 , the electronic device may also provide a mechanism for delaying the issuance of a vsync signal in a method for reducing power consumption.
[0201] For example, FIG7 is a schematic diagram of a process of distributing a vsync signal provided in an embodiment of the present application.
[0202] In the embodiment corresponding to FIG7 , the electronic device may run: APP1, APP2, APP3, a main thread in an event thread (or simply referred to as the main thread), a delay thread in the event thread (or simply referred to as the delay thread), and SF composit.
[0203] The main thread is used to detect the vsync signal requested by the application and implement the distribution of the vsync signal; the delay thread is used to implement the delayed distribution of the vsync signal by setting a timer.
[0204] The event thread can be a child thread of the display composition system. The SF composit can also be a child thread of the display composition system, and the SF composit is used to implement the composition processing of the layer.
[0205] As shown in Figure 7, the electronic device can be in a first frame rate. When the electronic device determines to downgrade the frame rate of the first application, the electronic device can switch the frame rate of the first application from the first frame rate to the second frame rate, and then when the electronic device determines to restore the frame rate of the first application, the electronic device can switch the frame rate of the first application from the second frame rate to the first frame rate.
[0206] When the first frame rate is 120 Hz, the vsync signal period can be approximately 8.3 ms, that is, the time interval between adjacent frames in Figure 7 can be approximately 8.3 ms. The embodiment of the present application takes the screen refresh rate of 120 Hz as an example for illustration; when the second frame rate is 15 Hz, the vsync signal period can be approximately 66.7 ms.
[0207] In frame 1, the electronic device can run APP1, APP1, APP2, and APP3 in the foreground at the same time. For example, the electronic device can display APP1 and APP2 in a split screen and display APP3 in a floating window. In the embodiment of the present application, there is no limitation on the form in which APP1, APP1, APP2, and APP3 are run in the foreground. Furthermore, APP1, APP2, and APP3 all request a vsync signal from the display synthesis system.
[0208] When the main thread determines that APP1, APP2, and APP3 all request a vsync signal, the main thread determines whether APP1, APP2, and APP3 are all in the second control list. When the main thread determines that APP1, APP2, and APP3 are not in the second control list, the main thread generates a vsync signal and distributes it to APP1, APP2, and APP3.
[0209] Before the main thread of frame 2 distributes the vsync signal, in response to APP3 exiting the foreground (or being understood as APP3 returning to the background), the electronic device can, based on the embodiment corresponding to FIG3 , after determining that APP3 meets the steps shown in S301-S305, set the frame rate of APP3 to 15Hz, and then add APP3 to the second control list. In this scenario, APP1 and APP2 can continue to run in the foreground of the electronic device.
[0210] In frame 2, the electronic device runs APP1 and APP2 in the foreground, and runs APP3 in the background. Furthermore, APP1, APP2, and APP3 all request a vsync signal.
[0211] When the main thread determines that APP1, APP2, and APP3 all request a vsync signal, it determines whether APP1, APP2, and APP3 are all in the second control list. When the main thread determines that APP1 and APP2 are not in the second control list, the main thread generates a vsync signal and distributes the vsync signal to APP1 and APP2.
[0212] When the main thread determines that APP3 is in the second control list, the main thread can add APP3 to the third control list. The third control list is used to store applications that have not yet distributed vsync signals. The subsequent delay thread can realize the vsync signal distribution of objects in the third control list.
[0213] For example, when the main thread determines that APP3 is an object in the third control list, the main thread can wake up the delay thread. The delay thread sets a first timer, the trigger time of the first timer is the first distribution time, and the delay thread sets the task of distributing the vsync signal to APP3 when the first timer initiates the notification. When the first timer determines that the first distribution time has arrived, the first timer can notify the delay thread through the SIGALRM signal, and the delay thread can execute the task of distributing the vsync signal to APP3. After the task is completed, the display synthesis system clears the objects in the third control list and records the first distribution time of distributing the vsync signal to APP3.
[0214] The main thread and the delayed thread may be created by the display composition system at the same time. For example, the display composition system may create the main thread, delayed thread and other threads in the display composition system after detecting that the device is powered on.
[0215] The first distribution time may be 1 ms or 2 ms after the delay thread sets the first timer. This means that the delay thread can almost immediately distribute the vsync signal of frame 2.
[0216] In frame 3, the electronic device runs APP1 and APP2 in the foreground, and the electronic device continues to run APP3 in the background. Furthermore, APP1, APP2, and APP3 all request a vsync signal.
[0217] When the main thread determines that APP1, APP2, and APP3 all request vsync signals, it determines whether APP1, APP2, and APP3 are all in the second control list. When the main thread determines that APP1 and APP2 are not in the second control list, the main thread distributes vsync signals to APP1 and APP2.
[0218] When the main thread determines that APP3 is in the second control list, the main thread can add APP3 to the third control list, the main thread can wake up the delay thread, the delay thread sets a second timer, the trigger event of the second timer is the second distribution time, and the delay thread sets the task of distributing the vsync signal to APP3 when the second timer initiates the notification. When the second timer determines that the second distribution time has arrived, the second timer can notify the delay thread through the SIGALRM signal, and the delay thread can perform the task of distributing the vsync signal to APP3. After the task is completed, the display synthesis system clears the objects in the third control list and records the second distribution time for distributing the vsync signal to APP3.
[0219] The second distribution time may be the time after adding 66.6ms to the first distribution time, for example, the second distribution time may be at frame 10. Alternatively, it may be understood that the duration between the first distribution time and the time when the delay thread sets the second timer is the first duration, the duration between the time when the delay thread sets the second timer and the second distribution time is the second duration, and the sum of the first duration and the second duration is 66.6ms. This ensures that the time interval between the distribution of the vsync signal to APP3 after frame 2 and the distribution of the vsync signal to APP3 in frame 10 is 66.6ms, which satisfies the frame rate of APP3 of 15Hz.
[0220] In a possible implementation, the electronic device may also be running APP4. When APP3 enters the background and APP4 also enters the background from the foreground, the display composition system can add the package name of APP4 to the second control list. Furthermore, the display composition system can control the signal distribution of APP3 and APP4 through a single delay thread, or the display composition system can control the signal distribution of APP3 and APP4 through two separate delay threads.
[0221] In one implementation, when the main thread confirms that APP4 requests a vsync signal and the package name of APP4 is on the second control list, the main thread can also add APP4 to the third control list. Since the third control list now includes APP3 and APP4, the delay thread can uniformly distribute vsync signals to APP3 and APP4 in the third control list when it determines that the second distribution time has arrived.
[0222] For example, Figure 8 is a schematic diagram of another vsync signal distribution process provided by an embodiment of the present application. As shown in Figure 8, the vsync signal distribution process of APP3 and APP4 in the background is illustrated.
[0223] After APP3 returns to the background, APP4 can return to the background at any time between frames 3 and 9, for example, APP4 can return to the background at frame 4. When APP4 returns to the background at frame 4, the display composition system can reduce the frame rate of APP4 to 15Hz and add APP4 to the second control list.
[0224] Furthermore, APP4 requests a vsync signal. When the main thread determines that APP4 is in the second control list, the main thread can add APP4 to the third control list. At this time, the third control list includes APP3 and APP4. When the second timer determines that the second distribution time has arrived, the second timer can notify the delay thread through the SIGALRM signal, and the delay thread implements the vsync signal distribution for APP3 and APP4 in the third control list.
[0225] In another implementation, when the main thread confirms that APP4 requests a vsync signal and APP4 is on the second control list, the main thread can add APP4 to the fourth control list and wake up another delay thread. The other delay thread can be used to control the delayed distribution of APP4. For example, a third timer can be set in the other delay thread according to the vsync signal distribution period of APP4, and the triggering event of the third timer can be the third distribution time. The delay thread is set to distribute the vsync signal to APP4 at the third distribution time. For example, when the frame rate of APP4 is 30Hz, the vsync signal distribution period of APP4 can be 33.3ms. It can be understood that the electronic device can control the vsync signal distribution of different applications at different frame rates through two delay threads. Among them, the vsync signal distribution process at different frame rates can refer to the process of delaying the distribution of APP3 using the delay thread, which will not be repeated here.
[0226] Between frames 4 and 9, the electronic device can run App 2 in the foreground and App 3 in the background. In this scenario, App 1 stops rendering (App 1 can stop running at this time), App 3 is in the background and has not yet requested a vsync signal. App 2 can request a vsync signal in every frame between frames 4 and 9.
[0227] Taking frame 4 as an example, the vsync signal distribution process between frames 5 to 9 can be referred to frame 4, which will not be repeated later.
[0228] In frame 4, the main thread determines whether App 2 is requesting a vsync signal and whether App 2 is on the second control list. If the main thread determines that App 2 is not on the second control list, the main thread distributes the vsync signal to App 2. However, since the second distribution time indicated by the second timer has not yet arrived, the main thread does not distribute the vsync signal requested by App 3.
[0229] In frame 10, the electronic device may run APP2 in the foreground and APP3 in the background. APP2 requests a vsync signal, but APP3 does not request a vsync signal.
[0230] When the main thread determines that APP2 requests a vsync signal, it determines whether APP2 is in the second control list. When the main thread determines that APP2 is not in the second control list, the main thread distributes the vsync signal to APP2.
[0231] When the second timer determines that the second distribution time has arrived, the second timer can notify the delay thread through the SIGALRM signal, and the delay thread can distribute the vsync signal requested by APP3 in frame 3 to APP3, thereby realizing delayed distribution of the vsync signal requested by the background application.
[0232] In frame 11, the electronic device may run APP2 in the foreground and APP3 in the background. APP2 requests a vsync signal, but APP3 does not request a vsync signal.
[0233] When the main thread determines that APP2 requests a vsync signal, it determines whether APP2 is in the second control list. When the main thread determines that APP2 is not in the second control list, the main thread distributes the vsync signal to APP2.
[0234] Before the main thread distributes the vsync signal in frame 12, APP3 returns to the foreground, and the display synthesis system can remove APP3 from the second control list, and the display synthesis system can switch the frame rate of APP3 to 120Hz.
[0235] In frame 12, the electronic device may run APP2 and APP3 in the foreground, and both APP2 and APP3 request a vsync signal.
[0236] After frame 12, the main thread can determine whether APP2 and APP3 are in the second control list when APP2 and APP3 request vsync signals. When the main thread determines that neither APP2 nor APP3 is in the second control list, the main thread distributes the vsync signal to APP2 and APP3.
[0237] It is understandable that the electronic device can delay the distribution of the vsync signal initiated by the background application by setting a delay thread to alleviate the power consumption waste caused by the background application applying for the vsync signal to draw the image frame.
[0238] In the embodiments corresponding to Figures 4-8 , the content of the first control list can be flexibly added or deleted in the cloud, and the cloud can push the first control list to the electronic device executing the model via a configuration file. Alternatively, the electronic device can receive the configuration file pushed from the cloud by registering for parameter update broadcasts in the AndroidManifest or setting up a parameter update broadcast receiver.
[0239] The first control list may be obtained by loading a configuration file when the electronic device is restarted, or the first control list may be obtained by loading an updated configuration file after the electronic device performs a software update.
[0240] In one implementation, FIG9 is a flow chart of a method for obtaining a first control list provided in an embodiment of the present application. As shown in FIG9 , the method for obtaining the first control list may include the following steps:
[0241] S901: The electronic device receives an operation from a user to open a software update interface.
[0242] The user can open the software update interface by following the path of Settings->System and Updates->Software Update to enter the software update interface.
[0243] S902: In response to the user opening the software update interface, the electronic device determines whether there is a configuration file that needs to be updated.
[0244] When the electronic device detects that there is an updated configuration file, it may display a configuration update button in the software update interface and then execute the step shown in S903; or, when the electronic device determines that there is no updated configuration file, it may execute the step shown in S908.
[0245] S903: The electronic device receives a user operation on a configuration update button.
[0246] S904: In response to the user's operation on the configuration update button, the electronic device notifies the system side that there is a configuration update.
[0247] S905: The electronic device determines whether the preset switch is turned on.
[0248] The electronic device executes the step shown in S906 when determining that the preset switch is on, or executes the step shown in S908 when determining that the preset switch is off. The meaning of the preset switch can be found in the step shown in S301 and will not be repeated here.
[0249] S906: The electronic device loads the updated configuration file.
[0250] S907: The electronic device parses the first control list in the configuration file and saves the first control list.
[0251] S908. The electronic device ends updating.
[0252] In another implementation, FIG10 is a flow chart of another method for obtaining the first control list provided in an embodiment of the present application. As shown in FIG10 , the method for obtaining the first control list may include the following steps:
[0253] S1001: The electronic device receives an operation from a user to restart the device.
[0254] S1002: The electronic device determines whether a configuration file exists in the product path.
[0255] The product path may store a file containing product characteristics of the electronic device. When the electronic device finds the configuration file in the product path, it executes the step shown in S1004, or when the electronic device does not find the configuration file in the product path, it executes the step shown in S1003.
[0256] S1003: The electronic device determines whether there is a configuration file in a preset path.
[0257] The preset path may be a default path for storing configuration files in the electronic device, and the preset path does not distinguish between device versions. When the electronic device finds the configuration file in the preset path, the step shown in S1004 is executed, or when the electronic device does not find the configuration file in the preset path, the step shown in S1006 is executed.
[0258] It is understandable that both the product path and the preset path are paths where configuration files can be stored. To accommodate more device scenarios, the electronic device can search for configuration files in the product path and the preset path respectively.
[0259] S1004: The electronic device loads the updated configuration file.
[0260] S1005. The electronic device parses the first control list in the configuration file and saves the first control list.
[0261] S1006. End the update.
[0262] It is understandable that the first control list is not static, but can be increased or decreased according to needs, and pushed to the electronic device through the configuration file to ensure the accuracy of the first control list described in the embodiment of this application.
[0263] In a possible implementation, a second application is also running on the electronic device, and the second application may be an application that does not allow frame rate drops. Referring to the interface shown in FIG6 a, in response to the operation of returning the first application to the background, the electronic device may also display the interface of the second application in the interface shown in FIG6 b. The operation of returning the first application to the background may be a user swiping left or right along the bottom of the display screen.
[0264] In response to the operation of the first application returning to the foreground, the electronic device can resume displaying the interface shown in a in Figure 6, while the second application is in the background.
[0265] In a scenario where the second application is switched from the background to the foreground or from the foreground to the background, the frame rate of the second application may remain unchanged.
[0266] The method provided in the embodiment of the present application is described above in conjunction with Figures 4 to 10. The device for executing the above method provided in the embodiment of the present application is described below. As shown in Figure 11, Figure 11 is a structural schematic diagram of a power consumption reduction device provided in the embodiment of the present application. The power consumption reduction device can be an electronic device in the embodiment of the present application, or a chip or chip system within the electronic device.
[0267] As shown in FIG11 , a power consumption reduction apparatus 1100 can be used in a communication device, circuit, hardware component, or chip, and includes a display unit 1101 and a processing unit 1102. The display unit 1101 is configured to support the display step of the power consumption reduction method; and the processing unit 1102 is configured to support the information processing step of the power consumption reduction apparatus 1100.
[0268] In a possible implementation, the apparatus for reducing power consumption 1100 may further include a communication unit 1103 , and the communication unit 1103 is configured to support the apparatus for reducing power consumption 1100 in executing steps such as receiving or sending a message.
[0269] The power consumption reduction devices described in the embodiments of the present application may include the units described in the embodiment corresponding to FIG11 .
[0270] Specifically, the processing unit 1102 and the display unit 1101 may be integrated together, and the processing unit 1102 and the display unit 1101 may communicate with each other.
[0271] In a possible implementation, the power consumption reduction apparatus 1100 may further include a storage unit 1104. The storage unit 1104 may include one or more memories, and the memories may be devices in one or more devices or circuits for storing programs or data.
[0272] The storage unit 1104 can exist independently and be connected to the processing unit 1102 via a communication bus. The storage unit 1104 can also be integrated with the processing unit 1102.
[0273] Taking the power consumption reduction device 1100 as an example, which can be a chip or chip system of an electronic device in an embodiment of the present application, the storage unit 1104 can store computer-executable instructions of the method of the electronic device, so that the processing unit 1102 executes the method of the electronic device in the above embodiment. The storage unit 1104 can be a register, a cache, or a random access memory (RAM), etc. The storage unit 1104 can be integrated with the processing unit 1102. The storage unit 1104 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions. The storage unit 1104 can be independent of the processing unit 1102.
[0274] In one possible implementation, the power consumption reduction apparatus 1100 may further include a communication unit 1103. The communication unit 1103 is configured to support interaction between the power consumption reduction apparatus 1100 and other devices. For example, when the power consumption reduction apparatus 1100 is an electronic device, the communication unit 1103 may be a communication interface or interface circuit. When the power consumption reduction apparatus 1100 is a chip or chip system within the electronic device, the communication unit 1103 may be a communication interface. For example, the communication interface may be an input / output interface, a pin, or a circuit.
[0275] The device of this embodiment can be used to execute the steps executed in the above method embodiment. Its implementation principles and technical effects are similar and will not be described in detail here.
[0276] FIG12 is a schematic diagram of the hardware structure of another electronic device provided in an embodiment of the present application.
[0277] The electronic device includes a processor 1201, a communication line 1204 and at least one communication interface (the communication interface 1203 is used as an example in FIG. 12 ).
[0278] The processor 1201 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0279] Communications link 1204 may include circuitry that transmits information between the aforementioned components.
[0280] The communication interface 1203 uses any transceiver or other device for communicating with other devices or communication networks, such as Ethernet, wireless local area networks (WLAN), etc.
[0281] Possibly, the electronic device may further include a memory 1202 .
[0282] The memory 1202 may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory may be independent and connected to the processor via a communication line 1204. The memory may also be integrated with the processor.
[0283] The memory 1202 is used to store computer-executable instructions for executing the solution of the present application, and the execution is controlled by the processor 1201. The processor 1201 is used to execute the computer-executable instructions stored in the memory 1202, thereby implementing the method provided by the embodiment of the present application.
[0284] Possibly, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, and the embodiments of the present application do not specifically limit this.
[0285] In a specific implementation, as an embodiment, the processor 1201 may include one or more CPUs, such as CPU0 and CPU1 in FIG12 .
[0286] In a specific implementation, as an embodiment, an electronic device may include multiple processors, such as processor 1201 and processor 1205 in FIG12 . Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).
[0287] In the above embodiment, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory or downloaded and installed in the memory in the form of software.
[0288] A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium can include magnetic media (e.g., floppy disk, hard disk or tape), optical media (e.g., digital versatile disc (DVD)), or semiconductor media (e.g., solid state disk (SSD)).
[0289] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part via software, hardware, firmware, or any combination thereof. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one location to another. The storage medium can be any target medium that can be accessed by a computer.
[0290] As one possible design, computer-readable media may include compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM or other optical disc storage; computer-readable media may include magnetic disk storage or other magnetic disk storage devices. Moreover, any connecting line may also be appropriately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while discs reproduce data optically using lasers.
[0291] The above combinations are also included within the scope of computer-readable media. The above are only specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
[0292] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.
Claims
1. A method for reducing power consumption, characterized in that: The method comprises: The electronic device displays a first interface of a first application, wherein the first application is at a first frame rate; In response to the first operation, the electronic device displays a second interface, where the second interface does not include any window of the first application; The first application issues a drawing request to draw in the first window, the electronic device sets a frame rate of the first application to a second frame rate, the second frame rate is less than the first frame rate, and the first window is invisible.
2. The method according to claim 1, characterized in that The electronic device sets the frame rate of the first application to a second frame rate, including: When the first application belongs to a first list, the electronic device sets the frame rate of the first application to a second frame rate, and the first list includes applications that are allowed to apply for a vertical synchronization vsync signal in the background.
3. The method according to claim 2, characterized in that The method further comprises: The electronic device displays a third interface of a second application, wherein the second application is at a first frame rate; In response to the second operation, the electronic device displays a fourth interface, where the fourth interface does not include any window of the second application; The second application issues a drawing request to draw in the second window, and the electronic device maintains the second application at the first frame rate, wherein the second window is not visible and the second application does not belong to the first list.
4. The method according to claim 2, characterized in that: After the electronic device sets the frame rate of the first application to a second frame rate, the method further includes: The electronic device adds the first application to a second list to obtain a third list, wherein the second list includes applications having a frame rate of the second frame rate, and the third list includes the first application.
5. The method according to claim 4, characterized in that The electronic device runs a first thread, and after the electronic device adds the first application to a second list, the method further includes: When the electronic device receives a first vsync signal request sent by the first application at a first moment, distributing the first vsync signal to the first application at a second moment through the first thread; When the electronic device receives a second vsync signal request sent by the first application at a third moment, the second vsync signal is distributed to the first application through the first thread at a fourth moment, the second vsync signal request is the next vsync signal request of the first vsync signal request, and the time interval between the fourth moment and the second moment is determined by the electronic device based on the second frame rate.
6. The method according to claim 5, characterized in that When the electronic device receives a second vsync signal request sent by the first application at a third time, distributing the second vsync signal to the first application at a fourth time through the first thread includes: When the electronic device receives a second vsync signal request sent by the first application through the second thread at a third moment and wakes up the first thread when it is determined that the first application is in the third list, wherein the first thread starts a timer, and the timer notifies the first thread to distribute the second vsync signal to the first application at the fourth moment.
7. The method according to claim 6, characterized in that The electronic device runs a third application in the foreground, and the method further includes: When the electronic device receives a third vsync signal request sent by a third application, the electronic device distributes the third vsync signal to the third application through the second thread, and the electronic device distributes the first vsync signal to the first application at a second moment through the first thread.
8. The method according to claim 5, characterized in that The electronic device further runs a fourth application, the fourth application belongs to the first list and the fourth application belongs to the third list, and the electronic device receives a fourth vsync signal request sent by the fourth application between the third moment and the fourth moment, and the method further includes: The electronic device distributes the second vsync signal to the first application at the fourth moment through the first thread, and distributes the fourth vsync signal to the fourth application at the fourth moment.
9. The method according to any one of claims 6 to 8, characterized in that: The electronic device is provided with a display synthesis system, in which an event thread event thread is run, the second thread is a main thread in the event thread, and the first thread is a delay thread in the event thread.
10. The method according to claim 4, characterized in that The method further comprises: In response to the operation of closing the first application, when the first application belongs to the first list, the electronic device sets the frame rate of the first application to the first frame rate; The electronic device removes the first application from the third list.
11. The method according to claim 1, characterized in that: The electronic device is configured with: an activity task manager service and a display synthesis system, and the electronic device sets the frame rate of the first application to a second frame rate, including: The task manager service sends a first message to the display composition system, wherein the first message includes: a package name of the first application, information indicating that a frame reduction feature is enabled, and information indicating that the first application is in the background; The display composition system acquires the second frame rate based on the information indicating that the frame reduction feature is enabled; The display composition system sets the frame rate of the first application to the second frame rate.
12. The method according to claim 11, characterized in that The first message also includes: a user identifier UID of the first application.
13. The method according to claim 4, characterized in that After the electronic device adds the first application to the second list to obtain a third list, the method further includes: In response to a third operation, the electronic device applies for the window of the first application to be visible; In a case where the first application belongs to the first list, the electronic device sets the frame rate of the first application to the first frame rate; The electronic device removes the first application from the third list.
14. The method according to claim 13, characterized in that Before the electronic device sets the frame rate of the first application to the first frame rate, the method further includes: When the electronic device receives the first frame data from the first application and the electronic device determines that the first application belongs to the third list, the electronic device sets the frame rate of the first application to the first frame rate, and the frame data is data obtained by layer rendering when the first application receives a vsync signal; The electronic device removes the first application from the third list.
15. The method according to claim 13, characterized in that The electronic device is configured with: a window manager, an activity task manager service and a display synthesis system. The window for the electronic device to apply for the first application is visible, including: The window manager applies for the window of the first application to be visible; The window manager sends a second message to the active task manager service, where the second message is used to instruct the first application to return to the foreground; In a case where the first application belongs to the first list, the electronic device sets the frame rate of the first application to the first frame rate, including: In response to the second message, when the active task manager service determines that the first application belongs to the first list, the active task manager service sends a third message to the display composition system, wherein the third message includes: a package name of the first application, information indicating that the frame drop feature is turned off, and information indicating that the first application is in the foreground; The display composition system acquires the first frame rate based on the information indicating that the frame reduction feature is turned off; The display composition system sets the frame rate of the first application to the first frame rate.
16. The method according to claim 15, characterized in that The second message also includes: a user identifier UID of the first application.
17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the electronic device executes the method according to any one of claims 1 to 16.
18. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the computer is caused to perform the method according to any one of claims 1 to 16.