Method for collecting statistics about use duration of terminal, and terminal and storage medium

By monitoring and recording statistical events of terminal devices and combining the time calculation stack solution, the problem of the existing technology inability to count the background operation time of the terminal device when the screen is out is not allowed, and accurate statistics of the real usage time of terminal devices is achieved, helping users better manage time.

WO2025129837A1PCT designated stage expired Publication Date: 2025-06-26SHANGHAI DROI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/084131
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-12-22
Filing Date
2024-03-27
Publication Date
2025-06-26

AI Technical Summary

Technical Problem

The prior art cannot accurately count the usage time of the terminal device in the backend operation under the screen-out state, resulting in the inability to accurately manage the actual usage time of the user.

Method used

By customizing statistical events, listen to and record events such as program start/stop, system turn on/off, and screen turn off, establish event records, and use the duration to calculate the stack plan, and calculate the real usage time of the terminal within the specified time range in the timeline order.

Benefits of technology

It realizes accurate statistics on the usage time of terminal devices in any state (including screen deactivation and background operation), helping users better manage their own time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024084131_26062025_PF_FP_ABST
    Figure CN2024084131_26062025_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides a method for collecting statistics about a use duration of a terminal, and a terminal and a storage medium. The method comprises the steps of: step S100, customizing statistical events, monitoring the statistical events, and recording event types, creation timestamps, and names so as to establish event records; step S200, determining a statistical time range, acquiring event records within the time range, and establishing a duration calculation stack; step S300, when it is determined that the stack is empty, storing an event representing a start state in the event records into the stack according to a time axis sequence, and recording the corresponding creation timestamp of the event as a real starting time a; when an event representing a stop state in the event records occurs, deleting a stack top node, and when it is determined that the stack is empty after the stack top node is deleted, recording the timestamp of the event as a real ending time b; and recording the use duration of the current statistical event as b-a; and step S400, repeating step S300 to calculate a sum of the use durations of the statistical events within the statistical time range. Therefore, the real use duration of the terminal can be accurately calculated in a statistical manner.
Need to check novelty before this filing date? Find Prior Art

Description

Method for counting terminal usage time, terminal, and storage medium Technical Field

[0001] The present invention relates to the technical field of intelligent terminals, and in particular to a method and system for counting terminal usage time, and a storage medium. Background Art

[0002] With the popularity of various mobile terminals, people spend a lot of time playing with their mobile phones every day. One of the important reasons is that people have no intuitive concept of how much time they spend on their mobile phones every day.

[0003] To this end, the prior art has proposed some solutions for counting the usage time of mobile terminals, such as "Terminal Usage Time Reminder Method and Device, Terminal and Storage" (Patent Application Number: 202010265255.6). This method proposes: within a preset time period, obtain and accumulate the usage time of the application running in the foreground to determine the usage time.

[0004] However, these existing technologies only roughly measure the time the device screen is on or the time an app is in the foreground. This is because, for example, the native Android system only provides statistics for the time an app is in the foreground, and therefore does not support recording usage time in specific scenarios, such as when the screen is off. Therefore, conventional solutions cannot address the problem of measuring usage time in the screen-off state. However, some apps often perform other operations (such as playing audio, recording, and making calls) in the background when the screen is off.

[0005] Therefore, how to accurately and reliably calculate the actual usage time of terminal devices within a certain period of time, including screen off and background operation, can greatly help users manage their own time.

[0006] Summary of the Invention

[0007] To this end, the main purpose of the present invention is to provide a method for counting the usage time of a terminal, a terminal, and a storage medium to solve the problems mentioned in the background technology.

[0008] To achieve the above object, according to a first aspect of the present invention, a method for counting terminal usage time is provided, comprising the steps of:

[0009] Step S100 customizes statistical events, monitors statistical events and records event type, creation timestamp, and name to create event records;

[0010] Step S200 determines the statistical time range, obtains event records within the time range, and establishes a duration calculation stack;

[0011] Step S300: When the stack is determined to be empty, the events representing the enabled state in the event record are stored in the stack in chronological order, and the corresponding event creation timestamp is recorded as the real start time a; when an event representing the stopped state occurs in the event record, the top node of the stack is deleted, and when it is determined that the stack is empty after deleting the top node, the event timestamp is recorded as the real end time b; the duration of the current statistical event usage is recorded as b-a;

