CN117312084A - Method and equipment for calculating application foreground and background use duration - Google Patents
Method and equipment for calculating application foreground and background use duration Download PDFInfo
- Publication number
- CN117312084A CN117312084A CN202311269296.2A CN202311269296A CN117312084A CN 117312084 A CN117312084 A CN 117312084A CN 202311269296 A CN202311269296 A CN 202311269296A CN 117312084 A CN117312084 A CN 117312084A
- Authority
- CN
- China
- Prior art keywords
- application
- target
- background
- time
- events
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 92
- 230000008569 process Effects 0.000 claims abstract description 39
- 238000012544 monitoring process Methods 0.000 claims abstract description 21
- 230000003993 interaction Effects 0.000 claims description 5
- 230000015654 memory Effects 0.000 description 15
- 238000010586 diagram Methods 0.000 description 11
- 238000004364 calculation method Methods 0.000 description 7
- 238000004590 computer program Methods 0.000 description 4
- 230000005291 magnetic effect Effects 0.000 description 4
- 238000005516 engineering process Methods 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000008859 change Effects 0.000 description 1
- 230000001186 cumulative effect Effects 0.000 description 1
- 230000003203 everyday effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
- 230000003936 working memory Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
- G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computing Systems (AREA)
- Physics & Mathematics (AREA)
- Quality & Reliability (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The application aims to provide a method and equipment for calculating the application foreground and background use duration, and by defining different background events in the running process of background services of mobile equipment, a data structure stored by the background events comprises an application to which the events belong, a time stamp when the events are created and event types; registering an event listener for listening to each background event with a native system of the mobile device; monitoring and recording all target events operated by a user when using a target application through a native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event; the stack structure and all target events are used, the application use duration of the target application used by the user in a preset time period is calculated, and the application use duration can be counted by the market for the foreground and the background of the application through expansion on the original system, so that the compatibility is good, the accuracy is high, the expansion is easy, and the statistics of the application use duration can be met.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for calculating a usage duration of a foreground and a background of an application.
Background
In the prior art, the popularization of mobile devices causes people to spend a great deal of time to play mobile phones every day, but users lack knowledge of the duration of each day of application use, so that a situation that an application can display the duration of each day of application used by the users in an intuitive way needs to be developed. However, the native system of the mobile device only counts the time when the native system is applied to the foreground page, that is, only counts the service time of the foreground page, and does not count the time of the background service, which results in a lack of user experience. The calculation of the background service cannot be performed, because the background service and the foreground page can be performed simultaneously, that is, the background service is performed while the foreground page is used, for example, the user can listen to songs while playing a mobile phone, and in this case, the timestamp section of the foreground page and the timestamp section of the background service intersect, so that the specific starting time and the specific ending time of one use cannot be accurately determined. Thus, there is an urgent need for a method to count the overall time that an application is used in a page and background service.
Disclosure of Invention
An object of the present application is to provide a method and an apparatus for calculating a background usage time length of an application, which are applied to a mobile device, by modifying a native system of the mobile device, so that the native system supports a background event for calculating operation of a background service, by recording a background event in an operation process of a self-defined background service to the native system, statistics of a usage time length of a background in a usage process of any time Duan Ren application is finally realized, and by expanding on the native system, compatibility is good, accuracy and easy to expand, and statistics of a market on a background usage time length of the application can be satisfied.
According to one aspect of the present application, there is provided a method of calculating a time period of application context usage, applied to a mobile device, wherein the method includes:
defining different background events in the running process of the background service of the mobile equipment, wherein a data structure stored by the background events comprises an application to which the event belongs, a time stamp when the event is created and an event type;
registering an event listener for listening to each of the background events with a native system of the mobile device, the native system supporting different foreground events in the running process of a foreground page of the mobile device;
monitoring and recording all target events operated by a user when using a target application through the native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event;
and calculating the application use duration of the user using the target application in the preset time period by using the stack structure and all the target events.
Further, in the above method, in the preset period of time, all target events that are run when the user uses the target application are monitored and recorded by the native system and the event monitor thereof, where the target events include a target background event and a target foreground event, and the method includes:
within a preset time period, monitoring all target background events corresponding to all background services operated by a user when using a target application through the event monitor, and writing all monitored target background events into a frame of the native system;
meanwhile, monitoring target foreground events corresponding to all foreground pages operated by a user when using the target application through the native system;
and carrying out serialization storage on all the target background events and all the target foreground events which are arranged on a time axis according to the time sequence.
Further, in the above method, the structure of the usage stack and the all target events calculate an application usage duration of the user using the target application in the preset time period, including:
setting the starting time of a target foreground event corresponding to a foreground page of a target application as fstart and the ending time as fstop, and setting the starting time of a target background event corresponding to a background service as bstart and the ending time as bstop; wherein,
step one, when fstart or bstart is detected, storing nodes of the fstart or bstart in a stack, and when the stack is empty, recording the time of the fstart or bstart as the real starting time of the current use target application, and setting the time as r_start, wherein r_start is the time of the stack bottom node;
step two, deleting a stack top node in the current stack when the fstop or the bstop is detected, and setting the fstop or the b_stop as the real ending time of the current use target application as r_stop if the stack is empty after deleting the stack top node;
step three, recording the current time using duration of the target application used by the user at the current time, wherein the current time using duration is as follows: r_stop-r_start;
and step four, repeating the step one to the step three until all time nodes recorded in the preset time period are completely calculated, and accumulating application using time lengths of all times of using the target application by a user in the preset time period, wherein the application using time lengths of the target application comprise the use of a foreground page and the use of a background service.
Further, in the above method, the method further includes:
registering a process monitor for monitoring application process death of each application to a native system of the mobile device;
and in the preset time period, when a user uses the target application, if the process monitor monitors that the application process of the target application dies, one or more target events which are running the target application are all written into the framework of the original system to finish recording.
Further, in the above method, the foreground page is used for indicating a UI page for interaction with the user;
the background service is used for indicating the service which can operate in the background without the interaction page.
According to another aspect of the present application, there is also provided a non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement a method for long-lived use in the context of a computing application as described above.
According to another aspect of the present application, there is also provided an apparatus for calculating a background usage time period of an application, where the apparatus includes:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
the one or more computer-readable instructions, when executed by the one or more processors, cause the one or more processors to implement a method for computing long-lived in the background of application as described above.
Compared with the prior art, the method and the device have the advantages that different background events in the running process of the background service of the mobile equipment are defined, and the data structure stored by the background events comprises the application to which the event belongs, the time stamp of the event creation and the event type; registering an event listener for listening to each of the background events with a native system of the mobile device, the native system supporting different foreground events in the running process of a foreground page of the mobile device; monitoring and recording all target events operated by a user when using a target application through the native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event; the structure of the stack and all the target events are used, the application using time of the target application by the user in the preset time period is calculated, the native system of the mobile device is transformed, the native system supports the background events for calculating the operation of the background service, the background events in the operation process of the self-defined background service are recorded to the native system, the statistics of the using time of the foreground and the background in the using process of any time Duan Ren application is finally realized, and the application is expanded on the native system, so that the compatibility is good, the application is accurate and easy to expand, and the statistics of the foreground and the background using time of the application in the market can be met.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the detailed description of non-limiting embodiments, made with reference to the following drawings, in which:
FIG. 1 illustrates a flow diagram of a method of computing a time-of-use in the background of an application in accordance with an aspect of the subject application;
FIG. 2 illustrates a process flow diagram of a method for computing the length of time of application in the background in an actual application scenario, in accordance with an aspect of the present application;
FIG. 3 is a schematic diagram of a method for computing application use time length by a native system in an actual application scenario for a method for computing application use time length in the background according to an aspect of the present application;
FIG. 4 illustrates a diagram of segment statistics of native systems on application usage durations in an actual application scenario for a method of computing application context usage durations in accordance with an aspect of the present application;
FIG. 5 is a schematic diagram of a method for computing the use time of an application in the foreground and background without crossing the use time of the foreground page and background service in the actual application scenario, including segment statistics, according to one aspect of the present application;
FIG. 6 is a schematic diagram illustrating a method of computing the usage time of an application in the foreground and background with cross-segment statistics of the usage time of the foreground page and background services in a real application scenario according to one aspect of the present application;
FIG. 7 is a schematic diagram of segment statistics of the use time of foreground pages and background services in another practical application scenario with a method of computing the use time of the foreground and background applications in a cross manner according to one aspect of the present application;
FIG. 8 illustrates a diagram of a method of computing the usage time of a foreground page in an actual application scenario including statistics of the usage time of a background service, according to one aspect of the present application;
FIG. 9 is a schematic diagram of statistics of the usage time of a background service in an actual application scenario including the usage time of a foreground page by a method of calculating the usage time of an application in the foreground according to one aspect of the present application;
FIG. 10 illustrates a schematic diagram of a cross-continuous time distribution of usage times of foreground pages and background services in an actual application scenario for a method of computing application foreground and background usage time lengths in accordance with an aspect of the subject application;
FIG. 11 is a logic diagram illustrating a method for computing the usage time of the foreground and background services shown in FIG. 10 through the stack structure in an actual application scenario according to an aspect of the present application;
the same or similar reference numbers in the drawings refer to the same or similar parts.
Detailed Description
The present application is described in further detail below with reference to the accompanying drawings.
In one typical configuration of the present application, the terminal, the device of the service network, and the trusted party each include one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer readable media, as defined herein, does not include non-transitory computer readable media (transmission media), such as modulated data signals and carrier waves.
As shown in fig. 1, fig. 1 is a flowchart of a method for calculating a usage time of an application in the foreground and the background, where the method is applied to a mobile device, and the mobile device includes, but is not limited to, a mobile terminal such as a smart phone, a computer, a watch, and the like, and the method includes steps S11, S12, S13, and S14, and specifically includes the following steps:
step S11, defining different background events in the running process of the background service of the mobile equipment, wherein a data structure stored by the background events comprises an application to which the event belongs, a time stamp when the event is created and an event type;
step S12, registering an event monitor for monitoring each background event with a native system of the mobile device, wherein the native system supports different foreground events in the running process of a foreground page of the mobile device; here, the native system of the mobile device is used for indicating the original operating system of the mobile device, in the native system, only the foreground use time in the use process of recording that the foreground page is opened to be closed is supported, so in the embodiment of the application, an event monitor for monitoring different background events in the running process of the background service of the mobile device needs to be registered in the native system, so that the background service of each application of the mobile device can also be monitored for starting and ending the use time.
Step S13, monitoring and recording all target events operated by a user when using a target application through the native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event; here, the preset time period includes, but is not limited to, any time period of one day, one week, one month, one quarter, even one year, etc.; the monitored and recorded target event comprises an application to which the target event belongs, a start time stamp, an end time stamp and an event type when the event is created.
And S14, calculating application use duration of the target application used by the user in the preset time period by using the stack structure and all the target events.
Through the steps S11 to S14, the native system of the mobile device is modified, so that the native system supports the operation of calculating the background service, the background event in the operation process of the self-defined background service is recorded to the native system, the statistics of the use duration of the foreground and the background in the use process of any time Duan Ren application is finally realized, and the statistics of the use duration of the foreground and the background in the use process of the application can be met by expanding the native system, so that the compatibility is good, the accuracy and the easiness in expanding are realized, and the statistics of the market on the use duration of the foreground and the background of the application can be met.
The foreground page is used for indicating a UI page for interaction with a user; the background service is used for indicating services which can operate in the background without an interactive page, such as music playing, and can operate in the background without the interactive page; and when the application using time length is used for indicating the screen of the mobile equipment to be on, the total time length of using the application is accumulated, wherein the total time length comprises the use of a foreground page and the use of a background service.
In the following, taking the target application as an example of the music player application, the application use duration of the music player application in the use process of the foreground page browsing operation and the background music playing is calculated, but only a preferred embodiment in the embodiments of the present application is taken as an example to explain the above steps S11 to S14 of the present application, and any background event corresponding to any other application is included in the scope of protection of the present application. In calculating the application usage duration, first, a background EVENT requiring custom background music playing, i.e., custom background EVENT, may include, but is not limited to, a start PLAY EVENT of custom music defined as event_play and a pause PLAY EVENT defined as event_stop, and both the custom start PLAY EVENT and pause PLAY EVENT are stored in a frame of the native system, wherein,
the data structure stored by each self-defined background EVENT is that
{
The unique identifier of the application is used for indicating the application to which the background event belongs
time stamp, time stamp at event creation time, including start time and end time
eventType types of EVENTs, event_PLAY and event_STOP, respectively, for custom types
}
Then registering an event monitor for monitoring a starting event and an ending event of a background playing corresponding to the music player application to a primary system of the mobile equipment, wherein the application for starting playing and suspending playing can be monitored through the event monitor;
then, in the process of actually using the mobile device, if the starting PLAY of the music player application is monitored, an event_play EVENT is written, and if the pause PLAY of the music player application is monitored, an event_stop EVENT is written, so that all target EVENTs which are operated by a user when using the target application, including a target background EVENT and a target foreground EVENT, are recorded, and all target EVENTs are queried through an API of the original system.
And finally, calculating the application use duration of the target application used by the user in the preset time period by using the structure of the stack and all the target events, wherein the application use duration comprises the use of a foreground page and the use of a background service, thereby realizing the application use duration of using an application in the preset time period.
Next, in the above embodiment of the present application, in the step S13, all the target events that are run when the user uses the target application are monitored and recorded by the native system and the event monitor thereof in a preset period, where the target events include a target background event and a target foreground event, and the method includes:
within a preset time period, monitoring all target background events corresponding to all background services operated by a user when using a target application through the event monitor, and writing all monitored target background events into a frame of the native system;
meanwhile, monitoring target foreground events corresponding to all foreground pages operated by a user when using the target application through the native system;
and carrying out serialization storage on all the target background events and all the target foreground events which are arranged on a time axis according to the time sequence.
As shown in fig. 2, an audio playing and pause monitor is registered first, then playing or pause of the referenced music is monitored, whether playing is started or paused is judged, if playing is started, an event_play EVENT is written into a frame of a native system of the mobile device, if playing is paused, an event_stop EVENT is written into a frame of a native system of the mobile device, finally, all the target background EVENTs and all the target foreground EVENTs arranged on a time axis are stored in sequence according to time sequence, so that the application foreground and background use time is read and queried later.
Following the above-described embodiment of the present application, while the step S12 registers an event listener for listening to each of the background events with the native system of the mobile device, the method further includes:
registering a process monitor for monitoring application process death of each application to a native system of the mobile device;
and in the preset time period, when a user uses the target application, if the process monitor monitors that the application process of the target application dies, one or more target events which are running the target application are all written into the framework of the original system to finish recording.
For example, since the progress of an application is forcibly killed, for example, a music progress which is playing music is forcibly killed, and a monitor is a program which can not monitor the music pause of a music player application corresponding to the music progress, a progress monitor for monitoring the death of the progress of the application needs to be registered with a native system of a mobile device, and during the preset period, when a user uses the target application, the progress monitor monitors that a certain application is killed, that is, the progress of the application is dead, and when audio is being played, an event_stop EVENT of the application needs to be written or other pause EVENTs related to the operation need to be written, so that the application is forcibly closed.
In the embodiment of the application, the native system does not have a method for recording the service time of the background service, namely does not support monitoring of the service time of the background service, and only supports calculation of the service time of the foreground page. Then, in the process of recording the application use time, the native system records the corresponding time stamp when the application enters the foreground page and exits the foreground page, as shown in fig. 4; the time of one use is the time stamp when the foreground page is exited minus the time stamp when the foreground page is entered, so the time of use of an application in a period of time is the cumulative sum of the differences between the time stamps of the application entering and exiting the application for a plurality of times in the period of time, as shown in fig. 3, the time length of use required to be calculated is:
fstop1-start1+fstop2-start2+fstop3-start3+fstop4-start4……+fstopn-startn
wherein n is the number of multiple entries or exits, the starting time of the foreground event is fstart, the ending time of the foreground event is fstop, the starting time of the background event is bstart, and the ending time of the background event is bstop.
However, in an actual application scenario used by a mobile device, a scenario of a native system does not record a timestamp of a background service, and in an embodiment of the present application, a problem to be solved first is to modify the native system, and record a timestamp of a start and an end of the background service of a specified service scenario.
After the time stamps of the current page use and the background service use are recorded in the original system, the application use duration can be calculated only by inquiring the recorded foreground event and background time.
Since the time stamps of the opening and closing of the foreground pages are continuous and non-crossed, the time of each segment of foreground use can be accumulated only by using the time length of each segment of segment statistics as shown in fig. 4. However, the calculation mode can only count the foreground use duration of the foreground page, and the calculation of the background use duration with the background service cannot be performed. Because in the practical application scene, the background service and the foreground page can be performed simultaneously, that is, the background service is performed while the foreground page is used, for example, the background service is performed while the mobile phone is playing and listening to the song, in this case, the timestamp section of the foreground page and the timestamp section of the background service are intersected, so that the specific starting time and the specific ending time of one use cannot be accurately determined. In the practical application scenario, the following three situations exist:
case one, no cross and no inclusion relation between the use time of foreground page and the use time of background service
As shown in fig. 5, there are three usage periods, and the total application usage period is: fstop1-start1+ bstop 1-bstop 1+ fstop 2-fstop 2.
Case two, where the foreground page has a cross relation with the use time period of the background service
The usage time period of the two foreground pages has a cross relation with the usage time of the background service, as shown in fig. 6 and 7, wherein the usage time periods of the applications actually used in fig. 6 and 7 are fstop 2-fstop 1 and bstop 2-bstop 1 in sequence.
Case three, the use time period of foreground page and background service has inclusion relation
The usage period of the background service in fig. 8 is included in the usage period of the foreground page, and the usage period of the foreground page in fig. 9 is included in the usage period of the background service, where the actual usage periods of the applications in fig. 8 and 9 are fstop 1-fstop 1 and bsttop 1-bstart1, respectively, in order.
In the embodiment of the present application, there is a relationship of intersection and inclusion with respect to a foreground page and a background service, so that there is a use time of the foreground page and the background service in a time period of one application use, a key to calculate a time length of one device use is to confirm a real starting and ending time point of one application use, and in order to solve this technical problem, in the embodiment of the present application, the step S14 uses a stack structure and all the target events, and calculates an application use time length of the user using the target application in the preset time period specifically includes:
setting the starting time of a target foreground event corresponding to a foreground page of a target application as fstart and the ending time as fstop, and setting the starting time of a target background event corresponding to a background service as bstart and the ending time as bstop; wherein,
step one, when fstart or bstart is detected, storing nodes of the fstart or bstart in a stack, and when the stack is empty, recording the time of the fstart or bstart as the real starting time of the current use target application, and setting the time as r_start, wherein r_start is the time of the stack bottom node;
step two, deleting a stack top node in the current stack when the fstop or the bstop is detected, and setting the fstop or the b_stop as the real ending time of the current use target application as r_stop if the stack is empty after deleting the stack top node;
step three, recording the current time using duration of the target application used by the user at the current time, wherein the current time using duration is as follows: r_stop-r_start;
and step four, repeating the step one to the step three until all time nodes recorded in the preset time period are completely calculated, and accumulating application using time lengths of all times of using the target application by a user in the preset time period, wherein the application using time lengths of the target application comprise the use of a foreground page and the use of a background service, and finally, the calculation of the real application using time lengths of the applications with the foreground page and the background service is realized.
By way of example, the structure of the usage stack and the all target events are further explained below, and the duration of the usage of the application by the user using the target application in the preset period is calculated, for example, in an actual application scenario of a preferred implementation of the present application, if a foreground page (fstart 1) is opened first, a background service (bstart 1) is started in the foreground page, then the foreground page (fstart 1) is exited, then the foreground page (fstart 2) is opened again, the background service (bstart 2) is stopped in the reopened foreground page, then only the reopened foreground page (fstart 2) is restarted, and then the reopened foreground page (fstart 2) is closed again for a while, and finally the reopened background service (bstart 2) is stopped again, as shown in fig. 10, so the actual duration of the usage of the present application is from fstart1 to bstart 2: bstop2-fstart1. The calculation logic of the application use time length through the stack structure is shown in fig. 11, when the fact that the foreground page fstart1 is opened is detected, the stack is empty, fstart1 is put into the stack and used as a stack bottom node, and the recording start time is fstart1; when detecting that the background service bstart1 exists, adding the bstart1 into a stack; when fstop1 is detected, deleting a stack top node bstart1 in the current stack; when the foreground page fstart2 is detected, fstart2 is added to the stack; when the bstop1 is detected, deleting a stack top node fstart2 in the current stack; when the background service bstart2 is detected, adding the bstart2 into a stack; when fstop2 is detected, deleting a stack top node bstart2 in the current stack; when the bstop2 is detected, deleting a stack top node fstart1 in the current stack, wherein the stack is empty, and recording the end time of the current use as bstop2; finally, the duration of the local equipment is calculated to be bstop2-fstart1, namely when the application comprises the use of the foreground page and the background service, the real application use duration of the application is bstop2-fstart1, and the real application use duration of the application is consistent with the overall use duration of the operation of each foreground page and the background service in fig. 10, so that the accurate calculation and determination of the real application use duration of the application with the simultaneous operation of the foreground page and the background service are realized.
In the embodiment of the application, not only the real foreground and background use time length of an application in a preset time period can be calculated, but also the foreground and background use time length in the process that the mobile equipment is used can be calculated, and the method for calculating the foreground and background use time length of the application is provided in one aspect of the application to calculate and realize.
According to another aspect of the present application, there is also provided a non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement a method for computing long-lived in the background as described above.
According to another aspect of the present application, there is also provided an apparatus for calculating a background usage time period of an application, where the apparatus includes:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
the one or more computer-readable instructions, when executed by the one or more processors, cause the one or more processors to implement a method that is long-lived in the context of computing applications as described above.
For details of each embodiment in the device for calculating the application foreground and background use duration, refer to the corresponding portion of the method embodiment for calculating the application foreground and background use duration, and will not be described herein.
In summary, by defining different background events in the running process of the background service of the mobile device, the data structure stored by the background events includes an application to which the event belongs, a timestamp when the event is created, and an event type; registering an event listener for listening to each of the background events with a native system of the mobile device, the native system supporting different foreground events in the running process of a foreground page of the mobile device; monitoring and recording all target events operated by a user when using a target application through the native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event; the structure of the stack and all the target events are used, the application using time of the target application by the user in the preset time period is calculated, the native system of the mobile device is transformed, the native system supports the background events for calculating the operation of the background service, the background events in the operation process of the self-defined background service are recorded to the native system, the statistics of the using time of the foreground and the background in the using process of any time Duan Ren application is finally realized, and the application is expanded on the native system, so that the compatibility is good, the application is accurate and easy to expand, and the statistics of the foreground and the background using time of the application in the market can be met.
It should be noted that the present application may be implemented in software and/or a combination of software and hardware, for example, using Application Specific Integrated Circuits (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software programs of the present application may be executed by a processor to implement the steps or functions as described above. Likewise, the software programs of the present application (including associated data structures) may be stored on a computer readable recording medium, such as RAM memory, magnetic or optical drive or diskette and the like. In addition, some steps or functions of the present application may be implemented in hardware, for example, as circuitry that cooperates with the processor to perform various steps or functions.
Furthermore, portions of the present application may be implemented as a computer program product, such as computer program instructions, which when executed by a computer, may invoke or provide methods and/or techniques in accordance with the present application by way of operation of the computer. Program instructions for invoking the methods of the present application may be stored in fixed or removable recording media and/or transmitted via a data stream in a broadcast or other signal bearing medium and/or stored within a working memory of a computer device operating according to the program instructions. An embodiment according to the present application comprises an apparatus comprising a memory for storing computer program instructions and a processor for executing the program instructions, wherein the computer program instructions, when executed by the processor, trigger the apparatus to operate a method and/or a solution according to the embodiments of the present application as described above.
It will be evident to those skilled in the art that the present application is not limited to the details of the foregoing illustrative embodiments, and that the present application may be embodied in other specific forms without departing from the spirit or essential characteristics thereof. The present embodiments are, therefore, to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. Any reference sign in a claim should not be construed as limiting the claim concerned. Furthermore, it is evident that the word "comprising" does not exclude other elements or steps, and that the singular does not exclude a plurality. A plurality of units or means recited in the apparatus claims can also be implemented by means of one unit or means in software or hardware. The terms first, second, etc. are used to denote a name, but not any particular order.
Claims (7)
1. A method for calculating the use time of an application in the background, which is applied to a mobile device, wherein the method comprises the following steps:
defining different background events in the running process of the background service of the mobile equipment, wherein a data structure stored by the background events comprises an application to which the event belongs, a time stamp when the event is created and an event type;
registering an event listener for listening to each of the background events with a native system of the mobile device, the native system supporting different foreground events in the running process of a foreground page of the mobile device;
monitoring and recording all target events operated by a user when using a target application through the native system and an event monitor thereof in a preset time period, wherein the target events comprise a target background event and a target foreground event;
and calculating the application use duration of the user using the target application in the preset time period by using the stack structure and all the target events.
2. The method of claim 1, wherein the monitoring and recording, by the native system and an event monitor thereof, all target events that are run when a user uses a target application, the target events including a target background event and a target foreground event, within a preset period of time, comprises:
within a preset time period, monitoring all target background events corresponding to all background services operated by a user when using a target application through the event monitor, and writing all monitored target background events into a frame of the native system;
meanwhile, monitoring target foreground events corresponding to all foreground pages operated by a user when using the target application through the native system;
and carrying out serialization storage on all the target background events and all the target foreground events which are arranged on a time axis according to the time sequence.
3. The method of claim 2, wherein the calculating the application usage duration of the user using the target application for the preset period of time using the structure of the stack and the all target events includes:
setting the starting time of a target foreground event corresponding to a foreground page of a target application as fstart and the ending time as fstop, and setting the starting time of a target background event corresponding to a background service as bstart and the ending time as bstop; wherein,
step one, when fstart or bstart is detected, storing nodes of the fstart or bstart in a stack, and when the stack is empty, recording the time of the fstart or bstart as the real starting time of the current use target application, and setting the time as r_start, wherein r_start is the time of the stack bottom node;
step two, deleting a stack top node in the current stack when the fstop or the bstop is detected, and setting the fstop or the b_stop as the real ending time of the current use target application as r_stop if the stack is empty after deleting the stack top node;
step three, recording the current time using duration of the target application used by the user at the current time, wherein the current time using duration is as follows: r_stop-r_start;
and step four, repeating the step one to the step three until all time nodes recorded in the preset time period are completely calculated, and accumulating application using time lengths of all times of using the target application by a user in the preset time period, wherein the application using time lengths of the target application comprise the use of a foreground page and the use of a background service.
4. The method of claim 1, wherein the method further comprises:
registering a process monitor for monitoring application process death of each application to a native system of the mobile device;
and in the preset time period, when a user uses the target application, if the process monitor monitors that the application process of the target application dies, one or more target events which are running the target application are all written into the framework of the original system to finish recording.
5. The method of any of claims 1 to 4, wherein the foreground page is to indicate a UI page for interaction with a user;
the background service is used for indicating the service which can operate in the background without the interaction page.
6. A non-volatile storage medium having stored thereon computer readable instructions which, when executed by a processor, cause the processor to implement the method of any of claims 1 to 5.
7. An apparatus for calculating a background usage time period of an application, wherein the apparatus comprises:
one or more processors;
a computer readable medium for storing one or more computer readable instructions,
when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1 to 5.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311269296.2A CN117312084A (en) | 2023-09-27 | 2023-09-27 | Method and equipment for calculating application foreground and background use duration |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311269296.2A CN117312084A (en) | 2023-09-27 | 2023-09-27 | Method and equipment for calculating application foreground and background use duration |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117312084A true CN117312084A (en) | 2023-12-29 |
Family
ID=89242097
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311269296.2A Pending CN117312084A (en) | 2023-09-27 | 2023-09-27 | Method and equipment for calculating application foreground and background use duration |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117312084A (en) |
-
2023
- 2023-09-27 CN CN202311269296.2A patent/CN117312084A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20060015888A1 (en) | Method of searching for clip differences in recorded video data of a surveillance system | |
TW200307922A (en) | A recording medium for storing virtual deletion information, and recording and/or reproducing method and apparatus. | |
CN112148571A (en) | Method and device for recording and playing back webpage operation process | |
CN111459760A (en) | Micro-service monitoring method and device and computer storage medium | |
CN110795311A (en) | Event playback method and device | |
WO2020118606A1 (en) | Media play control method and system and computer-readable medium | |
CN111901619B (en) | Message pushing method and device | |
EP2560105A1 (en) | Method and device for storing audio data | |
JP2002351466A5 (en) | ||
US20240144975A1 (en) | Audio and video editing method and apparatus, electronic device and storage medium | |
CN117312084A (en) | Method and equipment for calculating application foreground and background use duration | |
CN112685329B (en) | Method for processing data and related device | |
CN112181277B (en) | Data storage space management method and device, storage medium and electronic equipment | |
CN112486831A (en) | Test system, test method, electronic equipment and storage medium | |
EP3816836A1 (en) | Service execution method and apparatus | |
CN108089904B (en) | Display page expansion method and device | |
CN112799951B (en) | Method and equipment for generating automatic test case for charging system | |
CN109587548B (en) | Video playing data calculation method and device | |
CN112769928A (en) | Information interaction method and device based on service scene | |
CN109862193A (en) | It sends a telegram here in a kind of terminal the control method and device of video | |
CN112070533A (en) | Method and equipment for predicting user retention | |
CN110825809A (en) | Storage method and device for drug response information | |
CN112637659B (en) | Media audio playing method, device and system | |
CN102541878A (en) | Method and device for storing project file in non-linear editing | |
CN106454512A (en) | Player event statistical method and device player and terminal equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |