Abnormal power consumption processing method and apparatus, terminal device, and storage medium
By detecting and adjusting the judgment rules and power consumption data of abnormal power consumption types and levels in the main processor, and dynamically adjusting the processing strategy, the balance between application operation and device battery life in smart devices is solved, thus improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GOERTEK INC
- Filing Date
- 2024-11-28
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies struggle to balance application performance while ensuring the battery life of smart devices, leading to a decline in user experience.
By detecting abnormal power consumption in the main processor, obtaining the judgment rules and power consumption data for the type and level of abnormal power consumption, and dynamically adjusting the processing strategy, such as terminating the application or issuing power consumption reminders, to balance application operation and device battery life.
It enables applications to continue running while ensuring device battery life, making it suitable for real-world use cases of smart devices and enhancing the user experience.
Smart Images

Figure CN122111198A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of power management, and in particular to abnormal power consumption processing methods, abnormal power consumption processing devices, terminal equipment, and storage media. Background Technology
[0002] During the use of smart devices, there is a problem of abnormal power consumption caused by running applications, which in turn leads to a shorter battery life. Currently, the common solution to this problem is to directly terminate or exit the running application. However, this method cannot achieve a balance between application operation and device battery life. In other words, it cannot ensure that the device can run the application while maintaining battery life, making it unsuitable for the actual use scenarios of smart devices and significantly reducing the user experience.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main objective of this application is to provide an abnormal power consumption processing method, an abnormal power consumption processing device, a terminal device, and a storage medium, aiming to solve the technical problem that current abnormal power consumption processing methods are unable to achieve a balance between application operation and device battery life.
[0005] To achieve the above objectives, this application proposes an abnormal power consumption handling method, which is applied to a terminal device, the terminal device including a main processor, and the abnormal power consumption handling method includes:
[0006] During the application's operation on the main processor, detect whether there is abnormal power consumption when the application is running.
[0007] When abnormal power consumption occurs, obtain the first judgment rule for the type of abnormal power consumption, the second judgment rule for the level of abnormal power consumption, and the power consumption data when running the application.
[0008] Based on the first judgment rule, the second judgment rule, and the power consumption data, a first processing strategy for handling abnormal power consumption is determined, and the abnormal power consumption is processed based on the first processing strategy.
[0009] In one embodiment, the first judgment rule includes whether the duration for which the current application holds a partial wake-up lock in the background exceeds a preset holding duration threshold, and the power consumption data includes the holding duration in the partial wake-up lock holding record; the second judgment rule includes whether the time the application is in an active state exceeds a preset active duration threshold, and the power consumption data includes the time the application is in an active state.
[0010] The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data includes:
[0011] If the holding duration is detected to be greater than the preset holding duration threshold, it is determined that there is an abnormality in the application background using the application part of the wake-up lock to hold the lock.
[0012] If the application background uses the application part of the wake-up lock to hold the lock abnormally and the application is in an active state for a period of time exceeding a preset active duration threshold, then the first processing strategy is determined to terminate the running application.
[0013] If the application background uses the application part of the wake-up lock abnormally and the application is in an active state for a period of time that does not exceed the preset active duration threshold, then the first processing strategy is determined to be to issue an abnormal power consumption reminder.
[0014] In one embodiment, the first judgment rule includes whether the CPU utilization rate exceeds a preset utilization rate threshold, and the power consumption data includes the CPU utilization rate of the current application; the second judgment rule includes whether the CPU usage time exceeds a preset usage duration threshold, and the power consumption data includes the CPU usage time.
[0015] The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data includes:
[0016] If the CPU usage of the current application is detected to exceed a preset usage threshold, it is determined that the application is abnormally using CPU in the background.
[0017] If the application's background CPU usage is abnormal and the CPU usage time exceeds a preset usage time threshold, then the first processing strategy is determined to terminate the application.
[0018] If the application background CPU usage is abnormal and the CPU usage time does not exceed the preset usage time threshold, then the first processing strategy is determined to be to issue an abnormal power consumption reminder.
[0019] In one embodiment, the step of detecting whether abnormal power consumption occurs when running the application includes:
[0020] If the detected power consumption rate exceeds the preset power consumption rate threshold, and / or the application response time exceeds the preset response time threshold, and / or the CPU utilization rate exceeds the preset utilization rate threshold, then it is determined that abnormal power consumption has occurred when running the application.
[0021] In one embodiment, the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and the power consumption data when running the application include:
[0022] Identify the application runtime scenarios of the main processor;
[0023] If the application running scenario is that the running application is a preset whitelist application, and / or the current device running state is a preset active state, then return to the step of detecting whether abnormal power consumption occurs when the running application is running;
[0024] If the application running scenario is that the application is not on the preset whitelist and the current device is not in the preset active state, then the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and the power consumption data when running the application are executed.
[0025] In one embodiment, the terminal device further includes a secondary processor connected to the main processor, and the abnormal power consumption handling method further includes:
[0026] During the operation of applications on the secondary processor, the presence of application logging points is used to determine whether abnormal power consumption occurs when the application is running.
[0027] If the application event logs exist, then abnormal power consumption is determined and the abnormal power consumption level is obtained by parsing the application event logs.
[0028] Based on the abnormal power consumption level obtained from the analysis, a second processing strategy for handling abnormal power consumption is determined, and the abnormal power consumption is processed based on the second processing strategy.
[0029] In one embodiment, the step of processing abnormal power consumption based on the processing strategy is followed by:
[0030] Record abnormal power consumption logs and abnormal power consumption data when abnormal power consumption occurs;
[0031] The abnormal power consumption is investigated by using the abnormal power consumption log and the abnormal power consumption data.
[0032] Furthermore, to achieve the above objectives, this application also proposes an abnormal power consumption processing device, which includes:
[0033] The detection module is used to detect whether there is abnormal power consumption when the application is running on the main processor.
[0034] The acquisition module is used to acquire the first judgment rule for the abnormal power consumption type, the second judgment rule for the abnormal power consumption level, and the power consumption data when the application is running when abnormal power consumption occurs.
[0035] The determination module is used to determine a first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data, and to process the abnormal power consumption based on the first processing strategy.
[0036] In addition, to achieve the above objectives, this application also proposes a terminal device, the device comprising: a memory, a first processor, a second processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the abnormal power consumption handling method described above.
[0037] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the abnormal power consumption handling method described above.
[0038] One or more technical solutions proposed in this application have at least the following technical effects:
[0039] In this application, during the operation of an application on the main processor, after detecting abnormal power consumption while running the application, a first processing strategy for handling the abnormal power consumption is determined based on a first judgment rule for the type of abnormal power consumption, a second judgment rule for the level of abnormal power consumption, and power consumption data during the operation of the application, and the abnormal power consumption is processed based on the first processing strategy.
[0040] Therefore, a method for handling abnormal power consumption that balances application operation and device battery life is proposed. During the use of smart devices, if there is an abnormal power consumption problem caused by application operation, the abnormal power consumption is handled by determining the abnormal power consumption type and level judgment rules and the power consumption data when the application is running, instead of directly terminating or exiting the running application. This ensures that the device can run the application while maintaining its battery life, and is suitable for the actual use scenarios of smart devices. Attached Figure Description
[0041] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0042] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0043] Figure 1This is a flowchart illustrating an embodiment of the abnormal power consumption handling method of this application.
[0044] Figure 2 This is a flowchart illustrating Embodiment 2 of the abnormal power consumption handling method of this application;
[0045] Figure 3 This is a flowchart illustrating Embodiment 3 of the abnormal power consumption handling method of this application;
[0046] Figure 4 This is an application diagram illustrating an application scenario of the abnormal power consumption handling method of this application;
[0047] Figure 5 This is a schematic diagram of the module structure of the abnormal power consumption processing device according to an embodiment of this application;
[0048] Figure 6 This is a schematic diagram of the device structure of the hardware operating environment involved in the abnormal power consumption handling method in the embodiments of this application.
[0049] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0050] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0051] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or terminal device capable of performing the above functions. The following description uses an extended reality (XR) device as an example to illustrate this embodiment and the subsequent embodiments.
[0052] Based on this, embodiments of this application provide a method for handling abnormal power consumption, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the abnormal power consumption handling method of this application.
[0053] In this embodiment, the abnormal power consumption handling method is applied to an extended reality XR device, and the abnormal power consumption handling method includes steps S10 to S30:
[0054] Step S10: During the application's operation on the main processor, detect whether there is abnormal power consumption when the application is running;
[0055] It should be noted that the main processor can be a processor running operating systems including but not limited to desktop, server, or mobile operating systems such as Linux, Windows, macOS, and Chrome OS.
[0056] In this embodiment, the types and number of applications running on the main processor are not limited.
[0057] Abnormal power consumption refers to the abnormal power consumption of terminal devices equipped with main processors and running applications, such as extended reality (XR) devices, due to software problems, hardware failures, improper system settings, or external factors, which exceeds the power consumption range of normal use.
[0058] In this embodiment, the extended reality XR device can be an AR (Augmented Reality) device, a VR (Virtual Reality) device, or an MR (Mixed Reality) device.
[0059] In one feasible implementation, step S10 includes:
[0060] If the detected power consumption rate exceeds the preset power consumption rate threshold, and / or the application response time exceeds the preset response time threshold, and / or the CPU utilization rate exceeds the preset utilization rate threshold, then it is determined that abnormal power consumption has occurred when running the application.
[0061] If at least one of the following conditions is met, it is determined that abnormal power consumption is occurring while the application is running;
[0062] Judgment condition 1: The battery level decrease rate exceeds the preset decrease rate threshold;
[0063] Judgment condition two: The application response time exceeds the preset response time threshold;
[0064] Judgment condition 3: CPU utilization rate exceeds the preset utilization rate threshold.
[0065] In this embodiment, a method for detecting abnormal power consumption during application runtime is proposed.
[0066] If the power consumption rate of an application exceeds a preset power consumption rate threshold, it can be confirmed that the application is experiencing abnormal power consumption. If the application response time exceeds a preset response time threshold, it indicates that the application is malfunctioning, which is highly likely to cause abnormal power consumption. In this embodiment, it can be approximately confirmed that the application is experiencing abnormal power consumption. If the CPU utilization rate of an application exceeds a preset utilization rate threshold, it indicates that the background services running on the main processor for a long time will consume a lot of power, which can also confirm that the application is experiencing abnormal power consumption.
[0067] In one embodiment, a pending response instruction can be sent to the application. If no feedback is received from the application within a preset response time threshold, such as 10 minutes, it is determined that the application's response time exceeds the preset response time threshold.
[0068] It should be noted that abnormal power consumption during application runtime can also be determined by monitoring the application's network activity, such as frequent network requests and connections consuming a large amount of power; abnormal power consumption during application runtime can also be determined by monitoring the number of times the application is woken up, such as frequent broadcast reception, timer, service wake-ups causing the application to still consume power in an inactive state.
[0069] In this embodiment, the criteria for determining abnormal power consumption during application operation are not limited.
[0070] By using at least one of the above judgment conditions one to three, it can be determined whether abnormal power consumption occurs during application operation, thereby improving the detection efficiency and accuracy of abnormal power consumption.
[0071] Step S20: When abnormal power consumption occurs, obtain the first judgment rule for the type of abnormal power consumption, the second judgment rule for the level of abnormal power consumption, and the power consumption data when running the application.
[0072] In one embodiment, an abnormal power consumption function configuration file is pre-set. This file pre-defines a first judgment rule for the type of abnormal power consumption and a second judgment rule for the level of abnormal power consumption. When abnormal power consumption occurs, the first judgment rule for the type of abnormal power consumption and the second judgment rule for the level of abnormal power consumption can be obtained by loading and parsing this file.
[0073] Understandably, different abnormal power consumption types have different abnormal power consumption levels, which can be specifically set according to the actual power consumption scenario. For example, by obtaining the application's power consumption statistics and referring to the first judgment rule for abnormal power consumption types, the current abnormal power consumption type can be determined as either application partial wakelock holding abnormality (the application can be used normally but power consumption is abnormal) or CPU utilization abnormality (abnormal CPU consumption caused by application abnormality). Then, by obtaining the application's power consumption statistics and referring to the second judgment rule for abnormal power consumption levels under the current abnormal power consumption type, the abnormal power consumption level under the current abnormal power consumption type can be determined as Level 1 (sending a pop-up notification) or Level 2 (forcibly exiting the application).
[0074] In this embodiment, there are no restrictions on the classification of abnormal power consumption types or the setting of abnormal power consumption levels under each abnormal power consumption type.
[0075] In another embodiment, power consumption data while running applications can be obtained through various services that track and report battery usage, such as the BatteryStats service in the Android operating system, in conjunction with the command-line tool dumpsys batterystats to obtain detailed battery usage data of the device.
[0076] It should be noted that the BatteryStats service can directly provide at least the following data: 1. Total battery usage time, i.e., the usage time of the terminal device, such as an Extended Reality (XR) device, since its last charge. 2. Battery usage statistics, including CPU usage time, network usage, GPS usage, screen up time, etc., for each application. 3. Process wake-up and sleep time: Records the wake-up and sleep time of each process, i.e., the time an application is in an active state. 4. System parameters: such as signal level, wireless network status, Bluetooth status, etc. 5. Power consumption estimation: Estimates the power consumption of applications based on the collected data. 6. Battery health information: such as battery capacity, number of charging cycles, etc. 7. Connectivity changes: Records changes in the device's mobile network and Wi-Fi connectivity. 8. Radio activity time: Records the activity time of mobile network and Wi-Fi.
[0077] In another embodiment, the existing data of the Batterystats power consumption statistics function can be expanded to include kernel wakelock holding records, patchal wakelock holding records, Wi-Fi scan records, background CPU usage records, background GPS usage records, alarm wake-up records, and data network activity records.
[0078] Kernel wakelocks are a mechanism in the Linux kernel used to control the power states of devices. Kernel wakelocks work by activating and deactivating wakeup sources within the kernel. When a wakelock is activated, it prevents the system from entering a low-power state. Conversely, when a wakelock is released, the system can safely enter a low-power state. This mechanism allows the kernel to remain awake when necessary to respond to external events or perform critical tasks.
[0079] Partial Wakelock is a power management mechanism in the Android operating system that allows applications to tell the system to keep the device partially or fully awake while performing specific tasks. Specifically, Partial Wakelock keeps the CPU running without necessarily requiring the screen to remain on or the keyboard backlight to be on. This mechanism is typically used to ensure that applications performing tasks in the background are not interrupted by the system entering sleep mode. Developers may use Partial Wakelock to prevent the system from prematurely entering sleep mode when writing services that need to run for extended periods or handling broadcast receivers.
[0080] WiFi scan refers to a device using its wireless network card to scan for surrounding WiFi networks. This process helps the device identify available wireless networks for connection or network diagnostics. The mechanism of WiFi scanning may differ across different devices and operating systems. For example, in Android devices, WiFi scanning can be implemented using the WifiManager API, while in some embedded systems, specific libraries or frameworks may be used.
[0081] The alarm wake-up mechanism refers to the use of alarm clock functionality in mobile devices or embedded systems to wake the device at a specific time to perform certain tasks. In mobile operating systems such as Android, the AlarmManager class provides this functionality, allowing applications to set an alarm to be triggered at a future time, waking the device even if it is in sleep mode.
[0082] In one possible implementation, the following steps are included prior to step S20:
[0083] Identify the application runtime scenarios of the main processor;
[0084] If the application is running in a pre-defined whitelisted application and / or the current device is in a pre-defined active state, then return to the step of detecting whether abnormal power consumption occurs when the application is running.
[0085] If the application is not on the preset whitelist and the device is not in the preset active state, then the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and the power consumption data when the application is running are executed.
[0086] In one embodiment, the preset whitelist applications can be background applications, such as applications that frequently synchronize and update background data, like social media applications that need to check for new messages in the background, or email clients that exchange emails; they can also be applications that continuously use location services and sensors, such as map navigation and fitness trackers; or they can be background programs of local artificial intelligence applications. The preset whitelist applications can also be running applications, such as graphics processing applications and game applications that require significant computing resources; or streaming media applications that play video. In this embodiment, the specific applications of the preset whitelist applications are not limited.
[0087] In one embodiment, the device may have preset active states such as audio active, network active, or location active. In this embodiment, the active state is not limited.
[0088] In this embodiment, when the application running scenario of the main processor is a preset whitelist application, and / or the current device running state is a preset active state, the current application running scenario is regarded as an exemption scenario, that is, the subsequent abnormal power consumption processing steps are skipped, thereby improving the adaptability to the actual use scenario of the device and enhancing the flexibility of abnormal power consumption processing.
[0089] Step S30: Based on the first judgment rule, the second judgment rule, and the power consumption data, determine the first processing strategy for handling abnormal power consumption, and process the abnormal power consumption based on the first processing strategy.
[0090] During the operation of the main processor application, after detecting abnormal power consumption when running the application, a first processing strategy for handling abnormal power consumption is determined based on the first judgment rule for the type of abnormal power consumption, the second judgment rule for the level of abnormal power consumption, and the power consumption data when running the application, and the abnormal power consumption is handled based on the first processing strategy.
[0091] In one embodiment, the first judgment rule for the abnormal power consumption type and the second judgment rule for the abnormal power consumption level under the target abnormal power consumption type obtained from the preset abnormal power consumption function configuration file are combined with the power consumption data extracted from the BatteryStats service to obtain the abnormal power consumption type result and the abnormal power consumption level under the abnormal power consumption type, and the first processing strategy for abnormal power consumption is determined by the abnormal power consumption level under the abnormal power consumption type.
[0092] In this way, various applications can be dynamically monitored based on the device usage scenario, and abnormal applications can be quickly identified and dealt with.
[0093] In one feasible implementation, step S30 includes:
[0094] The first judgment rule includes whether the duration for which the current application holds a partial wake-up lock in the background exceeds a preset holding duration threshold, and the power consumption data includes the holding duration in the partial wake-up lock holding record; the second judgment rule includes whether the time the application is in an active state exceeds a preset active time threshold, and the power consumption data includes the time the application is in an active state.
[0095] The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and power consumption data includes:
[0096] If the holding time is detected to be greater than the preset holding time threshold, it is determined that there is an abnormality in the application background using the application part of the wake-up lock to hold the lock.
[0097] If the application fails to hold the application wake-up lock in the background and the application remains active for a period of time exceeding the preset active duration threshold, the first processing strategy is to terminate the application.
[0098] If the application uses the application's partial wake-up lock abnormally in the background and the application is in an active state for a period of time that does not exceed the preset active duration threshold, then the first processing strategy is to issue an abnormal power consumption reminder.
[0099] In one embodiment, the batterystats extension of the partial wakelock holding record, along with a first judgment rule such as whether the current application holds a partial wakelock for an extended period in the background, can be used to determine whether the target abnormal power consumption type is an application partial wakelock holding abnormality. When the target abnormal power consumption type is an application partial wakelock holding abnormality (the application can be used normally but consumes abnormal power), the batterystats data on the application's active state time, along with a second judgment rule such as whether the application's active state time exceeds a preset duration, further determines the target abnormal power consumption level as Level 1 if the application's active state time exceeds the preset duration, at which point the application is terminated. If the application's active state time does not exceed the preset duration, the target abnormal power consumption level is determined as Level 2, at which point an abnormal power consumption alert and notification are issued.
[0100] In one feasible implementation, step S30 includes:
[0101] The first judgment rule includes whether the CPU utilization rate exceeds a preset utilization rate threshold, and the power consumption data includes the CPU utilization rate of the current application; the second judgment rule includes whether the CPU usage time exceeds a preset usage duration threshold, and the power consumption data includes the CPU usage time.
[0102] The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and power consumption data includes:
[0103] If the CPU usage of the current application is detected to exceed the preset usage threshold, it is determined that the application is using CPU abnormally in the background.
[0104] If the application uses CPU abnormally in the background and the CPU usage time exceeds the preset usage time threshold, the first processing strategy is to terminate the application.
[0105] If the application uses CPU abnormally in the background but the CPU usage time does not exceed the preset usage time threshold, the first processing strategy is to issue an abnormal power consumption reminder.
[0106] In one embodiment, the background CPU usage records extended by the Batterystats power consumption statistics function, and the first judgment rule such as whether the CPU usage rate exceeds the preset usage rate threshold, can determine whether the target abnormal power consumption type is an abnormal CPU usage in the background of the application when the CPU usage rate of the current application exceeds the preset usage rate threshold.
[0107] If the target abnormal power consumption type is application background CPU usage abnormality, further use the CPU usage time in the power consumption statistics function Batterystats, and the second judgment rule, such as whether the CPU usage time exceeds the preset usage time threshold, to determine the target abnormal power consumption level as level one when the CPU usage time exceeds the preset usage time threshold, and at this time terminate the application. If the CPU usage time does not exceed the preset usage time threshold, the target abnormal power consumption level is determined as level two, and abnormal power consumption reminders and notifications are issued.
[0108] In this embodiment, the selection and implementation of the handling strategy for each target abnormal power consumption level are not limited.
[0109] Therefore, a method for handling abnormal power consumption that balances application operation and device battery life is proposed. During the use of smart devices, if there is an abnormal power consumption problem caused by application operation, the abnormal power consumption is handled by determining the abnormal power consumption type and level judgment rules and the power consumption data when the application is running, instead of directly terminating or exiting the running application. This ensures that the device can run the application while maintaining its battery life, and is suitable for the actual use scenarios of smart devices.
[0110] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2The terminal device further includes an auxiliary processor connected to the main processor, and the abnormal power consumption handling method further includes steps T10 to T30:
[0111] Step T10: During the application's operation on the secondary processor, determine whether there is abnormal power consumption while the application is running by checking whether there are application event logs.
[0112] It should be noted that a secondary processor is a processing unit that assists the main processor in completing certain specific tasks. A secondary processor can be a standalone hardware module or a part integrated into the main processor chip. For example, a secondary processor can be a DMA (Direct Memory Access) controller that allows peripheral devices to directly read and write memory, a GPU (Graphics Processing Unit) focused on processing graphics and video rendering tasks, or an NPU (Neural Processing Unit) that accelerates artificial intelligence and machine learning tasks.
[0113] In one embodiment, a system runs on both the main processor and the secondary processor. For example, the main processor may run an Android system, while the secondary processor may run a microcontroller system or an embedded system, thereby enabling the dual-system operation on the device.
[0114] Step T20: If application event logs exist, determine that abnormal power consumption has occurred and parse the application event logs to obtain the abnormal power consumption level;
[0115] In this embodiment, event tracking is achieved by embedding event logs within the application. The application event logs are specifically for abnormal power consumption. The printing of these logs indicates abnormal power consumption in the application running on the secondary processor. Conversely, the absence of printed logs indicates that the application running on the secondary processor is not currently experiencing abnormal power consumption. Once abnormal power consumption is confirmed, the application event logs are further analyzed to determine the level of abnormal power consumption. In other words, the application event logs contain code related to the level of abnormality; parsing the printed logs reveals the level of abnormal power consumption.
[0116] It's important to note that, unlike the main processor, the applications running on the secondary processor are relatively simple. Therefore, to improve the efficiency of detecting and handling abnormal power consumption, the secondary processor's abnormal power consumption handling method does not set and obtain a first rule for judging the type of abnormal power consumption, a second rule for judging the level of abnormal power consumption, or power consumption data during application execution. Instead, it directly handles abnormal power consumption based on application event logs. Furthermore, similar to the main processor, the secondary processor can also set and determine exemption scenarios to improve adaptability to actual device usage scenarios and enhance the flexibility of abnormal power consumption handling.
[0117] Step T30: Based on the abnormal power consumption level obtained from the analysis, determine the second processing strategy for handling the abnormal power consumption, and process the abnormal power consumption based on the second processing strategy.
[0118] In one embodiment, after parsing the abnormal power consumption level from the application's event logs, a second processing strategy corresponding to the abnormal power consumption level is determined. For example, if the abnormal power consumption level is level one, the application running on the secondary processor is terminated; if the abnormal power consumption level is level two, an abnormal power consumption reminder and notification are issued.
[0119] In this embodiment, an abnormal power consumption handling method for a secondary processor is proposed. This method performs simple and efficient abnormal power consumption handling based on application logging, and also adapts to actual usage scenarios based on the abnormal power consumption level.
[0120] Based on the first or second embodiment of this application, in the third embodiment of this application, the content that is the same as or similar to the first or second embodiment described above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 The step of processing abnormal power consumption based on the processing strategy is followed by steps P10 to P20:
[0121] Step P10: Record the abnormal power consumption log and abnormal power consumption data when abnormal power consumption occurs;
[0122] Step P20: Debug abnormal power consumption by using abnormal power consumption logs and abnormal power consumption data.
[0123] In this embodiment, after processing abnormal power consumption based on the processing strategy, abnormal power consumption logs and abnormal power consumption data can be used to debug the abnormal power consumption, determine the cause of abnormal power consumption, and provide corresponding methods to reduce power consumption, thereby further reducing abnormal power consumption and device overheating.
[0124] In one application scenario, refer to Figure 4 On the main processor, abnormal power consumption is determined by judging abnormal power consumption and exemption scenarios. Then, by loading the abnormal power consumption function configuration file and Batterystats service, the abnormal power consumption type and the abnormal power consumption level under the abnormal power consumption type are determined, thereby obtaining the processing strategy and processing the abnormal power consumption.
[0125] On the secondary processor, when application event logs are present, it is determined that the current application on the secondary processor is experiencing abnormal power consumption. The level of abnormal power consumption is further determined through the application event logs, thereby obtaining a processing strategy and handling the abnormal power consumption.
[0126] In addition, the main processor and the auxiliary processor are connected via an SPI interface (Serial Peripheral Interface) for data communication. The auxiliary processor can transmit abnormal power consumption logs to the main processor via the SPI interface. The main processor retains these logs for debugging, allowing it to determine the cause of abnormal power consumption and provide corresponding methods to reduce power consumption, thereby further reducing abnormal power consumption and device overheating.
[0127] In this way, each application can be dynamically monitored according to the device usage scenario, abnormal applications can be quickly identified and dealt with, and a balance can be achieved between application operation and device battery life.
[0128] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the abnormal power consumption processing method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0129] This application also provides an abnormal power consumption processing device, please refer to... Figure 5 The abnormal power consumption handling device includes:
[0130] The detection module 10 is used to detect whether there is abnormal power consumption when the application is running during the application operation on the main processor.
[0131] The acquisition module 20 is used to acquire, when abnormal power consumption occurs, the first judgment rule for the type of abnormal power consumption, the second judgment rule for the level of abnormal power consumption, and the power consumption data when the application is running.
[0132] The determination module 30 is used to determine a first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and power consumption data, and to process the abnormal power consumption based on the first processing strategy.
[0133] In one embodiment, the first judgment rule includes whether the duration for which the current application holds a partial wake-up lock in the background exceeds a preset holding duration threshold, and the power consumption data includes the holding duration in the partial wake-up lock holding record; the second judgment rule includes whether the time the application is in an active state exceeds a preset active time threshold, and the power consumption data includes the time the application is in an active state; the determining module 30 is further configured to:
[0134] If the holding time is detected to be greater than the preset holding time threshold, it is determined that there is an abnormality in the application background using the application part of the wake-up lock to hold the lock.
[0135] If the application fails to hold the application wake-up lock in the background and the application remains active for a period of time exceeding the preset active duration threshold, the first processing strategy is to terminate the application.
[0136] If the application uses the application's partial wake-up lock abnormally in the background and the application is in an active state for a period of time that does not exceed the preset active duration threshold, then the first processing strategy is to issue an abnormal power consumption reminder.
[0137] In one embodiment, the first judgment rule includes whether the CPU utilization rate exceeds a preset utilization rate threshold, and the power consumption data includes the CPU utilization rate of the current application; the second judgment rule includes whether the CPU usage time exceeds a preset usage duration threshold, and the power consumption data includes the CPU usage time; the determining module 30 is further configured to:
[0138] If the CPU usage of the current application is detected to exceed the preset usage threshold, it is determined that the application is using CPU abnormally in the background.
[0139] If the application uses CPU abnormally in the background and the CPU usage time exceeds the preset usage time threshold, the first processing strategy is to terminate the application.
[0140] If the application uses CPU abnormally in the background but the CPU usage time does not exceed the preset usage time threshold, the first processing strategy is to issue an abnormal power consumption reminder.
[0141] In one embodiment, the detection module 10 is further configured to:
[0142] If the detected power consumption rate exceeds the preset power consumption rate threshold, and / or the application response time exceeds the preset response time threshold, and / or the CPU utilization rate exceeds the preset utilization rate threshold, then it is determined that abnormal power consumption has occurred when running the application.
[0143] In one embodiment, the acquisition module 20 is further configured to:
[0144] Before the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and power consumption data when running the application:
[0145] Identify the application runtime scenarios of the main processor;
[0146] If the application is running in a pre-defined whitelisted application and / or the current device is in a pre-defined active state, then return to the step of detecting whether abnormal power consumption occurs when the application is running.
[0147] If the application is not on the preset whitelist and the device is not in the preset active state, then the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and the power consumption data when the application is running are executed.
[0148] In one embodiment, the terminal device further includes an auxiliary processor connected to the main processor, and the abnormal power consumption handling device further includes an auxiliary processor processing module, used for:
[0149] During the operation of applications on the secondary processor, the presence of application logging points is used to determine whether abnormal power consumption occurs when the application is running.
[0150] If application event logs exist, then abnormal power consumption is identified and the abnormal power consumption level is obtained by parsing the application event logs.
[0151] Based on the abnormal power consumption level obtained from the analysis, a second processing strategy for handling abnormal power consumption is determined, and the abnormal power consumption is processed based on the second processing strategy.
[0152] In one embodiment, the determining module 30 is further configured to:
[0153] After the step of processing abnormal power consumption based on the processing strategy:
[0154] Record abnormal power consumption logs and abnormal power consumption data when abnormal power consumption occurs;
[0155] Debug abnormal power consumption by using abnormal power consumption logs and abnormal power consumption data.
[0156] The abnormal power consumption processing device provided in this application, employing the abnormal power consumption processing method in the above embodiments, can solve the technical problem that current abnormal power consumption processing methods struggle to achieve a balance between application operation and device battery life. Compared with the prior art, the beneficial effects of the abnormal power consumption processing device provided in this application are the same as those of the abnormal power consumption processing method provided in the above embodiments, and other technical features in the abnormal power consumption processing device are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0157] This application provides a terminal device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the abnormal power consumption processing method in Embodiment 1 above.
[0158] The following is for reference. Figure 6 It shows a schematic diagram of the structure of a terminal device suitable for implementing the embodiments of this application. Figure 6 The terminal device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0159] like Figure 6As shown, the terminal device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the terminal device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows terminal devices to communicate wirelessly or wiredly with other devices to exchange data. Although terminal devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0160] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0161] The terminal device provided in this application, employing the abnormal power consumption handling method in the above embodiments, can solve the technical problem that current abnormal power consumption handling methods struggle to achieve a balance between application operation and device battery life. Compared with the prior art, the beneficial effects of the terminal device provided in this application are the same as those of the abnormal power consumption handling method provided in the above embodiments, and other technical features of this terminal device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0162] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0163] 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.
[0164] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the abnormal power consumption processing method in the above embodiments.
[0165] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0166] The aforementioned computer-readable storage medium may be included in the terminal device; or it may exist independently and not assembled into the terminal device.
[0167] The aforementioned computer-readable storage medium carries one or more programs. When the aforementioned one or more programs are executed by a terminal device, the terminal device: during the application running process on the main processor, detects whether abnormal power consumption occurs while the application is running; when abnormal power consumption occurs, obtains a first judgment rule for the type of abnormal power consumption, a second judgment rule for the level of abnormal power consumption, and power consumption data during application running; and determines a first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data, and processes the abnormal power consumption based on the first processing strategy.
[0168] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0169] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0170] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0171] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described abnormal power consumption handling method. This solves the technical problem that current abnormal power consumption handling methods struggle to achieve a balance between application operation and device battery life. Compared to the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the abnormal power consumption handling method provided in the above embodiments, and will not be repeated here.
[0172] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the abnormal power consumption handling method described above.
[0173] The computer program product provided in this application can solve the technical problem that current abnormal power consumption handling methods struggle to achieve a balance between application operation and device battery life. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the abnormal power consumption handling methods provided in the above embodiments, and will not be repeated here.
[0174] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. An abnormal power consumption processing method characterized by comprising: The abnormal power consumption handling method is applied to a terminal device, the terminal device including a main processor, and the abnormal power consumption handling method includes: During the application's operation on the main processor, detect whether there is abnormal power consumption when the application is running. When abnormal power consumption occurs, obtain the first judgment rule for the type of abnormal power consumption, the second judgment rule for the level of abnormal power consumption, and the power consumption data when running the application. Based on the first judgment rule, the second judgment rule, and the power consumption data, a first processing strategy for handling abnormal power consumption is determined, and the abnormal power consumption is processed based on the first processing strategy.
2. The abnormal power consumption processing method according to claim 1, wherein The first judgment rule includes whether the duration for which the current application holds a partial wake-up lock in the background exceeds a preset holding duration threshold, and the power consumption data includes the holding duration in the partial wake-up lock holding record; The second judgment rule includes whether the application is in an active state for a period of time exceeding a preset active duration threshold, and the power consumption data includes the application being in an active state. The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data includes: If the holding duration is detected to be greater than the preset holding duration threshold, it is determined that there is an abnormality in the application background using the application part of the wake-up lock to hold the lock. If the application background uses the application part of the wake-up lock to hold the lock abnormally and the application is in an active state for a period of time exceeding a preset active duration threshold, then the first processing strategy is determined to terminate the running application. If the application background uses the application part of the wake-up lock abnormally and the application is in an active state for a period of time that does not exceed the preset active duration threshold, then the first processing strategy is determined to be to issue an abnormal power consumption reminder.
3. The abnormal power consumption processing method of claim 1, wherein, The first judgment rule includes whether the CPU utilization rate exceeds a preset utilization rate threshold, and the power consumption data includes the CPU utilization rate of the current application; the second judgment rule includes whether the CPU usage time exceeds a preset usage duration threshold, and the power consumption data includes the CPU usage time. The step of determining the first processing strategy for handling abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data includes: If the CPU usage of the current application is detected to exceed a preset usage threshold, it is determined that the application is abnormally using CPU in the background. If the application's background CPU usage is abnormal and the CPU usage time exceeds a preset usage time threshold, then the first processing strategy is determined to terminate the application. If the application background CPU usage is abnormal and the CPU usage time does not exceed the preset usage time threshold, then the first processing strategy is determined to be to issue an abnormal power consumption reminder.
4. The abnormal power consumption processing method of claim 1, wherein, The steps for detecting whether abnormal power consumption occurs when running the application include: If the detected power consumption rate exceeds the preset power consumption rate threshold, and / or the application response time exceeds the preset response time threshold, and / or the CPU utilization rate exceeds the preset utilization rate threshold, then it is determined that abnormal power consumption has occurred when running the application.
5. The abnormal power consumption processing method of claim 1, wherein, Before the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and power consumption data during application operation, the following are included: Identify the application runtime scenarios of the main processor; If the application running scenario is that the running application is a preset whitelist application, and / or the current device running state is a preset active state, then return to the step of detecting whether abnormal power consumption occurs when the running application is running; If the application running scenario is that the application is not on the preset whitelist and the current device is not in the preset active state, then the steps of obtaining the first judgment rule for abnormal power consumption type, the second judgment rule for abnormal power consumption level, and the power consumption data when running the application are executed.
6. The abnormal power consumption processing method of claim 1, wherein, The extended reality terminal device further includes a secondary processor connected to the main processor, and the abnormal power consumption handling method further includes: During the operation of applications on the secondary processor, the presence of application logging points is used to determine whether abnormal power consumption occurs when the application is running. If the application event logs exist, then abnormal power consumption is determined and the abnormal power consumption level is obtained by parsing the application event logs. Based on the abnormal power consumption level obtained from the analysis, a second processing strategy for handling abnormal power consumption is determined, and the abnormal power consumption is processed based on the second processing strategy.
7. The abnormal power consumption processing method according to any one of claims 1 to 6, wherein The step of processing abnormal power consumption based on the processing strategy is followed by: Record abnormal power consumption logs and abnormal power consumption data when abnormal power consumption occurs; The abnormal power consumption is investigated by using the abnormal power consumption log and the abnormal power consumption data.
8. An abnormal power consumption processing device, characterized in that, The abnormal power consumption processing device includes: The detection module is used to detect whether there is abnormal power consumption when the application is running on the main processor. The acquisition module is used to acquire the first judgment rule for the abnormal power consumption type, the second judgment rule for the abnormal power consumption level, and the power consumption data when the application is running when abnormal power consumption occurs. The determination module is used to determine a processing strategy for abnormal power consumption based on the first judgment rule, the second judgment rule, and the power consumption data, and to process the abnormal power consumption based on the processing strategy.
9. A terminal device, characterized in that, The device includes: a memory, a first processor, a second processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the abnormal power consumption handling method as described in any one of claims 1 to 7.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the abnormal power consumption handling method as described in any one of claims 1 to 7.