Statistical applications using data methods and electronic devices
By saving event data of uninstalled applications through a delayed deletion mechanism, the problem of data loss after application uninstallation is solved, accurate statistics of application usage data are achieved, and the user experience is improved.
Patent Information
- Application Number
- CN202311647798.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-01
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2043-12-01
AI Technical Summary
When an application is uninstalled from an electronic device, its usage data is deleted, leading to inaccurate statistics and affecting the user experience.
A delayed deletion mechanism is adopted to save the event data of uninstalled applications to a second storage space, and the data is migrated and saved through healthy use of mobile applications to ensure data integrity.
It improves the accuracy of application usage data statistics, ensuring that usage data of uninstalled applications is fully collected, thus enhancing the user experience.
Smart Images

Figure CN118445159B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronics, in particular to a method for counting application usage data and an electronic device. BACKGROUND
[0002] With the increasing richness of functions of electronic devices, users can obtain more and more information or data through electronic devices. For example, taking a mobile phone as an electronic device, the mobile phone provides a health function of using the mobile phone, and the user can obtain his / her usage data on the mobile phone or an application at any time through the function, including but not limited to the total time length of using the mobile phone, the time length of using a certain application, and the like.
[0003] However, if a certain application is uninstalled after being used for a period of time, the usage data of the application in the electronic device will be deleted, which will result in inaccurate application usage data counted by the electronic device. SUMMARY
[0004] The present application provides a method for counting application usage data and an electronic device, which can improve the accuracy of counting application usage data by the electronic device.
[0005] In a first aspect, the present application provides a method for counting application usage data, which is executed by an electronic device and includes: in the case of receiving an uninstall operation on a first application, obtaining a first event corresponding to the first application from a first storage space, and saving the first event corresponding to the first application in a second storage space, wherein the first event is used for the electronic device to count usage data of the first application, and the second storage space is used for storing the first event corresponding to an uninstalled application; after a second preset time length, deleting the first event corresponding to the first application from the first storage space; in the case of receiving an operation of triggering the foreground running of a second application, obtaining the first event corresponding to the first application from the second storage space, and counting the usage data of the first application based on the first event corresponding to the first application.
[0006] The first application can be any one of the applications (such as an application program A) installed in the electronic device, and the first event corresponding to the first application is stored in the first storage space, that is, when the first event of the first application occurs, the electronic device will first store the first event in the first storage space, and then if the first application is uninstalled, the electronic device will delete the first event of the first application from the first storage space. In some implementation manners, the first storage space is a usage counting database.
[0007] In a case where the first application is uninstalled, the electronic device can acquire the first event corresponding to the first application from the first storage space, and save the first event corresponding to the first application in the second storage space, i.e., the second storage space stores the first event corresponding to the uninstalled application. In this way, even if the electronic device deletes the first event corresponding to the first application from the first storage space later, the first event corresponding to the first application is retained in the second storage space. It should be noted that the electronic device needs to delete the first event corresponding to the first application from the first storage space after the second preset time period (i.e., a delayed deletion mechanism is adopted), so as to reserve time for the electronic device to acquire the first event and save it to the second storage space. Then, in a case where an operation of triggering the second application to run in the foreground is received, the second application can acquire the first event corresponding to the first application from the second storage space, and count the usage data of the first application based on the first event corresponding to the first application.
[0008] In some implementations, the second application can be a health usage mobile application or a health usage tablet application, i.e., the application is used to count the usage data of the electronic device. In some implementations, the second storage space is a database corresponding to the second application.
[0009] Optionally, the second preset time period can be 30 seconds.
[0010] In the above implementations, if an application program is uninstalled, the electronic device can delay deleting the state event and the like information corresponding to the application program, and the second application can migrate and save the information, so that the electronic device can count the usage data of the uninstalled application, and accurately count the usage data of the application.
[0011] In combination with the first aspect, in some implementations of the first aspect, the first event includes an Activity state event corresponding to the first application.
[0012] In a case where the first application is started, the electronic device can create a corresponding Activity. The Activity class provides a callback method for each life cycle, so as to know the state of the current Activity. In a case where the state of the Activity changes, the electronic device can call the callback method to acquire and record the current Activity state event. For example, the Activity state event includes but is not limited to an Activity_Started event, an Activity_Resumed event, an Activity_Paused event, and an Activity_Stopped event, which are used in a subsequent process of counting the usage data of the first application.
[0013] With reference to the first aspect, in some implementations of the first aspect, in a case where the uninstall operation on the first application is received, the method further includes: saving the identifier of the first application in a third storage space.
[0014] Correspondingly, after the second preset time period, the method further includes: deleting the identifier of the first application from the third storage space.
[0015] The third storage space can be used to save the identifier (such as package name information) of the first application when the first application is uninstalled, so that the electronic device can know which application is uninstalled. Correspondingly, if the electronic device wants to delete the first event corresponding to the first application, the identifier of the first application can also be deleted from the third storage space. In some implementations, the third storage space can be a memory. In other implementations, the third storage space can also be the second storage space described above, that is, the database corresponding to the second application.
[0016] With reference to the first aspect, in some implementations of the first aspect, the electronic device includes a package management service and a usage statistics service, in a case where the uninstall operation on the first application is received, the first event corresponding to the first application is obtained from the first storage space, and the first event corresponding to the first application is saved in the second storage space, including:
[0017] The package management service detects the uninstall command, performs the uninstall operation on the first application; the package management service broadcasts a message that the first application is uninstalled; the second application receives the broadcast, and obtains the first event corresponding to the first application from the first storage space through the usage statistics service; the second application saves the first event corresponding to the first application in the second storage space.
[0018] When the first application receives the uninstall operation, an uninstall command can be generated, and the package management service detects the uninstall command and performs the uninstall operation on the first application. Then, the package management service can broadcast a corresponding uninstall message to notify the services and applications in the electronic device that the first application has been uninstalled. After receiving the broadcast that the first application is uninstalled, the second application can immediately query the first event corresponding to the first application and other information from the usage statistics service, because the usage statistics service adopts a delayed deletion mechanism, that is, the first event corresponding to the first application is still saved in the first storage space corresponding to the usage statistics service. Then, the second application can query these information from the first storage space through the usage statistics service and save them in its own database (that is, the second storage space). Therefore, when the electronic device subsequently performs statistics on application usage data, the usage data of the uninstalled application can be counted, and the application usage data can be accurately counted.
[0019] In some implementations of the first aspect, the deleting the first event corresponding to the first application from the first storage space after the second preset time period comprises: receiving a broadcast using the statistics service, and deleting the first event corresponding to the first application from the first storage space after the second preset time period.
[0020] That is, the statistics service uses a delayed deletion mechanism to delete the first event corresponding to the first application from the first storage space after a second preset time period after receiving the broadcast that the first application is uninstalled. The delayed deletion mechanism is used to enable the second application to obtain the first event corresponding to the first application for statistics.
[0021] In some implementations of the first aspect, the first event comprises a picture-in-picture (PIP) window change event and a floating window change event corresponding to the first application.
[0022] In some scenarios, the electronic device can not display the display interface of the first application in full screen or split screen, but can display the interface of the first application in a floating window or a picture-in-picture window. In this display mode, the first application is also in use. Therefore, to further improve the accuracy of the application usage data, the electronic device can also count the usage data of the first application in the floating window display state and the picture-in-picture window display state. Therefore, the first event can comprise the PIP window change event and the floating window change event in addition to the Activity state event.
[0023] In some implementations of the first aspect, before receiving the uninstall operation of the first application, the method further comprises: saving a PIP window change event corresponding to the first application in the first storage space when a PIP window state corresponding to the first application changes; and saving a floating window change event corresponding to the first application in the first storage space when a floating window state corresponding to the first application changes.
[0024] That is, if the electronic device detects that the PIP window state corresponding to the first application changes, for example, from a closed state to an open state, the corresponding PIP window change event can be saved in the first storage space. In some implementations, the PIP window change event can include an Activity_Enter_PIP event and an Activity_Exit_PIP event. In addition, if the electronic device detects that the floating window state corresponding to the first application changes, for example, from a closed state to an open state, the corresponding floating window change event can be saved in the first storage space. In some implementations, the floating window change event can include an Overlay_Window_Visibile event and an Overlay_Window_inVisibile event. When the electronic device subsequently counts the usage data of the first application, the first time can be calculated based on the Activity state event of the first application, the second time can be calculated based on the PIP window change event of the first application, and the third time can be calculated based on the floating window change event of the first application. The sum of the first time, the second time, and the third time is the usage time of the first application. In this way, the accuracy of counting application usage data is further improved.
[0025] In combination with the first aspect, in some implementations of the first aspect, in a case where the operation of triggering the second application to run in the foreground is received, the method further includes: obtaining, from the first storage space, the first event corresponding to each application other than the first application, and counting the usage data of each application based on the first event corresponding to each application.
[0026] In some scenarios, when the second application runs in the foreground, the usage statistics of the electronic device are displayed, which can include how long the electronic device has been used and the usage time of each application. To determine the usage time of each application, the electronic device needs to obtain the first event corresponding to each application from the first storage space, calculate the usage time of each application based on the system time corresponding to the first event, and then calculate the total usage time of the electronic device based on the usage time of each application.
[0027] In combination with the first aspect, in some implementations of the first aspect, after counting the usage data of the first application and counting the usage data of each application, the method further includes: displaying, on the running interface of the second application, the usage statistics of the electronic device, the usage statistics of the electronic device including the usage data of the first application and the usage data of each application, and the first application being displayed with an uninstalled marker on the running interface of the second application.
[0028] That is, when displaying the use statistics of the electronic device on the running interface of the second application, the second application can mark the uninstalled application, for example, mark as uninstalled, so that the user can know which application has been uninstalled.
[0029] In some implementations of the first aspect, before receiving the uninstall operation of the first application, the method further includes: saving the Activity state event corresponding to the first application in the first storage space in a case where the Activity state corresponding to the first application changes.
[0030] That is, if the electronic device detects that the Activity state corresponding to the first application changes, for example, changes from the Resumed state to the Paused state, the corresponding Activity change event can be saved in the first storage space for subsequent statistics of the use data of the first application.
[0031] In some implementations, the first storage space also stores the system time corresponding to the Activity state event.
[0032] In some implementations of the first aspect, saving the Activity state event corresponding to the first application in the first storage space includes: saving the Activity state event corresponding to the first application in a third storage space; after a first preset time period, saving the Activity state event corresponding to the first application in the third storage space in the first storage space, and deleting the Activity state event corresponding to the first application in the third storage space.
[0033] That is, after the electronic device obtains the Activity state event and other information, it does not immediately save these information in the first storage space, but uses a delayed saving mechanism to temporarily store the Activity state event and other information in the third storage space (for example, memory), and then save the data in the memory to the first storage space after a first preset time period, and clear the first storage space. Optionally, the first preset time period can be 20 minutes. Thus, by using the delayed saving mechanism, the number of accesses to the first storage space can be reduced, and the communication power consumption inside the electronic device can be reduced.
[0034] In a second aspect, the present application provides a device, which is included in an electronic device, and has the function of implementing the behavior of the electronic device in the first aspect and the possible implementations of the first aspect. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above functions. For example, a receiving module or unit, a processing module or unit, etc.
[0035] In a third aspect, the present application provides an electronic device, comprising a processor, a memory and an interface; the processor, the memory and the interface cooperate with each other, so that the electronic device executes any one of the methods in the technical solutions of the first aspect.
[0036] In a fourth aspect, the present application provides a chip comprising a processor. The processor is configured to read and execute a computer program stored in a memory, so as to execute the method in the first aspect and any possible implementation manner thereof.
[0037] Optionally, the chip further comprises a memory, and the memory is connected to the processor through a circuit or a wire.
[0038] Further optionally, the chip further comprises a communication interface.
[0039] In a fifth aspect, the present application provides a computer readable storage medium, and the computer readable storage medium stores a computer program. When the computer program is executed by a processor, the processor executes any one of the methods in the technical solutions of the first aspect.
[0040] In a sixth aspect, the present application provides a computer program product, and the computer program product comprises computer program code. When the computer program code runs on an electronic device, the electronic device executes any one of the methods in the technical solutions of the first aspect. BRIEF DESCRIPTION OF DRAWINGS
[0041] Figure 1 FIG. 1 is a schematic diagram of a setting interface of a healthy use of a mobile phone function provided by an embodiment of the present application;
[0042] Figure 2 FIG. 2 is a schematic diagram of another setting interface of a healthy use of a mobile phone function provided by an embodiment of the present application;
[0043] Figure 3 FIG. 3 is a schematic diagram of still another setting interface of a healthy use of a mobile phone function provided by an embodiment of the present application;
[0044] Figure 4 FIG. 4 is a schematic diagram of a running interface of a healthy use of a mobile phone function provided by an embodiment of the present application;
[0045] Figure 5 FIG. 5 is a schematic diagram of a structure of an electronic device provided by an embodiment of the present application;
[0046] Figure 6 FIG. 6 is a software structure block diagram of an electronic device provided by an embodiment of the present application;
[0047] Figure 7 FIG. 7 is a flowchart of a method for counting application use data provided by an embodiment of the present application;
[0048] Figure 8 is another example of a setting interface provided by an embodiment of the present application for health use of a mobile phone function;
[0049] Figure 9 is another example of a flowchart of a method for statistics application use data provided by an embodiment of the present application. DETAILED DESCRIPTION
[0050] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " represents the meaning of or, for example, A / B can represent A or B; "and / or" in this document only describes the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can represent the three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0051] Hereinafter, the terms "first", "second", "third" are only for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with "first", "second", "third" can explicitly or implicitly include one or more features.
[0052] With the increasing functions of electronic devices, users can obtain more and more information or data through electronic devices. For example, users can check news, social messages, entertainment games, etc. through electronic devices. In the process of using electronic devices, electronic devices also provide use statistics functions, for example, taking a mobile phone as an example, the mobile phone provides a health use of mobile phone function, taking a tablet computer as an example, the tablet computer provides a health use of tablet function, users can obtain their use data on the mobile phone or tablet (or the installed application) at any time through the function, including but not limited to the total time length of using the mobile phone or tablet, the time length of using a certain application, etc.
[0053] Exemplarily, as shown in Figure 1 , taking a mobile phone as an example, on the setting interface of the electronic device, there is a health use of mobile phone control 11, in the case that the user clicks the health use of mobile phone control 11, the electronic device can jump to the setting interface of the health use of mobile phone. On the setting interface of the health use of mobile phone, there is use statistics information of the electronic device, for example, how long the electronic device has been used and the use time of each application, and there are also various setting controls.
[0054] For each setting control, for example Figure 1As shown in FIG. 1, the setting interface of healthy use of the mobile phone includes a usable time control 12, which can be used to set the total time of screen use per day. If the user clicks the usable time control 12, the electronic device can jump to the usable time setting interface as shown in FIG. 2. Figure 2 On the usable time setting, the user can make settings of the usable time, including but not limited to settings for weekdays and rest days respectively. Exemplarily, if the user clicks the weekdays control 21, the electronic device can jump to the interface for editing the usable time, on which the user can edit the name, the repetition mode, and the daily usable time respectively, and click the complete control 22 after the editing is completed. If the user no longer needs to set the usable time for weekdays, the user can select the delete control 23 on the interface for editing the usable time, that is, the control rule of limiting the use time for weekdays can be deleted. In addition, the user can also add the usable time on the usable time setting interface of FIG. 2 according to the user's own needs, that is, the user can personalize the control rule of limiting the use time. Figure 2
[0055] Continuing to refer to FIG. 1, Figure 1 The setting interface of healthy use of the mobile phone also includes an application quota control 13, which can be used to set the use time of the application. If the user clicks the application quota control 13, the electronic device can jump to the application quota setting interface as shown in FIG. 3. Figure 3 On the application quota setting interface, the user can make quota settings for different applications respectively, such as shown in FIG. 3. Figure 3 As shown in FIG. 3, the user can click an application icon at will, for example, the map application icon 31 is clicked, and the electronic device can pop up the quota setting box for the map application, which includes the setting controls of different limiting modes. Exemplarily, if the user does not need to make quota settings for the map application, the user can click the switch control 32 of always allowed to set as always allowed to use the map application; if the user needs to prohibit the use of the map application (that is, the map application cannot be run at any time), the user can click the switch control 33 of prohibited use to set as prohibited use of the map application; if the user needs to make quota settings for the map application, the user can click the switch control 34 of limited time use and set the quota time in the time list below, for example, set as 1 hour, that is, only allow the use of the map application for 1 hour per day.
[0056] On the setting interface of healthy use of the mobile phone, in addition to the above-mentioned usable time control 12 and application quota control 13, the stop time control, remote daemon control, etc. can also be included, and the functions thereof will not be described herein.
[0057] It's understandable that if a user sets the above settings on their electronic device—for example, setting a total daily usage time of 6 hours, or setting a daily limit of 1 hour for a specific application—then the electronic device will display a message indicating that the usage time has expired and further use is not permitted after the set time is reached. For example, in a scenario where the limit for a map application is set to 1 hour, the message displayed on the electronic device would look like this: Figure 4 As shown, under the prompt of "Healthy Mobile Use", the message "Today's available time has been used up, the 'Map' app is unavailable" is displayed.
[0058] When the "Healthy Phone Use" function is enabled on an electronic device, the "Healthy Phone Use" application (or module) within the device records the device's or application's running time. Once the set running time has elapsed, the "Healthy Phone Use" application will launch and display the aforementioned information. Figure 4 The prompt interface shown is shown. However, if an application is uninstalled after a period of use, its usage data on the electronic device will be deleted, and the application's usage data will no longer be displayed in the Healthy Use of Phone app. In this case, if the electronic device calculates the total usage time for the day, it will not include the usage time of the uninstalled application. This results in the electronic device calculating less usage time than the actual usage time, meaning the calculated application usage data is inaccurate, affecting the user experience. For example, if the electronic device's actual usage time for the day is 6 hours, it should display a "Phone can no longer be used" prompt interface. However, because an application was uninstalled, its usage time for the day (let's say 2 hours) was not included in the calculation, meaning the electronic device calculates only 4 hours of usage time, and therefore the "Phone can no longer be used" prompt interface will not be displayed, leading the user to mistakenly believe that the set usable time has not yet been reached.
[0059] The reason for this is that the data source for the health-related mobile application in the relevant technology comes from the usage statistics service (UsageStatsService) on the electronic device. The usage statistics service can record the status events of each application, and the health-related mobile application can query the status events of the applications and count the usage time of the applications from the usage statistics service. However, the health-related mobile application does not save this data. When an application is uninstalled, the usage statistics service will delete the status event data related to that application. Therefore, the health-related mobile application can no longer query the status events of that application, and thus cannot count the usage data of that application.
[0060] In view of this, this application provides a method for statistical analysis of application usage data. When an application is uninstalled, a statistical service can be used to delay the deletion of the application's status event-related data, and the Healthy Usage mobile application can migrate and save the relevant data, thereby enabling the Healthy Usage mobile application to accurately analyze application usage data.
[0061] It should be noted that the method for counting application usage data provided by the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), and the like, which provide an application usage data counting function. The embodiments of the present application do not limit the specific type of electronic device.
[0062] An exemplary, Figure 5 is a structural schematic diagram of an example electronic device 100 provided by the embodiments of the present application. Taking the electronic device as a mobile phone as an example, the electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, and the like. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, and the like.
[0063] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors.
[0064] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of instruction fetching and instruction execution.
[0065] The memory in the processor 110 can also be configured to store instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. Avoiding repeated access reduces the waiting time of the processor 110, thus improving the efficiency of the system.
[0066] The wireless communication function of the electronic device 100 can be realized through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0067] The wireless communication module 160 can provide a solution for wireless communication, including wireless local area networks (WLAN) (such as a wireless fidelity (Wi-Fi) network), Bluetooth (BT), a global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, and the like, which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency-modulates and filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 can also receive signals to be transmitted from the processor 110, frequency-modulate them, amplify them, and radiate them as electromagnetic waves via the antenna 2.
[0068] The electronic device 100 implements a display function through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs that execute program instructions to generate or change display information.
[0069] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 performs various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required for a function (such as a sound playing function, an image playing function, and the like), and the like. The data storage area can store data created during use of the electronic device 100 (such as audio data, a phonebook, and the like), and the like. In addition, the internal memory 121 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
[0070] The indicator 192 can be an indicator light, which can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, and the like.
[0071] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than illustrated, or combine certain components, or split certain components, or different arrangement of components. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.
[0072] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take the Android system with a layered architecture as an example to illustrate the software structure of the electronic device 100.
[0073] Figure 6 is a software structure block diagram of the electronic device 100 of the embodiments of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer, the Android runtime and system library, and the kernel layer. The application layer can include a series of application packages.
[0074] As shown in Figure 6 , the application package can include camera, gallery, call, map, WLAN, Bluetooth, video, short message, settings, health use of mobile phone and other applications.
[0075] Among them, the settings application can be used by the user to set different functions, such as the above-mentioned settings of the health use of mobile phone function. The health use of mobile phone application can be used to manage the use of the electronic device or the application that has started the control function, such as managing the running time of the application.
[0076] The application framework layer provides the application layer with application programming interfaces (APIs) and programming frameworks for the applications. The application framework layer includes some pre-defined functions.
[0077] As shown in Figure 6 , the application framework layer can include activity manager service (AMS), activity record module (ActivityRecord), usage statistics service (UsageStatsService), usage statistics database (UsageStatsDatabase), package manager service (PackageManagerService), window manager, etc.
[0078] Android Application Management System (AMS) is a core component of the Android operating system. It acts as the application manager, responsible for managing the application lifecycle, task stack, process and activity switching, and more. AMS plays a crucial role in the Android system, ensuring applications can run correctly and interact with the user. Task stack management refers to the mechanism in the Android system for organizing and managing application activities (Activities). Each task stack corresponds to one application or a group of related activities. When a user launches a new Activity in an application, the system adds the task to which that Activity belongs to a task stack. For each Activity launched in an application, there is a corresponding ActivityRecord. The ActivityRecord monitors and records changes in the Activity's state and reports the Activity's state to AMS. AMS then reports the Activity state events to the usage statistics service. After receiving the Activity state events, the usage statistics service associates the Activity state events with the corresponding applications and saves them in the usage statistics database. It can also save the system time corresponding to the state events.
[0079] When a user uninstalls application A, the package management service detects the uninstallation command, executes the uninstallation operation, and broadcasts the uninstallation message to the usage statistics service and the healthy usage app. Upon receiving the broadcast, the usage statistics service can delete relevant data about application A (including but not limited to corresponding Activity state events and the system time corresponding to those state times) from the usage statistics database after a preset delay. During this preset time, the healthy usage app can query the usage statistics service for relevant data about application A, which is then stored in its corresponding database.
[0080] The window manager is used to manage window programs. The window manager can obtain the screen size, determine if a status bar is present, lock the screen, capture the screen, and record the state of the windows displayed on the screen, such as whether it is currently in full-screen mode, split-screen mode, or floating window mode.
[0081] In addition to the above, the application framework layer may also include content providers, view systems, phone managers, resource managers, notification managers, etc. Figure 6 (Not shown in the image).
[0082] The content provider stores and provides access to the data for the applications. The view system includes visual controls, such as a control to display text, a control to display an image, and the like. The view system can be used to build an application. The display interface can be composed of one or more views. The telephony manager provides the communication functionality of the electronic device 100. The resource manager provides various resources, such as localized strings, icons, images, layout files, video files, and the like, to the applications. The notification manager enables the applications to display notification information in the status bar, which can be used to convey a message of the notification type, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to notify the completion of a download, a message reminder, and the like. The notification manager can also be a notification that appears in the form of a chart or a scroll bar text in the status bar at the top of the system, such as a notification of an application running in the background, and can also be a notification that appears in the form of a dialog window on the screen. For example, a text message is prompted in the status bar, a prompt sound is emitted, the electronic device vibrates, an indicator light blinks, and the like.
[0083] The Android runtime includes a core library and a virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0084] The core library includes two parts: one part is a function function that the java language needs to call, and the other part is the core library of Android.
[0085] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the java files of the application layer and the application framework layer into binary files. The virtual machine is used to perform the management of the object life cycle, the management of the stack, the management of the thread, the management of the security and the exception, and the garbage collection, and the like.
[0086] The system library can include a plurality of functional modules. For example: a surface manager, media libraries, a three-dimensional graphics processing library (for example: OpenGL ES), a 2D graphics engine (for example: SGL), and the like.
[0087] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for a plurality of applications. The media library supports a plurality of commonly used audio, video format playback and recording, and static image files, and the like. The media library can support a plurality of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, and the like. The three-dimensional graphics processing library is used to realize three-dimensional graphics drawing, image rendering, synthesis, and layer processing, and the like. The 2D graphics engine is a drawing engine for 2D drawing.
[0088] The kernel layer is a layer between hardware and software. The kernel layer at least contains a display driver, a camera driver, an audio driver, and a sensor driver.
[0089] For ease of understanding, the following embodiments of the present application will take an electronic device with the structure shown in Figure 5 and Figure 6 as an example, and the method for counting application usage data provided by the embodiments of the present application will be described in detail in combination with the drawings and application scenarios.
[0090] First of all, the following embodiments take the opening, closing, backgrounding, uninstalling, and other operations of an application program A as an example to describe the usage process of the application. In the usage process of the application program A, the usage data of the application program A can be counted in the electronic device, and the specific process is as follows:
[0091] Figure 7 is a flowchart of a method for counting application usage data provided by an embodiment of the present application. The method comprises:
[0092] S11, the application program A receives a first operation.
[0093] The first operation herein can be an operation of opening or closing the application program A by the user, that is, triggering the application program A to start running or stop running. Illustratively, the first operation can be a click operation of the user on the icon of the application program A on the electronic device to open the application program A.
[0094] S12, the ActivityRecord detects that the Activity state changes, and reports the Activity state to the AMS.
[0095] Generally, when the application program A starts, the electronic device creates a corresponding Activity. The Activity class provides a callback method for each life cycle to know the state of the current Activity. For example, when the application program A starts, the state of the Activity is the started state (i.e., the Started state), and the onStart method callback is triggered. At this time, the ActivityRecord created along with the start of the Activity detects that the Activity state changes, that is, changes to the started state, and reports the Activity state to the AMS.
[0096] With the start of the application A running, after the execution of the onStart method is completed, the Activity enters a continued state (i.e., a Resumed state), and triggers the onResume method callback, at this time, the Activity is located at the top of the activity stack, is displayed in the foreground interface of the electronic device and supports interaction with the user, and the ActivityRecord monitors that the Activity state changes to the continued state. During the running of the application A, when the Activity loses focus or an interruption event occurs (for example, the application A retreats to the background, the electronic device enters a sleep state, etc.), the Activity enters a paused state (i.e., a Paused state), and triggers the onPause method callback, the onPause method call is the first sign that the user will leave the current Activity, at this time, the function of the Activity that is no longer located in the foreground can be stopped and resources can be released, and the ActivityRecord monitors that the Activity state changes to the paused state. During the running of the application A, when the Activity is completely invisible to the user, for example, when the electronic device jumps to a new Activity to occupy the display screen or the user closes the interface of the application A, the Activity enters a stopped state (i.e., a Stopped state), and triggers the onStop method callback, at this time, the ActivityRecord monitors that the Activity state changes to the stopped state. It can be understood that the ActivityRecord can report the monitored Resumed state, Paused state and Stopped state to the AMS. It can also be understood that if it is a scenario in which the user closes the interface of the application A, the Activity corresponding to the application A will be unregistered, and then the ActivityRecord will be destroyed.
[0097] In some implementations, when the ActivityRecord monitors that the Activity state changes, the recorded Activity state information includes but is not limited to: a ProcessRecord app (running in which process), a TaskRecord task (running in which task), an Activity Type, an Activity state, an Applicatoninfo (running in which application), a System Time, etc. The ActivityRecord can report the recorded information to the AMS, that is, the ActivityRecord associates the Activity state with the application (such as the identifier of the application) and reports it to the AMS, so that the AMS knows which application the Activity state belongs to.
[0098] S13, the AMS reports the Activity state event and the corresponding system time to the usage statistics service based on the Activity state.
[0099] The AMS can report the current state corresponding Activity state event and the corresponding system time to the usage statistics service (UsageStatsService) according to the Activity life cycle state after receiving the Activity state change. It can be understood that the AMS will register to obtain the service from the usage statistics service in advance, and the usage statistics service can return the service object to the AMS, so that the AMS can subsequently report the event data to the usage statistics service.
[0100] In some implementations, the Activity state event can include an Activity_Started event, an Activity_Resumed event, an Activity_Paused event, and an Activity_Stopped event. The Activity_Started event corresponds to the Started state described above, indicating that the Activity starts to start. The Activity_Resumed event corresponds to the Resumed state described above, indicating that the Activity will interact with the user, and at this time the Activity is located at the top of the activity stack. The Activity_Paused event corresponds to the Paused state described above, indicating that the Activity loses the system focus. The Activity_Stopped event corresponds to the Stopped state described above, indicating that the Activity becomes invisible.
[0101] S14, the usage statistics service saves the Activity state event and the corresponding system time to the usage statistics database.
[0102] After receiving the Activity state event and the corresponding system time and other information, the usage statistics service can save these information to the usage statistics database (UsageStatsDatabase) for subsequent query when needed.
[0103] In some implementations, after receiving information such as the Activity state event by the usage statistics service, the information is not immediately saved into the usage statistics database, but a delayed saving mechanism is adopted, and the information such as the Activity state event is temporarily stored in the memory, and after the first preset time length, the data in the memory is saved into the usage statistics database, and the memory is emptied. The specific process can be: the usage statistics service receives the first Activity state event, saves the information such as the state event in the memory, and if the state event is the first event saved in the memory, starts a timer to time a first preset time length, and within the first preset time length, the state events received by the usage statistics service are all saved in the memory. After reaching the first preset time length, the usage statistics service saves the information such as the state event in the memory into the usage statistics database, and empties the memory. Subsequently, if the usage statistics service receives the Activity state event again, it will also be saved in the memory (at this time it is the first event saved in the memory), and then the timer is started to time the first preset time length, and so on. Optionally, the first preset time length can be 20 minutes. It can be understood that the Activity state events saved in the usage statistics database can correspond to the identifier of the application program, that is, the Activity state events corresponding to the application program are saved. Thus, by using the delayed saving mechanism, the number of accesses to the usage statistics database can be reduced, and the communication power consumption inside the electronic device can be reduced.
[0104] S15, the health use mobile phone application receives a second operation.
[0105] Optionally, the second operation can be a click operation on the health use mobile phone control 11 in the above Figure 1 , to enter the setting interface of the health use mobile phone.
[0106] S16, the health use mobile phone application queries the usage statistics service for the Activity state events corresponding to each application program in the electronic device on the current date.
[0107] As can be seen from the above Figure 1 , the setting interface of the health use mobile phone includes the usage statistics information of the electronic device, which can include how long the electronic device has been used and the usage time of each application. Therefore, if the health use mobile phone application wants to determine the usage time of each application program, it needs to query the usage statistics service for the Activity state events corresponding to each application program on the current date, calculate the usage time of each application program based on the system time corresponding to the Activity state event, and then calculate the total usage time of the electronic device based on the usage time of each application program.
[0108] For example, assuming that the current date is January 1, 2023, the use statistics information of the electronic device displayed by the health use mobile phone application is the use time of the electronic device on January 1, 2023 and the use time of each application program.
[0109] In some implementations, the health use mobile phone application can also query the use statistics service for all Activity state events corresponding to each application program in the electronic device, and subsequently, the use time of each application program on the same date and the total use time of the electronic device can be respectively calculated according to the Activity state events corresponding to the application program on the same date.
[0110] S17, the use statistics service obtains, from the use statistics database, the Activity state events corresponding to each application program on the current date.
[0111] S18, the use statistics service returns the Activity state events corresponding to each application program on the current date to the health use mobile phone application.
[0112] The Activity state events corresponding to each application program include, but are not limited to, Activity_Started events, Activity_Resumed events, Activity_Paused events and Activity_Stopped events. Generally, if an application program is run, there will be a corresponding Activity_Started event. If the application program is closed, there will also be a corresponding Activity_Stopped event. If the application program is backgrounded, there will also be a corresponding Activity_Paused event. That is, the Activity_Started event will appear in pairs with other state events. It can be understood that each Activity state event will also correspond to the system time when the event occurs.
[0113] S19, the health use mobile phone application calculates and displays the use statistics information of the electronic device according to the Activity state events corresponding to each application program.
[0114] For the use time of each application in the use statistics information of the electronic device, the health use mobile phone application can calculate based on each Activity state event of the application. Taking application A as an example, if the Activity state event of application A contains a pair of Activity_Started event and Activity_Paused event, the use time of application A is the result of the system time corresponding to the Activity_Paused event minus the system time corresponding to the Activity_Started event; for example, the system time corresponding to the Activity_Paused event is 12:30:00, and the system time corresponding to the Activity_Started event is 12:00:00, so the use time of application A is 12:30:00-12:00:00=30 minutes. If the Activity state event of application A contains a pair of Activity_Started event and Activity_Stopped event, the use time of application A is the result of the system time corresponding to the Activity_Stopped event minus the system time corresponding to the Activity_Started event; for example, the system time corresponding to the Activity_Stopped event is 12:40:00, and the system time corresponding to the Activity_Started event is 12:00:00, so the use time of application A is 12:40:00-12:00:00=40 minutes. If application A experiences the processes of retreating to the background, switching to the foreground running, and closing during the running process, application A is suspended in the background during the period from retreating to the background to switching to the foreground running, and this period of time should not be calculated into the use time, then the use time of application A is the result of the system time corresponding to the retreat to the background minus the system time corresponding to the start state, plus the result of the system time corresponding to the closing minus the system time corresponding to the switching to the foreground running. If application A experiences multiple start and close, the use time of application A is the sum of the results of each Activity_Stopped event corresponding to the system time minus the Activity_Started event corresponding to the system time. Similarly.
[0115] For the total time currently used by the electronic device in the use statistics information of the electronic device, the health use mobile phone application can accumulate the use time of the application that has been run to obtain. For example, the use statistics information displayed by the electronic device is as shown in the above Figure 1 .
[0116] S20, application A receives a third operation.
[0117] The third operation can be an operation of uninstalling the application A for the user, i.e., deleting the application A from the electronic device. Alternatively, the third operation can be a long-press operation of an icon of the application A on the electronic device, and selecting an uninstall option in a pop-up menu to trigger uninstalling the application A.
[0118] S21, the package management service detects the uninstall command and performs an uninstall operation on the application A.
[0119] When the application A receives the third operation (i.e., the uninstall operation), an uninstall command can be generated, and the package management service (PackageManagerService) detects the uninstall command and performs an uninstall operation on the application A. Generally, when the package management service performs the uninstall operation on the application A, the installation package and related data of the application A can be completely deleted.
[0120] S22, the package management service broadcasts a message that the application A is uninstalled.
[0121] That is, after the package management service performs the uninstall operation on the application A, the corresponding uninstall message can be broadcasted to notify the services and applications in the electronic device that the application A has been uninstalled, and the above-mentioned usage statistics service and the health use phone application can receive the broadcast. It can be understood that the package management service carries the identifier of the application A (e.g., the package name information of the application A) in the broadcast to notify other services and applications which application is uninstalled.
[0122] S23, the usage statistics service receives the broadcast and saves the identifier of the application A in the memory.
[0123] S24, after a second preset time period, the usage statistics service deletes the identifier of the application A from the memory and deletes the Activity state event corresponding to the application A from the usage statistics database.
[0124] After receiving the broadcast that the application A is uninstalled, the usage statistics service saves the identifier of the application A (e.g., the package name information) in the memory, e.g., in a file in the memory or in the above-mentioned usage statistics database, and then uses a delayed deletion mechanism to delete the identifier of the application A from the memory and delete the Activity state event corresponding to the application A from the above-mentioned usage statistics database after a second preset time period. The purpose of using the delayed deletion mechanism is to enable the health use phone application to still obtain the Activity state event corresponding to the application A for statistics. Alternatively, the second preset time period can be 30 seconds.
[0125] In some scenarios, if the electronic device is powered off by the user within the second preset time length, the subsequent deletion operation will fail, and the identifier of the application A in the memory and the information of the Activity state event corresponding to the application A in the usage statistics database still exist, then after the electronic device is powered on, the usage statistics service can check whether these information exist, and if they exist, the identifier of the application A in the memory is immediately deleted, and the Activity state event corresponding to the application A in the usage statistics database is deleted.
[0126] S25, the health usage mobile application receives the broadcast, obtains the Activity state event corresponding to the application A on the current date from the usage statistics service, and saves it.
[0127] After receiving the broadcast that the application A is uninstalled, the health usage mobile application can immediately query the Activity state event corresponding to the application A on the current date from the usage statistics service, because the usage statistics service adopts a delayed deletion mechanism, that is, the usage statistics database corresponding to the usage statistics service still saves the Activity state event corresponding to the application A, then the health usage mobile application can query these information from the usage statistics database through the usage statistics service, and save them to its own database. In some implementation manners, the database corresponding to the health usage mobile application is only used to store the Activity state event corresponding to the uninstalled application.
[0128] In some implementation manners, the database corresponding to the health usage mobile application can save the Activity state event corresponding to the application A for a third preset time length, and optionally, the third preset time length can be 7 days.
[0129] S26, after the second preset time length, the health usage mobile application receives a fourth operation.
[0130] Among them, the fourth operation can be an operation of the user opening the health usage mobile application, for example, it can be the clicking operation of the health usage mobile control 11 in the above Figure 1 to enter the setting interface of the health usage mobile application.
[0131] S27, the health usage mobile application obtains the Activity state event corresponding to each application (excluding the application A) on the current date from the usage statistics service, and obtains the Activity state event corresponding to the application A on the current date from the database.
[0132] The process in which the health use mobile application obtains the Activity state events corresponding to each application program on the current date from the use statistics service can refer to the processes of S16-S18 described above. However, it should be noted that at this time, the second preset time period has passed, and the use statistics service has deleted the data of the application program A in the use statistics database. Therefore, the Activity state events obtained by the health use mobile application do not include the Activity state events corresponding to the application program A, and the Activity state events corresponding to the application program A are obtained by the health use mobile application from its own database.
[0133] S28, the health use mobile application calculates and displays the use statistics information of the electronic device.
[0134] The implementation process of this step can refer to the process of S19 described above. When displaying the use statistics information of the electronic device, the health use mobile application can mark the uninstalled application program A, for example, as uninstalled, so that the user can know which application programs have been uninstalled. For example, the use statistics information of the electronic device displayed by the health use mobile application can be as shown in FIG. 8. Figure 8 As shown in FIG. 8, the application has been uninstalled.
[0135] In some implementations, if the database corresponding to the health use mobile application saves the Activity state events corresponding to the application program A for a third preset time period, the user can also query the use statistics information of the electronic device within the third preset time period. If the user views the use statistics information of the electronic device at a time (e.g., 2023.01.03) after the current date (e.g., 2023.01.01), the use time of the application program A on 2023.01.01 can be included in the statistics, but the use time of the application program A after 2023.01.01 is not included (because the application program A has been uninstalled on 2023.01.01).
[0136] In the above embodiments, if an application program is uninstalled, the use statistics service in the electronic device can delay deleting the Activity state events and other information corresponding to the application program, and the health use mobile application can migrate and save these information. Therefore, the health use mobile application can count the use time of the uninstalled application program, and accurately count the use data of the application program.
[0137] In some scenarios, during the running of the electronic device, for example, the electronic device is running an application A, if the electronic device is full-screen display or split-screen display of the display interface of the application A, the statistical service can record the Activity state event corresponding to the application A. However, if the electronic device is a floating window display or a picture in picture (PIP) window display of the display interface of the application A, the statistical service in the related technology cannot record the window change event, and therefore, in the scenario that the application A is displayed in a floating window or a PIP window, the use time of the application A is not counted, that is, the statistical application use data is inaccurate.
[0138] Based on this, based on the above-mentioned embodiments, when the display window state of the application A changes, the window change event can be reported to the AMS, and then the AMS reports the window change event to the use statistical service, so as to realize accurate statistics of the use time of the application A.
[0139] Specifically, Figure 9 is a flowchart of another example method for counting application use data provided by the embodiments of the present application, the method comprising:
[0140] S31, the application A receives the fifth operation.
[0141] The fifth operation can be an operation input by a user to display the application A in a PIP window or to exit the PIP window display of the application A. For example, assuming that the application A is a video application, the user is watching a video using the video application, and then opens other interfaces, the video application can be displayed in a small window floating on the other interfaces, that is, the PIP window is opened; if the user switches the application A to full-screen display, the PIP window is exited.
[0142] S32, the ActivityRecord monitors the change of the PIP window state and reports the PIP window state to the AMS.
[0143] The PIP window state can generally include an open state and a closed state, if the PIP window state is the open state, the PIP window is visible, and if the PIP window state is the closed state, the PIP window is invisible. In the case that the ActivityRecord monitors the change of the PIP window state, the current PIP window state can be sent to the AMS.
[0144] S33, the AMS reports the PIP window change event and the corresponding system time to the use statistical service based on the PIP window state.
[0145] That is to say, after the AMS receives the PIP window state, the corresponding PIP window change event can be reported to the usage statistics service according to the PIP window state (open state or closed state). It can be understood that the AMS will register to obtain the service from the usage statistics service in advance, and the usage statistics service can return the service object to the AMS, so that the AMS can subsequently report the event data to the usage statistics service.
[0146] In some implementations, the PIP window change event can include an Activity_Enter_PIP event and an Activity_Exit_PIP event, the Activity_Enter_PIP event representing that the Activity interface of an application program exits and enters the PIP window display state, and the Activity_Exit_PIP event representing that the Activity interface of an application program enters and exits the PIP window display state. If the application program A is displayed in the PIP window, the Activity_Enter_PIP event and the Activity_Exit_PIP event will appear in pairs.
[0147] In some implementations, the PIP window change event can include an Activity_Enter_PIP event and an Activity_Exit_PIP event, the Activity_Enter_PIP event representing that the Activity interface of an application program exits and enters the PIP window display state, and the Activity_Exit_PIP event representing that the Activity interface of an application program enters and exits the PIP window display state. If the application program A is displayed in the PIP window, the Activity_Enter_PIP event and the Activity_Exit_PIP event will appear in pairs.
[0148] In some implementations, the PIP window change event can include an Activity_Enter_PIP event and an Activity_Exit_PIP event, the Activity_Enter_PIP event representing that the Activity interface of an application program exits and enters the PIP window display state, and the Activity_Exit_PIP event representing that the Activity interface of an application program enters and exits the PIP window display state. If the application program A is displayed in the PIP window, the Activity_Enter_PIP event and the Activity_Exit_PIP event will appear in pairs.
[0149] In some implementations, after receiving the PIP window change event and the like information using the statistical service, the information is not immediately saved into the usage statistics database, but a delayed saving mechanism is adopted, and the PIP window change event and the like information is temporarily stored in the memory first, and then the data in the memory is saved into the usage statistics database after a first preset time length, and the memory is emptied. The specific process can be: the usage statistics service receives the first PIP window change event, saves the change event and the like information in the memory, and if the change event is the first event saved in the memory, starts a timer to time a first preset time length. Within the first preset time length, the change events received by the usage statistics service will be saved in the memory first. After reaching the first preset time length, the usage statistics service saves the change event and the like information in the memory into the usage statistics database, and empties the memory. Subsequently, if the usage statistics service receives the PIP window change event again, it will also be saved in the memory first (at this time, it is the first event saved in the memory), and then the timer will be started to time the first preset time length, and so on. Optionally, the first preset time length can be 20 minutes. It can be understood that the PIP window change event saved in the usage statistics database can correspond to the identifier of the application program, that is, the PIP window change event corresponding to the application program is saved. Thus, by using the delayed saving mechanism, the number of accesses to the usage statistics database can be reduced, and the communication power consumption inside the electronic device can be reduced.
[0150] S35, the application program A receives a sixth operation.
[0151] The sixth operation can be an operation input by the user to display the application program A as a floating window or to exit the floating window display of the application program A. For example, assuming that the application program A is a video application, when the user is browsing on other interfaces, the video application is triggered to be displayed as a floating window through the selection control of the side bar of the electronic device, and the video application can be displayed as a floating window on the other interfaces. If the user closes the floating window or switches the floating window to full-screen display, the floating window display is exited.
[0152] In some implementations, the fifth operation and the sixth operation in S31 and S35 above can also be input by the user through the system user interface (SystemUI) of the electronic device, that is, the start of the PIP window or the floating window is triggered through the operable control provided on the UI interface.
[0153] S36, the window manager monitors the change of the floating window state and reports the floating window state to the AMS.
[0154] The state of the floating window can generally include an open state and a closed state. If the state of the floating window is the open state, the floating window is visible. If the state of the floating window is the closed state, the floating window is invisible. In a case where the window manager (WindowState) detects a change in the state of the floating window, the current state of the floating window can be sent to the AMS.
[0155] S37, the AMS reports the floating window change event and the corresponding system time to the usage statistics service based on the state of the floating window.
[0156] That is, after the AMS receives the state of the floating window, the corresponding floating window change event can be reported to the usage statistics service according to the state of the floating window (open state or closed state).
[0157] In some implementations, the floating window change event can include an Overlay_Window_Visibile event and an Overlay_Window_inVisibile event. The Overlay_Window_Visibile event represents that the floating window of the application is in a visible state, and the Overlay_Window_inVisibile event represents that the floating window of the application is in an invisible state. If the application A is displayed in the floating window, the Overlay_Window_Visibile event and the Overlay_Window_inVisibile event will appear in pairs.
[0158] S38, the usage statistics service saves the floating window change event and the corresponding system time to the usage statistics database.
[0159] After the usage statistics service receives the floating window change event and the corresponding system time and other information, the information can be saved to the usage statistics database (UsageStatsDatabase) for subsequent query when needed.
[0160] In some implementations, after the usage statistics service receives the floating window change event and other information, the information is not immediately saved to the usage statistics database, but a delayed saving mechanism is adopted. The floating window change event and other information are temporarily stored in the memory first. After a first preset time, the data in the memory is saved to the usage statistics database, and the memory is emptied. The specific process can be referred to S34 described above, and will not be described here.
[0161] S39, the health mobile application usage application receives a seventh operation.
[0162] Here, the seventh operation can be the user opening the Healthy Usage mobile application, i.e., triggering the Healthy Usage mobile application to start running. Optionally, the seventh operation can be one of the above... Figure 1 Clicking on the "Healthy Use of Mobile Phone Control 11" will take you to the settings interface for healthy mobile phone use.
[0163] S40, the health usage mobile application queries the usage statistics service for usage events of each application on the electronic device for the current date.
[0164] From the above Figure 1 As can be seen, the settings interface for healthy mobile phone use includes usage statistics of electronic devices. These statistics can include how long the electronic device has been used and the usage time of each application. If the healthy mobile phone use application wants to determine the usage time of each application, it needs to query the usage statistics service for the usage events corresponding to each application on the current date, calculate the usage time of each application based on the system time corresponding to the usage events, and then calculate the total usage time of the electronic device based on the usage time of each application.
[0165] S41, Use the statistics service to retrieve usage events for each application corresponding to the current date from the usage statistics database.
[0166] S42 uses the statistics service to return the usage events corresponding to each application for the current date to the health usage mobile application.
[0167] It should be noted here that the usage events queried by the health usage mobile application at this time include the Activity state events, PIP window change events, and floating window change events mentioned above.
[0168] S43, the Healthy Use mobile app calculates and displays usage statistics for electronic devices based on usage events corresponding to each application.
[0169] Among them, the healthy use of mobile applications can be calculated based on the application's Activity state events to calculate the first time, based on the application's PIP window change events to calculate the second time, and based on the application's floating window change events to calculate the third time. The sum of the first time, the second time, and the third time is the usage time of the application.
[0170] The process of calculating the first time based on the application's Activity state events for healthy use of mobile applications can be found in the description of S19 above, and will not be repeated here. The process of calculating the second time based on the application's PIP window change events may include: for paired Activity_Enter_PIP and Activity_Exit_PIP events, the system time corresponding to the Activity_Exit_PIP event minus the system time corresponding to the Activity_Enter_PIP event is the time when the application is displayed in a PIP window, which is the second time. The process of calculating the third time based on the application's overlay window change events may include: for paired Overlay_Window_Visibile and Overlay_Window_inVisibile events, the system time corresponding to the Overlay_Window_inVisibile event minus the system time corresponding to the Overlay_Window_Visibile event is the time when the application is displayed in a overlay window, which is the third time.
[0171] The total usage time of an electronic device, as shown in the usage statistics, can be obtained by summing up the usage time of all previously run applications in the health usage mobile application. For example, the usage statistics displayed by the electronic device are as described above. Figure 1 As shown.
[0172] It's understandable that if application A is uninstalled, when the "Healthy Use of Mobile App" retrieves usage events for application A from the usage statistics service, it can obtain the corresponding Activity state events, PIP window change events, and floating window change events, and store these events in its own database. Then, the usage statistics service can use a delayed deletion mechanism to remove the corresponding Activity state events, PIP window change events, and floating window change events from the usage statistics database. Consequently, the "Healthy Use of Mobile App" can calculate the usage time of application A based on these event data.
[0173] In the above embodiments, if an application has been displayed as a PIP window or a floating window, the usage statistics service in the electronic device can record the PIP window change event and the floating window change time corresponding to the application. When the Healthy Use of Mobile App counts the usage time of application A, the time when the application is displayed as a PIP window or a floating window can also be counted. Thus, the Healthy Use of Mobile App can count the usage time of the application in various display states and accurately count the application usage data.
[0174] The foregoing has detailed examples of methods for using data in statistical applications provided in the embodiments of this application. It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.
[0175] This application embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0176] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.
[0177] The electronic device provided in this embodiment is used to execute the above-described method for using statistical application data, and therefore can achieve the same effect as the above-described implementation method.
[0178] When using integrated units, the electronic device may further include a processing module, a storage module, and a communication module. The processing module is used to control and manage the operation of the electronic device. The storage module supports the execution of stored program code and data. The communication module supports communication between the electronic device and other devices.
[0179] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a digital signal processor (DSP), and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.
[0180] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 5 The device with the structure shown.
[0181] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it causes the processor to perform the method for statistical application usage data of any of the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0182] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the statistical application data usage method described in the above embodiments.
[0183] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory; wherein the memory is used to store computer execution instructions, and when the apparatus is running, the processor may execute the computer execution instructions stored in the memory to cause the chip to execute the statistical application data usage method in the above method embodiments.
[0184] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0185] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0186] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0187] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for a statistical application to use data, the method being executed by an electronic device, characterized by, The electronic device comprises an activity record module, an activity management service (AMS), a window manager, a package management service and a usage statistics service, and the method comprises the following steps: In the case of receiving an operation of displaying and exiting a picture-in-picture (PIP) window display of a first application, the activity record module monitors a change in a PIP window state, reports the PIP window state to the AMS, the PIP window state is an open state when the first application is displayed in a PIP window, and the PIP window state is a closed state when the first application exits the PIP window display; The AMS reports a PIP window change event and a corresponding system time to the usage statistics service based on the PIP window state, the usage statistics service saves the PIP window change event and the corresponding system time to a first storage space, the PIP window change event comprises an event of the first application entering a PIP window display state and an event of the first application exiting the PIP window display state; In the case of receiving an operation of displaying and exiting a floating window display of the first application, the window manager monitors a change in a floating window state, reports the floating window state to the AMS, the floating window state is an open state when the first application is displayed in a floating window, and the floating window state is a closed state when the first application exits the floating window display; The AMS reports a floating window change event and a corresponding system time to the usage statistics service based on the floating window state, the usage statistics service saves the floating window change event and the corresponding system time to the first storage space, the floating window change event comprises an event of the first application's floating window being in a visible state and an event of the first application's floating window being in an invisible state; In the case of receiving an uninstall operation of the first application, the package management service detects an uninstall command, and performs an uninstall operation on the first application; The package management service broadcasts a message that the first application is uninstalled; A second application receives the broadcast, acquires a first event corresponding to the first application and a system time corresponding to the first event from the first storage space through the usage statistics service, and saves the first event corresponding to the first application and the system time corresponding to the first event in a second storage space, wherein the first event corresponding to the first application comprises an Activity state event corresponding to the first application, the PIP window change event and the floating window change event, the first storage space is used to store first events corresponding to all applications on the electronic device, the second storage space is used to store first events corresponding to uninstalled applications, and the second application is used to count usage data of the electronic device; The usage statistics service receives the broadcast, adopts a delayed deletion mechanism, and deletes the first event corresponding to the first application from the first storage space after a second preset time period. In a case where an operation of triggering the second application to run in the foreground is received, the second application acquires a first event corresponding to the first application from the second storage space, and acquires a first event corresponding to each application other than the first application from the first storage space; Based on the first event corresponding to the first application, usage data of the first application is counted, and based on the first event corresponding to each application other than the first application, usage data of the each application is counted, the usage data of the first application including usage time of the first application, and the usage data of the each application including usage time of the each application.
2. The method of claim 1, wherein, In a case where an uninstall operation of the first application is received, the method further includes: storing an identifier of the first application in a third storage space; Correspondingly, after the second preset time period, the method further includes: deleting the identifier of the first application from the third storage space.
3. The method according to claim 1 or 2, characterized in that, After counting the usage data of the first application and counting the usage data of the each application, the method further includes: displaying usage statistical information of the electronic device on a running interface of the second application, the usage statistical information of the electronic device including the usage data of the first application and the usage data of the each application, and the first application being displayed with an uninstallation mark on the running interface of the second application.
4. The method of claim 1, wherein, Before the receiving of the uninstall operation of the first application, the method further includes: in a case where an Activity state corresponding to the first application changes, storing an Activity state event corresponding to the first application in the first storage space.
5. The method of claim 4, wherein, The first storage space further stores system time corresponding to the Activity state event.
6. The method according to claim 4 or 5, characterized in that, The storing of the Activity state event corresponding to the first application in the first storage space includes: storing the Activity state event corresponding to the first application in a third storage space; after a first preset time period, storing the Activity state event corresponding to the first application in the third storage space in the first storage space, and deleting the Activity state event corresponding to the first application in the third storage space.
7. The method of claim 1, wherein, The second application is a health phone usage application.
8. An electronic device, comprising: comprise: one or more processors; one or more memories; The memory stores one or more programs, when the one or more programs are executed by the processor, the electronic device executes the method of any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, when the computer program is executed by the processor, the processor executes the method of any one of claims 1 to 7. The computer readable storage medium stores a computer program, when the computer program is executed by the processor, the processor executes the method of any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for managing application programs in mobile terminal
CN105824670A
Application use duration statistical method and device, equipment and storage medium
CN114036152A
Method for counting use duration of application, electronic equipment and readable storage medium
CN116662130A