A method and system for controlling application power consumption of an Android system
By calculating and predicting the remaining power of applications, refined power consumption management and control of applications in the Android system is achieved, which solves the problem of unrefined power consumption management in the existing technology and significantly saves power.
Patent Information
- Application Number
- CN202410747206.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-11
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-11
AI Technical Summary
Existing technology makes it difficult to accurately locate and manage applications that consume more power in the Android system, making it difficult for users to effectively save power.
By obtaining the power consumption proportion value of the target application, calculate its initial value of remaining power, and collect the power consumption according to the time window to update the remaining power, predict the remaining power duration, and prohibit the application from running if it is insufficient. If it is sufficient, wait until the duration is reached.
It achieves refined power consumption control of applications, effectively saves power and avoids users’ need for frequent charging.
Smart Images

Figure CN118312028B
Abstract
Description
Technical Field
[0001] The present invention relates to system application management technology, and in particular to an application power consumption control method and system of an Android system. Background Art
[0002] Currently, the Android system can support a variety of applications. These applications will occupy the system's hardware resources, resulting in a rapid power consumption of smart terminals equipped with the Android system, which require frequent charging to maintain daily use.
[0003] The existing technology often guides users to stop or uninstall power-consuming applications by collecting statistics on the power consumption of all applications and ranking the applications with high power consumption. However, there may be a situation where the user's frequently used applications are ranked at the top, making it difficult for users to accurately locate the uncommon applications that actually need to be stopped or uninstalled. Summary of the invention
[0004] The technical problem to be solved by the present invention is: in view of the technical problems existing in the prior art, the present invention provides an application power consumption control method and system of an Android system, which can perform fine-grained power consumption control for each application of the system.
[0005] In order to solve the above technical problems, the technical solution proposed by the present invention is:
[0006] An Android system application power consumption control method comprises the following steps:
[0007] Obtaining the power consumption ratio value of the target application, calculating the product of the power consumption ratio value of the target application and the total battery capacity, and obtaining the initial value of the remaining power of the target application;
[0008] The power consumption of the time window of the target application is collected at a specified interval, and the power consumption of the corresponding time window is subtracted from the remaining power of the target application to update the remaining power of the target application;
[0009] Determine whether the remaining power of the target application is insufficient. If the remaining power of the target application is insufficient, prohibit the target application from running. If the remaining power of the target application is sufficient, predict the remaining power duration of the target application, and prohibit the target application from running after waiting for the remaining power duration to be reached.
[0010] Furthermore, the remaining battery life of the target application is predicted, including:
[0011] Obtain the historical power consumption information records of the target application, calculate the average foreground power consumption, the average background non-sleep state power consumption, and the average background sleep state power consumption of the target application based on the historical power consumption information records, and calculate the foreground running time ratio, the background non-sleep state running time ratio, and the background sleep state running time ratio of the target application;
[0012] Divide the remaining power of the target application by the average foreground power consumption, the average background non-sleep state power consumption, and the average background sleep state power consumption respectively, and then take the foreground running time ratio, background non-sleep state running time ratio, and background sleep state running time ratio of the target application as the corresponding weights of the calculation results for weighted summation to obtain the predicted value of the remaining power time.
[0013] Furthermore, the predicted value expression of the remaining battery time is as follows:
[0014] Remaining battery life = a × remaining battery life of the app / X + b × remaining battery life of the app / Y + c × remaining battery life of the app / Z
[0015] Among them, a, b, and c are the foreground running time ratio, background non-sleeping state running time ratio, and background sleeping state running time ratio of the target application, respectively; X, Y, and Z are the average foreground power consumption, background non-sleeping state power consumption, and background sleeping state power consumption of the target application, respectively.
[0016] Furthermore, after waiting for the remaining battery time to be reached, prohibiting the target application from running includes:
[0017] If the remaining power duration of the target application is greater than the specified interval, jump to the step of collecting the power consumption of the target application in the time window according to the specified interval;
[0018] If the remaining battery life of the target application is less than the specified interval, the timer duration is set to the remaining battery life, and the target application is prohibited from running after the timer duration is reached.
[0019] Furthermore, the target application is prohibited from running, including:
[0020] Prohibit the operation of various components, including one or more components corresponding to the target application in Activity, Service, ContentProvider, and Broadcast;
[0021] Kill the running target application.
[0022] Furthermore, before obtaining the power consumption ratio value of the target application, the step of configuring the power consumption ratio value of the target application is also included, including:
[0023] If the target application is a commonly used application, the power consumption ratio value of the target application is configured to be a first interval value;
[0024] If the target application is an infrequently used application, the power consumption ratio value of the target application is configured to be a second interval value, and the second interval value is smaller than the first interval value;
[0025] The power consumption ratio value of the target application is saved in a local configuration file.
[0026] Furthermore, prohibiting the target application from running also includes:
[0027] Generate a prompt message and wait for a specified time. If a new power consumption ratio value of the target application is obtained within the specified time, calculate the product of the new power consumption ratio value and the total battery capacity, and then subtract the initial value of the remaining power to obtain the newly added remaining power of the target application, and execute the step of predicting the remaining power duration of the target application.
[0028] Furthermore, obtaining the power consumption ratio value of the target application includes:
[0029] Get the content of the local configuration file, parse the power consumption ratio value corresponding to the target application, and use Map<String, AppWater> Structure storage.
[0030] Furthermore, when collecting the time window power consumption of the target application at a specified interval, it includes:
[0031] Poll once at preset time intervals to collect the power consumption of each hardware under the target application, calculate the difference in power consumption between two adjacent pollings, and obtain the power consumption value of each hardware in each time window. The total power consumption of all hardware under the target application in the same time window is used as the power consumption of the corresponding time window of the target application.
[0032] The present invention also proposes an application power consumption control system of an Android system, comprising:
[0033] The module for calculating the initial value of the remaining power of the application is used to obtain the power consumption ratio value of the target application, calculate the product of the power consumption ratio value of the target application and the total capacity of the battery, and obtain the initial value of the remaining power of the target application;
[0034] The application remaining power update module is used to collect the time window power consumption of the target application at a specified interval, and subtract the corresponding time window power consumption from the remaining power of the target application to update the remaining power of the target application;
[0035] The application cleaning module is used to determine whether the remaining power of the target application is insufficient. If the remaining power of the target application is insufficient, the target application is prohibited from running. If the remaining power of the target application is sufficient, the remaining power duration of the target application is predicted, and the target application is prohibited from running after the remaining power duration is reached.
[0036] Compared with the prior art, the advantages of the present invention are:
[0037] The present invention sets a power consumption ratio value for the application, multiplies the power consumption ratio value and the total battery capacity of the device to calculate the initial value of the remaining power of the application, so that the user can adjust the power consumption ratio value according to actual needs to adapt to different scenario requirements.
[0038] The present invention updates the remaining power of an application by subtracting the power consumption of the application's time window from the remaining power of the application. When the remaining power of the application is sufficient, the remaining power duration of the application is predicted, and the application is prohibited from running after the remaining power duration is reached. This allows for refined management of the application and effectively saves power consumption. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 is a flow chart of an embodiment of the present invention. DETAILED DESCRIPTION
[0040] The present invention is further described below in conjunction with the accompanying drawings and specific preferred embodiments, but the protection scope of the present invention is not limited thereby.
[0041] Embodiment 1
[0042] In the Android system, in order to perform fine-grained control over the power consumption of each application in the system, this embodiment considers presetting a power consumption threshold for each application, quantifying the power consumption of all applications during the operation of the operating system, and completely limiting the power consumption of the application when the power consumption of the application reaches or exceeds the preset threshold.
[0043] like Figure 1 As shown, based on the above ideas, this embodiment proposes an application power consumption control method of an Android system, including the following steps:
[0044] S101) Configure the power consumption ratio value of the target application, including:
[0045] If the target application is a commonly used application, the power consumption ratio value of the target application is configured to be a value within the range of 30% to 40%, which is referred to as the first interval value in this embodiment for distinction;
[0046] If the target application is an infrequently used application, the power consumption ratio value of the target application is configured to be a value within a range of 5% to 10%, which is referred to as the second interval value in this embodiment for distinction;
[0047] The power consumption ratio value of the target application is saved in a local configuration file.
[0048] It should be noted that the target application may be one or more applications specified in the Android system, or may be all applications in the Android system, which is not limited in this embodiment.
[0049] S102) calculating the initial value of remaining power according to the power consumption ratio of the target application;
[0050] Specifically, the power consumption ratio value of the target application is obtained, and the product of the power consumption ratio value of the target application and the total battery capacity is calculated to obtain the initial value of the remaining power of the target application. When obtaining the power consumption ratio value of the target application, the following steps are included:
[0051] Initialization: First create an independent working thread, and add the epoll message mechanism to this thread, which can handle any time-consuming work tasks;
[0052] Loading strategy: Get the local configuration file content, parse it to find the power consumption ratio value (a decimal value is used, which indicates the proportion of the total battery consumption of the device that the application is allowed to consume) corresponding to the target application, and use Map<String,AppWater> Structure storage.
[0053] S103) updating the remaining power according to the power consumption in the time window;
[0054] Specifically, the time window power consumption of the target application is collected at a specified interval, and the remaining power of the target application is subtracted from the corresponding time window power consumption to update the remaining power of the target application. When the time window power consumption of the target application is collected at a specified interval, the following steps are included:
[0055] Poll once at preset time intervals, collect power consumption of each hardware (such as CPU, screen, etc.) under the target application, calculate the difference in power consumption between two adjacent pollings, obtain the power consumption value of each hardware in each time window, and calculate the total power consumption of all devices under the target application. Thus, the total power consumption of all hardware under the target application in the same time window is used as the corresponding time window power consumption of the target application. The remaining power of the target application is subtracted from the time window power consumption to update the remaining power.
[0056] It should be noted that how to collect the power consumption of each hardware under the application for the Android system is well known to those skilled in the art, and the specific implementation process will not be repeated in this embodiment.
[0057] S104) Cleaning up target applications based on the remaining power;
[0058] First, determine whether the remaining power of the target application is insufficient. In this embodiment, determine whether the remaining power of the target application is insufficient, including but not limited to the following methods:
[0059] Determine whether the remaining power of the target application is less than a specified threshold, such as 0 or other values. If it is less than or equal to the specified threshold, the remaining power is insufficient; if it is greater than the specified threshold, the remaining power is sufficient;
[0060] Determine whether the remaining power of the target application is less than a specified percentage of the initial value of the remaining power, such as 5% or other values. If it is less than or equal to the specified percentage, the remaining power is insufficient; if it is greater than the specified percentage, the remaining power is sufficient;
[0061] Then, different processing is performed according to the different conditions of the remaining power, including:
[0062] 1. The target application has insufficient remaining battery power
[0063] If the remaining power of the target application is insufficient, the target application is prohibited from running. In this embodiment, when the target application is prohibited from running, the application is fully controlled at the system level to prohibit the use and operation of the application. The control starts from Activity, Service, Content Provider, and Broadcast, and one or more components corresponding to the target application in Activity, Service, Content Provider, and Broadcast are fully prohibited from running, and the target application that is already running is killed;
[0064] It should be noted that how to comprehensively control applications from the system level starting from Activity, Service, ContentProvider, and Broadcast is well known to those skilled in the art, and the specific implementation process will not be described in detail in this embodiment.
[0065] 2. The target application has enough remaining power
[0066] If the remaining power of the target application is sufficient, the remaining power duration of the target application is predicted, and the target application is prohibited from running after the remaining power duration is reached. In this embodiment, the remaining power duration of the target application is predicted, including:
[0067] Obtain the historical power consumption information records of the target application, and calculate the target application's foreground power consumption average value X (total foreground application power consumption / foreground running time), background non-sleeping state power consumption average value Y (total background non-sleeping application power consumption / background non-sleeping running time), and background sleeping state power consumption average value Z (using empirical estimation) based on the historical power consumption information records, and calculate the target application's foreground running time ratio a, background non-sleeping state running time ratio b, and background sleeping state running time ratio c;
[0068] Divide the remaining power of the target application by the average power consumption of the foreground X, the average power consumption of the background non-sleep state Y, and the average power consumption of the background sleep state Z, respectively. Then take the foreground running time ratio a, the background non-sleep state running time ratio b, and the background sleep state running time ratio c of the target application as the corresponding weights of the calculation results for weighted summation to obtain the predicted value of the remaining power time. The expression is as follows:
[0069] Remaining battery life = a × remaining battery life of the app / X + b × remaining battery life of the app / Y + c × remaining battery life of the app / Z
[0070] Among them, a, b, and c are the foreground running time ratio, background non-sleeping state running time ratio, and background sleeping state running time ratio of the target application, respectively; X, Y, and Z are the average foreground power consumption, background non-sleeping state power consumption, and background sleeping state power consumption of the target application, respectively.
[0071] Furthermore, after waiting for the remaining battery time to be reached, prohibiting the target application from running includes:
[0072] If the remaining power duration of the target application is longer than the specified interval, jump to the step of collecting the power consumption of the target application in the time window according to the specified interval, wait for entering the next time window, and continue to update the remaining power with the power consumption through the next time window;
[0073] If the remaining battery life of the target application is less than the specified interval, the timer duration is set to the remaining battery life, and the target application is prohibited from running after the timer duration is reached.
[0074] Considering that users may have special needs, for example, some chat applications need to release application restrictions to maintain continued use after the power consumption reaches or exceeds a preset value. Therefore, in this embodiment, prohibiting the target application from running also includes:
[0075] Generate a prompt message to inform the user that the power consumption of the target application has reached or exceeded the limit, and generate a fill-in box for the user to fill in or modify the power consumption ratio value, and wait for a specified time. If the waiting timeout occurs, the target application is prohibited from running;
[0076] If a new power consumption ratio value of the target application is obtained from the fill-in box within the specified time (the new power consumption ratio value must be greater than the preset power consumption ratio value), the product of the new power consumption ratio value and the total battery capacity is calculated, and then the initial value of the remaining power is subtracted to obtain the newly added remaining power of the target application, thereby releasing the power consumption limit of the target application;
[0077] The step of predicting the remaining power duration of the target application is performed until the newly added remaining power is exhausted.
[0078] Embodiment 2
[0079] Based on the first embodiment, this embodiment proposes an application power consumption control system of an Android system, which is a power consumption precise control subsystem applied in the Android system, specifically including:
[0080] The module for calculating the initial value of the remaining power of the application is used to obtain the power consumption ratio value of the target application, calculate the product of the power consumption ratio value of the target application and the total capacity of the battery, and obtain the initial value of the remaining power of the target application;
[0081] The application remaining power update module is used to collect the time window power consumption of the target application at a specified interval, and subtract the corresponding time window power consumption from the remaining power of the target application to update the remaining power of the target application;
[0082] The application cleaning module is used to determine whether the remaining power of the target application is insufficient. If the remaining power of the target application is insufficient, the target application is prohibited from running. If the remaining power of the target application is sufficient, the remaining power duration of the target application is predicted, and the target application is prohibited from running after the remaining power duration is reached.
[0083] The following is an explanation of the workflow of the application power consumption control system of the Android system in this embodiment:
[0084] 1) Create an independent working thread and add the epoll message mechanism to this thread to handle any time-consuming work tasks;
[0085] 2) The application remaining power initial value calculation module obtains the local configuration file content, parses it to find the power consumption ratio value corresponding to each application, and uses Map<String, AppWater> Structure storage.
[0086] 3) The application remaining power update module polls once every preset time interval, collects the power consumption of the application on each hardware, calculates the difference between each polling (that is, the power consumption value of a certain hardware in this time window), and then calculates the total power consumption of all hardware under the application. The application remaining power initial value calculation module multiplies the power consumption ratio of the application by the total battery capacity of the device to equal the initial value of the application remaining power. After each polling, the application remaining power update module subtracts the application power consumption in this time window from the application remaining power to obtain the latest application remaining power.
[0087] 4) The application cleaning module determines the remaining battery power of the application. If the remaining battery power of the application is insufficient, the use and operation of the application will be completely prohibited from the system level. The management and control starts from Activity, Service, ContentProvider, and Broadcast, and all components are completely prohibited from running. Those that are already running will be killed.
[0088] If the remaining battery power of the application is sufficient, the remaining battery time of the application is predicted and calculated first. If the calculated predicted time is longer than the time window, no processing is done, and the remaining battery power update module of the application waits for entering the next time window to continue updating the remaining battery power of the application, and then the application cleanup module determines the remaining battery power of the application; on the contrary, if the calculated predicted time is less than the time window, a timer is added, and the timing time is the predicted time. When the timing time is reached, the application is fully controlled. The control also starts from Activity, Service, ContentProvider, and Broadcast, and all components are completely prohibited from running, and those that are already running are killed.
[0089] In summary, the present invention proposes an application power consumption control method for an Android system, which realizes accurate control of the power consumed by each application and reduces the power consumption of the entire machine. At the same time, based on this method, a new power consumption accurate control subsystem is proposed, which can perform refined management of applications in the Android system and save power consumption.
[0090] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the process Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0091] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A method for controlling application power consumption in an Android system, characterized in that: The following steps are involved: Obtaining the power consumption ratio value of the target application, calculating the product of the power consumption ratio value of the target application and the total battery capacity, and obtaining the initial value of the remaining power of the target application; The power consumption of the time window of the target application is collected at a specified interval, and the power consumption of the corresponding time window is subtracted from the remaining power of the target application to update the remaining power of the target application; Determine whether the remaining power of the target application is insufficient. If the remaining power of the target application is insufficient, prohibit the target application from running. If the remaining power of the target application is sufficient, predict the remaining power duration of the target application, and prohibit the target application from running after waiting for the remaining power duration to be reached. Prohibiting the target application from running after waiting for the remaining power duration to be reached includes: If the remaining power duration of the target application is greater than the specified interval, jump to the step of collecting the power consumption of the target application in the time window according to the specified interval; If the remaining battery life of the target application is less than the specified interval, the timer duration is set to the remaining battery life, and the target application is prohibited from running after the timer duration is reached.
2. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: When predicting the remaining battery life of the target application, it includes: Obtain the historical power consumption information records of the target application, calculate the average foreground power consumption, the average background non-sleep state power consumption, and the average background sleep state power consumption of the target application based on the historical power consumption information records, and calculate the foreground running time ratio, the background non-sleep state running time ratio, and the background sleep state running time ratio of the target application; Divide the remaining power of the target application by the average foreground power consumption, the average background non-sleep state power consumption, and the average background sleep state power consumption respectively, and then take the foreground running time ratio, background non-sleep state running time ratio, and background sleep state running time ratio of the target application as the corresponding weights of the calculation results for weighted summation to obtain the predicted value of the remaining power time.
3. The method for controlling application power consumption of an Android system according to claim 2, characterized in that: The predicted value expression of the remaining battery time is as follows: Remaining battery life = a × remaining battery life of the app / X + b × remaining battery life of the app / Y + c × remaining battery life of the app / Z Among them, a, b, and c are the foreground running time ratio, background non-sleeping state running time ratio, and background sleeping state running time ratio of the target application, respectively; X, Y, and Z are the average foreground power consumption, background non-sleeping state power consumption, and background sleeping state power consumption of the target application, respectively.
4. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: Prohibit the target application from running, including: Prohibit the operation of various components, including one or more components corresponding to the target application in Activity, Service, ContentProvider, and Broadcast; Kill the running target application.
5. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: Before obtaining the power consumption ratio value of the target application, the step of configuring the power consumption ratio value of the target application includes: If the target application is a commonly used application, the power consumption ratio value of the target application is configured to be a first interval value; If the target application is an infrequently used application, the power consumption ratio value of the target application is configured to be a second interval value, and the second interval value is smaller than the first interval value; The power consumption ratio value of the target application is saved in a local configuration file.
6. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: Prohibiting the target application from running also includes: Generate a prompt message and wait for a specified time. If a new power consumption ratio value of the target application is obtained within the specified time, calculate the product of the new power consumption ratio value and the total battery capacity, and then subtract the initial value of the remaining power to obtain the newly added remaining power of the target application, and execute the step of predicting the remaining power duration of the target application.
7. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: When obtaining the power consumption ratio value of the target application, it includes: Get the content of the local configuration file, parse the power consumption ratio value corresponding to the target application, and use Map<String,AppWater> Structure storage.
8. The method for controlling application power consumption of an Android system according to claim 1, characterized in that: When collecting the target application's time window power consumption at specified intervals, it includes: Poll once at preset time intervals to collect the power consumption of each hardware under the target application, calculate the difference in power consumption between two adjacent pollings, and obtain the power consumption value of each hardware in each time window. The total power consumption of all hardware under the target application in the same time window is used as the power consumption of the corresponding time window of the target application.
9. An application power consumption control system for an Android system, characterized in that: include: The module for calculating the initial value of the remaining power of the application is used to obtain the power consumption ratio value of the target application, calculate the product of the power consumption ratio value of the target application and the total capacity of the battery, and obtain the initial value of the remaining power of the target application; The application remaining power update module is used to collect the time window power consumption of the target application at a specified interval, and subtract the corresponding time window power consumption from the remaining power of the target application to update the remaining power of the target application; The application cleaning module is used to determine whether the remaining power of the target application is insufficient. If the remaining power of the target application is insufficient, the target application is prohibited from running. If the remaining power of the target application is sufficient, the remaining power duration of the target application is predicted, and the target application is prohibited from running after the remaining power duration is reached. When the target application is prohibited from running after the remaining power duration is reached, it includes: If the remaining power duration of the target application is greater than the specified interval, jump to the step of collecting the power consumption of the target application in the time window according to the specified interval; If the remaining battery life of the target application is less than the specified interval, the timer duration is set to the remaining battery life, and the target application is prohibited from running after the timer duration is reached.
