Process control method, electronic equipment and storage medium
By limiting resources or reducing the priority of processes that are not in the foreground application, the high power consumption problem of the foreground application is solved, and the usage time of the mobile terminal is extended.
Patent Information
- Application Number
- CN202511503206.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-05
- Publication Date
- 2026-03-03
AI Technical Summary
Applications running in the foreground on a mobile device consume far more power than those running in the background, resulting in high power consumption and affecting device usage time.
By identifying processes in the foreground application that are not in a visible state, their use of system resources can be restricted or their priority reduced, thereby reducing the power consumption of the foreground application.
It effectively reduces the number of power-consuming processes in the foreground application, lowers the power consumption of electronic devices, extends device runtime, and does not affect the display interface, thereby improving the flexibility of device management.
Smart Images

Figure CN121603594A_ABST
Abstract
Description
[0001] This application is a divisional application of Chinese Patent Application No. 202211218267.9, filed on October 5, 2022, entitled "Method for Process Control, Electronic Device and Storage Medium". Technical Field
[0002] This application relates to the field of terminals, and more particularly to a method for process management, an electronic device, and a storage medium. Background Technology
[0003] With the continuous development of mobile devices, the number of applications running on them is constantly increasing, leading to higher power consumption. To reduce power consumption, mobile devices manage background applications, such as closing them.
[0004] However, the power consumption of applications running in the foreground on mobile devices is much greater than that of applications running in the background, resulting in high power consumption on mobile devices. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a process management method, an electronic device, and a storage medium, enabling the electronic device to reduce the power consumption of applications running in the foreground and extend the operating time of the electronic device.
[0006] In a first aspect, this application provides a process management method, comprising: obtaining a first application running in the foreground; obtaining a first process in the first application that is in a non-display state, wherein the non-display state is the state in which the canvas of the process in the first application is not displayed; and managing the first process, wherein the management includes: restricting the first process from using system resources, or reducing the first priority of the first process.
[0007] In this way, electronic devices can manage processes that are not in the display state within the foreground application. Since the management operations include limiting process usage of system resources or lowering process priority, the number of power-consuming processes in the foreground application can be reduced, thereby reducing the power consumption of the foreground application, lowering the power consumption of the electronic device, and extending the device's runtime. Furthermore, the object of management can be a process, rather than the entire application, ensuring that the electronic device does not affect the currently displayed interface when managing objects. Managing processes also increases the flexibility of electronic device management.
[0008] According to the first aspect, obtaining the first process in the first application that is in a non-display state includes: obtaining the number of displayed canvases for each process in the first application; and obtaining the process with zero displayed canvases as the first process. In this way, each process can include multiple canvases, and each canvas has a unique corresponding process. By detecting whether a process has displayed canvases, the detection standard for determining whether a process is in a display state is used. This method has high accuracy in determining whether a process is in a display state and avoids management errors.
[0009] According to the first aspect, obtaining the number of displayed canvases for each process in the first application includes: obtaining the display attributes of each canvas in each process of the first application; and determining the number of displayed canvases for each process in the first application based on the display attributes of each canvas. Thus, since each canvas has its own display attributes, which can be used to indicate whether the canvas is displayed, the control application can determine the number of displayed canvases for each process based on the display attributes of each canvas. This method is simple and fast.
[0010] According to the first aspect, the number of displayed canvases in each process of the first application is determined based on the display attributes of each canvas, including: obtaining the number of canvases in each process whose display attribute is in the display state; and using the obtained number of canvases as the number of displayed canvases in each process of the first application. In this way, the control application can directly determine the number of displayed canvases in each process of the first application by directly obtaining the number of canvases in the display state.
[0011] According to the first aspect, obtaining the number of displayed canvases for each process in the first application includes: obtaining a first display attribute for each canvas in each process of the first application; if a screen switch is detected, obtaining a second display attribute for each canvas in each process of the first application; and determining the number of displayed canvases for each process in the first application based on the first and second display attributes. Thus, the first display attribute includes the display attributes of each canvas. When the screen switches, the first display attribute contains canvases whose display attributes have changed. When the screen switches, the display attributes (i.e., the second display attribute) of each canvas in that process are re-obtained, which can accurately determine the number of displayed canvases corresponding to each process at that time.
[0012] According to the first aspect, after obtaining the first display attribute of each canvas for each process in the first application, the method further includes: determining the number of first canvases displayed in the first application based on the first display attribute, wherein the number of first canvases includes the number of canvases displayed for each process in the first application; and determining the number of canvases displayed for each process in the first application based on the first display attribute and the second display attribute, including: updating the number of first canvases if it is detected that the second display attribute is different from the first display attribute. In this way, by detecting whether the first display attribute and the second display attribute are different, the problem of duplicate display attributes of canvases can be avoided, improving the accuracy of determining the number of canvases currently displayed for a process.
[0013] According to the first aspect, the method further includes: if a second display attribute is detected to be the same as a first display attribute, then maintaining the first canvas count. Thus, when the electronic device detects that the second display attribute is the same as the first display attribute, it indicates that there are no canvases whose display attributes have changed, and the first canvas count is not updated, avoiding update errors and unnecessary resource consumption.
[0014] According to the first aspect, if a difference between the second display attribute and the first display attribute is detected, the first canvas count is updated, including: acquiring the canvas whose display attribute has changed as the target canvas; if the target canvas's display attribute is detected as displayed, incrementing the number of displayed canvases in the process to which the target canvas belongs by 1; if the target canvas's display attribute is detected as non-displayable, decrementing the number of displayed canvases in the process to which the target canvas belongs by 1. In this way, the electronic device can update the number of displayed canvases corresponding to each process in a timely manner, enabling the timely acquisition of processes in a non-displayable state when a foreground application is detected. Simultaneously, since the target canvas is the canvas whose display attribute has changed, updating the number of displayed canvases in the process to which the target canvas belongs based on the target canvas ensures that the update only applies to the number of displayed canvases in the process to which the target canvas belongs, thus avoiding update errors.
[0015] According to the first aspect, system resources include hardware resources and software resources; hardware resources include one or more of the following: CPU, network resources, Bluetooth resources, location positioning resources, and sensors; software resources include one or more of the following: service resources, activity resources, broadcast receivers, and content providers.
[0016] According to the first aspect, lowering the first priority of the first process includes: reducing the first priority of the first process to the second priority, or lowering the first priority of the first process by a preset number. In this way, by lowering the first priority of the first process, the electronic device cannot preferentially access computing resources, and the first process will not consume computing resources, thereby reducing the power consumption of the electronic device. At the same time, due to sufficient computing resources, the computing performance of the electronic device is also improved.
[0017] According to the first aspect, if an interface switch is detected, obtaining the second display attribute of each canvas in each process of the first application includes: obtaining the second display attribute of each canvas in each process of the first application through the canvas controller. In this way, since the canvas controller can set the display attributes of the canvas, obtaining the second display attribute of each canvas through the canvas controller ensures that the second display attribute of the canvas can be obtained in a timely manner.
[0018] According to the first aspect, obtaining the second display attribute of each canvas of each process in the first application through the canvas controller includes: the canvas controller setting the second display attribute of each canvas in response to a setting instruction.
[0019] According to the first aspect, the canvas controller controls at least one canvas. Thus, the canvas controller acquires at least one canvas from the canvases controlling each process in the first application; that is, the canvas controller controls canvases in a one-to-one correspondence, ensuring accurate acquisition of the canvas's display attributes. Alternatively, the canvas controller can set the display attributes of multiple canvases, making it more convenient to acquire the display attributes of each canvas.
[0020] According to the first aspect, the method further includes: if a change from a non-display state to a display state is detected, then the control over the first process is cancelled. In this way, the electronic device can promptly cancel the control over the first process, avoiding any impact on the display of the first process.
[0021] According to the first aspect, the method further includes: if it is detected that the first process has restricted its use of system resources for a preset period of time, then the first process's use of system resources is restored. In this way, the first process is controlled at preset intervals to avoid affecting its display.
[0022] According to the first aspect, before acquiring the first application running in the foreground, the method further includes: detecting that the power consumption of the electronic device is less than or equal to a first preset threshold. This allows the electronic device to promptly manage processes in the foreground application that are not currently displayed.
[0023] According to the first aspect, if the power consumption of the electronic device is detected to be greater than or equal to the second preset threshold, the control over the first process is cancelled. In this way, the electronic device can promptly cancel the control over the first process, avoiding any impact on the display of the first process.
[0024] Secondly, this application provides an electronic device, including: a memory and a processor, wherein the memory is coupled to the processor; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device performs the process control method corresponding to the first aspect and any implementation thereof.
[0025] The second aspect and any implementation thereof correspond to the first aspect and any implementation thereof, respectively. The technical effects of the second aspect and any implementation thereof are similar to those of the first aspect and any implementation thereof, and will not be repeated here.
[0026] Thirdly, this application provides a chip including one or more interface circuits and one or more processors; the interface circuits are used to receive signals from the memory of an electronic device and send the signals to the processors, the signals including computer instructions stored in the memory; when the processor executes the computer instructions, it causes the electronic device to execute the process control method corresponding to the first aspect and any implementation thereof.
[0027] Fourthly, this application provides a computer-readable medium for storing a computer program that, when run on an electronic device, causes the electronic device to execute the process control method corresponding to the first aspect and any implementation thereof. Attached Figure Description
[0028] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is an illustrative diagram showing how a mobile phone manages applications running in the background.
[0030] Figure 2 This is a schematic diagram of the structure of an exemplary electronic device.
[0031] Figure 3 This is a schematic diagram of the software structure of an electronic device, as exemplarily shown.
[0032] Figure 4 This is an illustrative diagram of a portion of the processes in a foreground application.
[0033] Figure 5 This is a schematic diagram illustrating an exemplary method for process management.
[0034] Figure 6 This is an example illustrating the internal interaction process when an electronic device manages the first process.
[0035] Figure 7 This is an illustrative diagram of an example interface switching scenario.
[0036] Figure 8 This is an illustrative diagram of a mobile game scenario. Detailed Implementation
[0037] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0038] In some embodiments, the increasing number of applications on electronic devices (such as mobile phones) increases power consumption, leading to shorter usage time. Sources of power consumption in electronic devices can include applications running in the foreground and applications running in the screen-off state. When an electronic device is in the screen-on state and an application is running in the foreground, it consumes 5 to 15 times more power than an application running in the screen-off state. Over a day's usage, applications running in the foreground consume 3 to 5 times more power than those running in the screen-off state. With the screen on, applications running in the foreground consume approximately 3 to 5 times more power than those running in the background. Applications running in the foreground account for about 55% of the total power consumption of the electronic device. Therefore, applications running in the foreground consume significantly more power than those running in the background.
[0039] Applications typically include one or more processes. In this example, a foreground running state can be a state where at least one process of the application is displayed on the screen; that is, the application runs directly on the screen's display window or interface. An application in the foreground running state can be an interactive application, meaning the user can interact with the application through its interface. A foreground running state can also be a running state where an application requests a new activity through the Activity Manager (AMS), or an Activity that is in a Paused state re-enters the active state. A background running state can be a running state where no process of the application is displayed on the screen. An application in the background running state does not display its interface on the screen, but its process continues to provide services in the background. For applications with a display interface, an application in the background running state can switch to the foreground running state, and vice versa. In this example, an application in the foreground running state can be called a foreground application, and an application in the background running state can be called a background application. For example, when a phone's screen displays the interface of a chat application while the phone is playing music, the music application is a background application, and the chat application is a foreground application.
[0040] The power consumption of foreground applications refers to the power used by each process of the foreground application to access various components of the phone while running. The power consumption of background applications refers to the power used by various components of the phone while running in the background.
[0041] Since applications running in the foreground are those currently in use by the user, they cannot be controlled to avoid data loss or application lag. Therefore, current practices typically focus on controlling applications running in the background to reduce the power consumption of electronic devices. For example, closing background applications reduces the number of applications running in the background, thereby reducing the phone's power consumption and extending the device's runtime.
[0042] Figure 1 This is an illustrative diagram showing how a mobile phone manages applications running in the background. Figure 1 As shown in Figure 1a, the phone's display shows the game interface 101, and the current battery percentage is 100%. The user has enabled power management to reduce power consumption. In response to the user's power management activation, the phone detects background applications and closes them. After running the game for 3 hours, as shown... Figure 1As shown in 1b, the game interface 103 displays that the phone's battery level is 30% remaining. Since the game is always running in the foreground, it is the main power-consuming application on the phone. Although the phone's management application closed the application running in the background, the phone's runtime was not effectively extended.
[0043] This application provides a process management method. When an electronic device detects a management command, it can acquire applications running in the foreground (hereinafter referred to as foreground applications) and manage processes within those foreground applications that are not currently displayed. Because the managed processes are not displayed, they do not affect the operation of other currently displayed processes, thus avoiding application lag. Furthermore, since the processes in the foreground applications are managed, the power consumption of the electronic device can be effectively reduced, extending its usage time. In this application, the electronic device can be a smartphone, smartwatch, tablet, or other similar device.
[0044] Figure 2 This is a schematic diagram illustrating the structure of an electronic device 100 according to an embodiment of this application. It should be understood that... Figure 2 The electronic device 100 in the figure is only one example of an electronic device, and the electronic device 100 may have more or fewer components than shown in the figure, may combine two or more components, or may have different component configurations. Figure 1 The various components shown can be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application-specific integrated circuits.
[0045] Electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, antenna 1, antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, bone conduction sensors, etc.
[0046] Figure 3This is a software structure block diagram of the electronic device 100 according to an embodiment of this application.
[0047] The layered architecture of the electronic device 100 divides the software into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into three layers, from top to bottom: the application layer, the application framework layer, and the kernel layer. It is understood that... Figure 3 The layers in the software structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer layers than illustrated, and each layer may include more or fewer components; this application does not impose any limitations.
[0048] like Figure 3 As shown, the application layer can include a series of application packages. These application packages can include management applications, desktop applications, audio / video applications, educational applications, games, SMS applications, gallery applications, calling applications, navigation applications, etc. Applications can also include instant messaging, office applications, etc. Management applications are used to manage running processes based on the battery level or computing resources of the electronic device, in order to reduce power consumption or improve the device's performance. Management applications can be applications with process management capabilities, such as phone manager applications or power optimization applications. This management application can be a system-level application, providing interfaces for process management to other third-party applications. Optionally, this system-level management application may not be visible to the user.
[0049] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0050] like Figure 3 As shown, the application framework layer may include a window manager, canvas controller, resource manager, content provider, view system, activity manager, notification manager, etc.
[0051] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0052] The WindowSurfaceController is an object in Android applications used to control the properties of the canvas (Surface) and associate the canvas with a process. The canvas is an object in the Android display system that describes the currently displayed interface. Each currently displaying process has its own corresponding canvas, and each process can have one or more canvases. Each canvas uniquely corresponds to a specific process.
[0053] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0054] Content providers store and retrieve data, making that data accessible to applications. This data can include videos, images, audio, phone calls made and received, browsing history and bookmarks, phone books, and more.
[0055] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0056] The ActivityManagerService (AMS) is primarily responsible for starting, switching, scheduling, and managing and scheduling application processes of the four main components of the system. These four components are: Activity, Service, BroadcastReceiver, and Content Provider.
[0057] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0058] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0059] Understandable, Figure 3 The layers in the illustrated software structure and the components contained in each layer do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer layers than illustrated, and each layer may include more or fewer components; this application does not impose any limitations.
[0060] Figure 4 This is a schematic diagram illustrating a portion of the processes in a foreground application. For example... Figure 4As shown, during the runtime of the foreground application, some processes are in a displayed state, while others are in a non-displayed state. The displayed state of a process can refer to the state where the process in the first application has a displayed canvas. In other words, the displayed state of a process refers to the state where it is shown on the screen, where interactive information such as videos, images, text, and controls can be displayed. The non-displayed state of a process can refer to the state where the process's canvas in the first application is not displayed. This can be understood as the state where the process in the first application does not have a displayed canvas; that is, the non-displayed state of a process is the state where the process in the first application is not displayed on the screen. For example... Figure 4 As shown in Figure 4a, which illustrates some processes in application A, and Figure 4b, which illustrates some processes in application B, the first item in Figure 4a is the main process of application A, the second is the media streaming download process, the third is the webpage view process, and the fourth is the media process. When the webpage and video in the main process of application A are started, the main process of application A is in a displayed state because the content of the webpage and the video are displayed on the screen. When the main process of application A is not used, it is in a hidden state. The media streaming download process and the media process are background processes and are always in a hidden state. When the webpage view process is used, it is in a displayed state.
[0061] As shown in 4b, the first item in application B is the mini-program process, the second is the mini-program pre-installed process, the third is the webpage process, the fourth is the push notification process, and the fifth is the main process. Similar to the processes in application A, some processes in application B are displayed when used and hidden when not used, such as the mini-program process, the webpage process, and the main process of application B. Some processes remain hidden, such as the push notification process. Since processes running in the background are not displayed, the process management method in this application can manage processes in the hidden state to reduce the power consumption of electronic devices.
[0062] Figure 5 This is a schematic diagram illustrating an exemplary process management method. The method is executed by an electronic device; in this example, a mobile phone is used as an example. Figure 5 As shown, the process management method includes the following steps: Step 501: The electronic device acquires the first application that is running in the foreground.
[0063] For example, a management application can be installed in an electronic device (such as a mobile phone). This application can be used to manage a target object, which can be an application or a process. In this example, management may include: restricting the target's use of system resources, or lowering the priority of the target object. System resources include hardware resources and / or software resources. Hardware resources may include: CPU, network resources, Bluetooth resources, location resources, sensors, camera resources, etc. Software resources may include service resources, activity resources, broadcast receivers, and content providers.
[0064] The control application in this example can reduce the power consumption of the mobile phone by controlling the target object.
[0065] The management application starts when the phone boots up. Once running, it monitors the phone's power consumption in real time (e.g., every 10 or 5 seconds). When the management application detects that the phone's power consumption is less than or equal to a first preset threshold, it selects the first application running in the foreground. The first preset threshold can be set to be less than or equal to half of the electronic device's total battery level, i.e., the first preset threshold ≤ 50% of the battery level. For example, the first preset threshold can be 50%, 30%, 20%, 10%, 5%, etc. In this example, the percentage of battery level can be the ratio of the remaining battery level to the total battery level in the electronic device.
[0066] Optionally, the control application can detect the phone's operating current or instantaneous current in real time (e.g., every 10 or 5 seconds). If the detected operating current is greater than or equal to a first current threshold, the application running in the foreground is selected. The first current threshold can be a value greater than 100mA, such as 100mA or 150mA. If the detected instantaneous current is greater than or equal to a second current threshold, the application running in the foreground is selected. The second current threshold can be a value greater than 200mA, such as 200mA or 220mA.
[0067] Optionally, after the control application is started, it can obtain the first application running in the foreground at preset time intervals (such as 1 hour, 30 seconds, 1 minute, etc.).
[0068] Optionally, the management application can also respond to user-input management commands (such as clicking the cleanup button) and obtain the first application running in the foreground.
[0069] Optionally, the control application can also detect whether the current time is within a preset time period. If it detects that the current time is within the preset time period, it retrieves the first application running in the foreground. For example, the preset time period can be a user-specified time period, such as 18:00~20:00. Optionally, the phone can also determine the preset time period based on the user's phone usage time; that is, the preset time period is the time when the user frequently uses the phone.
[0070] It should be noted that the management application in this example can be a system application, which can run in the background after it is started.
[0071] In some embodiments, multiple first applications can exist in the foreground at the same time; that is, the managing application can access one or more first applications. For example, when the phone is in split-screen mode, with the screen divided into a first screen and a second screen, the first screen displays the interface of a video application, and the second screen displays the main interface of a chat application. Currently, the phone accesses two first applications: a video application and a chat application.
[0072] Step 502: The electronic device acquires the first process in the first application that is in a non-display state.
[0073] For example, an application in an electronic device may include one or more processes (e.g., two or more), each process may include one or more canvases. A WindowSurfaceController can control one or more canvases. In this example, the WindowSurfaceController controls one canvas. The WindowSurfaceController can set the display properties of the canvas, including a display state and a non-display state. The display state indicates that the canvas is displayed on the screen, and the non-display state indicates that the canvas is not displayed on the screen. A canvas (Surface) can be understood as a drawing surface in an application, which can hold various views. When the canvas's display property is in a display state, the canvas and the views it holds are displayed on the screen. When the canvas's display property is in a non-display state, the canvas is not displayed and there are no views displayed on the canvas. For example, the canvas's display property can be represented as isShown. If the display property of canvas A is set to true, it indicates that canvas A is in a display state; if the display property of canvas A is set to false, it indicates that canvas A is in a non-display state.
[0074] In this example, the object used to describe the interface currently displayed on the screen is represented by a canvas. In other display systems, the object used to describe the currently displayed interface can be represented by other names, such as window.
[0075] In this example, the management application can determine whether a process is in a non-display state based on the number of canvases displayed. Since a process may have one or more canvases, the process is in a display state when any one of its canvases is displayed. When none of the canvases in a process are displayed, the process is in a non-display state. Therefore, this example uses the presence of displayed canvases in a process as the criterion for detecting whether a process is in a display state. For example, the management application can identify processes with zero displayed canvases as non-display processes. When the management application detects that the number of displayed canvases in a process is greater than zero, it determines that the process is in a display state; when the management application detects that the number of displayed canvases in a process is equal to zero, it determines that the process is in a non-display state.
[0076] The following details the process by which the phone determines the number of displayed canvases for each process in the first application.
[0077] In some embodiments, the mobile phone can obtain a first display attribute of each canvas of each process in the first application; if a screen switch is detected, it can obtain a second display attribute of each canvas of each process in the first application; and determine the number of canvases displayed for each process in the first application based on the first display attribute and the second display attribute.
[0078] In some embodiments, the canvas controller can obtain the display attributes of each canvas in each process of the first application. The first display attributes may include the display attributes of each canvas in each process. For example, the first application includes two processes, process A and process B. Process A includes canvas 1 and canvas 2, and process B includes canvas 3 and canvas 4. The display attribute of canvas 1 is in a displayed state (i.e., isShown=true), the display attribute of canvas 2 is in a non-displayed state, and the display attributes of canvas 3 and canvas 4 are both in a non-displayed state. The first display attributes may include the display attributes of canvas 1, canvas 2, canvas 3, and canvas 4. The first display attributes may also include the identification information of the process to which each canvas belongs.
[0079] Optionally, the management application can store the display attributes of each canvas for each process in the first application.
[0080] In one example, after the management application obtains the first display attribute, it can determine the number of first canvases displayed in the first application based on the first display attribute. This number of first canvases includes the number of canvases displayed for each process within the first application. For example, the first display attribute includes: Canvas 1 is in the displayed state, and Canvas 2 is in the non-displayed state. {Canvas 3 is not displayed, Canvas 4 is not displayed}; The first display attribute can be represented as an array, with each row corresponding to a process, and each element in each row representing the display attribute of the canvas in that process. The element in the first row and first column indicates that the display attribute of canvas 1 in process A is "displaying". The control application can determine, based on the first display attribute, that the number of canvases displayed for process A is 1, and the number of canvases displayed for process B is 0. This first canvas count can also be stored as an array, such as {1, 0}, where each element represents the number of canvases displayed for each corresponding process, where 1 indicates that process A has 1 displayed canvas, and 0 indicates that process B has 0 displayed canvases.
[0081] In some embodiments, the phone's activity manager can detect whether the interface has changed. When the interface changes, the canvas controller obtains a second display attribute for each canvas of each process in the first application. This second display attribute may include the display attributes of each canvas of each process. If the managing application detects that the second display attribute is different from the first display attribute, it updates the number of first canvases.
[0082] For example, the interface switching operation can be a user-inputted instruction, such as a user clicking an application icon on the phone's home screen. The phone's sensors can detect the location of the user's click and identify the clicked application. The phone launches the clicked application, which can send interface information (including an identifier) to the Activity Manager. Upon receiving the interface information, the Activity Manager can determine that an interface switch has been detected. After receiving the interface information, the Activity Manager can hide and destroy the home screen interface and instruct the canvas controller in the process to which the home screen belongs to set the display attribute of the canvas for that process to a non-display state. After hiding and destroying the home screen, the Activity Manager can launch the application's interface based on the interface information and instruct the canvas controller in the process to which the interface belongs to set the display attribute of the canvas for that process to a display state.
[0083] In other embodiments, the interface switching operation can be generated by the system. For example, application A has an advertising display window. When a preset time is detected, the application generates an instruction to display the advertising window on the current interface. This instruction carries the interface information of the advertising window. Assuming the size of the advertising window is smaller than the size of the currently displayed interface, the advertising window is displayed on the current interface. The activity manager receives the instruction to display the advertising window (which confirms that an interface switch has been detected). Based on this instruction, it can start the advertising window and instruct the canvas controller in the process to which the advertising window belongs to set the display attribute of the canvas of the process to be displayed.
[0084] In this example, the Activity Manager detects a screen transition upon receiving a command to switch interfaces. This command can be to launch a new interface. If the Activity Manager does not detect a screen transition, it will not instruct the canvas controller to acquire the second display property.
[0085] In one example, if the Activity Manager detects a screen switching command and instructs the displayed screen to switch from the first screen to the second screen, the Activity Manager responds to this command by hiding and destroying the canvas of the process belonging to the first screen. While hiding and destroying the canvas, the Activity Manager instructs the canvas controller to set the display attributes of the canvas corresponding to the first screen to a non-display state. The canvas controller then sets the display attributes of the canvas corresponding to the first screen and retrieves the reset display attributes. In other words, when the Activity Manager hides and destroys the canvas corresponding to the first screen, the display attributes of that canvas are always in a non-display state.
[0086] After destroying the canvas of the process belonging to the first interface, the Activity Manager can launch the second interface. When launching the second interface, the Activity Manager instructs the Canvas Controller to set the display attribute of the canvas corresponding to the second interface to the displayed state. The Canvas Controller sets the display attribute of the canvas corresponding to the second interface and obtains the reset display attribute of the canvas. This can be understood as the canvas controller launching the canvas corresponding to the second interface having the display attribute of the canvas in the displayed state. The Canvas Controller can use the obtained reset display attribute of each canvas as the second display attribute. Optionally, the Canvas Controller can report the obtained second display attribute to the management application, which then compares it with the first display attribute. If the management application detects that the second display attribute is different from the first display attribute, it obtains the canvas whose display attribute has changed as the target canvas; if the management application detects that the target canvas's display attribute is in the displayed state, it increments the number of displayed canvases in the process belonging to the target canvas by 1. If the management application detects that the target canvas's display attribute is in the non-displayed state, it decrements the number of displayed canvases in the process belonging to the target canvas by 1.
[0087] For example, the first screen belongs to process A, and its corresponding canvas is canvas 1; the second screen belongs to process A, and its corresponding canvas is canvas 2. At time t1, the display shows the first screen, and the first display attribute obtained by the control application is: Canvas 1 is in the displayed state, and Canvas 2 is in the non-displayed state. {Canvas 3 is not displayed, Canvas 4 is not displayed}}.
[0088] Based on the first display attribute, the first canvas number is determined, which is represented as {1,0}, where 1 indicates that the number of canvases displayed by process A is 1; and 0 indicates that the number of canvases displayed by process B is 0.
[0089] At time t2, the Activity Manager detects a screen switch and instructs the Canvas Controller to obtain a second display attribute. If the screen switches from the first screen to the second screen, this second display attribute is: Canvas 1 is in a non-display state, and Canvas 2 is in a display state. {Canvas 3 is not displayed, Canvas 4 is not displayed}}.
[0090] The canvas controller reports the second display attribute to the management application. The management application compares the first and second display attributes and determines that the display attributes of canvas 1 and canvas 2 have changed. If the management application determines that canvas 1 is not in a display state, it decrements the number of displayed canvases for process A by 1, i.e., 1-1=0. If the management application determines that canvas 2 is in a display state, it increments the number of displayed canvases for process A by 1, i.e., 0+1=1; the updated number of the first canvases is {1,0}.
[0091] Assume the process to which the third interface belongs is process B, and the canvas corresponding to the third interface is canvas 3; the process to which the fourth interface belongs is process B, and the canvas corresponding to the fourth interface is canvas 4. At time t3, the Activity Manager detects that the second interface has been closed, and the third and fourth interfaces have started. At this time, the first display attribute is: Canvas 1 is in a non-display state, and Canvas 2 is in a display state. {Canvas 3 is not displayed, Canvas 4 is not displayed}}.
[0092] The first canvas size is {1, 0}. The second display property is: Canvas 1 is in a non-display state, Canvas 2 is in a non-display state. {Canvas 3 is in display state, canvas 4 is in display state}}.
[0093] The canvas controller reports the second display attribute to the management application. The management application compares the first and second display attributes and determines that the display attributes of canvases 2, 3, and 4 have changed. If the management application determines that canvas 2 is not displayed, it decrements the number of displayed canvases in process A by 1 (1-1=0). If the management application determines that canvas 3 is displayed, it increments the number of displayed canvases in process B by 1 (0+1=1). If the management application determines that canvas 4 is displayed, it increments the number of displayed canvases in process B by 1 (1+1=1). The updated number of the first canvases is {0,2}.
[0094] It is understandable that the first display attribute, the second display attribute, and the number of first canvases in this example can also be represented in other forms, not limited to arrays. For example, the system can also store the first display attribute of each canvas as a data structure, using the canvas identifier and the identifier of the process to which the canvas belongs as the key, and the display attribute of the canvas before reset as the value of the key. Similarly, the system can store the second display attribute and the number of first canvases, and so on, without further listing.
[0095] In other embodiments, each canvas is controlled by a corresponding canvas controller. Different canvas controllers control different canvas display attributes. Once a canvas controller sets the display attributes of its corresponding canvas, it can obtain those attributes.
[0096] In this example, we take the canvas corresponding to the first interface as an example to illustrate the process of determining the number of canvases displayed in the process to which the first interface belongs. It can be understood that the process of determining the number of canvases displayed in other processes is similar.
[0097] In some embodiments, since the canvas needs to be hidden before the display module destroys the canvas, in order to avoid the canvas controller reporting duplicate display attributes to the management application, resulting in an error in the count of the number of canvases displayed for the corresponding process.
[0098] In this example, the canvas controller detects whether the original display attributes of the canvas corresponding to the first interface (hereinafter referred to as the second canvas) are different from the current display attributes. If the original display attributes of the second canvas are detected to be different from the current display attributes, the canvas controller reports the current display attributes of the second canvas to the management application so that the management application can update the number of displayed canvases corresponding to the process to which the second canvas belongs. If the original display attributes of the second canvas are detected to be the same as the current display attributes, the canvas controller does not report the current display attributes of the second canvas to the management application.
[0099] Optionally, upon receiving the current display attribute of the second canvas, the management application updates the number of displayed canvases for the process to which the second canvas belongs. Specifically, if the management application detects that the current display attribute of the second canvas is not displayed, it decrements the number of displayed canvases for the process to which the second canvas belongs by 1; if it detects that the current display attribute of the second canvas is displayed, it increments the number of displayed canvases for the process to which the second canvas belongs by 1. The management application can store the correspondence between each process and the number of displayed canvases corresponding to that process.
[0100] Optionally, when the canvas controller reports the display attributes of the second canvas to the management application, it may also carry the identifier of the process to which the second canvas belongs, so that the management application can accurately find the process to which the second canvas belongs and modify the number of canvases displayed for the process to which the second canvas belongs.
[0101] Similarly, in response to this interface switching operation, the Activity Manager launches the second interface, that is, displays the canvas of the process to which the second interface belongs. For ease of understanding, in this example, the canvas of the process to which the second interface belongs can be represented as a third canvas. The Activity Manager instructs the canvas controller corresponding to the third canvas to set the canvas's display properties to the displayed state.
[0102] The Activity Manager instructs the canvas controller corresponding to the third canvas to set its display properties. It can also retrieve the display properties of the third canvas before reset as its original display properties, and retrieve the display properties after reset as its current display properties. When the Activity Manager starts the third canvas, the canvas controller will set its display properties to the displayed state; that is, when the third canvas is started (or displayed), its display properties are in the displayed state.
[0103] For example, the canvas controller of the third canvas detects whether the original display attributes of the third canvas are different from the current display attributes. If the original display attributes of the third canvas are different from the current display attributes, the canvas controller of the third canvas reports the current display attributes of the third canvas to the management application so that the management application can update the number of canvases displayed in the process to which the third canvas belongs. If the original display attributes of the third canvas are the same as the current display attributes, the canvas controller does not report the current display attributes of the third canvas to the management application.
[0104] Optionally, upon receiving the current display attribute of the third canvas, the management application modifies the number of displayed canvases in the process to which the third canvas belongs. Specifically, if the management application detects that the current display attribute of the third canvas is not displayed, it obtains the number of displayed canvases in the process to which the third canvas belongs and decrements the number of displayed canvases by 1; if it detects that the current display attribute of the third canvas is displayed, it obtains the number of displayed canvases in the process to which the third canvas belongs and increments the number of displayed canvases by 1.
[0105] Understandably, the process of storing the number of displayed canvases for other processes is similar; the management application stores the number of displayed canvases for each process. Optionally, when the management application obtains the first application running in the foreground, it can query the stored number of displayed canvases for each process within that first application.
[0106] In this example, the canvas controller detects whether the current display attributes of the canvas are different from the original display attributes, and determines whether to report the display attributes of each canvas to the management application. This can reduce the amount of computation required by the management application.
[0107] For example, in response to switching from interface 1 to interface 2, the display module obtains that the process to which interface 1 belongs includes canvas A. The display module hides canvas A and instructs the canvas controller corresponding to canvas A to set the display attribute of canvas A to a hidden state. This display attribute can be represented by a Boolean value; for example, if the display attribute of canvas A is true at time t1, it indicates that the canvas is in a displayed state. At time t2, the canvas controller sets the display attribute of canvas A to false, indicating that canvas A is in a hidden state. The canvas controller obtains the original display attribute of canvas A as displayed and the current display attribute of canvas A as hidden.
[0108] The canvas controller of canvas A detects that the current display attribute of canvas A (which is in a non-display state at time t2) differs from the original display attribute (which is in a display state at time t1). Therefore, it reports the current display attribute of canvas A (i.e., the current display attribute is false) to the management application. Assuming the management application obtains the number of displayed canvases for the process belonging to canvas A at time t1 as 1, upon receiving the current display attribute of canvas A, the management application subtracts 1 from the number of displayed canvases for the process belonging to canvas A, updating the number of displayed canvases for the process belonging to canvas A to 0.
[0109] After hiding Canvas A of the second process, the display module destroys Canvas A. The display module instructs the canvas controller corresponding to Canvas A to set its display attribute to non-display. For example, at time t2, the canvas controller corresponding to Canvas A sets its display attribute to false; at time t3, it resets the display attribute to false. The canvas controller of Canvas A detects that the current display attribute of Canvas A (false at time t3) is the same as the original display attribute (false at time t2), and therefore does not report the current display attribute of Canvas A to the management application (i.e., the display attribute of Canvas A is false at time t3). At time t2, the management application obtains that the number of displayed canvases of the process to which Canvas A belongs is 0. Since the canvas controller of Canvas A did not report the display attribute of Canvas A at time t3 to the management application, the number of displayed canvases of the process to which Canvas A belongs remains unchanged.
[0110] Simultaneously, the display module starts canvas B corresponding to the process of interface 2. The display module starts canvas B and instructs the canvas controller corresponding to canvas B to set its display attribute to the displayed state. At time t3, the display attribute of canvas A is false; at time t4, the canvas controller sets the display attribute of canvas B to true. The canvas controller obtains that the original display attribute of canvas B was non-displaying, and also obtains that the current display attribute of canvas B is non-displaying.
[0111] The canvas controller of canvas B detects a difference between the current display attribute of canvas B (which is false at time t4) and the original display attribute (which is not displayed at time t3). Therefore, it reports the current display attribute of canvas B (i.e., the current display attribute is true) to the management application. Assuming that at time t3 the management application obtains that the number of displayed canvases for the process to which canvas B belongs is 0, the management application receives the current display attribute of canvas B and increments the number of displayed canvases for the process to which canvas B belongs by 1, thus updating the number of displayed canvases for the process to which canvas B belongs to 1.
[0112] Optionally, the management application can use concurrent read / write operations to record the number of displayed canvases corresponding to the process to which the canvas belongs. Using concurrent read / write operations to record the number of displayed canvases corresponding to the process to which the canvas belongs ensures that when the management application updates the number of displayed canvases for the process to which the canvas belongs and simultaneously retrieves the number of displayed canvases for that process, it obtains the accurate number of displayed canvases for that process. For example, at time t4, the management application updates the number of displayed canvases for process A from 1 to 0. At the same time, the management application retrieves the number of displayed canvases for process A. Because the upper-layer application uses concurrent read / write operations, at time t4, the upper-layer application obtains a number of displayed canvases for process A that is 0.
[0113] In another embodiment, the canvas controller can periodically acquire the display attributes of each canvas in each process of the first application and report the display attributes of each canvas to the management application. The management application then acquires the number of canvases in each process that are in a display state based on each display attribute, and uses the acquired number of canvases in a display state as the number of canvases displayed in each process of the first application.
[0114] Specifically, the canvas controller can acquire the display attributes of each canvas in each process of the first application at preset first intervals. The first interval can be pre-set, such as 30 seconds, 40 seconds, 50 seconds, 1 minute, or longer than 1 minute. Optionally, each canvas controller can acquire the display attributes of its own canvas separately. After acquiring the display attributes of its own canvas, each canvas controller can directly report them to the management application. When reporting the display attributes of each canvas to the management application, the canvas controller can also report the identification information of each canvas and the identification information of the process to which the canvas belongs. Upon receiving the display attributes of each canvas, the management application can identify the canvases that are in a display state and the process to which the canvases in a display state belong, thereby determining the number of canvases displayed for each process.
[0115] For example, the first interface belongs to process A, and its corresponding canvas is canvas 1; the second interface belongs to process A, and its corresponding canvas is canvas 2; the third interface belongs to process B, and its corresponding canvas is canvas 3; the fourth interface belongs to process B, and its corresponding canvas is canvas 4. At time t5, the canvas controller for each canvas obtains the display attribute of that canvas once. Assume that canvas 1 is displayed, canvas 2 is not displayed, canvas 3 is not displayed, and canvas 4 is not displayed. The canvas controller reports the display attribute of each canvas and the identifier of the process to which each canvas belongs to the management application. The management application obtains the display attribute of each canvas and the identifier of the process to which each canvas belongs, identifies the canvas that is displayed (i.e., canvas 1), and detects that the process to which canvas 1 belongs is process A. The management application determines that process A has 1 displayed canvas and process B has 0 displayed canvases.
[0116] At time t5+30, the canvas controller for each canvas retrieves the display attributes of that canvas once. Assume that canvas 1 is in a non-display state, canvas 2 is in a display state, canvas 3 is in a non-display state, and canvas 4 is in a non-display state. The canvas controller reports the display attributes of each canvas and the identifier of the process to which each canvas belongs to the management application. The management application retrieves the display attributes of each canvas and the identifier of the process to which each canvas belongs, identifies the canvas in a display state (canvas 2), and detects that the process to which canvas 2 belongs is process A. The management application determines that process A has 1 canvas displayed, and process B has 0 canvases displayed. This management application can store the number of canvases displayed for each process.
[0117] In some embodiments, multiple first applications can exist running in the foreground at the same time; that is, the management application can acquire one or more first applications. Processes acquired by the management application that are not in the visible state can be in the same application or in different applications. For example, the processes acquired by the management application that are not in the visible state include process A, process B, and process C, where process A belongs to application A, process B belongs to application A, and process C belongs to application C.
[0118] Step 503: The electronic device manages the first process.
[0119] For example, a control application in an electronic device restricts the first process's use of hardware and / or software resources. Hardware resources may include: CPU, network resources, Bluetooth resources, location resources, sensors, camera resources, etc. Software resources may include service resources, activity resources, broadcast receivers, and content providers.
[0120] Optionally, limiting the first process's use of hardware and / or software resources can be achieved by reducing the duration of the first process's access to hardware and / or software resources, or by directly disabling the first process's use of hardware and / or software resources for a preset duration, which can be 10 seconds, 20 seconds, 1 minute, or more than 1 minute.
[0121] Optionally, each process has a corresponding priority. The electronic device (i.e., the management application of the electronic device) determines the order in which processes call computing resources based on their priorities. Higher priorities allow for the use of more computing resources or earlier access to computing resources. The management application can also adjust the first process's first priority to a second priority. The first priority allows the first process to use system resources higher than the second priority. The second priority can be the lowest priority. The management application can also lower the first process's first priority by a preset number, such as 1 or 2, meaning the first process's priority is lowered by two levels. For example, if the first priority is the highest priority and the second priority is the lowest priority, the first priority allows the first process to use the CPU for 50% more time than the second priority allows. Optionally, the first priority can also allow the first process to use the CPU for 10%, 20%, 30%, 40%, etc., more time than the second priority allows.
[0122] Optionally, the management application can use the process's nice value as its priority. This nice value ranges from -20 to 19, where a smaller nice value indicates a higher priority. Higher priority allows the process to access CPU resources more efficiently than lower priority processes. The second priority is lower than the first priority. The first priority corresponds to a nice value of -18, the second priority to a nice value of 1, and so on, with nice=19, etc. In this example, when the difference between the first priority and the lowest priority is n, where n is a positive integer, the preset number of levels to lower the priority can be set from 1 to n.
[0123] Optionally, the Android system can utilize Linux's grouping mechanism to assign different levels of groups to different processes, such as "top group," "foreground group," and "background group," where the top group is higher than the foreground group, and the foreground group is higher than the background group. By setting these groups, the management application can influence whether the operating system prioritizes resource allocation to processes within that group. In this example, the management application can lower the priority of the first process by changing its group. For instance, if the first process was previously in the background group, the management application can change its group to the foreground group. The foreground group has a higher priority than the background group, and processes with higher priority are allocated resources first.
[0124] The management application lowers the priority of the first process, so that the first process does not consume computing resources, thereby reducing the power consumption of electronic devices. At the same time, by prioritizing other high-priority processes, the operating performance of electronic devices is improved.
[0125] In some embodiments, after the management application manages the first process, it can periodically (e.g., every 5 seconds, 10 seconds, 30 seconds) acquire the display status of the first process. If the management application detects that the first process has changed from a non-display state to a display state, it cancels its management of the first process. Specifically, the management application monitors the display attributes of the first process in real time; if it detects that the first process has switched from a non-display state to a display state, it cancels its management of the first process.
[0126] Optionally, if the management application detects that the first process has been restricted from using system resources for a preset duration, it will restore the first process's access to system resources. This preset duration can be set in advance, such as 30 seconds.
[0127] Optionally, if the control application detects that the power consumption of the electronic device is greater than or equal to a second preset threshold, the second preset threshold is greater than a first preset threshold. For example, the second preset threshold can be 80%, 70%, 60% of the power consumption, etc., and the first preset threshold is 50% of the power consumption.
[0128] In some embodiments, the management application can also manage background applications, which can further reduce the power consumption of the phone and extend its operating time.
[0129] In this example, the electronic device manages processes that are not currently displayed within the foreground application. This reduces the number of power-consuming processes in the foreground, thereby reducing the power consumption of the foreground application, lowering the phone's power consumption, and extending the phone's runtime. Furthermore, the managed object can be a process, rather than the entire application, ensuring that the management does not affect the currently displayed interface. Managing processes also allows for greater flexibility.
[0130] The following will combine Figure 6 This section details the internal interaction process when an electronic device manages the first process. In this example, the electronic device is a mobile phone, which includes a display module, a canvas controller, and an upper-layer application (such as a management application). The display module may include an activity manager. The process of managing this process includes: Step 601: The display module detects the interface switching operation and proceeds to step 602.
[0131] Specifically, the display module detects interface switching operations, such as clicking a switch button or swiping the screen. Interface switching operations can also include split-screen operations, opening a floating window, and closing a floating window.
[0132] Figure 7 This is a schematic diagram illustrating an example of an interface switching scenario. For example... Figure 7 As shown in 7a, the phone's display interface 701 is interface 1, and the user clicks control 702. The display module responds to the user's click operation by switching the interface to interface 703, as shown below. Figure 7 As shown in 7b, interface 1 corresponds to process 1, and interface 2 corresponds to process 2. When interface 1 is displayed, the display attribute of canvas 1 corresponding to process 1 (i.e., canvas 1 corresponding to interface 1) is set to display state. In response to the operation of switching from interface 1 to interface 2, the display module hides canvas 1 and instructs the canvas controller corresponding to canvas 1 to modify the display attribute of canvas 1, i.e., execute step 602.
[0133] Step 602: The display module instructs the canvas controller corresponding to canvas 1 to modify the display properties of canvas 1.
[0134] Specifically, such as Figure 7 As shown in 7a, the display interface switches from interface 1 to interface 2. The display module instructs the canvas controller corresponding to canvas 1 to change the display attribute of canvas 1 from the display state to the non-display state.
[0135] Step 603: Modify the display properties of canvas 1 in the process before switching, according to the canvas controller corresponding to canvas 1.
[0136] Specifically, the canvas controller corresponding to canvas 1 modifies the display attributes of canvas 1 in process 1. For example, if process 1 corresponds to canvas 1, at time t1, the display attribute of canvas 1 is in the display state, denoted as surface1.isShown=true. After receiving the modification instruction from the display module, the canvas controller corresponding to canvas 1 changes the display attribute of canvas 1 to the non-display state at time t2, i.e., surface1.isShown=false.
[0137] Step 604: The canvas controller detects whether the current display attributes of canvas 1 are different from the previous display attributes. If it detects that the current display attributes of canvas 1 are different from the previous display attributes, then proceed to step 605. If it detects that the current display attributes of canvas 1 are the same as the previous display attributes, then proceed to step 608.
[0138] Specifically, the controller corresponding to canvas 1 obtains the previous display attribute of canvas 1 and compares whether the previous display attribute of canvas 1 is different from the current display attribute. For example, at time t1, the display attribute of canvas 1 is in the display state, denoted as surface1.isShown=true; at time t2, the display attribute of canvas 1 is in the non-display state, denoted as surface1.isShown=false. The canvas controller of canvas 1 detects that the previous display attribute (i.e., at time t1) is true and the current display attribute (i.e., at time t2) is false, and determines that the current display attribute of canvas 1 is different from the previous display attribute, and executes step 605.
[0139] If the canvas controller corresponding to canvas 1 determines that the current display attributes of canvas 1 are the same as the previous display attributes, then it will not report the current display attributes of canvas 1 to the management application.
[0140] Step 605: The canvas controller obtains the current display properties of canvas 1.
[0141] Step 606: The canvas controller reports the current display properties of canvas 1 to the management application.
[0142] Specifically, when the canvas controller corresponding to canvas 1 reports the current display attributes of canvas 1, it can also carry the identification information of the process to which canvas 1 belongs.
[0143] Optionally, the canvas controller corresponding to canvas 1 can also report the current time at the same time.
[0144] Step 607: Manage application statistics and store the number of canvases displayed in each process.
[0145] Specifically, the management application can store the correspondence between each process and the number of canvases displayed in that process. For example, the management application can use the process identification information as the key and the number of canvases displayed in that process as the value corresponding to the key, such as process1:1, where process1 is the process identification information and the number 1 corresponding to process1 indicates that the number of canvases displayed in process1 is 1.
[0146] When the management application receives the reported display attributes of a canvas, it locates the process to be modified based on the identifier of the process to which the canvas belongs, and then modifies the number of canvases displayed for that process. For example, if the management application receives the display attributes of canvas 1 and the identifier of the process to which canvas 1 belongs (e.g., the identifier is process 1), and finds that the number of canvases displayed for process 1 is 1, and the management application detects that the reported display attribute of canvas 1 is false, it changes the number of canvases displayed for process 1 to 0 and stores the number of canvases displayed for process 1.
[0147] The management application stores the number of displayed canvases for each of the different processes.
[0148] Step 608: The canvas controller determines not to report the display properties of canvas 1.
[0149] Step 609: If the management application detects that the preset conditions for process management are met, it will select the application running in the foreground as the first application.
[0150] This step is similar to step 501, and the relevant description can be found in the description in step 501. It will not be repeated here.
[0151] Step 610: The management application queries the process in the first application where the number of canvases displayed is 0, and selects it as the first process.
[0152] Specifically, the management application stores a second correspondence between applications and processes, and a first correspondence between a process and the number of canvases displayed within that process. Based on the application identifier of the first application and the second correspondence, the management application can query each process within the first application. The management application can then query the number of canvases displayed for each process within the first application based on the process identifiers and the first correspondence, and identify the process with zero displayed canvases as the first process.
[0153] Step 611: The management application manages the first process.
[0154] Specifically, this step is largely the same as step 503, and will not be described again here.
[0155] It should be noted that the first process disables preset resources. If the electronic device is connected to the Android Debug Bridge (ADB), ADB responds to the user's ps-A command, displaying all processes currently running on the electronic device and the running status of each process. The running status of the first process is __refrigerator (i.e., it is in a frozen state). Using ADB tools, it can be detected that the first process is disabled from using preset resources.
[0156] Step 612: If the control application detects that the number of canvases displayed in the first process is greater than 0, then it cancels the control over the first process.
[0157] In this example, Figure 6 The document only shows the process of the canvas controller corresponding to canvas 1 reporting the display attributes of canvas 1. After the display module hides canvas 1, it destroys canvas 1 and instructs the canvas controller corresponding to canvas 1 to modify the display attributes of canvas 1. At time t3, the canvas controller corresponding to canvas 1 sets the display attribute of canvas 1 to false (i.e., not displayed). Similar to step 604, if the canvas controller corresponding to canvas 1 detects that the display attribute of canvas 1 at time t2 (if false) is the same as the current display attribute (i.e., at time t3), it does not report the display attribute of canvas 1 at time t3 to the management application.
[0158] Since interface 2 needs to be displayed, the display module creates interface 2 and instructs the canvas controller corresponding to canvas 2 to modify the display attributes of canvas 2. At time t5, the canvas controller corresponding to canvas 2 sets the display attribute of canvas 2 to true (i.e., display state). The default display attribute of canvas 2 when it is created is false (i.e., non-display state). Similar to step 604, if the canvas controller corresponding to canvas 2 detects that the display attribute of canvas 2 in the previous instance (e.g., false) is different from the current display attribute (i.e., at time t5), it reports the display attribute of canvas 2 at time t5 to the management application. After receiving the display attribute of canvas 2, the management application obtains the number of displayed canvases in process 2 to which canvas 2 belongs. If the management application detects that the display attribute of canvas 2 is true, it increments the number of displayed canvases in process 2 by 1, for example, changing the number of displayed canvases in process 2 from 0 to 1.
[0159] Figure 8 This is an illustrative diagram illustrating a mobile game scenario. The phone launches the game at 9:00 AM, as shown below. Figure 8As shown in Figure 8b, the phone displays the game interface 801, with the current battery percentage at 100%. To reduce power consumption, the user opened a power management application (which can be a power optimization app). The phone responds to the user's action by launching the power management application. This application can identify foreground applications at preset intervals (e.g., 30 seconds) and manage processes within those foreground applications that are not currently displayed. After running the game for 3 hours, as shown in Figure 8b, at 12 o'clock, the remaining battery level displayed on interface 803 is 60%. Compared to... Figure 1 In cases where processes in the foreground application are not in a display state, the power consumption of the mobile phone is significantly reduced. It can be seen that the process control method in this application can extend the running time of the mobile phone.
[0160] It is understood that, in order to achieve the above-mentioned functions, electronic devices include hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0161] In addition, this application also provides an apparatus, which may specifically be a chip, component or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the process control methods in the above method embodiments.
[0162] This embodiment also provides a computer storage medium storing computer instructions. When these computer instructions are executed on an electronic device, the electronic device performs the aforementioned method steps to implement the process control method described in the above embodiment. The storage medium includes various media capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0163] This embodiment also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned related steps to implement the process control method described in the above embodiment.
[0164] In this embodiment, the electronic device, computer storage medium, computer program product or chip are all used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding method provided above, and will not be repeated here.
[0165] Any content in the various embodiments of this application, as well as any content in the same embodiment, can be freely combined. Any combination of the above content is within the scope of this application.
[0166] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0167] The terms "first" and "second," etc., used in the specification and claims of this application are used to distinguish different objects, not to describe a specific order of objects. For example, "first target object" and "second target object," etc., are used to distinguish different target objects, not to describe a specific order of target objects.
[0168] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of the terms "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0169] In the description of the embodiments in this application, unless otherwise stated, "multiple" means two or more. For example, multiple processing units means two or more processing units; multiple systems means two or more systems.
[0170] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for process management, characterized in that, The method, applied to a first application running in the foreground, includes: The first application is obtained, which includes a process in a display state and a process in a non-display state, wherein the process in the display state is the process in which the canvas is displayed, and the process in the non-display state is the process in which the canvas is not displayed. The system obtains a first process that is not in a display state and manages the first process, wherein the management includes: restricting the first process from using system resources, or reducing the first priority of the first process.
2. The method according to claim 1, characterized in that, Retrieve the first process that is not in a display state, including: Get the number of canvases displayed for each process in the first application; The process with zero displayed canvases is selected as the first process.
3. The method according to claim 2, characterized in that, Obtain the number of canvases displayed for each process in the first application, including: Obtain the display attributes of each canvas in each process of the first application; Based on the display attributes of each canvas, the number of canvases displayed for each process in the first application is determined.
4. The method according to claim 3, characterized in that, Determining the number of displayed canvases for each process in the first application based on the display attributes of each canvas includes: Get the number of canvases in each process whose display attribute is in the display state; The number of canvases obtained is used as the number of canvases displayed in each process of the first application.
5. The method according to claim 2, characterized in that, Obtain the number of canvases displayed for each process in the first application, including: Obtain the first display attribute of each canvas in each process of the first application; If a screen switch is detected, obtain the second display attribute of each canvas in each process of the first application; Based on the first display attribute and the second display attribute, determine the number of canvases displayed for each process in the first application.
6. The method according to claim 5, characterized in that, After obtaining the first display attribute of each canvas for each process in the first application, the method further includes: Based on the first display attribute, the number of first canvases displayed in the first application is determined, and the number of first canvases includes the number of canvases displayed in each process of the first application. Determining the number of canvases displayed for each process in the first application based on the first display attribute and the second display attribute includes: If the second display attribute is detected to be different from the first display attribute, then the first canvas quantity is updated.
7. The method according to claim 6, characterized in that, The method further includes: If the second display attribute is detected to be the same as the first display attribute, then the first canvas number is maintained.
8. The method according to claim 6, characterized in that, The step of updating the number of first canvases if the second display attribute is detected to be different from the first display attribute includes: Get the canvas whose display properties have changed as the target canvas; If the target canvas is detected to be in a display state, the number of displayed canvases in the process to which the target canvas belongs is incremented by 1; If the target canvas is detected to be in a non-display state, the number of displayed canvases in the process to which the target canvas belongs is reduced by 1.
9. The method according to claim 5, characterized in that, If an interface switch is detected, the second display attribute of each canvas in each process of the first application is obtained, including: The second display attribute of each canvas in each process of the first application is obtained through the canvas controller.
10. The method according to claim 9, characterized in that, The step of obtaining the second display attribute of each canvas of each process in the first application through the canvas controller includes: The canvas controller responds to a setting command to set a second display attribute for each canvas.
11. The method according to claim 9 or 10, characterized in that, The canvas controller controls at least one of the canvases.
12. The method according to any one of claims 1 to 11, characterized in that, The system resources include hardware resources and software resources; The hardware resources include one or more of the following: CPU, network resources, Bluetooth resources, location resources, and sensors; The software resources include one or more of the following: service resources, activity resources, broadcast receivers, and content providers.
13. The method according to any one of claims 1 to 11, characterized in that, The reduction of the first priority of the first process includes: The first priority of the first process is lowered to the second priority, or the first priority of the first process is lowered by a preset number.
14. The method according to any one of claims 1 to 11, characterized in that, The method further includes: If the first process is detected to change from a non-display state to a display state, then the control over the first process is cancelled.
15. The method according to any one of claims 1 to 11, characterized in that, The method further includes: If it is detected that the first process has been restricted from using system resources for a preset period of time, then the first process is allowed to use the system resources again.
16. The method according to any one of claims 1 to 11, characterized in that, Before retrieving the first application running in the foreground, the method further includes: The power consumption of the electronic device is detected to be less than or equal to a first preset threshold.
17. The method according to any one of claims 1 to 11, characterized in that, The method further includes: If the power consumption of the electronic device is detected to be greater than or equal to the second preset threshold, the control over the first process is cancelled.
18. An electronic device, characterized in that, include: A memory and a processor, wherein the memory is coupled to the processor; The memory stores program instructions that, when executed by the processor, cause the electronic device to perform the process control method according to any one of claims 1 to 17.
19. A chip, characterized in that, The device includes one or more interface circuits and one or more processors; the interface circuits are configured to receive signals from the memory of an electronic device and send the signals to the processors, the signals including computer instructions stored in the memory; when the processor executes the computer instructions, the electronic device performs the process control method according to any one of claims 1 to 17.
20. A computer-readable storage medium comprising a computer program, characterized in that, When the computer program is run on an electronic device, it causes the electronic device to perform the process control method as described in any one of claims 1 to 17.