CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a National Stage of International Application No. PCT/CN2018/079244, filed on 16 Mar. 2018, which is hereby incorporated by reference in its entirety.

TECHNICAL FIELD

This disclosure relates to the field of communications, and in particular, to a wake-up management method, a timer management method, and a terminal device.

BACKGROUND

As mobile phone functions become more diversified, increasing applications are installed on mobile phones, and users spend an increasing amount of time on the mobile phones. When a user performs various operations in a normal working state of a mobile phone, battery power of the mobile phone is consumed. After the mobile phone enters a sleep state, if an interruption signal is generated because, for example, the mobile phone receives a call or an SMS message, an application periodically starts to check a network connection, or the user presses a power button, the mobile phone enters a normal working state from the sleep state. This further consumes the battery power of the mobile phone, and shortens standby duration of the mobile phone.

SUMMARY

Embodiments of this disclosure provide a wake-up management method and a terminal device, to reduce a quantity of times that a terminal device performs wake-up in a time period, and to reduce power consumption of the terminal device in the time period.

According to a first aspect, an embodiment of this disclosure provides a wake-up management method, including: setting at least two timers in a terminal device, where the at least two timers support wake-up, and each of the at least two timers corresponds to an operation related to an application; determining, by the terminal device, whether each of the at least two timers has a triggering time range, and grouping timers having the triggering time ranges, to obtain M timer groups, where M is an integer greater than 0, and a common intersection set of triggering time ranges of all timers in each of the M timer groups is not empty; determining, by the terminal device, a triggering moment of each of the M timer groups, to obtain M triggering moments; determining N timers that have no triggering time range, and determining a triggering moment of each of the N timers, to obtain N triggering moments, where N is an integer greater than 0; setting, by the terminal device, an earliest moment in the M triggering moments and the N triggering moments as an RTC moment; and when the RTC moment is reached, performing, by the terminal device, wake-up if the terminal device is in the sleep state.

In the technical solution provided in this embodiment of this disclosure, after running an application to register and set a timer, the terminal device identifies whether the timer supports wake-up, groups timers that support wake-up and have triggering time ranges, to obtain each timer group that supports wake-up and has a triggering time range, determines a triggering moment of each timer group that supports wake-up and has the triggering time range, determines a triggering moment of each timer that supports wake-up and does not have a triggering time range, and sets an earliest moment in the triggering moments as an RTC moment, so that when the RTC moment is reached, the terminal device can perform wake-up. In the prior art, whether the timer supports wake-up is not identified. During grouping, the timers having the triggering time ranges are grouped to obtain timer groups having the triggering time. When the triggering moment of each timer group having the triggering time range is determined, because a triggering time range of a timer that does not support wake-up in the timer group is relatively early, the triggering moment of the timer group may be relatively early, and when the earliest moment in the triggering moments is set as the RTC moment, the RTC moment may be consequently relatively early. Compared with the prior art, according to the wake-up management method provided in this embodiment of this disclosure, when the RTC moment is set, a timer that does not support wake-up may not be considered. To some extent, a triggering moment of a timer group having a triggering time may be delayed. In this case, the RTC moment is delayed, and the terminal can delay performing wake-up, to reduce a quantity of times that the terminal device performs wake-up in a time period.

In a possible implementation, the timer may be an alarm timer or another timer.

In a possible implementation, M may be zero. To be specific, none of the timers that the terminal device runs the application to register and set and that support wake-up has a triggering time range. In this case, the terminal device determines N timers that do not have the triggering time interval, determines a triggering moment of each of the N timers, and after obtaining N triggering moments, sets an earliest moment in the N triggering moments as the RTC moment.

In a possible implementation, N may be zero. To be specific, all the timers that the terminal device runs the application to register and set and that support wake-up have triggering time ranges. In this case, the terminal device groups the timers that support wake-up and that have the triggering time ranges, to obtain M timer groups, determines a triggering moment of each of the M timer groups, to obtain M triggering moments, and sets an earliest moment in the M triggering moments as the RTC moment.