[0012] Step S400 repeats step S300 to calculate the cumulative usage duration of each statistical event within the statistical time range.

[0013] In a possible preferred implementation, the statistical events include: program start / stop events, system screen on / off events, and each event is recorded in the system data storage space through the framework interface.

[0014] In a possible preferred embodiment, the method for counting terminal usage time further includes the following steps:

[0015] Step S500: When there is only one statistical event or no event within the statistical time range, the event type after the end time point of the time range is determined to calculate the usage duration according to the terminal usage logic.

[0016] In a possible preferred embodiment, the step of monitoring statistical events and establishing event records includes:

[0017] Use AudioManager.AudioPlaybackCallback to monitor the audio playback status. When the audio is started / stopped, at least the creation timestamp information is written into the program start / stop event.

[0018] The current audio application process status is monitored through IProcessObserver. When it is detected that the audio application is killed and the audio application is in the playing state, at least the creation timestamp when the audio application is killed is written into the program stop event.

[0019] In a possible preferred embodiment, the step of monitoring statistical events and establishing event records includes:

[0020] Add an OnRecorderStatusChanged interface in the system framework layer AudioRecorder to monitor the status of the application occupying the Mic. When the start / stop status is monitored, at least the creation timestamp will be written into the program start / stop event.

[0021] In a possible preferred embodiment, the step of monitoring statistical events and establishing event records includes:

[0022] Register a listener with the system to monitor call status changes to monitor the status of the call application. When the answer / hang up status is detected, at least the creation timestamp is written into the program start / stop event.

[0023] In a possible preferred embodiment, the step of monitoring statistical events and establishing event records includes:

[0024] Listen to the startOp and finishOp interfaces of the application operation management class AppOpsManager. When the start / stop status of the positioning program is detected, at least the creation timestamp information is written into the program start / stop event.

[0025] In order to achieve the above-mentioned purpose, corresponding to the above-mentioned method, according to the second aspect of the present invention, a terminal is also provided, which includes: a processor and a memory; wherein the processor is used to execute the computer program stored in the memory to perform the steps of the method for counting the terminal usage time as described in any of the above items.

[0026] In order to achieve the above-mentioned purpose, corresponding to the above-mentioned method, according to the third aspect of the present invention, a computer-readable storage medium is also provided, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the method for counting the terminal usage time as described in any of the above items are implemented.

[0027] The method for counting terminal usage time, the terminal, and the storage medium provided by the present invention can accurately count the actual usage time of the terminal in all usage behavior intersection states within a period of time, and is not subject to the limitation that the program application running in the background after the terminal screen is turned off cannot be counted, thereby providing users with a good usage experience in managing their own time. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are intended to explain the present invention and do not constitute an undue limitation of the present invention. In the accompanying drawings:

[0029] FIG1 is a schematic flow chart of the steps of a method for counting terminal usage time according to the present invention;

[0030] FIG2 is a flow chart showing the steps of monitoring system screen on / off events and establishing event records in the method for counting terminal usage time of the present invention;

[0031] 3 is a schematic flow chart of the steps of monitoring audio program start / stop events and establishing event records in the method for counting terminal usage time of the present invention;

[0032] FIG4 is a flowchart illustrating the steps of monitoring the start / stop event of the Mic program and establishing an event record in the method for counting the terminal usage time of the present invention;

[0033] 5 is a flowchart illustrating the steps of monitoring call program start / stop events and establishing event records in the method for counting terminal usage time of the present invention;

[0034] FIG6 is a flowchart illustrating the steps of monitoring the start / stop event of the positioning program and establishing an event record in the method for counting the terminal usage time of the present invention;

[0035] FIG7 is a schematic diagram of a time axis for calculating device usage time based on the cumulative sum of time differences between system screen on / off events in the prior art;

[0036] 8 to 12 are schematic diagrams of time axes illustrating various intersection states of usage behaviors in the method for counting terminal usage time of the present invention;

[0037] FIG13 is a schematic diagram of a timeline in a usage behavior intersection state using stack calculation in a method for counting terminal usage duration according to the present invention;

[0038] FIG14 is a schematic diagram illustrating a process of using stack calculation in a method for counting terminal usage time according to the present invention;

