TASK MANAGEMENT PROCEDURES AND DEVICE

DE602014091552T2Active Publication Date: 2025-02-12HUAWEI DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
DE602014091552
Authority / Receiving Office
DE · DE
Patent Type
Patents
Current Assignee / Owner
Priority Date
2013-12-10
Filing Date
2014-12-04
Publication Date
2025-02-12
Estimated Expiration
2034-12-04

AI Technical Summary

Technical Problem

Current devices suffer from high power consumption and power loss due to the continuous execution of background tasks that do not require user interaction.

Method used

A task management method that determines scenarios corresponding to foreground tasks and identifies background tasks within scenarios where task limitation is allowed, then performs limitation processing to reduce system resource usage.

Benefits of technology

This approach reduces power consumption and power loss by selectively limiting background tasks in specific scenarios, thereby enhancing the device's power efficiency and stability.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present invention relates to the communications field, and in particular, to a task management method and device.BACKGROUND

[0002] With development of communications technologies, currently many devices support a multi-task system, that is, a device may run multiple application programs at the same time, and one application program may have one or more threads, each of which is referred to as a task. Multiple tasks usually include a foreground task and a background task. The foreground task refers to a task that requires user interaction, that is, an operation input by a user needs to be received during execution of the foreground task. The background task refers to a task that does not require user interaction, that is, an operation input by a user does not need to be received during execution of the background task. Because the background task does not require user interaction, the background task is generally not a user-sensitive task, or the background task is not of user concern. In other words, some background tasks do not need to be executed. However, the background tasks are continually executed in the background of a system, and continuously consume power of a device. It can be seen that, currently a device may suffer from great power consumption and power loss. US 2013 / 067475 A1 describes managing processes within suspended states and execution states. Kraig Brockschmidt: "Programming Windows 8 Apps with HTML, CSS and Java Script" In: "Programming Windows 8 Apps with HTML, CSS and JavaScript", 26 October 2012 (2012-10-26), Microsoft Press, US, ISBN: 978-0-7356-7261-1 pages ToC, Ch01, Ch11-Ch17, describes process lifetimes states for Windows Store apps.SUMMARY

[0003] The present invention is set out in the appended set of claims. In the following, parts of the description and drawing referring to embodiments, which are not covered by the claims are not presented as embodiments of the invention, but as examples useful for understanding the invention.BRIEF DESCRIPTION OF DRAWINGS

[0004] To describe the technical solutions in the embodiments of the present invention or in the prior art more clearly, the following briefly introduces the accompanying drawings required for describing the embodiments or the prior art. Apparently, the accompanying drawings in the following description show merely some embodiments of the present invention, and a person of ordinary skill in the art may still derive other drawings from these accompanying drawings without creative efforts. FIG. 1 is a schematic flowchart of a task management method; FIG. 2 is a schematic flowchart of another task management method; FIG. 3 is a schematic flowchart of another task management method; FIG. 4 is a schematic flowchart of another task management method; FIG. 5 is a schematic flowchart of another task management method; FIG. 6 is a schematic flowchart of another task management method; FIG. 7 is a schematic diagram of another task management method; FIG. 8 is a schematic diagram of a structure of a task management device; FIG. 9 is a schematic diagram of a structure of another task management device; FIG. 10 is a schematic diagram of a structure of another task management device; FIG. 11 is a schematic diagram of a structure of another task management device; FIG. 12 is a schematic diagram of a structure of another task management device; FIG. 13 is a schematic diagram of a structure of another task management device; FIG. 14 is a schematic diagram of a structure of another task management device; FIG. 15 is a schematic diagram of a structure of another task management device; FIG. 16 is a schematic diagram of a structure of another task management device; FIG. 17 is a schematic diagram of a structure of another task management device; FIG. 18 is a schematic diagram of a structure of another task management device; and FIG. 19 is a schematic diagram of a structure of another task management device. DESCRIPTION OF EMBODIMENTS

[0005] The following clearly and completely describes the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention.

[0006] In the embodiments of the present invention, a first scenario and a second scenario are not limited to two scenarios. The first scenario may indicate one or more scenarios, and the second scenario may also indicate one or more scenarios. For example, the first scenario may be a scenario corresponding to a foreground task, and there may be one or more foreground tasks at the same time, that is, the first scenario may be one or more scenarios. The second scenario may be any one or more scenarios except the first scenario; for example, the second scenario may be a scenario corresponding to a task excluding a foreground task. Here, the first and the second are named only for distinguishing two different scenarios.

[0007] In addition, in the embodiments of the present invention, a scenario may refer to a status of an action of a device that implements the embodiments of the present invention. The status of the action of the device may refer to a status in which the device uses a system resource. The system resource may be specifically a hardware resource, such as a CPU resource or a memory resource, or the system resource may be specifically a virtual resource, such as a network bandwidth resource or an operating system resource, which is not limited in the embodiments of the present invention. A scenario may be making a call, sending a short message service message, using a browser, playing a 2D / 3D game, viewing a main user interface, downloading a file, reading an ebook, playing music, watching a video, navigating through a website, browsing a photo, taking a photo, making a video, sending an email, and the like.

[0008] In addition, in the embodiments of the present invention, a scenario corresponding to a task may be specifically a scenario that a task enters when the task is executed. For example, when a music task is being executed, the task enters a music scenario and a download scenario, that is, a scenario corresponding to the music task may include the music scenario and the download scenario. In addition, a task corresponding to a scenario may be specifically a task that enters the scenario. For example, when a music task is being executed, the task enters a download scenario; when a browser task is being executed, the task also enters the download scenario; when a software update task is being executed, the task also enters the download scenario. In this way, the tasks corresponding to the download scenario may include: the music task, the browser task, and the software update task, that is, one scenario corresponds to different tasks.

[0009] In addition, in the embodiments of the present invention, a foreground task may refer to a task that requires user interaction, that is, an operation input by a user needs to be received during execution of the foreground task. Alternatively, a foreground task may refer to a task that is displayed on a screen. A background task may refer to a task that does not require user interaction during execution, that is, an operation input by a user does not need to be received during execution of the background task. Alternatively, a background task may refer to a task that is not displayed on a screen. In addition, it can be understood that a task may be a thread in the embodiments of the present invention.

[0010] Referring to FIG. 1, FIG. 1 is a schematic flowchart of a task management method, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 1, the method includes the following steps: 101. Determine, according to a foreground task, a first scenario corresponding to the foreground task.

[0011] Optionally, step 101 may be specifically determining, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario, the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, step 101 may include: determining, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, step 101 may include: determining, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0012] 102. When the first scenario corresponding to the foreground task is in a first list, search for at least one background task corresponding to the first scenario, where the first list includes a scenario in which task limitation is allowed.

[0013] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, a user likes to reduce power consumption of a device, and the user may set in the first list multiple scenarios in which task limitation is allowed, for example, setting a browser scenario, a game scenario, a navigation scenario, or the like as the scenario in which task limitation is allowed. In this way, when the first scenario corresponding to the current task is the browser scenario, the game scenario, or the navigation scenario, step 102 can be performed to reduce power consumption of the device.

[0014] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, only a few scenarios in which task limitation is allowed may be set in the first list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, more scenarios in which task limitation is allowed may be set in the first list. Because the first list has more scenarios in which task limitation is allowed, and step 102 and step 103 are performed multiple times, limitation processing can be performed on multiple background tasks, so as to reduce power consumption of the device and ensure stable running of the device.

[0015] Optionally, the at least one background task corresponding to the first scenario may refer to at least one background task in all background tasks corresponding to the first scenario, or the at least one background task corresponding to the first scenario may refer to all background tasks corresponding to the first scenario. This embodiment sets no limit thereto.

[0016] 103. Perform limitation processing on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage.

[0017] Optionally, the limitation processing may be processing for reducing a system resource currently used by a task. For example, a quantity of system resources used by a background task A is A when step 101 is performed, and after the limitation processing is performed on the background task A, a quantity of system resources used by the background task A is B, where A is greater than B. In addition, B may be zero.

[0018] Optionally, the method may be specifically applied to any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a personal computer (Personal Computer, PC), a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0019] In the foregoing technical solutions, a first scenario corresponding to a foreground task is determined according to the foreground task, and when the first scenario corresponding to the foreground task is in a first list, at least one background task corresponding to the first scenario is searched for, where the first list includes a scenario in which task limitation is allowed; and limitation processing is performed on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage. In this way, limitation processing is implemented on at least one background task corresponding to a scenario in which task limitation is allowed. Compared with the prior art in which a background task is always being executed, this can reduce power consumption and power loss of a device.

[0020] Referring to FIG. 2, FIG. 2 is a schematic flowchart of another task management method, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 2, the method includes the following steps: 201. Determine, according to a foreground task, a first scenario corresponding to the foreground task. 202. Determine whether the first scenario is in a first list. If yes, perform step 203. If no, end the process. The first list includes a scenario in which task limitation is allowed. 203. Search for at least one background task corresponding to the first scenario.

[0021] Optionally, step 203 may be specifically: searching for at least one background task that is in background tasks corresponding to the first scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or searching for at least one pre-determined background task in background tasks corresponding to the first scenario; or searching for at least one background task that is in background tasks corresponding to the first scenario and whose user identifier corresponds to a common user. For example, step 203 may include: searching for a user identifier of each background task corresponding to the first scenario, and searching for a background task whose user identifier (User Identifier, UID) corresponds to a common user as the at least one background task corresponding to the first scenario.

[0022] That is, this step is used to implement that the at least one background task that is corresponding to the first scenario and is searched for in step 203 is the background task whose UID corresponds to a common user. A UID is an inherent identifier of each task and is used to uniquely identify the task. In addition, a UID may correspond to a system user and a common user. When a UID of a background task corresponds to a system user, it indicates that the background task is a background task included in an operating system. When a UID of a background task corresponds to a common user, it indicates that the background task is not a background task included in an operating system.

[0023] Optionally, the method may further include: ignoring a background task whose UID corresponds to a system user in the at least one background task corresponding to the first scenario. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0024] Optionally, step 203 may be: searching for at least one background task that is in background tasks corresponding to the first scenario and whose system resource usage reaches a preset threshold. For example, searching for at least one background task that is in the background tasks corresponding to the first scenario and whose CPU resource usage reaches 10% of CPU resources; or searching for at least one background task that is in the background tasks corresponding to the first scenario and whose sleep lock holding duration reaches 10 minutes; or searching for at least one background task that is in the background tasks corresponding to the first scenario and whose average data download speed reaches 10M per minute.

[0025] 204. Perform limitation processing on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage.

[0026] Optionally, as shown in FIG. 3, the method may further include: 205. Search for a second scenario except the first scenario corresponding to the foreground task, where the second scenario corresponds to at least one background task, and the first list includes the second scenario. 206. Perform the limitation processing on the at least one background task corresponding to the second scenario.

[0027] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment.

[0028] In addition, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. This embodiment sets no limit thereto. In addition, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. In addition, step 205 may be specifically: searching for at least one background task that is in the background tasks corresponding to the second scenario and will not affect other tasks or an operating system after undergoing limitation processing; or searching for at least one pre-determined background task in the background tasks corresponding to the second scenario; or searching for at least one background task that is in the background tasks corresponding to the second scenario and whose user identifier corresponds to a common user.

[0029] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited. The scenario in which task limitation is prohibited may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is prohibited, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, the user may set, in the second list, a scenario that requires user attention as the scenario in which task limitation is prohibited, for example, a short message service message scenario, a call scenario, and a download scenario. Alternatively, the scenario in which task limitation is prohibited may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, more scenarios in which task limitation is prohibited may be set in the second list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, only a few scenarios in which task limitation is prohibited may be set in the second list.

[0030] Optionally, before step 204, the method may further include: querying a UID of the at least one background task corresponding to the first scenario; if the UID of the at least one background task corresponding to the first scenario corresponds to a system user, ignoring the at least one background task; and if the UID of the at least one background task corresponds to a common user, performing the limitation processing on the at least one background task. That is, step 204 is performing the limitation processing on the at least one background task whose UID corresponds to a common user.

[0031] In this implementation manner, because the background task whose UID corresponds to a common user is not a task of an operating system, other tasks are not affected after limitation processing is performed on the background task Therefore, limitation processing is performed only on a background task whose UID corresponds to a common user in step 204, which can reduce power consumption and power loss of the device without affecting other tasks.

[0032] Optionally, before step 204, the method may further include: starting a timer for the at least one background task corresponding to the first scenario; and stopping, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the first scenario.

[0033] Optionally, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. Meanwhile, a status value of the system component when the system component is paused may be saved in the foregoing step, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the first scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the first scenario.

[0034] Optionally, before step 204, the method may further include: querying whether the at least one background task corresponding to the first scenario uses a system component; and if the at least one background task corresponding to the first scenario uses the system component, stopping the system component.

[0035] In this implementation manner, because the system component used by the at least one background task corresponding to the first scenario is stopped, power consumption and power loss of the device may also be reduced.

[0036] Optionally, the processing for reducing system resource usage may include at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0037] In this case, step 204 may be: freezing the at least one background task corresponding to the first scenario, or stopping the at least one background task corresponding to the first scenario, or limiting a system resource used by the at least one background task corresponding to the first scenario.

[0038] Optionally, the freezing the at least one background task corresponding to the first scenario may be prohibiting the background task from calling a system resource, for example, prohibiting a CPU from calling the at least one background task corresponding to the first scenario. Specifically, a task scheduler of an operating system is used to prohibit the at least one background task corresponding to the first scenario from participating in any scheduling. Because the at least one background task corresponding to the first scenario is prohibited from calling the system resource, power consumption of the device is reduced.

[0039] Optionally, the limiting a system resource used by the at least one background task corresponding to the first scenario may be limiting a time within which the CPU calls the at least one background task corresponding to the first scenario. For example, a time value for CPU calling is set for the at least one background task corresponding to the first scenario, so that the CPU can call the at least one background task corresponding to the first scenario within a time indicated by the time value. In addition, the limiting a system resource used by the at least one background task corresponding to the first scenario may further be limiting use of the system resource by the at least one background task corresponding to the first scenario. For example, limiting use of a network bandwidth by the at least one background task corresponding to the first scenario or limiting use of memory space by the at least one background task corresponding to the first scenario. In addition, it may further be using different limitation measures depending on different scenarios corresponding to the at least one background task corresponding to the first scenario. Because use of the system resource by the at least one background task corresponding to the first scenario is limited in the foregoing step, power consumption of the device is reduced.

[0040] Optionally, step 201 may further include: when a temperature reaches a preset temperature threshold, determining, according to the foreground task, a first scenario corresponding to the foreground task.

[0041] The temperature may be a temperature of the device that implements this embodiment, where the temperature of the device may specifically refer to a temperature of the CPU of the device or a temperature of a modem of the device.

[0042] In this implementation manner, it may be implemented that limitation processing is performed on the background task only when the temperature of the device reaches the preset temperature threshold.

[0043] Optionally, the method may further include: releasing the limitation processing on the at least one background task corresponding to the first scenario. Specifically, when the first scenario is not in the first list, the limitation processing is released for the background task that has undergone the limitation processing.

[0044] Optionally, the method may be specifically applied to any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0045] In the foregoing technical solution, multiple optional implementation manners are implemented on the basis of the first embodiment, all of which can reduce power consumption and power loss of a device.

[0046] Referring to FIG. 4, FIG. 4 is a schematic flowchart of another task management method, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 4, the method includes the following steps: 401. Determine, according to a foreground task, a first scenario corresponding to the foreground task.

[0047] Optionally, step 401 may specifically be determining, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario or the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, step 401 may include: determining, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, step 401 may include: determining, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0048] 402. Determine a second scenario except the first scenario corresponding to the foreground task, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task.

[0049] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment. In addition, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented.

[0050] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited.

[0051] 403. Search for the at least one background task corresponding to the second scenario.

[0052] Optionally, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. In addition, step 403 may be specifically: searching for at least two background tasks that are in the background tasks corresponding to the second scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or searching for at least one pre-determined background task in the background tasks corresponding to the second scenario; or searching for at least one background task that is in the background tasks corresponding to the second scenario and whose UID corresponds to a common user. For example, step 403 may include: searching for a UID of each background task corresponding to the second scenario, and searching for a background task whose UID corresponds to a common user as the at least one background task corresponding to the second scenario.

[0053] That is, this step is used to implement that the at least one background task that is corresponding to the second scenario and is searched for in step 403 is the background task whose UID corresponds to a common user.

[0054] Optionally, the method may further include: ignoring a background task whose UID corresponds to a system user in the at least one background task corresponding to the second scenario. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0055] Optionally, step 403 may be: searching for at least one background task whose system resource usage reaches a preset threshold in the background tasks corresponding to the second scenario.

[0056] 404. Perform limitation processing on the at least one background task corresponding to the second scenario, where the limitation processing refers to processing for reducing system resource usage.

[0057] Optionally, as shown in FIG. 5, the method may further include: 405. Search for at least one background task corresponding to the first scenario. 406. If a UID of the at least one background task corresponding to the first scenario corresponds to a common user, perform the limitation processing on the at least one background task corresponding to the first scenario.

[0058] For this implementation manner of this embodiment, further refer to the implementation manner in which the limitation processing is performed on the at least one background task corresponding to the first scenario in the first and second embodiments, which is not repeatedly described here.

[0059] Optionally, before step 404, the method may further include: starting a timer for the at least one background task corresponding to the second scenario; and stopping, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the second scenario.

[0060] Optionally, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. Meanwhile, a status value of the system component when the system component is paused may be saved in the foregoing step, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the second scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the second scenario.

[0061] Optionally, before step 404, the method may further include: querying whether the at least one background task uses a system component; and if the at least one background task uses the system component, stopping the system component.

[0062] In this implementation manner, because the system component used by the at least one background task corresponding to the second scenario is stopped, power consumption and power loss of the device may be reduced.

[0063] Optionally, the processing for reducing system resource usage includes at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0064] In this case, step 404 may be: freezing the at least one background task corresponding to the second scenario; stopping the at least one background task corresponding to the second scenario; or limiting a system resource used by the at least one background task corresponding to the second scenario.

[0065] Optionally, the freezing the at least one background task corresponding to the second scenario may be prohibiting the background task from calling a system resource, for example, prohibiting a CPU from calling the at least one background task corresponding to the first scenario. Specifically, a task scheduler of an operating system is used to prohibit the at least one background task corresponding to the first scenario from participating in any scheduling. Because the at least one background task corresponding to the second scenario is prohibited from calling the system resource, power consumption of the device is reduced.

[0066] Optionally, the limiting a system resource used by the at least one background task corresponding to the second scenario may be limiting a time within which the CPU calls the at least one background task corresponding to the second scenario. For example, a time value for CPU calling is set for the at least one background task corresponding to the second scenario, so that the CPU can call the at least one background task corresponding to the second scenario within a time indicated by the time value. In addition, the limiting a system resource used by the at least one background task corresponding to the second scenario may further be limiting use of the system resource by the at least one background task corresponding to the second scenario. For example, limiting use of a network bandwidth by the at least one background task corresponding to the second scenario or limiting use of memory space by the at least one background task corresponding to the second scenario. In addition, it may further be using different limitation measures depending on different scenarios corresponding to the at least one background task corresponding to the second scenario. Because use of the system resource by the at least one background task corresponding to the second scenario is limited in the foregoing step, power consumption of the device is reduced.

[0067] Optionally, the method may be specifically applied to any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0068] In the foregoing technical solution, a first scenario corresponding to a foreground task is determined according to the foreground task; a second scenario except the first scenario corresponding to the foreground task is determined, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task; the at least one background task corresponding to the second scenario is searched for; and limitation processing is performed on the at least one background task corresponding to the second scenario, where the limitation processing refers to processing for reducing system resource usage. Therefore, power consumption and power loss of a device can be reduced.

[0069] Referring to FIG. 6, FIG. 6 is a schematic flowchart of a task management method, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 6, the method includes the following steps: 601. Determine whether a scenario that is currently switched to is a scenario included in a whitelist. If yes, perform step 602. If no, end the process. The whitelist is a preset list including at least one scenario in which background task limitation is allowed.

[0070] Optionally, the foregoing scenario may be specifically a status of an action of a device that implements step 601. The status of the action of the device may refer to a status in which the device uses a system resource. The system resource may be specifically a hardware resource, for example, a CPU resource or a memory resource, or the system resource may be specifically a virtual resource, for example, a network bandwidth resource or an operating system resource. A scenario may be making a call, sending a short message service message, using a browser, playing a 2D / 3D game, viewing a main user interface, downloading a file, reading an ebook, playing music, watching a video, navigating through a website, browsing a photo, taking a photo, making a video, sending an email, and the like. In addition, the scenario that is currently switched to may be one or more scenarios. In addition, scenario switching may be specifically switching generated by a switching time of a foreground task. For example, when a foreground task is started, one or more scenarios are switched to. For example, when a task of making a call is started, the device switches to a scenario of making a call; when a music task is started, the device switches to a music playing scenario and a music download scenario; when a game task is started, the device switches to a game scenario and an Internet access scenario. For example, when a foreground task is stopped, the device switches to one or more scenarios. For example, when a game task is stopped, the device switches from a game scenario to a main user interface scenario.

[0071] Optionally, the scenario in which background task limitation is allowed may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which background task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, a user likes to reduce power consumption of a device, and the user may set in the whitelist multiple scenarios in which background task limitation is allowed, for example, setting a browser scenario, a game scenario, a navigation scenario, or the like as the scenario in which background task limitation is allowed. In this way, when a current scenario of the device is the browser scenario, the game scenario, or the navigation scenario, step 602 can be performed to reduce power consumption of the device.

