Method and system for locating energy consumption anomalies of mobile applications
By collecting and analyzing event and resource usage dynamic information of mobile applications, the trigger points of abnormal power consumption are identified, solving the problem of difficulty in locating the root cause of abnormal power consumption in existing technologies. This enables accurate location and rapid repair of various causes, thereby improving the battery life of mobile devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN INST OF ADVANCED TECH
- Filing Date
- 2019-12-12
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies struggle to accurately pinpoint the root cause of abnormal power consumption in mobile applications, especially power consumption issues caused by reasons other than sleep-related anomalies, leading to resource waste and reduced battery life.
By collecting dynamic information on events and resource usage during the operation of mobile applications, analyzing power consumption changes, identifying trigger points that cause abnormal power consumption, using instrumentation technology to mark events and normalize them, and combining preset thresholds and frequency thresholds to filter abnormal instances, accurate location can be achieved.
It can accurately pinpoint abnormal power consumption caused by various reasons, helping developers quickly fix problems and improve the battery life of mobile devices.
Smart Images

Figure CN112988526B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of mobile applications, and in particular to a method and system for locating abnormal energy consumption in mobile applications. Background Technology
[0002] In mobile applications, anomalies that generate excessive power consumption are common. For example, some sensors on mobile devices may not release their power promptly after use, leading to abnormal power consumption. This phenomenon causes unnecessary waste of resources, significantly increases the power consumption of mobile devices, and severely impacts battery life. Although users can easily detect these anomalies after they occur, they often struggle to accurately recall the circumstances and methods that triggered them. Therefore, without this relevant information, application developers find it difficult to pinpoint the root cause or trigger point (under what circumstances and during what operation) of the power consumption anomaly, making it challenging to resolve the problem. Therefore, identifying the root cause of power consumption anomalies is crucial for resolving such issues.
[0003] Existing technologies include methods such as static analysis (dataflow analysis) to determine whether relevant resources in an application have not been properly released. For example, in some applications, wakelocks are not properly released after use, preventing the CPU from entering sleep mode and causing unnecessary power consumption. However, these methods can only detect power consumption anomalies triggered by no-sleep bugs. They cannot effectively detect power consumption anomalies caused by other reasons (configuration issues, loop issues) or accurately locate the root cause of power consumption anomalies, which has significant limitations. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a method and system for locating abnormal power consumption in mobile applications to solve the above problems.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] This invention provides a method for locating energy consumption anomalies in mobile applications, comprising: collecting event dynamic information and resource usage dynamic information during the operation of the mobile application; obtaining power consumption changes between instances corresponding to different time points in each event based on the event dynamic information and resource usage dynamic information; analyzing and confirming all abnormal instances whose power consumption changes exceed a preset threshold relative to other instances of the same type, as well as the sequence of events for each abnormal instance; and selecting the trigger point that causes energy consumption anomalies in the mobile application from all abnormal instances and their sequence of events.
[0007] Preferably, the event dynamic information and resource usage dynamic information are event dynamic information and resource usage dynamic information during the user interaction process.
[0008] Preferably, the event dynamic information includes mobile application state transition events and user interaction events.
[0009] Preferably, the method for collecting event dynamic information during the operation of a user's mobile application includes: decompressing and decompiling the application package of the mobile application; performing instrumentation on the mobile application to mark events that need to be recorded; recompiling and packaging to obtain the instrumented application package of the mobile application; and after installing the mobile application from the instrumented application package, obtaining the event dynamic information according to the markings.
[0010] Preferably, the method for collecting dynamic information on resource usage during the operation of a mobile application includes: periodically reading the hardware usage information of the mobile application at a preset period.
[0011] Preferably, the method for obtaining the power consumption changes between instances corresponding to different time points in each event based on the event dynamic information and resource usage dynamic information includes: obtaining the energy consumption of the mobile application at each time point, the start time of various events, and the end time of various events based on the event dynamic information and the resource usage dynamic information, so as to integrate and obtain the power consumption information of each event in each interaction with the user; and performing normalization processing on the instances corresponding to different time points in each event to obtain the relative power consumption changes between different instances in each event.
[0012] Preferably, the method for selecting the trigger point that causes abnormal power consumption of the mobile application from all abnormal instances and their successive events includes: selecting events with an occurrence frequency greater than a frequency threshold from all abnormal instances and their successive events; and determining the events with an occurrence frequency greater than the frequency threshold as the trigger point that causes abnormal power consumption of the mobile application.
[0013] The present invention also provides a computer-readable storage medium storing a power consumption anomaly location program for a mobile application, the power consumption anomaly location program for a mobile application being executed by a processor to implement the power consumption anomaly location method for a mobile application as described above.
[0014] This invention also provides a mobile application energy consumption anomaly localization system, which includes a server. The server is used to provide mobile application downloads that have been instrumented to mark events to be recorded, enabling mobile devices with the downloaded and installed mobile applications to collect dynamic event information and resource usage information of the mobile applications and upload them to the server; then, the mobile application energy consumption anomaly localization method described above is used to determine the trigger point causing the mobile application energy consumption anomaly, and a diagnostic analysis report is generated.
[0015] The present invention provides a method and system for locating energy consumption anomalies in mobile applications. Based on the collection of dynamic event information and resource usage information during the operation of the mobile application, it obtains the power consumption changes between different instances of each event. Then, by performing deviation analysis on the relative power consumption between event instances, it identifies the turning point from normal power consumption to abnormal power consumption. Furthermore, it filters and analyzes events surrounding the turning point, or events occurring sequentially, to identify trigger points that cause energy consumption anomalies in the mobile application, thus achieving accurate location of energy consumption anomalies. Unlike existing technologies, this invention is applicable to energy consumption anomalies caused by various reasons, effectively providing developers with information to locate the root cause and helping them effectively fix energy consumption anomalies in mobile applications. Attached Figure Description
[0016] Figure 1 This is a flowchart of the mobile application energy consumption anomaly location method provided by the present invention;
[0017] Figure 2 This is a flowchart illustrating the methods for collecting dynamic event information during the operation of mobile applications.
[0018] Figure 3 It is a flowchart of event analysis during the process of obtaining power consumption changes between instances in each event;
[0019] Figure 4 This is a flowchart of the energy consumption anomaly localization system for mobile applications provided by the present invention, which is involved in the diagnosis and repair of energy consumption anomalies in mobile applications based on crowd intelligence perception. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of the present invention clearer, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Examples of these preferred embodiments are illustrated in the drawings. The embodiments of the present invention shown in and described with reference to the drawings are merely exemplary, and the present invention is not limited to these embodiments.
[0021] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related are omitted.
[0022] This invention provides a method for locating energy consumption anomalies in mobile applications, referring to... Figure 1 As shown, the method for locating energy consumption anomalies in the mobile application includes:
[0023] A dynamic information collection mechanism based on user interaction and application scenario changes:
[0024] T1. Collect dynamic information on events and resource usage during the operation of mobile applications;
[0025] Offline diagnostic strategies based on joint analysis:
[0026] T2. Based on the event dynamic information and resource usage dynamic information, obtain the power consumption changes between instances at different time points corresponding to each event;
[0027] T3. Analyze and confirm all abnormal instances whose power consumption changes exceed the preset threshold relative to other instances of the same type, as well as the sequence of events for each abnormal instance. Filter out the trigger points that cause abnormal power consumption in mobile applications from all abnormal instances and their sequence of events.
[0028] The mobile application energy consumption anomaly localization method provided by this invention firstly recognizes that energy consumption anomalies are typically triggered under specific application scenarios and behaviors. Therefore, the event dynamics and resource usage dynamics collected during the mobile application's operation in stage T1 will include both triggered and untriggered energy consumption anomalies. Based on these collected event dynamics and resource usage dynamics, the power consumption changes between different instances of each event can be obtained. Furthermore, since energy consumption anomalies typically affect the overall power consumption of the mobile application for a considerable period, and also influence the power consumption of events triggered during this process—meaning the impact of energy consumption anomalies can lead to significant deviations in power consumption between different instances of the same event—a deviation analysis of the relative power consumption of event instances can be performed to identify the turning point from normal to abnormal power consumption. Events surrounding this turning point, or events occurring sequentially, can then be screened and analyzed to identify trigger points that cause energy consumption anomalies in the mobile application.
[0029] Energy consumption anomalies are always triggered by specific events (such as misconfiguration or the application being switched to the background). After the anomaly is triggered, the application's energy usage changes from normal to abnormal. The aforementioned method for locating energy consumption anomalies in mobile applications effectively analyzes and diagnoses these events and scenarios that trigger energy consumption anomalies. This allows developers to quickly locate the cause of the anomaly and resolve the problem by referring to the obtained analysis and diagnostic results. Furthermore, compared to existing static analysis (data flow analysis) methods, the energy consumption anomaly location method for mobile applications provided by this invention has excellent versatility. It can effectively detect energy consumption anomalies caused by various reasons, including no-sleep anomalies, and accurately locate the root cause of energy consumption anomalies, achieving fine-grained diagnosis of energy consumption anomalies caused by different reasons. This invention has been practically verified in forty real-world applications, proving its effectiveness in locating energy consumption anomalies in mobile applications and diagnosing the cause of energy consumption anomalies. Additionally, the aforementioned preset threshold is an exemplary setting; other strategies and screening schemes for determining anomaly instances can be formulated as needed.
[0030] The following provides a more detailed description of the mobile application energy consumption anomaly localization method provided by the present invention:
[0031] This invention establishes a dynamic information collection mechanism based on user interaction and application scenario transitions. Firstly, regarding the collection of dynamic event information: the mobile system provides different Application Programming Interfaces (APIs) and callback functions to characterize different states of the mobile application and its resource usage. During operation, the mobile application generates various events, such as events characterizing application state transitions (e.g., onCreate, onStart, onResume), events characterizing user interactions (e.g., onClick, onLongClick), and events characterizing related hardware usage (e.g., partial_wake_lock, full_wake_lock). This invention precisely monitors these events to subsequently compare and analyze large amounts of event data with power consumption data to pinpoint the trigger points of abnormal energy consumption phenomena.
[0032] Because many energy consumption anomalies occur under specific interaction behaviors between mobile devices and users, and are triggered and manifested by applications in certain specific states, considering the monitoring overhead and the impact of monitoring events on the granularity of energy consumption anomaly location, in this embodiment, for example, the event dynamic information and resource usage dynamic information are event dynamic information and resource usage dynamic information during the interaction process with the user. Specifically, the event dynamic information includes the state transition events of the mobile application and the events of the mobile application interacting with the user.
[0033] Most Android-based mobile applications are written in Java; however, native Java programs typically don't run directly on mobile devices. They must first be compiled and then packaged into an APK (Android Application Package) file that can be recognized by the mobile device's operating system (this invention uses Android as an example) before they can run. Generally, Java source files are first compiled into bytecode files. Then, the system's dex tool converts the bytecode files into Dalvik bytecode files. Finally, the Apkbuilder tool packages all the Dalvik bytecode files into an APK file.
[0034] Therefore, in order to achieve automatic monitoring of event triggering during runtime, the present invention refers to... Figure 2 As shown, the method for collecting event dynamic information during the operation of a user's mobile application further includes: decompressing and decompiling the application package of the mobile application; performing instrumentation on the mobile application to mark the events that need to be recorded; recompiling and packaging to obtain the instrumented application package of the mobile application; and after installing the mobile application from the instrumented application package, obtaining the event dynamic information according to the markings.
[0035] More specifically, the APK file (application package) is first decompressed and the Dalvik bytecode file is decompiled. Then, instrumentation is performed on this basis to mark the events that need to be recorded so that dynamic event information, including the start and end times of each event and information about the event itself (the event name and its position in the source code), can be recorded when the mobile application is running. The instrumented files are then compiled into Dalvik bytecode files and packaged into an APK file. When the user installs and runs the mobile application through this APK file, the dynamic event information can be obtained based on the markings.
[0036] The collection of dynamic resource usage information aims to obtain the energy consumption of mobile applications during operation. The methods for collecting this information include periodically reading the hardware usage information of the mobile application at preset intervals. More specifically, a corresponding background service is proposed to monitor the hardware usage of the mobile application by periodically reading the proc file system (procfs). Users and applications can obtain system information through proc and can change certain kernel parameters. System information, such as processes, changes dynamically, so when reading the proc file, the proc file system dynamically reads the required information from the system kernel and submits it. Since the resource usage of each mobile application (e.g., CPU utilization) can be distinguished based on its PID (Process ID), the simultaneous operation of multiple applications will not interfere with resource monitoring. For example, monitoring system calls can also be used during information collection to achieve more granular monitoring of the mobile application's resource usage.
[0037] The above-mentioned mobile application energy consumption anomaly localization method, in stages T2 and T3, constructs an offline diagnostic strategy based on joint analysis. Specifically, stage T2, based on the event dynamic information and resource usage dynamic information, obtains the power consumption changes between instances corresponding to different time points for each event, including:
[0038] T21. Power consumption estimation of events: Based on the event dynamic information and the resource usage dynamic information, obtain the energy consumption of the mobile application at each time point, the start time of various events, and the end time of various events, so as to integrate and obtain the power consumption information of each event in each interaction with the user.
[0039] Specifically, firstly, the dynamic resource usage information collected periodically during runtime is transformed into the power consumption of the mobile application at different points in time using a relevant model; after the power consumption conversion is completed, the energy consumption of the mobile application at each point in time, the start time of various events during the interaction process, and the end time of various events can be obtained; finally, by integrating the two types of information in the time dimension, the power consumption information of each event in each interaction with the user can be obtained. Figure 3 As shown in Step 1, each user interaction process (trace) is represented by the chronological order of the instances that occur at different points in time for each event.
[0040] T22. Normalization analysis of events: Normalize the instances corresponding to different time points in each event to obtain the relative power consumption changes between different instances in each event.
[0041] Because events have different functions, they often have significant power consumption differences. For example, an event that retrieves data from a server typically consumes more power than an event that simply receives user input. Therefore, simply analyzing the initial power consumption of a particular event in the interaction trace cannot accurately pinpoint anomalies in power consumption. This invention analyzes the relative power consumption of each event, specifically, such as... Figure 3 As shown in Step 2, instances of a certain event appearing in all interaction traces and their corresponding power consumption are collected and listed. Then, the instances in each event are normalized. This normalization process eliminates power consumption differences between different events caused by functional differences, while preserving the differences between different instances of the same event. Therefore, the power consumption variation between different instances of each event is obtained accordingly. Figure 3 As shown in Step 3, it can be found that the power consumption after normalization of each event represents the trigger point of the corresponding interaction process (trace), which is the inflection point of the mobile application's energy consumption changing from normal energy consumption to abnormal energy consumption.
[0042] Specifically, T3, Trigger Point Detection for Energy Consumption Anomalies: Analyze and confirm all abnormal instances whose power consumption changes exceed a preset threshold relative to other instances of the same type, and the sequence of events for each abnormal instance. From all abnormal instances and their sequence of events, filter out the trigger points determined to cause energy consumption anomalies in the mobile application. As mentioned earlier, since energy consumption anomalies typically affect the overall power consumption of the mobile application for a considerable period, they also affect the power consumption of events triggered during this process. That is, the impact of energy consumption anomalies can cause significant deviations in power consumption between different instances of the same event (relative power consumption changes from low to high). (Refer to...) Figure 3 As shown in Steps 4 and 5, this invention performs a deviation analysis on the relative power consumption of event instances in stage T3 to find the turning point from normal power consumption to abnormal power consumption. Furthermore, it filters and analyzes the events around the turning point, or the events that occur in sequence, to identify the trigger points that cause abnormal power consumption in mobile applications. It also displays the events affected by abnormal power consumption and their proportion in the interaction process, so as to find the root cause of abnormal power consumption in mobile applications and fix it based on this information.
[0043] More specifically, if certain events frequently occur around turning points in most interaction traces, these events are likely trigger points causing abnormal energy consumption. Therefore, for example, a method for filtering out trigger points that cause abnormal energy consumption in a mobile application from all abnormal instances and their sequential events includes: filtering events whose occurrence frequency exceeds a frequency threshold (which can be preset); and determining the events whose occurrence frequency exceeds the frequency threshold as trigger points causing abnormal energy consumption in the mobile application. Furthermore, developers can analyze the causes of abnormal energy consumption based on the location of these events in the application's source code. Of course, other adapted specific schemes for filtering such events can also be designed based on actual energy consumption anomaly cases.
[0044] Furthermore, the present invention also provides a computer-readable storage medium storing a power consumption anomaly location program for a mobile application, the power consumption anomaly location program for a mobile application being executed by a processor to implement the power consumption anomaly location method for a mobile application as described above.
[0045] Based on the principle of crowd intelligence sensing, the present invention also provides a mobile application energy consumption anomaly location system, the mobile application energy consumption anomaly location system including a server.
[0046] The server is configured to: provide mobile application downloads that have been instrumented to mark events that need to be recorded; enable mobile devices that have downloaded and installed the mobile application to collect event dynamic information and resource usage dynamic information of the mobile application and upload them to the server; and then use the mobile application energy consumption anomaly localization method described above to determine the trigger point that causes the mobile application energy consumption anomaly and generate a diagnostic analysis report.
[0047] The detailed process of the mobile application energy consumption anomaly localization system participating in the mobile application's energy consumption anomaly diagnosis and repair work based on crowd intelligence sensing is as follows:
[0048] Mobile application developers perform instrumentation on their mobile applications and upload the instrumented version to app stores (such as Google Play, App Store) or other places where users can download (obtain) the mobile application.
[0049] By downloading and installing the mobile application, users of mobile devices can enable the mobile device to automatically collect dynamic information about events and resource usage during the user's interaction with the mobile application.
[0050] The mobile device uploads the collected event dynamic information and resource usage dynamic information to the server;
[0051] Based on the principle of crowd intelligence perception, after the server obtains the above information collected by a large number of users (mobile devices), the server can use the mobile application energy consumption anomaly localization method as described above to determine the trigger point that causes the mobile application energy consumption anomaly, extract relevant events when the energy consumption anomaly occurs, and generate a diagnostic analysis report.
[0052] Developers refer to the diagnostic analysis report to locate the root cause of abnormal energy consumption in the mobile application source code and fix the related issues.
[0053] In summary, the mobile application energy consumption anomaly localization method and system provided by this invention can effectively locate the events and scenarios that trigger energy consumption anomalies. This allows developers to quickly pinpoint the root cause of energy consumption anomalies based on the analysis and diagnostic results obtained from the method and system, thus resolving the energy consumption anomaly problem. Furthermore, compared to existing technologies, it is applicable to effectively detecting energy consumption anomalies caused by various reasons, including no-sleep anomalies and accurately locating the root cause, enabling fine-grained diagnosis of energy consumption anomalies caused by different factors.
[0054] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0055] The above description is only a specific embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for locating energy consumption anomalies in mobile applications, characterized in that, include: Collect dynamic information on events and resource usage during the operation of mobile applications; Based on the event dynamic information and resource usage dynamic information, obtain the power consumption changes between instances corresponding to different time points in each event; Analyze and confirm all abnormal instances whose power consumption changes exceed a preset threshold relative to other instances of the same type, as well as the sequence of events for each abnormal instance. Filter out the trigger points that cause abnormal power consumption in mobile applications from all abnormal instances and their sequence of events. The methods for collecting dynamic event information during the operation of a user's mobile application include: Decompress and decompile the application package of mobile applications; Instrument mobile applications to mark events that need to be logged; Recompile and repackage to obtain the instrumented mobile application package; After the mobile application is installed from the instrumented application package, event dynamic information is obtained based on the markers.
2. The energy consumption anomaly location method according to claim 1, characterized in that, The event dynamic information and resource usage dynamic information refer to the event dynamic information and resource usage dynamic information during the user interaction process.
3. The energy consumption anomaly location method according to claim 2, characterized in that, The event dynamic information includes mobile application state transition events and user interaction events.
4. The energy consumption anomaly location method according to claim 1, characterized in that, Methods for collecting dynamic information on resource usage during the operation of mobile applications include: The hardware usage information of the mobile application is periodically read according to a preset cycle.
5. The energy consumption anomaly location method according to claim 1 or 2, characterized in that, The method for obtaining the power consumption changes between instances corresponding to different time points in each event, based on the event dynamic information and resource usage dynamic information, includes: Based on the event dynamic information and the resource usage dynamic information, the energy consumption of the mobile application at each time point, the start time of various events, and the end time of various events are obtained, so as to integrate and obtain the power consumption information of each event in each interaction with the user. Normalize the instances corresponding to different time points in each event to obtain the relative power consumption changes between different instances in each event.
6. The energy consumption anomaly location method according to claim 1, characterized in that, Methods for identifying trigger points that cause abnormal power consumption in mobile applications from all abnormal instances and their sequence of events include: Filter out events with a frequency greater than a frequency threshold from all abnormal instances and their sequential events; Events that occur more frequently than a frequency threshold are determined to be trigger points that cause abnormal power consumption in mobile applications.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a power consumption anomaly location program for a mobile application, which is executed by a processor to implement the power consumption anomaly location method for a mobile application as described in any one of claims 1 to 6.
8. A mobile application energy consumption anomaly location system, characterized in that, Including servers, The server is used to provide mobile application downloads that have been instrumented to mark events that need to be recorded, enabling mobile devices that have downloaded and installed the mobile application to collect event dynamic information and resource usage dynamic information of the mobile application and upload them to the server; then, the mobile application energy consumption anomaly localization method as described in any one of claims 1 to 6 is used to determine the trigger point that causes the mobile application energy consumption anomaly, and a diagnostic analysis report is generated.
Citation Information
Patent Citations
Peak power detection in digital designs using emulation systems
US20090271167A1