[0039] FIG15 is a schematic diagram of a time axis illustrating various special scenarios in the method for counting terminal usage time of the present invention. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the specific technical solutions of the present invention will be clearly and completely described below in conjunction with the embodiments to help those skilled in the art further understand the present invention. Obviously, the embodiments described in this case are only embodiments of a part of the present invention, rather than all embodiments. It should be pointed out that, for those of ordinary skill in the art, the embodiments in this application and the features in the embodiments can be combined with each other without departing from the concept of the present invention and without conflicting with each other. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without making creative work should fall within the disclosure and protection scope of the present invention.

[0041] In addition, the terms "first", "second", "S100", "S200", etc. in the specification, claims and drawings of the present invention are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the features used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those described herein. At the same time, the terms "including" and "having" and any variations thereof in the present invention are intended to cover non-exclusive inclusions. Unless otherwise expressly specified and limited, the terms "setting", "laying out", "installing", "connecting" and "connecting" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be a communication between the two elements. For ordinary technicians in this field, the specific meanings of the above terms in this case can be understood according to the specific circumstances and in combination with the existing technology.

[0042] The terminals referred to in the examples of the present invention include: mobile phones, tablet computers, smart TVs, smart watches, car computers, etc., all kinds of smart devices with display screens and capable of running operating systems to execute application tasks.

[0043] Given that the native Android system doesn't have a method for recording device usage time, existing techniques typically monitor the system's screen on / off broadcasts to mark screen on / off operations, record them, and then calculate the cumulative sum of the time differences between each screen on and screen off to represent the device's usage time. As shown in Figure 7, the sum of time periods ①②...N is calculated to represent the total usage time for that period.

[0044] However, if background services are still running when the screen is off, such as listening to music, positioning, recording, making and receiving calls, etc., the timestamps of the screen-off operation and the background services will overlap, making it impossible to accurately calculate the time occupied by background operations in the screen-off state. However, this uncounted time is precisely the actual usage time of the terminal device.

[0045] Therefore, in order to accurately and reliably calculate the actual usage time of the terminal device within a certain period of time, including the screen being off and the background running, as shown in Figures 1 to 6, the method for calculating the terminal usage time provided by the present invention mainly includes the following example steps:

[0046] Step S100 customizes statistical events, monitors statistical events and records event type, creation timestamp, and name to create event records.

[0047] Specifically, taking the Android system as an example, preferred examples of customized statistical events in the present invention include: program startup events, program stop events, system screen-on events, and system screen-off events. Through the classification of these four events, the terminal usage scenarios can basically be covered. At the same time, in order to be able to distinguish events and use them for subsequent usage time statistics, after each statistical event is monitored, the event information of the event will be recorded, including: type, creation timestamp, and name information.

[0048] The event type (enentType) is used to record the start / stop status of the event, such as the system screen on / off status and the program start / stop status. The event creation timestamp (timeStamp) is used to record the timestamp when the event start / stop status is created. The event name (packageName) serves as the unique identifier of the application.

[0049] The following, as shown in FIG. 2 to FIG. 6 , illustrates the process of monitoring various statistical events to establish event records.

[0050] Monitor system screen on / off events:

[0051] As shown in Figure 2, in this example, it is preferred to monitor the system screen on / off broadcast (ACTION_SCREEN_ON / ACTION_SCREEN_OFF), and by adding a custom interface reportEventStaus(int enentType) method in the system, inject the event information corresponding to the system screen on / off event screen_on / screen_off into the place where the system monitors the screen on / off to complete the event recording.

[0052] Monitor audio program start / stop events:

[0053] As shown in Figure 3, first register a listener to monitor audio playback with the system. For example, through AudioManager.AudioPlaybackCallback, you can monitor the application that starts and pauses playback. If the application starts playing, the audio program start event bg_play is recorded. If the application pauses playing, the audio program stop event bg_stop is recorded. Then, use the newly added reportStatusEvent interface to inject the corresponding event information into the system to complete the event recording.

[0054] In addition, since the application process may be forcibly killed, such as the process that is playing music is forcibly killed, the listener cannot detect the pause of the application's music. Therefore, it is also necessary to register a listener for process killing (IProcessObserver) with the system. When it is detected that an application is killed and the application is in the playing state, the audio program stop event bg_stop is recorded, and then the newly added reportStatusEvent interface is used to inject the corresponding event information into the system to complete the event recording.

[0055] Monitor the recording program start / stop events:

[0056] As shown in Figure 4, since the system does not natively monitor recording status changes, the example adds an OnRecorderStatusChanged interface to the AudioRecorder system framework layer. By monitoring this interface, the start / stop status events of the application currently occupying the microphone focus are recorded, just like monitoring the start / stop events of audio programs. The reportStatusEvent interface is then used to inject the corresponding event information into the system to complete event recording.

[0057] Monitor call program start / stop events:

[0058] As shown in Figure 5, a listener (PhoneStateListener) that monitors call status changes is registered with the system. It can monitor call status changes. If the monitored call starts (CALL_STATE_OFFHOOK), the call program start event call_start is recorded. If the monitored call stops, the call program stop event call_stop is recorded, and the reportStatusEvent interface is used to inject corresponding event information into the system to complete event recording.

[0059] Listen for positioning program start / stop events:

[0060] As shown in Figure 6, screen-off positioning is a daily use scenario, and the native Android system does not have an interface for recording positioning status changes. The inventors considered that for runtime permissions such as positioning, which involve hardware call permissions, third-party applications usually perform permission verification in the native system through the following method of AppOpsManager.java (application operation management class) when using terminals (such as mobile phones and tablets) for positioning:

[0061] startOp(@NonNull String op,int uid,@NonNull String packageName);

[0062] Similarly, when third-party applications stop using location services, they will call the following interface to release them:

[0063] finishOp(@NonNull String op,int uid,@NonNull String packageName);

[0064] Therefore, based on the above two characteristics, when the positioning service starts and stops, that is, when the above interface is called synchronously, the corresponding positioning program start / stop status event can be recorded, and the reportStatusEvent interface can be used to inject the corresponding event information into the system to complete the event recording.

[0065] In addition, in a preferred embodiment, each event in this example preferably writes the event record into the system data storage space through the framework interface to avoid data loss in situations such as terminal restart.

[0066] After obtaining the event record of step S100, a common practice is to establish a calculation formula for different usage scenarios based on the time axis to calculate the usage duration, for example:

[0067] Assumptions:

[0068] screen_off1: indicates the first screen-off event point of the device (and so on);

[0069] screen_on1: indicates the first time the device turns on the screen (and so on);

[0070] bg_start1: indicates the first start event point of the background audio service (and so on);

[0071] bg_stop1: indicates the first stop event point of the background audio service (and so on).

[0072] Figure 8 shows a scenario where the screen on / off time and background service usage time do not overlap or overlap within the timeline. In this scenario, there are three usage periods, with a total usage time of: screen_off1–screen_on1+bs_top1–bs_start1+screen_off2–screen_on1.

[0073] Figures 9 and 10 show scenarios where the screen on / off timeframe overlaps with the background service usage timeframe. In Figure 9, the total usage time is screen_off2 - screen_on1, and in Figure 10, the total usage time is bg_stop2 - bg_start1.

[0074] Figures 11 and 12 show scenarios where the screen on / off time period and background service usage time period are included within the time axis. Figure 11 shows a scenario where the background usage time period is included within the screen on / off time period, with the total usage time being: screen_off1 - screen_on1. Figure 12 shows a scenario where the screen on / off time period is included within the background usage time period, with the total usage time being: bg_stop1 - bg_start1.

[0075] According to the above calculation logic, it can be seen that the five calculation schemes shown in Figures 8 to 12 have covered the more common terminal usage scenarios. Generally speaking, to settle the usage time in these scenarios, you can calculate the terminal usage time in each scenario separately by establishing a logical calculation formula for each scenario, but this calculation method is relatively cumbersome and primitive.

[0076] To this end, the present invention designs a duration calculation stack solution to cleverly and efficiently calculate the actual usage duration of the terminal within a preset time range based on the event records obtained in step S100.

[0077] The duration calculation stack solution includes:

[0078] Step S200 determines a statistical time range, obtains event records within the time range, and establishes a duration calculation stack.

[0079] In step S300, when the stack is judged to be empty, the events representing the enabled state (such as screen-on events, program startup events) in the event record are stored in the stack in the order of the time axis, and the corresponding event creation timestamp is recorded as the real start time a; when an event representing the stopped state (such as screen-off events, program stop events) occurs in the event record, the top node of the stack is deleted, and when it is judged that the stack is empty after deleting the top node of the stack, the event timestamp is recorded as the real end time b; the usage duration of the current statistical event is recorded as b-a.

[0080] Step S400 repeats step S300 to calculate the cumulative usage duration of each statistical event within the statistical time range.