[0072] Optionally, the scenario in which background task limitation is allowed may be automatically set according to performance of the device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, only a few scenarios in which background task limitation is allowed may be set in the whitelist. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, more scenarios in which background task limitation is allowed may be set in the whitelist. Because the whitelist has more scenarios in which background task limitation is allowed, and step 602 and step 603 are performed multiple times, limitation processing can be performed on multiple background tasks that allow limitation processing, so as to reduce power consumption of the device and ensure stable running of the device.

[0073] 602. When it is determined that the scenario that is currently switched to is the scenario included in the whitelist, search for a background task that allows limitation processing in currently running background tasks, where the limitation processing refers to processing for reducing system resource usage.

[0074] Optionally, the background task that allows limitation processing may be specifically a background task that will not affect other tasks (such as a foreground task) or an operating system after undergoing the limitation processing; or the background task that allows limitation processing may be specifically a pre-determined background task; or the background task that allows limitation processing may be specifically a background task that meets a specific condition.

[0075] Optionally, the limitation processing may be specifically an operation used to reduce a system resource currently used by a task. For example, a quantity of system resources used by a background task A is A when step 101 is performed, and after the limitation processing is performed on the background task A, a quantity of system resources used by the background task A is B, where A is greater than B. In addition, B may be zero.

[0076] 603. Perform the limitation processing on the background task that allows limitation processing.

[0077] Optionally, the method may be specifically applied to any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0078] It should be noted that, the scenario in this embodiment may be equivalent to the scenario in the foregoing embodiments. In addition, the whitelist in this embodiment may be the first list in the foregoing embodiments.

[0079] In the foregoing technical solution, whether a scenario that is currently switched to is a scenario included in a whitelist is determined, where the whitelist is a preset list including at least one scenario in which background task limitation is allowed; when it is determined that the scenario that is currently switched to is the scenario included in the whitelist, a background task that allows limitation processing is searched for in currently running background tasks, where the limitation processing refers to processing for reducing system resource usage; and the limitation processing is performed on the background task that allows limitation processing. In this way, limitation processing is implemented on a background task that allows limitation processing. Compared with the prior art in which a background task is always being executed, this can reduce power consumption and power loss of a device.

[0080] Referring to FIG. 7, FIG. 7 is a schematic diagram of another task management method according to the present invention. As shown in FIG. 7, the method includes the following steps: 701. Detect that a device enters a game scenario, a browser scenario, or a navigation scenario, where the game scenario, the browser scenario, and the navigation scenario are only examples, and this embodiment includes but is not limited to these scenarios, for example, may also include an audio playing or video playing scenario. 702. Query and determine a background task that needs to be frozen. 703. Determine whether the background task that needs to be frozen uses a system component. If yes, perform step 704. If no, perform step 705. Step 703 may include: determining whether the background task that needs to be frozen uses a sleep lock, and / or determining whether the background task that needs to be frozen uses a timer, and / or determining whether the background task that needs to be frozen uses broadcast notification. 704. Pause the system component, where step 704 may include: if the background task that needs to be frozen uses a sleep lock, pausing the sleep lock; if the background task that needs to be frozen uses a timer, pausing the timer; if the background task that needs to be frozen uses broadcast notification, pausing the broadcast notification. 705. Freeze the background task that needs to be frozen.

[0081] The task management method may further include: 706. Detect that the device switches to a main user interface scenario. 707. Query the background task that has been frozen. 708. Resume the system component for the background task that has been frozen, where step 708 may include: resuming the sleep lock, resuming the timer, and resuming the broadcast notification. 709. Unfreeze the background task that has been frozen.

[0082] The following describes apparatus embodiments of the present invention. The apparatus embodiments of the present invention are used to execute the methods implemented in the first embodiment to the fifth embodiment of the present invention. For ease of description, the following describes only the part related to the embodiments of the present invention. For specific technology details that are not disclosed, refer to the first embodiment, the second embodiment, the third embodiment, the fourth embodiment, and the fifth embodiment of the present invention.

[0083] Referring to FIG. 8, FIG. 8 is a schematic diagram of a structure of a task management device, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 8, the task management device includes: a determining unit 81, a first search unit 82, and a first processing unit 83.

[0084] The determining unit 81 is configured to determine, according to a foreground task, a first scenario corresponding to the foreground task.

[0085] Optionally, the determining unit 81 may specifically determine, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario or the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, the determining unit 81 may be configured to determine, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, the determining unit 81 may determine, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0086] The first search unit 82 is configured to search for, when the first scenario that corresponds to the foreground task and is determined by the determining unit 81 is in a first list, at least one background task corresponding to the first scenario, where the first list includes a scenario in which task limitation is allowed.

[0087] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, a user likes to reduce power consumption of a device, and the user may set in the first list multiple scenarios in which task limitation is allowed, for example, setting a browser scenario, a game scenario, a navigation scenario, or the like as the scenario in which task limitation is allowed. In this way, when the first scenario corresponding to the current task is the browser scenario, the game scenario, or the navigation scenario, the first search unit 82 can perform a search action to reduce power consumption of the device.

[0088] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, only a few scenarios in which task limitation is allowed may be set in the first list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, more scenarios in which task limitation is allowed may be set in the first list. In this way, power consumption of the device can be reduced.

[0089] Optionally, the at least one background task corresponding to the first scenario may refer to at least one background task in all background tasks corresponding to the first scenario, or the at least one background task corresponding to the first scenario may refer to all background tasks corresponding to the first scenario. This embodiment sets no limit thereto.

[0090] The first processing unit 83 is configured to perform limitation processing on the at least one background task that corresponds to the first scenario and is searched for by the first search unit 82, where the limitation processing refers to processing for reducing system resource usage.

[0091] Optionally, the limitation processing may be processing for reducing a system resource currently used by a task.

[0092] Optionally, the device may be specifically any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0093] In the foregoing technical solutions, a first scenario corresponding to a foreground task is determined according to the foreground task, and when the first scenario corresponding to the foreground task is in a first list, at least one background task corresponding to the first scenario is searched for, where the first list includes a scenario in which task limitation is allowed; and limitation processing is performed on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage. In this way, limitation processing is implemented on at least one background task corresponding to a scenario in which task limitation is allowed. Compared with the prior art in which a background task is always being executed, the embodiments of the present invention can reduce power consumption and power loss of a device.

[0094] Referring to FIG. 9, FIG. 9 is a schematic diagram of a structure of a task management device, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 9, the task management device includes: a determining unit 91, a judging unit 92, a first search unit 93, and a first processing unit 94, where: The determining unit 91 is configured to determine, according to a foreground task, a first scenario corresponding to the foreground task.

[0095] The judging unit 92 is configured to determine whether the first scenario that is determined by the determining unit 91 is in a first list, where the first list includes a scenario in which task limitation is allowed.

[0096] The first search unit 93 is configured to search for, when the judging unit 92 determines that the first scenario that is determined by the determining unit 91 is in the first list, at least one background task corresponding to the first scenario.

[0097] Optionally, the first search unit 93 may specifically search for at least one background task that is in background tasks corresponding to the first scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in background tasks corresponding to the first scenario; or search for at least one background task that is in background tasks corresponding to the first scenario and whose user identifier corresponds to a common user. For example, a user identifier UID of each background task corresponding to the first scenario is searched for, and a background task whose UID corresponds to a common user is searched for and used as the at least one background task corresponding to the first scenario.

