Embodiment
For making the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Embodiment one
Embodiments provide a kind of method waking hardware device up, see Fig. 1, method flow comprises:
101: receive the wake request to predetermined hardware that application sends, in described wake request, at least carry the wakeup time that described application is specified;
102: determine that described wakeup time is the need of delay according to described wakeup time and default delay wake-up period;
103: when described wakeup time needs Delay time, then determine the delay wakeup time to described predetermined hardware according to described wakeup time and described default delay wake-up period, and wake described predetermined hardware up according to described delay wakeup time.
Wherein, described hardware device is one or more in central processor CPU, Wireless Fidelity Wifi module, global position system GPS module.
The embodiment of the present invention, by the wakeup time of specifying in the wake request of application and the delay wake-up period preset are postponed the application of wakeup time by needing, carries out waking delay disposal up.Reduce and wake the serious situation of power consumption that hardware device causes up due to frequently unordered, improve the stand-by time of terminal.
Embodiment two
Embodiments provide a kind of method waking hardware device up, see Fig. 2.
It should be noted that, the embodiment of the present invention is that example is described the method waking hardware device up with the process of application call CPU (CentralProcessingUnit, central processing unit) in Android (Android) system.
When being applied in the CPU waking up and be in dormant state, when CPU is waken up by sending AlarmManager message apprizing system.Wherein, AlarmManager is available to the interface to fixed cycle operator management of upper layer application, application can arrange timing wake-up operation that is single and that repeat by set and the setRepeating interface calling AlarmManager, wake CPU up to carry out and apply the operation customized in advance after the time that system can be arranged in application arrives.
In embodiments of the present invention, application call be this interface of set of AlarmManager, when apprizing system wakes CPU up, wherein also carries application identities in request message, i.e. uid.Further, the content of this message is: AlarmManager.set (inttype, longtriggerAtMillis, PendingIntentoperation), wherein parametric t ype is time type, triggerAtMillis is the wakeup time of setting, and operation is the operation then carried out afterwards.
Time type wherein in type is divided into four kinds: RTC, to start the then time that millisecond number is till now digit setting Alarm zero point on January 1st, 1970, if then terminal is in dormant state and does not wake hardware device up, but wait for that next hardware device is waken up laggard line operate; RTC_WAKEUP, is the then time setting Alarm for digit with the millisecond number started zero point on January 1st, 1970 till now, if then hardware device dormancy, wakes hardware device up and operate; ELAPSED_REALTIME, is start the millisecond number till now then time for digit setting Alarm with this starting up of terminal, if then hardware device dormancy does not wake hardware device up, but waits for that next hardware device wakes laggard line operate up; ELAPSED_REALTIME_WAKEUP, is start the millisecond number till now then time for digit setting Alarm with this starting up of terminal, if then hardware device dormancy, wakes hardware device up and operate.
Wherein, method flow comprises:
201: receive the wake request to predetermined hardware that application sends, in described wake request, at least carry the wakeup time that described application is specified.
Wakeup time and time type and concrete operation can be carried in the wake request that system receives, if when wherein time type is ELAPSED_REALTIME_WAKEUP, when calculating wakeup time the need of the process postponed in following flow process, this time is then needed to be added with the system boot time, calculate millisecond value till now from zero point on January 1st, 1970, and time type for this time be RTC_WAKEUP time, then directly use this millisecond value to calculate.
202: judge the white list whether described application identities belongs to default.
Preferably, consider certain applications, such as: alarm clock application etc., very accurate to the time accuracy requirement of fixed cycle operator, therefore the application identities of this type of application assert authoritative organization (official or have the tissue of similar power influence power) is added in the white list prestored and manage, thus the delay request that application corresponding for the application identities belonged in white list is sent, time unifying strategy is not carried out to ensure that this kind of application program can work normally in the normal time to it.
203: determine that described wakeup time is the need of delay according to described wakeup time and default delay wake-up period.
In time judging in step 202 in the white list that application identities belongs to default, then step 203 can be:
When described application identities does not belong to described default white list, then determine that described wakeup time is the need of delay according to described wakeup time and default delay wake-up period.
Postpone wake-up period, being the standard of a default time unifying, is a millisecond value.If the wakeup time in wake request needs to carry out postponing through calculating with delay wake-up period, postpone the wakeup time of application.Wherein, account form is: computing wakeup time and delay wake-up period being carried out complementation, checks whether be zero after obtaining remainder, if be zero, illustrate that this wakeup time is without the need to postponing, when the wakeup time of wake request arrives, system can wake CPU up; If non-vanishing, illustrate that this wakeup time needs to postpone.
Such as: default wake-up period is 300000 milliseconds, namely with 5 minutes for standard carries out time unifying, the time must be the time can divided exactly by 300000, just allows not to be delayed by.When 12:08 subsystem receives the wake request of A application transmission, the wakeup time wherein carried in request is that 12:13 divides, according to 12:13 divide corresponding from zero point on January 1st, 1970 millisecond number be till now that the millisecond value of digit and default wake-up period 300000 milliseconds determine that this wakeup time is the need of delay, 12:13 divides corresponding millisecond value divided by can not be divided evenly after 300000, and remainder is 120000 non-zero, illustrates that this wakeup time needs to postpone.
When 12:10 subsystem receives the wake request of application B transmission, the wakeup time wherein carried in request is that 12:15 divides, according to 12:15 divide corresponding from zero point on January 1st, 1970 millisecond number be till now that the millisecond value of digit and default wake-up period 300000 milliseconds determine that this wakeup time is the need of delay, 12:15 divides corresponding millisecond value divided by can be divided evenly after 300000, and remainder is 0 and illustrates that this wakeup time is without the need to postponing.
Step 203 determines that wakeup time the need of the process postponed is:
2031: complementation computing is carried out to described wakeup time and default delay wake-up period, obtains the first remainder;
2032: when described first remainder is zero, then determine that described wakeup time does not need to postpone.
If do not need to postpone, then perform step 205.
2033: when described first remainder is non-vanishing, then determine that described wakeup time needs to postpone.
If need to postpone, then perform step 204.
204: when described wakeup time needs Delay time, then determine the delay wakeup time to described predetermined hardware according to described wakeup time and described default delay wake-up period, and wake described predetermined hardware up according to described delay wakeup time.
The mode that namely wakeup time calculated after postponing postpones wakeup time is:
Described wakeup time and described first remainder are subtracted each other, and is added with described default delay wake-up period and obtains the very first time, and the described very first time is defined as postpone wakeup time.
Connect the example in step 202, the remainder calculated is 120000, is divided by 12:13 corresponding millisecond value to deduct 120000, and be added with 300000, the delay wakeup time obtained is that 12:15 divides, and CPU wakes up in 12:15 timesharing by system, for application A carries out concrete call operation.
205: when described wakeup time does not need Delay time, then wake the hardware device of described application call up according to described wakeup time.
12:10 in step 202 divides the application B that the receives wake request sent, and wakeup time corresponding to this wake request does not need to be delayed by, and therefore CPU wakes up in 12:15 timesharing by system, for application B carries out concrete call operation.
For the wake request of the application A in step 202 example and application B, system only need be divided at 12:15 and waken the wake operation that CPU completes twice wake request up.
The embodiment of the present invention, by the wakeup time of specifying in the wake request of application and the delay wake-up period preset are postponed the application of wakeup time by needing, carries out waking delay disposal up.Reduce and wake the serious situation of power consumption that hardware device causes up due to frequently unordered, improve the stand-by time of terminal.
Embodiment three
Embodiments provide a kind of method waking hardware device up, see Fig. 3.
It should be noted that, some application needs the CPU that wakes up repeated to carry out concrete operation.In embodiments of the present invention, application call be this interface of setRepeating of AlarmManager, when apprizing system wakes CPU up, and at every periodic wakeup CPU when one-period wakeup time arrives, wherein also carry application identities in request message, i.e. uid.Further, the content of this message is: AlarmManager.setRepeating (inttype, longtriggerAtMillis, longintervalMillis, PendingIntentoperation), wherein parametric t ype is time type, and triggerAtMillis is the wakeup time of setting, intervalMillis is the periodic wakeup time interval, and operation is the operation then carried out afterwards.
Further, in the embodiment of the present invention, part steps is identical with the description in embodiment two, does not repeat them here.
301: receive the wake request to predetermined hardware that application sends, in described wake request, at least carry the wakeup time that described application is specified.
Wakeup time can be carried in the wake request that system receives, time type, the periodic wakeup time interval and concrete operation, wherein the periodic wakeup time interval is for after being applied in and waking CPU up first, periodically wakes the time of CPU every this periodic wakeup time interval up.
303: judge the white list whether described application identities belongs to default.
303: according to described wakeup time and default delay wake-up period, determine that described wakeup time is the need of delay.
In time judging in step 302 in the white list that application identities belongs to default, then step 303 can be:
When described application identities does not belong to described default white list, then determine that described wakeup time is the need of delay according to described wakeup time and default delay wake-up period.
Such as: when 12:08 subsystem receives the wake request of A application transmission, the wakeup time wherein carried in request is that 12:13 divides and the periodic wakeup time interval is 660000 milliseconds, namely 11 minutes.According to 12:13 divide corresponding from zero point on January 1st, 1970 millisecond number be till now that the millisecond value of digit and default wake-up period 300000 milliseconds determine that this wakeup time is the need of delay, 12:13 divides corresponding millisecond value divided by can not be divided evenly after 300000, and remainder is 120000 non-zero, illustrates that this wakeup time needs to postpone.
Step 303 determines that wakeup time the need of the process postponed is:
3031: complementation computing is carried out to described wakeup time and default delay wake-up period, obtains the first remainder;
3032: when described first remainder is zero, then determine that described wakeup time does not need to postpone.
If do not need to postpone, then perform step 305.
3033: when described first remainder is non-vanishing, then determine that described wakeup time needs to postpone.
If need to postpone, then perform step 304.
304: when described wakeup time needs Delay time, then determine the delay wakeup time to described predetermined hardware according to described wakeup time and described default delay wake-up period, and wake described predetermined hardware up according to described delay wakeup time.
Connect the example in step 302, the remainder calculated is 120000, is divided by 12:13 corresponding millisecond value to deduct 120000, and be added with 300000, the delay wakeup time obtained is that 12:15 divides, and CPU wakes up in 12:15 timesharing by system, for application A carries out concrete call operation.
305: when described wakeup time does not need Delay time, then wake the hardware device of described application call up according to described wakeup time.
306: when waking the hardware device of described application call up, according to current time, the delay wake-up period preset and the described periodic wakeup time interval, determine next cycle wakeup time, and wake the hardware device of described application call up according to described next cycle wakeup time.
When CPU is waken up at 12:15 first, according to 12:15 divide corresponding from zero point on January 1st, 1970 millisecond number be till now the millisecond value of digit, default wake-up period 300000 milliseconds and the periodic wakeup time interval are 660000 milliseconds, determine the next cycle wakeup time applying A.
Therefore determine that the process of next cycle wakeup time is:
3061: described current time was added with the periodic wakeup time interval and obtained for the second time, and complementation computing is carried out to described second time and described default delay wake-up period, obtain the second remainder.
To 12:15 divide corresponding from zero point on January 1st, 1970 millisecond number be till now the millisecond value of digit, be 660000 milliseconds of additions with the periodic wakeup time interval, the time obtained be 12:26 divide corresponding from zero point on January 1st, 1970 millisecond number be till now the millisecond value of digit.This millisecond value and default wake-up period 300000 milliseconds are carried out complementation computing, obtains remainder 60000.
3062: when described second remainder is zero, to be then added with the described periodic wakeup time interval according to described current time and to obtain for the 3rd time, and described 3rd time is defined as next cycle wakeup time.
3063: when described second remainder is non-vanishing, then subtract each other according to described current time and described second remainder, and be added with the described periodic wakeup time interval and obtained for the 4th time, and described 4th time is defined as next cycle wakeup time.
By 12:15 is divided corresponding from zero point on January 1st, 1970 millisecond number be till now that the millisecond value of digit and remainder 60000 subtract each other, and to be added with default wake-up period 300000 milliseconds, to obtain next cycle wakeup time.
Further, be, after application A wakes CPU up, all will calculate next cycle wakeup time so that when the time arrives, wake CPU up afterwards at every turn.
The embodiment of the present invention, by the wakeup time of specifying in the wake request of application and the delay wake-up period preset are postponed the application of wakeup time by needing, carries out waking delay disposal up.Reduce and wake the serious situation of power consumption that hardware device causes up due to frequently unordered, improve the stand-by time of terminal.
Embodiment four
Embodiments provide a kind of device waking hardware device up, see Fig. 4, this device comprises:
Receiver module 401, for receiving the wake request to predetermined hardware that application sends, at least carries the wakeup time that described application is specified in described wake request;
According to described wakeup time and default delay wake-up period, determination module 402, for determining that described wakeup time is the need of delay;
First wake module 403, for needing Delay time when described wakeup time, then determine the delay wakeup time to described predetermined hardware according to described wakeup time and described default delay wake-up period, and wake described predetermined hardware up according to described delay wakeup time.
Wherein, in a specific embodiment, described determination module 402, comprising:
First computing unit 4021, for carrying out complementation computing to described wakeup time and default delay wake-up period, obtains the first remainder;
First determining unit 4022, for when described first remainder is zero, then determines that described wakeup time does not need to postpone;
Second determining unit 4023, for when described first remainder is non-vanishing, then determines that described wakeup time needs to postpone.
Wherein, described first wake module 403 specifically for:
Described wakeup time and described first remainder are subtracted each other, and is added with described default delay wake-up period and obtains the very first time, and the described very first time is defined as postpone wakeup time.
Wherein, in described wake request, also carry the periodic wakeup time interval,
Accordingly, described device also comprises:
Second wake module 404, for when waking the hardware device of described application call up, according to current time, the delay wake-up period preset and the described periodic wakeup time interval, determine next cycle wakeup time, and wake the hardware device of described application call up according to described next cycle wakeup time.
Wherein, described second wake module 404, comprising:
Second computing unit 4041, obtained for the second time for described current time being added with the periodic wakeup time interval, and carried out complementation computing to described second time and described default delay wake-up period, obtained the second remainder;
First wakeup unit 4042, for when described second remainder is zero, is then added with the described periodic wakeup time interval according to described current time and obtained for the 3rd time, and described 3rd time is defined as next cycle wakeup time;
Second wakeup unit 4043, for when described second remainder is non-vanishing, then subtract each other according to described current time and described second remainder, and be added with the described periodic wakeup time interval and obtained for the 4th time, and described 4th time is defined as next cycle wakeup time.
Wherein, when also carrying application identities in described wake request,
Described device also comprises:
Judge module 405, for judging the white list whether described application identities belongs to default;
Correspondingly, described determination module specifically for:
When described application identities does not belong to described default white list, then determine that described wakeup time is the need of delay according to described wakeup time and default delay wake-up period.
Wherein, described hardware device is one or more in central processor CPU, Wireless Fidelity Wifi module, global position system GPS module.
The embodiment of the present invention, by the wakeup time of specifying in the wake request of application and the delay wake-up period preset are postponed the application of wakeup time by needing, carries out waking delay disposal up.Reduce and wake the serious situation of power consumption that hardware device causes up due to frequently unordered, improve the stand-by time of terminal.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
One of ordinary skill in the art will appreciate that all or part of step realizing above-described embodiment can have been come by hardware, the hardware that also can carry out instruction relevant by program completes, described program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium mentioned can be ROM (read-only memory), disk or CD etc.
The foregoing is only preferred embodiment of the present invention, not in order to limit the present invention, within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.