[0081] Specifically, in scenarios where the screen-on and screen-off time periods overlap and include background computing services, the key to calculating the time a terminal is used is to confirm the actual start and end time points of the terminal's use.

[0082] The following example uses the duration calculation stack to calculate the usage time of a music app.

[0083] The first step is to set the time range to be counted, and then find the statistical events and their event information within the time range in the event log.

[0084] In the second step, when screen_on or bg_start is detected, the nodes of screen_on and bg_start are stored in the stack. When the stack is empty, the time of screen_on or bg_start is recorded as the real start time of the application phase, which is real_start, which is also the time of the bottom node of the stack.

[0085] In the third step, when screen_off or bg_stop is detected, the top node of the stack is deleted. If the stack is empty after deleting the top node, screen_off and bg_stop are the actual end times of the application usage period, set to real_stop. At this time, the application usage time of the first period is real_stop – real_start.

[0086] The fourth step is to repeat the second to third steps until all the time nodes of all applications in the time range are calculated. After the final accumulation, the actual usage time of the terminal within the time range can be calculated.

[0087] To demonstrate the effectiveness of the aforementioned duration calculation stack, Figure 13 illustrates a terminal usage scenario: the screen is first turned on, a background service is started while the screen is on, the screen is then turned off, the screen is then turned on again, the background service is stopped while the screen is on, the screen is then turned on again, the background service is started again, the screen is turned off again, and the background service is finally stopped. Therefore, the actual application usage time for this period should be from screen_on1 to bg_stop2 = bg_stop2 – screen_on1.

[0088] Figure 14 illustrates the derivation process of the usage duration calculation stack. The final result is that the terminal's usage duration within this time range is bg_stop2 – screen_on1, which is consistent with the scenario described in Figure 13.

[0089] On the other hand, as shown in FIG15 , there are also some special scenarios that require additional special processing of the algorithm. For this reason, the present invention further designs some supplementary steps to expand the statistical range of adaptation, such as:

[0090] Step S500: When there is only one statistical event or no event within the statistical time range, the event type after the end time point of the time range is determined to calculate the usage duration according to the terminal usage logic.

[0091] Specifically, the usage logic is:

[0092] In scenario ① of Figure 15 , when there is only one system screen-on event, screen_on, within the statistical time range, determine whether there is a program start / stop event after the end time point of the time range. If there is a program stop event, the actual usage duration is the duration of the statistical time range; if there is a program start event, the actual usage duration is end-screen_on.

[0093] In the scenario of Figure 15, when there is only one system screen-off operation screen_off within the statistical time range, determine whether there is a program start / stop event after the end time point of the time range end; if there is a program start event, the actual usage duration is screen_off - the start time point of the time range start; if there is a program stop event, the actual usage duration is the duration of the statistical time range.

[0094] In the scenario of Figure 15, when there is only one program startup event, such as bg_start, within the statistical time range, determine whether there is a system screen-on event, screen_on, or screen-off event, after the end time point of the time range. If there is a system screen-on event, the actual usage duration is end-bg_start. If there is a system screen-off event, the actual usage duration is the duration of the statistical time range.

[0095] In the scenario of Figure 15, when there is only one program stop event, such as bg_stop, within the statistical time range, determine whether there is a system screen-on event screen_on / screen-off event screen_off after the end time point of the time range; if there is a system screen-off event, the actual usage duration is the duration of the statistical time range; if there is a system screen-on event, the actual usage duration is bg_stop-the beginning of the time range start.

[0096] In the scenario of Figure 15, when there is no event within the statistical time range, determine whether there is a screen_off, screen_on, bg_start, or bg_stop event after the end time point of the time range; if there is a screen_off or bg_stop event, the actual usage duration is the duration of the statistical time range; if there is a screen_on event and the next event is bg_stop, the actual usage duration is the duration of the statistical time range; if it is any other event, the actual usage duration is 0; if there is a bg_start event and the next event is screen_off, the actual usage duration is the duration of the statistical time range; if it is any other event, the actual usage duration is 0.

[0097] On the other hand, corresponding to the above method, the present invention also provides a terminal, which includes: a processor and a memory; wherein the processor is used to execute the computer program stored in the memory to perform the steps of the method for counting the terminal usage time as described in any of the above items.