[0098] In this way, it can be implemented that the at least one background task that is corresponding to the first scenario and is searched for by the first search unit 93 is the background task whose UID corresponds to a common user. A UID is an inherent identifier of each task and may be used to uniquely identify the task. In addition, a UID may correspond to a system user and a common user. When a UID of a background task corresponds to a system user, it indicates that the background task is a background task included in an operating system. When a UID of a background task corresponds to a common user, it indicates that the background task is not a background task included in an operating system.

[0099] Optionally, the device may be further configured to ignore a background task that is in the at least one background task corresponding to the first scenario and whose UID corresponds to a system user. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0100] Optionally, the first search unit 93 may search for at least one background task that is in background tasks corresponding to the first scenario and whose system resource usage reaches a preset threshold. For example, at least one background task that is in the background tasks corresponding to the first scenario and whose CPU resource usage reaches 10% of CPU resources is searched for; or at least one background task that is in the background tasks corresponding to the first scenario and whose sleep lock holding duration reaches 10 minutes is searched for; or at least one background task that is in the background tasks corresponding to the first scenario and whose average data download speed reaches 10M per minute is searched for.

[0101] The first processing unit 94 is configured to perform limitation processing on the at least one background task that corresponds to the first scenario and is searched for by the first search unit 93, where the limitation processing refers to processing for reducing system resource usage.

[0102] Optionally, as shown in FIG. 10, the device may further include: a second search unit 95, configured to search for a second scenario except the first scenario that corresponds to the foreground task and is searched for by the determining unit 91, where the second scenario corresponds to at least one background task, and the first list includes the second scenario; and a second processing unit 96, configured to perform the limitation processing on the at least one background task that corresponds to the second scenario and is searched for by the second search unit 95.

[0103] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment.

[0104] In addition, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. This embodiment sets no limit thereto. In addition, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. In addition, the second search unit 95 may specifically search for at least one background task that is in the background tasks corresponding to the second scenario and will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in the background tasks corresponding to the second scenario; or search for at least one background task that is in the background tasks corresponding to the second scenario and whose user identifier corresponds to a common user.

[0105] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited. The scenario in which task limitation is prohibited may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is prohibited, and that is set according to the operation input by the user, and meets the user's requirements or habits can be implemented. For example, the user may set, in the second list, a scenario that requires user attention as the scenario in which task limitation is prohibited, for example, a short message service message scenario, a call scenario, and a download scenario. Alternatively, the scenario in which task limitation is prohibited may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, more scenarios in which task limitation is prohibited may be set in the second list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, only a few scenarios in which task limitation is prohibited may be set in the second list.

[0106] Optionally, as shown in FIG. 11, the device may further include: a first query unit 97, configured to query a user identifier of the at least one background task; and an ignoring unit 98, configured to: if the user identifier that is of the at least one background task and queried by the first query unit corresponds to a system user, ignore the at least one background task, where the first processing unit 94 may be configured to: if the user identifier that is of the at least one background task and queried by the first query unit 97 corresponds to a common user, perform the limitation processing on the at least one background task.

[0107] In this implementation manner, because the background task whose UID corresponds to a common user is not a task of an operating system, other tasks are not affected after limitation processing is performed on these background tasks. Therefore, the first processing unit 94 limits only a background task whose UID corresponds to a common user, which can reduce power consumption and power loss of the device without affecting other tasks.

[0108] Optionally, as shown in FIG. 12, the device may further include: a timing unit 99, configured to start a timer for the at least one background task corresponding to the first scenario; and a first stopping unit 100, configured to stop, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the first scenario.

[0109] Optionally, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. In addition, a status value of the system component when the system component is paused may be saved in the device, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the first scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the first scenario.

[0110] Optionally, as shown in FIG. 13, the device may further include: a second query unit 101, configured to query whether the at least one background task uses a system component; and a second stopping unit 102, configured to: if the second query unit 101 finds that the at least one background task uses the system component, stop the system component.

[0111] In this implementation manner, because the system component used by the at least one background task corresponding to the first scenario is stopped, power consumption and power loss of the device may be reduced.

[0112] Optionally, the processing for reducing system resource usage includes at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0113] In this way, the first processing unit 94 may freeze the at least one background task corresponding to the first scenario, or stop the at least one background task corresponding to the first scenario, or limit a system resource used by the at least one background task corresponding to the first scenario.

[0114] According to the present invention, the freezing the at least one background task corresponding to the first scenario may be prohibiting the background task from calling a system resource, for example, prohibiting a CPU from calling the at least one background task corresponding to the first scenario. Specifically, a task scheduler of an operating system is used to prohibit the at least one background task corresponding to the first scenario from participating in any scheduling. Because the at least one background task corresponding to the first scenario is prohibited from calling the system resource, power consumption of the device is reduced.

[0115] Optionally, the limiting a system resource used by the at least one background task corresponding to the first scenario may be limiting a time within which the CPU calls the at least one background task corresponding to the first scenario. For example, a time value for CPU calling is set for the at least one background task corresponding to the first scenario, so that the CPU can call the at least one background task corresponding to the first scenario within a time indicated by the time value. In addition, the limiting a system resource used by the at least one background task corresponding to the first scenario may further be limiting use of the system resource by the at least one background task corresponding to the first scenario from using the system resource. For example, limiting the at least one background task corresponding to the first scenario or limiting use of memory space by the at least one background task corresponding to the first scenario. In addition, it may further be using different limitation measures depending on different scenarios corresponding to the at least one background task corresponding to the first scenario. Because use of the system resource by the at least one background task corresponding to the first scenario is limited in the foregoing step, power consumption of the device is reduced.

[0116] Optionally, when a temperature reaches a preset temperature threshold, the determining unit 91 may be further configured to determine, according to the foreground task, a first scenario corresponding to the foreground task.

[0117] The temperature may be a temperature of the device, where the temperature of the device may specifically refer to a temperature of the CPU of the device or a temperature of a modem of the device.

[0118] In this implementation manner, it may be implemented that limitation processing is performed on the background task only when the temperature of the device reaches the preset temperature threshold.

[0119] Optionally, the device may be further configured to release the limitation processing on the at least one background task corresponding to the first scenario. Specifically, when the first scenario is not in the first list, the limitation processing is released for the background task that has undergone the limitation processing.

[0120] Optionally, the device may be specifically any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0121] In the foregoing technical solution, multiple optional implementation manners are implemented on the basis of the first embodiment, all of which can reduce power consumption and power loss of a device.

[0122] Referring to FIG. 14, FIG. 14 is a schematic diagram of a structure of another task management device, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 14, the task management device includes: a first determining unit 141, a second determining unit 142, a first search unit 143, and a first processing unit 144.

[0123] The first determining unit 141 is configured to determine, according to a foreground task, a first scenario corresponding to the foreground task.

[0124] Optionally, the first determining unit 141 may specifically determine, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario or the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, the first determining unit 141 may be configured to determine, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, the first determining unit 141 may be configured to determine, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0125] The second determining unit 142 is configured to determine a second scenario except the first scenario that corresponds to the foreground task and is determined by the first determining unit 141, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task.

[0126] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment. In addition, according to the present invention, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented.

[0127] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited.

[0128] The first search unit 143 is configured to search for the at least one background task corresponding to the second scenario that is determined by the second determining unit 142.

