Summary of the invention
The technical problem to be solved in the present invention is to provide a kind of method and device that obtains mobile terminal application power consumption, can detect the concrete power consumption of mobile terminal application.
For solving the problems of the technologies described above, embodiments of the invention provide technical scheme as follows:
On the one hand, provide a kind of method of obtaining mobile terminal application power consumption, be applied in the mobile terminal of Android system, described method comprises:
Obtain the unit interval power consumption of mobile terminal application;
Obtain the working time of mobile terminal application;
According to described mobile terminal application units' time power consumption with calculate the power consumption of mobile terminal application working time.
Further, in such scheme, the unit interval power consumption that obtains mobile terminal application comprises:
Described mobile terminal application is only installed on mobile terminal, moves described mobile terminal application Preset Time, draw the electric quantity consumption curve of mobile terminal, obtain the unit interval power consumption of mobile terminal application by calculating mean value; Or
Calculate the mean value of applying other application units' time power consumption of the same type with described mobile terminal, as the unit interval power consumption of described mobile terminal application.
Further, in such scheme, described in obtain mobile terminal application working time comprise:
Obtain the front stage operation time t1 of mobile terminal application, obtain the running background time t2 of mobile terminal application;
Describedly comprise according to described mobile terminal application units' time power consumption and the power consumption that calculates mobile terminal application working time:
The power consumption that calculates mobile terminal application by formula m=n*t1+n*t2/k, wherein, k is reduction coefficient, and n is the unit interval power consumption of mobile terminal application, and m is the power consumption of mobile terminal application.
Further, in such scheme, described in obtain mobile terminal application front stage operation time t1 comprise:
Obtain the foreground application of mobile terminal every Preset Time, and the foreground application that current time is obtained is compared with the last foreground application of obtaining, if the foreground application that current time obtains is different from the last foreground application of obtaining, the end time using the time corresponding current time as last foreground application, the start time using the time corresponding current time as current foreground application;
Obtain start time and the end time of mobile terminal application as foreground application by above-mentioned steps, the end time is deducted to the front stage operation time t1 that the start time obtains mobile terminal application.
Further, in such scheme, described in obtain mobile terminal application running background time t2 comprise:
Obtain all background application of mobile terminal every Preset Time, and the background application that current time is obtained is compared with the last background application of obtaining, if the background application that current time obtains is different from the last background application of obtaining, using the start time of time corresponding current time as newly-increased background application, using the end time of time corresponding current time as disappearance background application;
Obtain start time and the end time of mobile terminal application as background application by above-mentioned steps, the end time is deducted to the running background time t2 that the start time obtains mobile terminal application.
The embodiment of the present invention also provides a kind of device that obtains mobile terminal application power consumption, is applied in the mobile terminal of Android system, and described device comprises:
The first acquisition module, for obtaining the unit interval power consumption of mobile terminal application;
The second acquisition module, for obtaining the working time of mobile terminal application;
Computing module, for according to described mobile terminal application units' time power consumption with calculate the power consumption of mobile terminal application working time.
Further, in such scheme, described the first acquisition module specifically for only installing described mobile terminal application on mobile terminal, move described mobile terminal application Preset Time, draw the electric quantity consumption curve of mobile terminal, obtain the unit interval power consumption of mobile terminal application by calculating mean value; Or
Calculate the mean value of applying other application units' time power consumption of the same type with described mobile terminal, as the unit interval power consumption of described mobile terminal application.
Further, in such scheme, described the second acquisition module, specifically for obtaining the front stage operation time t1 of mobile terminal application, obtains the running background time t2 of mobile terminal application;
Described computing module is specifically for calculating the power consumption of mobile terminal application by formula m=n*t1+n*t2/k, wherein, k is reduction coefficient, and n is the unit interval power consumption of mobile terminal application, and m is the power consumption of mobile terminal application.
Further, in such scheme, described the second acquisition module is specifically for obtaining the foreground application of mobile terminal every Preset Time, and the foreground application that current time is obtained is compared with the last foreground application of obtaining, if the foreground application that current time obtains is different from the last foreground application of obtaining, the end time using the time corresponding current time as last foreground application, the start time using the time corresponding current time as current foreground application; Obtain start time and the end time of mobile terminal application as foreground application by above-mentioned steps, the end time is deducted to the front stage operation time t1 that the start time obtains mobile terminal application.
Further, in such scheme, described the second acquisition module is specifically for obtaining all background application of mobile terminal every Preset Time, and the background application that current time is obtained is compared with the last background application of obtaining, if the background application that current time obtains is different from the last background application of obtaining, using the start time of time corresponding current time as newly-increased background application, using the end time of time corresponding current time as disappearance background application; Obtain start time and the end time of mobile terminal application as background application by above-mentioned steps, the end time is deducted to the running background time t2 that the start time obtains mobile terminal application.
Embodiments of the invention have following beneficial effect:
In such scheme, can calculate the concrete power consumption of mobile terminal according to the unit interval power consumption of the working time of the mobile terminal application of obtaining and mobile terminal application, like this in the time that user need to the amount of saving energy, just can close pointedly the many application of some power consumption, prevent that the battery power consumption of mobile terminal is too fast.
Embodiment
For technical matters, technical scheme and advantage that embodiments of the invention will be solved are clearer, be described in detail below in conjunction with the accompanying drawings and the specific embodiments.
Embodiments of the invention can not detect the power consumption details of certain money application for smart mobile phone in prior art, the concrete power consumption situation of application can only detect by special power consumption checkout equipment, user there is no method knows the concrete power consumption situation of application, like this in the time that user need to the amount of saving energy, just cannot close pointedly the problem of the many application of some power consumption, a kind of method and device that obtains mobile terminal application power consumption is provided, can detects the concrete power consumption of mobile terminal application.
Fig. 1 is the schematic flow sheet of the method for obtaining mobile terminal application power consumption of the embodiment of the present invention, the method of obtaining mobile terminal application power consumption of the embodiment of the present invention is applied in the mobile terminal of Android system (wherein, Android is a kind of freedom based on Linux and the operating system of open source code, mainly be used in portable equipment, as smart mobile phone and panel computer), as shown in Figure 1, the present embodiment comprises:
Step 101: the unit interval power consumption that obtains mobile terminal application;
Step 102: the working time of obtaining mobile terminal application;
Step 103: according to mobile terminal application units time power consumption with calculate the power consumption of mobile terminal application working time.
Further, in another embodiment of the present invention, comprise that on the basis of above-mentioned steps 101 ~ 103, step 101 specifically comprises:
Mobile terminal application is only installed on mobile terminal, operation mobile terminal application Preset Time, the electric quantity consumption curve of drafting mobile terminal, obtains the unit interval power consumption of mobile terminal application by calculating mean value; Or
Calculate the mean value of applying other application units' time power consumption of the same type with mobile terminal, as the unit interval power consumption of mobile terminal application.
Further, in another embodiment of the present invention, comprise that on the basis of above-mentioned steps 101 ~ 103, step 102 specifically comprises:
Obtain the front stage operation time t1 of mobile terminal application, obtain the running background time t2 of mobile terminal application;
Step 103 comprises:
The power consumption that calculates mobile terminal application by formula m=n*t1+n*t2/k, wherein, k is reduction coefficient, and n is the unit interval power consumption of mobile terminal application, and m is the power consumption of mobile terminal application.
Further, the front stage operation time t1 that obtains mobile terminal application comprises:
Obtain the foreground application of mobile terminal every Preset Time, and the foreground application that current time is obtained is compared with the last foreground application of obtaining, if the foreground application that current time obtains is different from the last foreground application of obtaining, the end time using the time corresponding current time as last foreground application, the start time using the time corresponding current time as current foreground application;
Obtain start time and the end time of mobile terminal application as foreground application by above-mentioned steps, the end time is deducted to the front stage operation time t1 that the start time obtains mobile terminal application.
Further, the running background time t2 that obtains mobile terminal application comprises:
Obtain all background application of mobile terminal every Preset Time, and the background application that current time is obtained is compared with the last background application of obtaining, if the background application that current time obtains is different from the last background application of obtaining, using the start time of time corresponding current time as newly-increased background application, using the end time of time corresponding current time as disappearance background application;
Obtain start time and the end time of mobile terminal application as background application by above-mentioned steps, the end time is deducted to the running background time t2 that the start time obtains mobile terminal application.
The method of obtaining mobile terminal application power consumption of the present invention, can calculate the concrete power consumption of mobile terminal according to the unit interval power consumption of the working time of the mobile terminal application of obtaining and mobile terminal application, like this in the time that user need to the amount of saving energy, just can close pointedly the many application of some power consumption, prevent that the battery power consumption of mobile terminal is too fast.
Fig. 2 is the structured flowchart of the device that obtains mobile terminal application power consumption of the embodiment of the present invention, and the application of installation that obtains mobile terminal application power consumption of the embodiment of the present invention is in the mobile terminal of Android system, and as shown in Figure 2, the present embodiment comprises:
The first acquisition module 20, for obtaining the unit interval power consumption of mobile terminal application;
The second acquisition module 21, for obtaining the working time of mobile terminal application;
Computing module 22, for according to mobile terminal application units time power consumption with calculate the power consumption of mobile terminal application working time.
Further, in such scheme, the first acquisition module 20, specifically for mobile terminal application is only installed on mobile terminal, moves mobile terminal application Preset Time, draw the electric quantity consumption curve of mobile terminal, obtain the unit interval power consumption of mobile terminal application by calculating mean value; Or
Calculate the mean value of applying other application units' time power consumption of the same type with mobile terminal, as the unit interval power consumption of mobile terminal application.
Further, in such scheme, the second acquisition module 21, specifically for obtaining the front stage operation time t1 of mobile terminal application, obtains the running background time t2 of mobile terminal application;
Computing module 22 is specifically for calculating the power consumption of mobile terminal application by formula m=n*t1+n*t2/k, wherein, k is reduction coefficient, and n is the unit interval power consumption of mobile terminal application, and m is the power consumption of mobile terminal application.
Further, in such scheme, the second acquisition module 21 is specifically for obtaining the foreground application of mobile terminal every Preset Time, and the foreground application that current time is obtained is compared with the last foreground application of obtaining, if the foreground application that current time obtains is different from the last foreground application of obtaining, the end time using the time corresponding current time as last foreground application, the start time using the time corresponding current time as current foreground application; Obtain start time and the end time of mobile terminal application as foreground application by above-mentioned steps, the end time is deducted to the front stage operation time t1 that the start time obtains mobile terminal application.
Further, in such scheme, the second acquisition module 21 is specifically for obtaining all background application of mobile terminal every Preset Time, and the background application that current time is obtained is compared with the last background application of obtaining, if the background application that current time obtains is different from the last background application of obtaining, using the start time of time corresponding current time as newly-increased background application, using the end time of time corresponding current time as disappearance background application; Obtain start time and the end time of mobile terminal application as background application by above-mentioned steps, the end time is deducted to the running background time t2 that the start time obtains mobile terminal application.
The device that obtains mobile terminal application power consumption of the present invention, can calculate the concrete power consumption of mobile terminal according to the unit interval power consumption of the working time of the mobile terminal application of obtaining and mobile terminal application, like this in the time that user need to the amount of saving energy, just can close pointedly the many application of some power consumption, prevent that the battery power consumption of mobile terminal is too fast.
Below in conjunction with Fig. 3-Fig. 4 and specific embodiment, the method for obtaining mobile terminal application power consumption of the present invention is described in detail:
First can obtain by professional power consumption checkout equipment the power consumption data of mobile terminal application, method of testing is, application to be tested is only installed on mobile terminal, other application are not installed on mobile terminal, move this application Preset Time (such as being 400 seconds), the real-time power consumption (unit milliampere) of a mobile terminal of record per second, draws electric quantity consumption curve as shown in Figure 3, obtains the unit interval power consumption of this application by calculating mean value.After being completed, the power consumption data of mobile terminal application are stored in database.
For some unknown applications, can also infer by known power consumption data the unit interval power consumption of this application in addition.As this is applied as 3D game, analyze the unit interval power consumption of existing 3D game, calculate the mean value of existing 3D game unit interval power consumption as the unit interval power consumption of this application.Can expand application power consumption data by this kind of mode.If cannot detect this application type, obtain the unit interval power consumption of whole application, and average as the unit interval power consumption of this application.
Detect afterwards the working time of mobile terminal application, comprise front stage operation time and the running background time of mobile terminal application this working time.
In the time detecting the front stage operation time of mobile terminal, need to create separately a process, the every Preset Time (such as 1-15s) of crossing of this process can be by the API(Application Programming Interface of mobile terminal, application programming interface) obtain current Activity storehouse, and obtain the application (foreground application) of storehouse stack top.Can be with the foreground application contrast of obtaining before after obtaining, if it is different from the last foreground application of obtaining that current time obtains foreground application, the end time using the time corresponding current time as last foreground application, simultaneously as after start time of foreground application, obtain the front stage operation time t1 of mobile terminal with this.As shown in Figure 4, obtain foreground application one time every 1s, application A starts during from 0s as foreground application operation, becomes B to foreground application time 3s, thinks that the front stage operation time of A is 3s; When 4s, foreground application becomes C, and the front stage operation time of B is 1s.
In the time that mobile terminal is applied in running background, its power consumption is very low, can obtain by experiment the reduction coefficient k of mobile terminal application foreground power consumption and backstage power consumption, is about 10-30.Similar with foreground application, obtain the current all background application of mobile terminal one time every Preset Time (such as 10s-50s), calculate certain by the mode of traversal and be applied in and when start, when finish, obtain the running background time t2 of mobile terminal application.
The power consumption that calculates afterwards mobile terminal application by formula m=n*t1+n*t2/k, wherein, k is reduction coefficient, and n is the unit interval power consumption of mobile terminal application, and m is the power consumption of mobile terminal application.
In one embodiment, the computation process of the power consumption of mobile terminal application is as follows:
In certain mobile terminal, total A, B, C, tetra-sections of application of D move.The method of obtaining average power consumption by continuous operation application is learnt, in the working time of 400s, the average unit interval power consumption of A is that 369.4 milliamperes, the average unit interval power consumption of B are 438 milliamperes, the average unit interval power consumption of C is 286.5 milliamperes, and the average unit interval power consumption of D is 314 milliamperes.The reduction coefficient k of four sections of application is 20.
In a certain moment, pass through method:
List<RunningTaskInfo>runRasks=activityMgr
.getRunningTasks(1);
RunningTaskInfo?taskInfo=runRasks.get(0);
Obtain, what this moment foreground was being moved is applied as A.
Pass through method:
List<RunningAppProcessInfo>
android.app.ActivityManager.getRunningAppProcesses()
Obtain, the set of the background application of these all operations of moment is { A, B, C, D }.
Follow-up timing (as every 10s) repeated obtain foreground application and the background application of passing through, obtains N moment, and foreground application and background application that each moment is current are as shown in the table:
Time |
Foreground application |
Background application |
10s |
A |
A、B、C、D |
20s |
A |
A、B、C、D |
30s |
A |
A、B、C |
40s |
A |
A、B、C |
50s |
A |
A、B、C |
60s |
B |
A、B、C |
70s |
C |
B、C |
80s |
C |
B、C |
90s |
C |
A、B、C |
100s |
C |
A、C |
In 60s, the foreground application of mobile terminal is B, and the foreground application contrast during with 50s, finds inconsistent.Think that the front stage operation time of A is 60s, B brings into operation in the time of 60s.Pass through formula: foreground power consumption=front stage operation time * unit interval power consumption, the foreground power consumption that calculates A is 60/3600*369.4=6.16 MAH.
When 60s, A is not closed, but proceeds to running background.The background application set of 60s and 70s is respectively { A, B, C } and { B, C }, by two set are traveled through respectively and contrasted, applies A and is thoroughly closed, so A has moved 10s altogether on backstage when finding 70s.Pass through formula: background application power consumption=running background time * unit interval power consumption/reduction coefficient, the backstage power consumption that calculates A is 10/3600*369.4/20=0.308 MAH.The power consumption that this operation of A consumes is altogether 6.16+0.308=6.468 MAH.
Can obtain the concrete power consumption of mobile terminal application by technical scheme of the present invention, and then the power consumption of mobile terminal application can be shown to user, allow user have at fingertips to the application power consumption in own mobile terminal.And technical scheme of the present invention can be distinguished foreground application and background application, and calculate respectively power consumption, not only can show the power consumption details of certain application, can also make user where know electric quantity consumption, whether there is the hiding application consumes power in backstage, thereby can, in the time that user need to the amount of saving energy, close pointedly the many application of some power consumption, reduce electric quantity consumption, extend the service time of mobile terminal.
Many functional parts described in this instructions are all called as module, to emphasize more especially the independence of its implementation.
In the embodiment of the present invention, module can realize with software, to carried out by various types of processors.For instance, the executable code module of a mark can comprise one or more physics or the logical block of computer instruction, and for instance, it can be built as object, process or function.However, the executable code of institute's identification module is without being physically located in together, but can comprise and be stored in different different instructions physically, in the time combining in these command logics, and its composition module and realize the regulation object of this module.
In fact, executable code module can be individual instructions or many instructions, and even can be distributed on multiple different code segments, is distributed in the middle of distinct program, and crosses over multiple memory devices distributions.Similarly, service data can be identified in module, and can realize and be organized in the data structure of any suitable type according to any suitable form.Described service data can be used as individual data collection and is collected, or can be distributed on diverse location and (be included in different storage device), and can only be present on system or network as electronic signal at least in part.
In the time that module can utilize software to realize, consider the level of existing hardware technique, so module that can realize with software, in the situation that not considering cost, those skilled in the art can build corresponding hardware circuit and realize corresponding function, and described hardware circuit comprises conventional ultra-large integrated (VLSI) circuit or gate array and the existing semiconductor such as logic chip, transistor or other discrete element.Module can also be used programmable hardware device, realizations such as field programmable gate array, programmable logic array, programmable logic device.
In the each embodiment of the method for the present invention; the sequence number of described each step can not be used for limiting the sequencing of each step; for those of ordinary skill in the art, do not paying under the prerequisite of creative work, the priority of each step is changed also within protection scope of the present invention.
The above is the preferred embodiment of the present invention; it should be pointed out that for those skilled in the art, do not departing under the prerequisite of principle of the present invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.