[0098] On the other hand, corresponding to the above method, the present invention also provides a computer-readable storage medium on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the method for counting the terminal usage time as described in any of the above items are implemented.

[0099] To sum up, the method for counting terminal usage time, terminal, and storage medium provided by the present invention can accurately count the actual usage time of the terminal under all usage behavior intersection states within a period of time, and is not subject to the limitation that program applications running in the background after the terminal screen is turned off cannot be counted, thereby providing users with a good usage experience in managing their own time.

[0100] The preferred embodiments of the present invention disclosed above are only used to help illustrate the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made based on the contents of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can better understand and utilize the present invention. The present invention is only limited by the claims and their full scope and equivalents. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

[0101] Those skilled in the art will understand that, in addition to implementing the systems, devices, units, and their respective modules provided by the present invention in purely computer-readable program code, it is entirely possible to implement the same programs in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. by logically programming the method steps. Therefore, the systems, devices, and their respective modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.

[0102] In addition, all or part of the steps in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a program. The program is stored in a storage medium and includes a number of instructions for causing a single-chip microcomputer, chip, or processor to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., various media that can store program code.

[0103] In addition, various implementations of the embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the embodiments of the present invention, they should also be regarded as the contents disclosed in the embodiments of the present invention.

Claims

1. A method for counting terminal usage time, comprising the steps of: Step S100 customizes statistical events, monitors statistical events and records event type, creation timestamp, and name to establish event records; Step S200 determines the statistical time range, obtains event records within the time range, and establishes a duration calculation stack; Step S300: When it is determined that the stack is empty, the events representing the enabled state in the event record are stored in the stack according to the timeline order, and the corresponding event creation timestamp is recorded as the real start time a; When an event representing a stop state occurs in the event record, the top node of the stack is deleted, and when it is determined that the stack is empty after deleting the top node, the event timestamp is recorded as the real end time b; the duration of the current statistical event is recorded as b-a; Step S400 repeats step S300 to calculate the cumulative usage duration of each statistical event within the statistical time range.

2. The method for counting terminal usage time according to claim 1, wherein the statistical events include: Program start / stop events, system screen on / off events, each event is recorded in the system data storage space through the framework interface.

3. The method for counting terminal usage time according to claim 1, wherein the steps further include: Step S500: When there is only one statistical event or no event in the statistical time range, the event type after the end time point of the time range is determined to calculate the usage duration according to the terminal usage logic.

4. The method for counting terminal usage time according to claim 2, wherein the step of monitoring statistical events and establishing event records comprises: Through AudioManager.AudioPlaybackCallback, monitor the audio playback status. When the start / stop audio is monitored, at least the creation timestamp information is written into the program start / stop event. The current audio application process state is monitored through IProcessObserver. When it is detected that the audio application is killed and the audio application is in the playing state, at least the creation timestamp when the audio application is killed is written into the program stop event.

5. The method for counting terminal usage time according to claim 2, wherein the step of monitoring statistical events and establishing event records comprises: Add an OnRecorderStatusChanged interface in the system framework layer AudioRecorder to monitor the status of the application occupying the Mic. When the start / stop status is monitored, at least the creation timestamp is written into the program start / stop event.

6. The method for counting terminal usage time according to claim 2, wherein the step of monitoring statistical events and establishing event records comprises: Register a listener to monitor call status changes with the system to monitor the status of the call application. When the answer / hang up status is detected, at least the creation timestamp is written into the program start / stop event.

7. The method for counting terminal usage time according to claim 2, wherein the step of monitoring statistical events and establishing event records comprises: Listen to the startOp and finishOp interfaces of the application operation management class AppOpsManager. When the start / stop status of the located program is detected, at least the creation timestamp information is written into the program start / stop event.

8. A terminal, comprising: A processor and a memory; wherein the processor is used to execute a computer program stored in the memory to perform the steps of the method for counting the terminal usage time as described in any one of claims 1-7.

9. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method for counting terminal usage time as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • A method and a device for displaying current states of applications in recent tasks

    CN106126226A

  • Method and device for acquiring application usage data and terminal equipment

    CN106293445A

  • Terminal use time management method and device

    CN106326065A

  • Terminal use duration reminding method and device thereof, terminal and storage medium

    CN111479016A

  • Statistical method and device for operation events in terminal system, terminal and storage medium

    CN112395470A

Cited By

  • Mobile terminal application running state statistical method based on counter

    CN120723607A