[0129] Optionally, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. In addition, the first search unit 143 may specifically search for at least two background tasks that are in the background tasks corresponding to the second scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in the background tasks corresponding to the second scenario; or search for at least one background task that is in the background tasks corresponding to the second scenario and whose UID corresponds to a common user. For example, the first search unit 143 may be configured to search for a UID of each background task corresponding to the second scenario, and search for a background task whose UID corresponds to a common user as the at least one background task corresponding to the second scenario.

[0130] The foregoing operations can implement that the at least one background task that is corresponding to the second scenario and is searched for by the first search unit 143 is the background task whose UID corresponds to a common user.

[0131] Optionally, the device may be further configured to ignore a background task whose UID corresponds to a system user in the at least one background task corresponding to the second scenario. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0132] Optionally, the first search unit 143 may be configured to search for at least one background task whose system resource usage reaches a preset threshold in the background tasks corresponding to the second scenario.

[0133] The first processing unit 144 is configured to perform limitation processing on the at least one background task that corresponds to the second scenario and is searched for by the first search unit 143, where the limitation processing refers to processing for reducing system resource usage.

[0134] Optionally, as shown in FIG. 15, the device may further include: a second search unit 145, configured to search for at least one background task corresponding to the first scenario; and a second processing unit 146, configured to: if a user identifier of the at least one background task corresponding to the first scenario corresponds to a common user, perform the limitation processing on the at least one background task corresponding to the first scenario.

[0135] Optionally, as shown in FIG. 16, the device may further include: a timing unit 147, configured to start a timer for the at least one background task corresponding to the second scenario; and a first stopping unit 148, configured to stop, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the second scenario.

[0136] According to the present invention, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. Meanwhile, a status value of the system component when the system component is paused may be saved in the foregoing step, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the second scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the second scenario.

[0137] Optionally, as shown in FIG. 17, the device may further include: a query unit 149, configured to query whether the at least one background task uses a system component; and a second stopping unit 150, configured to: if the query unit finds that the at least one background task uses the system component, stop the system component.

[0138] In this implementation manner, because the system component used by the at least one background task corresponding to the second scenario is stopped, power consumption and power loss of the device may be reduced.

[0139] Optionally, the processing for reducing system resource usage may include at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0140] In this case, the first processing unit 144 may freeze the at least one background task corresponding to the second scenario, or stop the at least one background task corresponding to the second scenario, or limit a system resource used by the at least one background task corresponding to the second scenario.

[0141] Optionally, the freezing the at least one background task corresponding to the second scenario may be prohibiting the background task from calling a system resource, for example, prohibiting a CPU from calling the at least one background task corresponding to the first scenario. Specifically, a task scheduler of an operating system is used to prohibit the at least one background task corresponding to the first scenario from participating in any scheduling. Because the at least one background task corresponding to the second scenario is prohibited from calling the system resource, power consumption of the device is reduced.

[0142] Optionally, the limiting a system resource used by the at least one background task corresponding to the second scenario may be limiting a time within which the CPU calls the at least one background task corresponding to the second scenario. For example, a time value for CPU calling is set for the at least one background task corresponding to the second scenario, so that the CPU can call the at least one background task corresponding to the second scenario within a time indicated by the time value. In addition, the limiting a system resource used by the at least one background task corresponding to the second scenario may further be limiting use of the system resource by the at least one background task corresponding to the second scenario. For example, limiting use of a network bandwidth by the at least one background task corresponding to the second scenario or limiting use of memory space by the at least one background task corresponding to the second scenario. In addition, it may further be using different limitation measures depending on different scenarios corresponding to the at least one background task corresponding to the second scenario. Because use of the system resource by the at least one background task corresponding to the second scenario is limited in the foregoing step, power consumption of the device is reduced.

[0143] Optionally, the device may be specifically any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0144] In the foregoing technical solution, a first scenario corresponding to a foreground task is determined according to the foreground task; a second scenario except the first scenario corresponding to the foreground task is determined, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task; the at least one background task corresponding to the second scenario is searched for; and limitation processing is performed on the at least one background task corresponding to the second scenario, where the limitation processing refers to processing for reducing system resource usage. Therefore, power consumption and power loss of a device can be reduced.

[0145] Referring to FIG. 18, FIG. 18 is a schematic diagram of a structure of another task management device, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 18, the task management device includes: a memory 181 and a processor 182 connected to the memory 181, where the memory 181 is configured to store program code, and the processor 182 is configured to invoke a program stored in the memory 181 to perform the following operations: determining, according to a foreground task, a first scenario corresponding to the foreground task; searching for, when the first scenario corresponding to the foreground task is in a first list, at least one background task corresponding to the first scenario, where the first list includes a scenario in which task limitation is allowed; and performing limitation processing on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage.

[0146] Optionally, the processor 182 may specifically determine, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario or the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, the processor 182 may be configured to determine, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, the processor 182 may determine, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0147] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, a user likes to reduce power consumption of a device, and the user may set in the first list multiple scenarios in which task limitation is allowed, for example, setting a browser scenario, a game scenario, a navigation scenario, or the like as the scenario in which task limitation is allowed. In this way, when the first scenario corresponding to the current task is the browser scenario, the game scenario, or the navigation scenario, the processor 182 may perform a search operation to reduce power consumption of the device.

[0148] Optionally, the scenario in which task limitation is allowed and that is included in the first list may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, only a few scenarios in which task limitation is allowed may be set in the first list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, more scenarios in which task limitation is allowed may be set in the first list because the first list has a large number of scenarios in which task limitation is allowed.

[0149] Optionally, the at least one background task corresponding to the first scenario may refer to at least one background task in all background tasks corresponding to the first scenario, or the at least one background task corresponding to the first scenario may refer to all background tasks corresponding to the first scenario. This embodiment sets no limit thereto.

[0150] Optionally, the limitation processing may be processing used to reduce current system resource usage.

[0151] In another embodiment, the processor 182 may be further configured to perform the following operations: determining, according to a foreground task, a first scenario corresponding to the foreground task; determining whether the first scenario is in the first list, if yes, searching for at least one background task corresponding to the first scenario; performing limitation processing on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage; and when a result of the determining is no, ending the process.

[0152] Optionally, the processor 182 may specifically search for at least one background task that is in background tasks corresponding to the first scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in the background tasks corresponding to the first scenario; or search for at least one background task that is in background tasks corresponding to the first scenario and whose user identifier corresponds to a common user. For example, the operation, performed by the processor 182, of searching for at least one background task corresponding to the first scenario may include: searching for a user identifier of each background task corresponding to the first scenario, and searching for a background task whose UID corresponds to a common user as the at least one background task corresponding to the first scenario.

[0153] That is, this operation is used to implement that the at least one background task that is corresponding to the first scenario and is searched for by the processor 182 is the background task whose UID corresponds to a common user. A UID is an inherent identifier of each task and is used to uniquely identify the task. In addition, a UID may correspond to a system user and a common user. When a UID of a background task corresponds to a system user, it indicates that the background task is a background task included in an operating system. When a UID of a background task corresponds to a common user, it indicates that the background task is not a background task included in an operating system.