In a possible implementation, the terminal device may group the N timers that do not have the triggering time range, where one timer is determined in one timer group, to obtain some timer groups, and determines a triggering moment of each timer in the timer groups, to obtain N triggering moments.

Optionally, when the terminal device determines the triggering moment of each of the M timer groups, for example, when the terminal device determines a triggering moment of a first timer group in the M timer groups, the terminal device may determine a latest moment in a first intersection set as the triggering moment of the first timer group, where the first intersection set is a common intersection set of triggering time ranges of all timers in the first timer group. The terminal device may sequentially determine a triggering moment of each of the remaining M−1 timer groups by using a similar method.

The first timer group may be any one of the M timers, and may include a first timer and a second timer that have different triggering time ranges. The terminal device runs a first application to register and set the first timer, and runs a second application to register and set the second timer. The first timer is used to instruct the terminal device at a specified moment to perform wake-up and perform a first operation corresponding to the first application, and the first timer corresponds to the first operation of the first application. The second timer is used to instruct the terminal device at a specified moment to perform wake-up and perform a second operation corresponding to the second application, and the second timer corresponds to the second operation of the second application.

In the technical solution provided in this embodiment of this disclosure, when determining the triggering moment of each of the M timer groups, the terminal device uses a latest moment in a common intersection set of triggering time ranges of all timers in each timer group as the triggering moment of the timer group, and the triggering moment of the timer group is delayed. In this way, the RTC moment is delayed, and the terminal delays performing wake-up, to reduce a quantity of times that the terminal device performs wake-up in a time period.

In a possible implementation, each of the M timer groups may include only one timer. In other words, timers that support wake-up and have triggering time ranges are not grouped. In this case, the terminal device uses a latest moment in a triggering time ranges of a timer that supports wake-up as a fixed triggering moment of the timers. In addition, a fixed triggering moment of a timer that supports wake-up and that does not have a triggering time range is determined, and the terminal device may set an earliest moment in fixed triggering moments of all timers that support wake-up as the RTC moment.

Optionally, if the triggering moment of the first timer group is set as the RTC moment, when the RTC moment is reached, the terminal device triggers all timers in the first timer group, and the terminal device performs operations related to applications corresponding to all the timers in the first timer group, including performing the first operation corresponding to the first application and performing the second operation corresponding to the second application.

Optionally, after the terminal device triggers all the timers in the first timer group, the terminal device may delete all the timers in the first timer group.

In the technical solution provided in this embodiment of this disclosure, after triggering the timer, the terminal device may perform the operation related to the application corresponding to the timer, and may delete the timer, thereby improving implementability of the solution.

Optionally, if the triggering moment of the first timer group is set as the RTC moment, when the RTC moment is reached, for timers in the remaining M−1 timer groups in the M timer groups except the first timer group, because the fixed triggering moments of the timers in the M−1 timer groups have not been reached, the terminal device may not process the timers in the M−1 timer groups. For the N timers, because fixed triggering moments of timers in the N timer groups have not been reached, the terminal device may also not process the N timers. The terminal device may delete the triggering moment of the first timer group, and the terminal device may set, as a new RTC moment, an earliest moment in the N triggering moments and the remaining M−1 triggering moments obtained after the triggering moment of the first timer group is removed from the M triggering moments.

When the new RTC moment is reached, the terminal device may trigger all timers in a timer group of which a triggering moment is set as the new RTC moment, perform operations related to applications corresponding to all timers in the timer group, delete the triggering moment of the timer, and set a next RTC moment by using the similar method.

Optionally, if the triggering moment of the first timer group is set as the RTC moment, when the RTC moment is reached, if the terminal device registers and sets a new timer that supports wake-up and has an available triggering time range, or the terminal device modifies triggering time ranges of one or more timers in the M−1 timer groups based on a situation, the terminal device may regroup the timers in the M−1 timer groups based on the first rule. This is not specifically limited herein.

In the technical solution provided in this embodiment of this disclosure, when the RTC moment is reached, the terminal device may be set as a triggering moment of a timer at the RTC moment, and set the earliest moment in remaining triggering moments as the new RTC moment, thereby improving implementability of the solution.

Optionally, when the terminal device groups, according to the preset first rule, the timers that support wake-up and have the triggering time ranges, the terminal device may sort the timers that have the triggering time range in ascending order of earliest available triggering moments. If the terminal device determines that an earliest available triggering moment of a third timer is the earliest, a timer of which a triggering time range intersects with the triggering time range of the third timer and the third timer may be determined to be in a second timer group. For the timers that are in the timers having the triggering time ranges and that are not determined to be in the second timer group, similarly, the terminal device may sort these timers in ascending order of earliest available triggering moments. If the terminal device determines that an earliest available triggering moment of a fourth timer is the earliest, a timer of which a triggering time range intersects with the triggering time range of the fourth timer and the fourth timer may be determined in a third timer group. The determining is performed in sequence until all the timers having the triggering time ranges are allocated to corresponding timer groups, to obtain the M timer groups in sequence. It should be noted that the second timer group and the third timer group herein are merely examples, the second timer group and the third timer group are not a same group, the second timer group and the foregoing first timer group may be a same group, and the third timer group and the foregoing first timer group may also be a same group.

In the technical solution provided in this embodiment of this disclosure, when the timers that support wake-up and have the triggering time ranges are grouped, starting from a timer that has the earliest available triggering moment, timers of which the available triggering moments have a common intersection set are determined in a timer group, and similarly, the timers that have not been grouped are sorted in ascending order of earliest available triggering moments, and each timer group is determined in sequence. The grouping starts from the timer of the earliest available triggering moment, and fixed triggering moments of timers in a same group are unified, so that the fixed triggering moment of the timer of which the earliest available triggering moment is the earliest may be delayed, thereby delaying the RTC moment to some extent, and reducing a quantity of times of performing wake-up in a time period.

In a possible implementation, for a timer that does not support wake-up, when the terminal device is in a normal working state, the terminal device may determine whether a current moment is later than a moment in a triggering time range of the timer that cannot be woken up, and if the current moment is later than the moment, the terminal device triggers the timer that cannot be woken up, and performs a related operation corresponding to an application that registers the timer that cannot be woken up.

According to a second aspect, an embodiment of this disclosure provides a terminal device. The terminal device has a function of implementing the terminal device in the foregoing method. This function may be implemented by hardware, or may be implemented by hardware by executing corresponding software. The hardware or the software includes one or more modules corresponding to the foregoing functions.

In a possible implementation, the terminal device includes a memory and one or more processors, where the memory stores one or more programs, the one or more programs include an instruction, and when the instruction is executed by the terminal, the terminal device is enabled to perform:

setting at least two timers, where the at least two timers support wake-up, and each of the at least two timers corresponds to an operation related to an application; determining whether each of the at least two timers has a triggering time range; grouping, according to a preset first rule, timers that have triggering time ranges, to obtain M timer groups, where M is an integer greater than 0, and a common intersection set of triggering time ranges of all timers in each of the M timer groups is not empty; determining a triggering moment of each of the M timer groups, to obtain M triggering moments; determining N timers that have no triggering time range, and determining a triggering moment of each of the N timers, to obtain N triggering moments, where N is an integer greater than 0; setting an earliest moment in the M triggering moments and the N triggering moments as an RTC moment; and when the RTC moment is reached, performing wake-up if the terminal device is in a sleep state.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to perform: when determining a triggering moment of a first timer group in the M timer groups, determining that a latest moment in a first intersection set is the triggering moment of the first timer group, where the first intersection set is a common intersection set of triggering time ranges of all timers in the first timer group, the first timer group comprises a first timer and a second timer that have different triggering time ranges, the first timer corresponds to a first operation of a first application, and the second timer corresponds to a second operation of a second application.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to perform: if the triggering moment of the first timer group is set as the RTC moment, when the RTC moment is reached, triggering all timers in the first timer group; performing the first operation and the second operation; and after all the timers in the first timer group are triggered, deleting all the timers in the first timer group.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to perform: if the triggering moment of the first timer group is set as the RTC moment, when the RTC moment is reached, deleting the triggering moment of the first timer group; and setting, as a new RTC moment, an earliest moment in the N triggering moments and the remaining M−1 triggering moments obtained after the triggering moment of the first timer group is removed from the M triggering moments.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to perform: sorting the timers having the triggering time ranges in ascending order of earliest available triggering moments; if it is determined that an earliest available triggering moment of a third timer is the earliest, determining a timer of which a triggering time range intersects with a triggering time range of the third timer and the third timer to be in a second timer group; sorting, in ascending order of earliest available triggering moments, timers that are in the timers having the triggering time ranges and that are not determined to be in the second timer group; and if it is determined that the earliest available triggering moment of a fourth timer is the earliest, determining a timer of which a triggering time range intersects with a triggering time range of the fourth timer and the fourth timer to be in a third timer group.

The embodiments of this disclosure provide a timer management method and a terminal device, to reduce a quantity of times that a terminal device performs wake-up, and reduce power consumption of the terminal device.

According to a first aspect, an embodiment of this disclosure provides a timer management method, including: when a terminal device performs wake-up from a sleep state based on a first interruption signal, determining, by the terminal device, a first moment, where the first moment is a moment at which the first interruption signal is sent, the first interruption signal may be sent by a module in the terminal device, may be sent by an RTC module, may be sent by a Wi-Fi module, or may be sent by another module, and the terminal device can determine a module that sends the first interruption signal; determining, by the terminal device, whether the wake-up performed based on the first interruption signal is non-alarm wake-up; if the wake-up is non-alarm wake-up, determining, by the terminal device, a first target timer, where the first target timer is registered and set by the terminal device by running a first target application, and is used to instruct the terminal device to perform wake-up at a specified moment and perform a first target operation corresponding to the first target application at a specified moment, the first target timer corresponds to the first target operation of the first target application and has a triggering time range, a time range between an available triggering moment of the first target timer and the first moment is less than a preset first duration threshold, and the available triggering moment of the first target timer is any moment in the triggering time range of the first target timer; and deleting, by the terminal device, the first target timer.

In the technical solution provided in this embodiment of this disclosure, when the terminal device performs non-alarm wake-up, the terminal device determines, by using a sending moment (the first moment) of an interruption signal in the current non-alarm wake-up as a reference, the first target timer whose available triggering moment and the first moment have duration less than the preset first duration threshold, where the first target timer is used to instruct the terminal device to perform wake-up at a specified moment and has a triggering time range. The available triggering moment may be any moment in the triggering time range of the first target timer. The terminal device deletes the first target timer, so that the terminal device may no longer perform wake-up at a moment because of the first target timer, and a quantity of times of performing wake-up is reduced, thereby reducing power consumption of the terminal device.

Optionally, if the fixed triggering moment of the first target timer has been set as the RTC moment, the terminal device may delete the RTC moment.

In the technical solution provided in this embodiment of this disclosure, because the RTC moment set by using the fixed triggering moment of the first target timer is deleted, it is implemented that the terminal device may not perform wake-up when the fixed triggering moment of the first target timer is reached, thereby reducing a quantity of times that the terminal device performs wake-up.

Optionally, before the terminal device deletes the first target timer, the terminal device may trigger the first target timer, and after triggering the first target timer, the terminal device may perform the first target operation corresponding to the first target application.

In the technical solution provided in this embodiment of this disclosure, the terminal device may trigger the first target timer and may perform the first target operation corresponding to the first target application, so that it is implemented to trigger the first target timer in advance and perform the corresponding operation, thereby improving implementability of the solution.

Optionally, after the terminal device deletes the first target timer, when the terminal device has not entered the sleep state again, the terminal device may determine whether a second moment exists, where the second moment is a sending moment of an interruption signal for non-alarm wake-up. If the second moment exists, the terminal device determines, by using the second moment as a reference, a second target timer and a third target timer, where the second target timer is registered and set by the terminal device to instruct the terminal device to perform wake-up at a first fixed triggering moment, and the third target timer is registered and set by the terminal device to instruct the terminal device to perform wake-up at a second fixed triggering moment. The second target timer has a first triggering time range, and the third target timer has a second triggering time range. A time range between a first available triggering moment of the second target timer and the second moment is less than a preset second duration threshold, and the first available triggering moment is earlier than the second moment. Duration between a second available triggering moment of the third target timer and the second moment is less than a preset third duration threshold, and the second available triggering moment is later than the second moment. The first available triggering moment is any moment within the first triggering time range, and the second available triggering moment is any moment within the second triggering time range. The terminal device determines the first fixed triggering moment and the second fixed triggering moment as the second moment.

In the technical solution provided in this embodiment of this disclosure, after determining the sending moment (the second moment) of the interruption signal for non-alarm wake-up, the terminal device may determine the second target timer and the third target timer whose available triggering moments and the second moment each have duration less than the preset duration threshold, and set the fixed triggering moments of the second target timer and the third target timer as the second moment. In this way, a quantity of times that the terminal device performs wake-up can be further reduced.

Optionally, after determining the first fixed triggering moment and the second fixed triggering moment as the second moment, the terminal device may delete the first triggering time range and the second triggering time range.

According to a second aspect, an embodiment of this disclosure provides a terminal device. The terminal device has a function of implementing the terminal device in the foregoing method. This function may be implemented by hardware, or may be implemented by hardware by executing corresponding software. The hardware or the software includes one or more modules corresponding to the foregoing function.

In a possible implementation, the terminal device includes a memory and one or more processors, where the memory stores one or more programs, the one or more programs include an instruction, and when the instruction is executed by the terminal device, the terminal device is enabled to perform:

when the terminal device performs wake-up from a sleep state based on a first interruption signal, determining a first moment, where the first moment is a moment at which the first interruption signal is sent; determining whether the wake-up performed based on the first interruption signal is non-alarm wake-up; if the performed wake-up is non-alarm wake-up, determining a first target timer, where the first target timer is registered and set by the terminal device by running a first target application, the first target timer corresponds to a first target operation of the first target application and has a triggering time range, duration between an available triggering moment of the first target timer and the first moment is less than a preset first duration threshold, and an available triggering moment of the first target timer is any moment in the triggering time range of the first target timer; and deleting the first target timer.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to trigger the first target timer and perform the first target operation.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to perform: when the terminal device has not entered the sleep state again, determining whether a second moment exists, where the second moment is a moment at which the non-alarm wake-up interruption signal is sent; if the second moment exists, determining a second target timer and a third target timer, where the second target timer and the third target timer are registered and set by the terminal device, the second target timer is used to instruct the terminal device to perform wake-up at a first fixed triggering moment, the third target timer is used to instruct the terminal device to perform wake-up at a second fixed triggering moment, the second target timer has a first triggering time range, the third target timer has a second triggering time range, duration between a first available triggering moment of the second target timer and the second moment is less than a preset second duration threshold, the first available triggering moment is earlier than the second moment, duration between a second available triggering moment of the third target timer and the second moment is less than a preset third duration threshold, the second available triggering moment is later than the second moment, the first available triggering moment is any moment within the first triggering time range, the second available triggering moment is any moment within the second triggering time range; and determining the first fixed triggering moment and the second fixed triggering moment as the second moment.

Optionally, when the instruction is executed by the terminal device, the terminal device is further enabled to delete the first triggering time range and the second triggering time range.