[0154] Optionally, the processor 182 may be further configured to: ignore a background task whose UID corresponds to a system user in the at least one background task corresponding to the first scenario. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0155] Optionally, the processor 182 may search for at least one background task that is in background tasks corresponding to the first scenario and whose system resource usage reaches a preset threshold. For example, at least one background task that is in the background tasks corresponding to the first scenario and whose CPU resource usage reaches 10% of CPU resources is searched for; or at least one background task that is in the background tasks corresponding to the first scenario and whose sleep lock holding duration reaches 10 minutes is searched for; or at least one background task that is in the background tasks corresponding to the first scenario and whose average data download speed reaches 10M per minute is searched for.

[0156] Optionally, the processor 182 may be further configured to perform the following operations: searching for a second scenario except the first scenario corresponding to the foreground task, where the second scenario corresponds to at least one background task, and the first list includes the second scenario; and performing the limitation processing on the at least one background task corresponding to the second scenario.

[0157] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment.

[0158] In addition, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. This embodiment sets no limit thereto. In addition, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. In addition, the processor 182 may specifically search for at least one background task that is in the background tasks corresponding to the second scenario and will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in the background tasks corresponding to the second scenario; or search for at least one background task that is in the background tasks corresponding to the second scenario and whose user identifier corresponds to a common user.

[0159] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited. In addition, the second list may be referred to as a blacklist. The scenario in which task limitation is prohibited may be a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is prohibited, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented. For example, the user may set, in the second list, a scenario that requires user attention as the scenario in which task limitation is prohibited, for example, a short message service message scenario, a call scenario, and a download scenario. Alternatively, the scenario in which task limitation is prohibited may be automatically set according to performance of a device. For example, when the device has better performance, for example, a CPU of the device is running at a high speed, the device has a larger memory, or the device has enough battery, more scenarios in which task limitation is prohibited may be set in the second list. For example, when the device has poor performance, for example, the CPU of the device is running at a low speed, the device has a smaller memory, or the device does not have enough battery, only a few scenarios in which task limitation is prohibited may be set in the second list.

[0160] Optionally, before the processor 182 performs the operation of performing limitation processing on the at least one background task corresponding to the first scenario, the processor 182 may be further configured to perform the following operations: querying a UID of the at least one background task corresponding to the first scenario; and if the UID of the at least one background task corresponding to the first scenario corresponds to a system user, ignoring the at least one background task; or if the UID of the at least one background task corresponds to a common user, performing the limitation processing on the at least one background task. That is, step 204 is performing the limitation processing on the at least one background task whose UID corresponds to a common user.

[0161] In this implementation manner, because the background task whose UID corresponds to a common user is not a task of an operating system, other tasks are not affected after limitation processing is performed on these background tasks. Therefore, limitation processing is performed only on a background task whose UID corresponds to a common user in step 204, which can reduce power consumption and power loss of the device without affecting other tasks.

[0162] Optionally, before the processor 182 performs the operation of performing limitation processing on the at least one background task corresponding to the first scenario, the processor 182 may be further configured to perform the following operations: starting a timer for the at least one background task corresponding to the first scenario; and stopping, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the first scenario.

[0163] Optionally, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. Meanwhile, a status value of the system component when the system component is paused may be saved in the foregoing step, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the first scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the first scenario.

[0164] Optionally, before the processor 182 performs the operation of performing limitation processing on the at least one background task corresponding to the first scenario, the processor 182 may be further configured to perform the following operations: querying whether the at least one background task corresponding to the first scenario uses a system component; and if the at least one background task corresponding to the first scenario uses the system component, stopping the system component.

[0165] In this implementation manner, because the system component used by the at least one background task corresponding to the first scenario is stopped, power consumption and power loss of the device may be reduced.

[0166] Optionally, the processing for reducing system resource usage may include at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0167] In this case, the processor 182 may freeze the at least one background task corresponding to the first scenario, or stop the at least one background task corresponding to the first scenario, or limit a system resource used by the at least one background task corresponding to the first scenario.

[0168] Optionally, the operation, performed by the processor 182, of determining, according to a foreground task, a first scenario corresponding to the foreground task may include: when a temperature reaches a preset temperature threshold, determining, according to the foreground task, a first scenario corresponding to the foreground task.

[0169] The temperature may be a temperature of the device, where the temperature of the device may specifically refer to a temperature of the CPU of the device or a temperature of a modem of the device.

[0170] In this implementation manner, it may be implemented that limitation processing is performed on the background task only when the temperature of the device reaches the preset temperature threshold.

[0171] Optionally, the processor 182 may be further configured to perform the following operations: releasing the limitation processing on the at least one background task corresponding to the first scenario. Specifically, when the first scenario is not in the first list, the limitation processing is released for the background task that has undergone the limitation processing.

[0172] Optionally, the method may be specifically applied to any devices having a multi-task system, such as a tablet computer, a mobile phone, an e-reader, a remote control, a PC, a notebook computer, an in-vehicle device, a web TV, a wearable device, or other intelligent devices having a network function.

[0173] In the foregoing technical solutions, a first scenario corresponding to a foreground task is determined according to the foreground task, and when the first scenario corresponding to the foreground task is in a first list, at least one background task corresponding to the first scenario is searched for, where the first list includes a scenario in which task limitation is allowed; and limitation processing is performed on the at least one background task corresponding to the first scenario, where the limitation processing refers to processing for reducing system resource usage. In this way, limitation processing is implemented on at least one background task corresponding to a scenario in which task limitation is allowed. Compared with the prior art in which a background task is always being executed, this embodiment can reduce power consumption and power loss of a device.

[0174] Referring to FIG. 19, FIG. 19 is a schematic diagram of a structure of another task management device, which is not covered by the claims but an example useful for understanding the invention. As shown in FIG. 19, the task management device includes: a memory 191 and a processor 192 connected to the memory 191, where the memory 191 is configured to store program code, and the processor 192 is configured to invoke a program stored in the memory 191 to perform the following operations: determining, according to a foreground task, a first scenario corresponding to the foreground task; determining a second scenario except the first scenario corresponding to the foreground task, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task; searching for the at least one background task corresponding to the second scenario; and performing limitation processing on the at least one background task corresponding to the second scenario, where the limitation processing refers to processing for reducing system resource usage.

[0175] Optionally, the processor 192 may specifically determine, when a current task is switched, a corresponding first scenario according to the current task. For example, when the current task, a music task, is being executed, the task enters a music scenario or a download scenario. In this way, it can be determined that the first scenario corresponding to the foreground task may be the music scenario, the download scenario, or the like. In addition, the foreground task may be one or multiple foreground tasks. In the case of multiple foreground tasks, the processor 192 may be configured to determine, according to multiple foreground tasks, a first scenario corresponding to each foreground task. That is, the processor 192 may determine, according to at least one foreground task, a first scenario corresponding to each foreground task.

[0176] Optionally, the second scenario may refer to one or more scenarios. In addition, the second scenario may refer to all scenarios except the first scenario, or one or more scenarios except the first scenario, which is not limited in this embodiment. In addition, the second scenario may be specifically a pre-determined scenario, for example, a scenario that is set for receiving an operation input by a user. In this way, the scenario in which task limitation is allowed, and that is set according to the operation input by the user and meets the user's requirements or habits can be implemented.

[0177] Optionally, the second scenario may be a scenario except the first scenario and not in a second list, where the second list may include a scenario in which task limitation is prohibited.

[0178] Optionally, the at least one background task corresponding to the second scenario may refer to at least one background task in all background tasks corresponding to the second scenario, or the at least one background task corresponding to the second scenario may refer to all background tasks corresponding to the second scenario. In addition, the processor 192 may specifically search for at least two background tasks that are in the background tasks corresponding to the second scenario and that will not affect other tasks or an operating system after undergoing limitation processing; or search for at least one pre-determined background task in the background tasks corresponding to the second scenario; or search for at least one background task that is in the background tasks corresponding to the second scenario and whose UID corresponds to a common user. For example, the operation, performed by the processor 192, of searching for at least one background task corresponding to the second scenario may include: searching for a UID of each background task corresponding to the second scenario, and searching for a background task whose UID corresponds to a common user as the at least one background task corresponding to the second scenario.

[0179] That is, this step is used to implement that the at least one background task that is corresponding to the second scenario and is searched for by the processor 192 is the background task whose UID corresponds to a common user.

[0180] Optionally, the processor 192 may be further configured to perform the following operations: ignoring a background task whose UID corresponds to a system user in the at least one background task corresponding to the second scenario. That is, processing is not performed on the background task whose UID corresponds to a system user.

[0181] Optionally, the processor 192 may search for at least one background task whose system resource usage reaches a preset threshold in the background tasks corresponding to the second scenario.

[0182] Optionally, the processor 192 may be further configured to perform the following operations: searching for at least one background task corresponding to the first scenario; and if a UID of the at least one background task corresponding to the first scenario corresponds to a common user, performing the limitation processing on the at least one background task corresponding to the first scenario.

[0183] For this implementation manner of this embodiment, further refer to the implementation manner in which the limitation processing is performed on the at least one background task corresponding to the first scenario in the first and second embodiments, which is not repeatedly described here.

[0184] Optionally, before the processor 192 performs the operation of performing limitation processing on the at least one background task corresponding to the second scenario, the processor 192 may be further configured to perform the following operations: starting a timer for the at least one background task corresponding to the second scenario; and stopping, when the timer exceeds a preset threshold, a system component used by the at least one background task corresponding to the second scenario.

[0185] Optionally, the system component includes but is not limited to a timer, a sleep lock, and broadcast notification. Meanwhile, a status value of the system component when the system component is paused may be saved in the foregoing step, so that the background task can call the saved status value of the system component after the limitation processing is released. In addition, the system component used by the at least one background task corresponding to the second scenario is stopped only when the timer reaches the preset threshold (for example, 10s, 30s, or the like). This may avoid frequently stopping the system component used by the at least one background task corresponding to the second scenario.

[0186] Optionally, before the processor 192 performs the operation of performing limitation processing on the at least one background task corresponding to the second scenario, the processor 192 may be further configured to perform the following operations: querying whether the at least one background task uses a system component; and if the at least one background task uses the system component, stopping the system component.

[0187] In this implementation manner, because the system component used by the at least one background task corresponding to the second scenario is stopped, power consumption and power loss of the device may be reduced.

[0188] Optionally, the processing for reducing system resource usage may include at least one of the following manners: freezing the at least one background task; stopping the at least one background task; and limiting a system resource used by the at least one background task.

[0189] In this case, the processor 192 may freeze the at least one background task corresponding to the second scenario; stop the at least one background task corresponding to the second scenario; or limit a system resource used by the at least one background task corresponding to the second scenario.

[0190] In the foregoing technical solution, a first scenario corresponding to a foreground task is determined according to the foreground task; a second scenario except the first scenario corresponding to the foreground task is determined, where the second scenario is a scenario in which task limitation is allowed and the second scenario corresponds to at least one background task; the at least one background task corresponding to the second scenario is searched for; and limitation processing is performed on the at least one background task corresponding to the second scenario, where the limitation processing refers to processing for reducing system resource usage. Therefore, power consumption and power loss of a device can be reduced.

[0191] A person of ordinary skill in the art may understand that all or some of the processes of the methods in the embodiments may be implemented by a computer program instructing relevant hardware. The program may be stored in a computer-readable storage medium. When the program runs, the processes of the methods in the embodiments are performed. The foregoing storage medium may include: a magnetic disc, an optical disc, a read-only memory (Read-Only Memory, ROM for short), or a random access memory (Random Access Memory, RAM for short).

Claims

1. A task management method, comprising: detecting (701), by the electronic device, that the electronic device enters a game scenario, a browser scenario, a navigation scenario or another audio playing or video playing scenario for which task limitation is allowed, wherein the game scenario, the browser scenario or the navigation scenario is a scenario that is set for receiving an operation input by a user that meets the user's requirements or habits; querying and determining (702), by an electronic device, a background task that needs to be frozen, wherein the background task is a task corresponding to the game scenario, the browser scenario, the navigation scenario or another audio playing or video playing scenario; determining (703), by the electronic device, whether the background task that needs to be frozen uses a system component, wherein freezing the background task means prohibiting the background task from calling a system resource or reducing usage of the system resource; when determining the background task that needs to be frozen uses the system component, pausing (704), by the electronic device, the system component, wherein the system component used by the background task, comprises at least one of: a sleep lock, a timer or a broadcast notification; freezing (705), by the electronic device, the background task.

2. The method according to claim 1, the method further comprising: detecting, by the electronic device, the electronic device switches to a main user interface scenario; querying, by the electronic device, the background task that has been frozen; wherein when the system component has been paused, by the electronic device, after the determining of the background task that needs to be frozen uses the system component, resuming, by the electronic device, the system component for the background task that has been frozen, wherein the resuming, by the electronic device, the system component, comprising at least one of: resuming, by the electronic device, a sleep lock, resuming a timer, or resuming a broadcast notification; and unfreezing, by the electronic device, the background task that has been frozen.

3. An electronic device, comprises: at least one processor; and at least one memory, the at least one memory comprising instructions that when executed by the at least one processor, cause the electronic device to perform, at least, the following: querying and determining (702) a background task that needs to be frozen; determining (703) whether the background task that needs to be frozen uses a system component; pausing (704) the system component and freezing the background task when determining the background task that needs to be frozen uses the system component, wherein the system component used by the background task, comprises at least one of: a sleep lock, a timer or a broadcast notification, wherein freezing the background task means prohibiting the background task from calling a system resource or reducing usage of the system resource; freezing (705) the background task; and wherein before the querying and determining step, the at least one memory comprising instructions that when executed by the at least one processor, further cause the electronic device to perform, at least, the following: detecting (701) that the electronic device enters a game scenario, a browser scenario, or a navigation scenario or another audio playing or video playing scenario for which task limitation is allowed, wherein the game scenario, the browser scenario or the navigation scenario is a scenario that is set for receiving an operation input by a user that meets the user's requirements or habits, wherein the background task is a task corresponding to the game scenario, the browser scenario, the navigation scenario or another audio playing or video playing scenario.

4. The electronic device according to claim 3, wherein the at least one memory comprising instructions that when executed by the at least one processor, further cause the electronic device to perform, at least, the following: detecting that the device switches to a main user interface scenario; querying the background task that has been frozen; wherein when the system component has been paused, by the electronic device, after the determining of the background task that needs to be frozen uses the system component, resuming the system component for the background task that has been frozen, wherein the resuming the system component, comprising at least one of: resuming a sleep lock, resuming a timer, or resuming a broadcast notification; and unfreezing the background task that has been frozen.

5. A computer readable storage medium comprising instructions to cause an electronic device to carry out any one of claims of 1 to 2.