Android system energy saving method, terminal equipment and storage medium

By recording and analyzing the function call sequence flow of the application and extracting features using the LCS algorithm, the problem of misjudgment of Wakelock release judgment in the prior art is solved, and more effective system energy consumption reduction and battery life extension are achieved.

CN120045343APending Publication Date: 2025-05-27XIAMEN YAXON ZHILLAN TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311531816.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-16
Publication Date
2025-05-27

AI Technical Summary

Technical Problem

When judging and releasing Wakelock in the Android system, the timing cycle selection is too small or too large will lead to misjudgment, causing the system to enter low-power sleep too early or too late, affecting the complete execution of program functions and power savings.

Method used

By recording the application's function call sequence flow, it is divided into normal flow and exception flow, and the common subsequence is extracted using the LCS algorithm to record normal features and exception features. Then, compare the LCS lengths of the function call sequence flow of the application to be analyzed with the normal and exception characteristics, and determine whether there is a Wakelock exception not released.

Benefits of technology

It realizes timely judgment on whether Wakelock is used abnormally, thereby timely release, effectively reducing system energy consumption and extending battery life.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120045343A_ABST
    Figure CN120045343A_ABST
Patent Text Reader

Abstract

The invention relates to an Android system energy saving method, terminal equipment and a storage medium, and the method comprises the steps: recording a function call sequence flow of an application program, and dividing the function call sequence flow into a normal flow and an abnormal flow; comparing all the normal streams with the abnormal streams one by one, extracting a common subsequence in each pair of the normal streams and the abnormal streams by adopting an LCS algorithm, removing the common subsequences from the normal streams and the abnormal streams to obtain normal features and abnormal features, and recording the normal features and the abnormal features; when the LCS length of the function call sequence flow of the application program to be analyzed and the abnormal feature is larger than the LCS length of the function call sequence flow of the application program to be analyzed and the normal feature, it is judged that the situation that the Wakelock is not released abnormally exists. According to the invention, the Wakelock can be released in time, so that the energy consumption of the system is effectively reduced, and the endurance time of the battery is prolonged.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of energy conservation, and particularly to an energy-saving method for Android systems, terminal devices, and storage media. Background Art

[0002] The Wakelock mechanism is a unique power management mechanism in the Android system. Application software uses it to keep the system in a wake state and prevent the system from entering the sleep state, which may affect the execution of the functions of the application software. For Android application software, before running the Wakelock mechanism, it is necessary to apply for a Wakelock first to wake up the CPU through the Wakelock. After the software function is completed, the applied Wakelock needs to be released. If the applied Wakelock is not released correctly, the device cannot enter the sleep mode whether it is in the running or idle state, resulting in a waste of the terminal power.

[0003] To avoid this problem, a common method (such as the invention patent with the publication number CN115114035A) is that the monitoring program performs periodic timing on the application program. If the Wakelock belonging to this application program has not been released and the CPU occupancy rate is low when the timing is full, it is judged that it has not been released correctly, and the monitoring program forcibly releases the Wakelock to save system energy consumption. However, if the timing period of this conventional timing method is selected too small, it may cause misjudgment, resulting in the Wakelock being forcibly released prematurely, and the system entering the low-power sleep state prematurely, resulting in the possible incomplete execution of the program functions. If the timing period is selected too large, it may cause the Wakelock not to be released in time, and a lot of power has been wasted when the timing is full. Since different programs have different functions, different CPU usage situations, and diverse program execution time periods, the traditional method has great difficulty in application and is not universal. Summary of the Invention

[0004] To solve the above problems, the present invention proposes an energy-saving method for Android systems, terminal devices, and storage media, which is used to timely judge whether there is a possibility of incorrect use of the Wakelock, so as to release it in time to save energy consumption.

[0005] The specific solutions are as follows:

[0006] An energy-saving method for Android systems includes the following steps:

[0007] S1: Record the function call sequence flow of the application program, and classify the function call sequence flow into two categories, namely the normal flow and the abnormal flow, according to whether the application and release of the Wakelock are included in the function call sequence flow and the order of the application and release of the Wakelock, and store them.

[0008] S2: Compare all normal flows and abnormal flows one by one. After using the LCS algorithm to extract the common subsequences in each pair of normal and abnormal flows, take the result after removing the common subsequence from the normal flow as the normal feature, and take the result after removing the common subsequence from the abnormal flow as the abnormal feature, and record the normal feature and the abnormal feature.

[0009] S3: Compare the function call sequence flow of the application to be analyzed with the recorded normal feature and abnormal feature respectively in terms of the LCS length. When the LCS length between it and the abnormal feature is greater than the LCS length between it and the normal feature, it is determined that there is a situation where the Wakelock exception of the application to be analyzed is not released.

[0010] Further, the recording process of the function call sequence flow includes the following steps:

[0011] S101: Obtain the function names called by the application.

[0012] S102: Determine whether wakelock is applied in this function. If so, go to S103; otherwise, go to S104.

[0013] S103: Determine whether it is in the wakelock state before applying wakelock. If so, end the recording of the function call sequence flow, mark it as an abnormal flow, and return to S101; otherwise, start the recording of the function call sequence flow and return to S101.

[0014] S104: Determine whether wakelock is released in this function. If so, go to S105; otherwise, return to S101.

[0015] S105: Determine whether it is in the wakelock state before releasing wakelock. If so, end the recording of the function call sequence flow, mark it as a normal flow, and return to S101; otherwise, directly return to S101.

[0016] Further, the function names called are obtained from the Android underlying API or log.

[0017] Further, whether wakelock is applied and released is obtained from the relevant Android API.

[0018] An energy-saving terminal device for an Android system, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of the method in the above embodiments of the present invention are implemented.

[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method in the above embodiments of the present invention are implemented.

[0020] By adopting the above technical solution, the present invention can predict the abnormal Wakelock call through the application program function call process feature, so as to release the Wakelock in time, so as to more effectively reduce the system power consumption and extend the battery life. Brief Description of the Drawings

[0021] Figure 1 The flowchart of the first embodiment of the present invention is shown.

[0022] Figure 2 The flowchart of the recording process of the function call sequence flow in this embodiment is shown. Detailed Embodiments

[0023] To further illustrate the embodiments, the present invention provides drawings. These drawings are part of the disclosure of the present invention, which are mainly used to illustrate the embodiments and can be used to explain the operating principle of the embodiments in conjunction with the relevant descriptions in the specification. With reference to these contents, those of ordinary skill in the art should be able to understand other possible implementation manners and the advantages of the present invention.

[0024] The present invention will be further described below in conjunction with the drawings and specific embodiments.

[0025] Embodiment 1:

[0026] The embodiment of the present invention provides an energy-saving method for an Android system, as Figure 1 shown, the method includes the following steps:

[0027] S1: Record the function call sequence flow of the application program, and classify and store the function call sequence flow into two categories: normal flow and abnormal flow according to whether the application and release of Wakelock are included in the function call sequence flow and the order of application and release of Wakelock.

[0028] The function call sequence flow is abbreviated as the call flow, which is used to record the function call sequence of the application program, that is, to record the function names currently called by the application program in sequence. In this embodiment, the function names called by the application program can be obtained from the Android underlying API or log, and whether to apply and release wakelock is obtained from the relevant Android API.

[0029] As Figure 2 shown, the recording process of the function call sequence flow in this embodiment includes the following steps:

[0030] S101: Obtain the function names called by the application program;

[0031] S102: Determine whether wakelock is applied in this function. If so, go to S103; otherwise, go to S104;

[0032] S103: Determine whether it is in the wakelock state before applying for wakelock. If so, end the call flow record, mark it as an abnormal flow, and return to S101; otherwise, start the call flow record and return to S101;

[0033] S104: Determine whether wakelock is released in this function. If so, proceed to S105; otherwise, return to S101;

[0034] S105: Determine whether it is in the wakelock state before releasing wakelock. If so, end the call flow record, mark it as a normal flow, and return to S101; otherwise, directly return to S101.

[0035] In this embodiment, it is set that only when there are the same number of applications for Wakelock and releases of Wakelock in the call flow, and the release of Wakelock is after the application for Wakelock, is it determined as a normal flow, and other situations are considered abnormal flows.

[0036] S2: Compare all normal flows and abnormal flows one by one. After using the LCS (Longest Common Subsequence) algorithm to extract the common subsequence in each pair of normal flow and abnormal flow, take the result after removing the common subsequence from the normal flow as the normal feature, and take the result after removing the common subsequence from the abnormal flow as the abnormal feature, and record the normal feature and the abnormal feature.

[0037] In this embodiment, function names are expressed by non-repeating symbols. For example, use letters to express a function name. At this time, for a normal flow, its function call sequence flow is AGCEDF; the function call sequence flow of an abnormal flow is AEDCYX; using the LCS algorithm, the longest common subsequence AED can be automatically extracted. The common sequence may represent common function calls. After deducting the common sequence from the normal flow and the abnormal flow, the normal feature and the abnormal feature are obtained. For example, for the above example, the normal feature is GCF, and the abnormal feature is CYX.

[0038] S3: Compare the function call sequence flow of the application to be analyzed with the recorded normal feature and abnormal feature respectively in terms of the LCS length. When the LCS length with the abnormal feature is greater than the LCS length with the normal feature, it is determined that there is a situation where the Wakelock of the application to be analyzed is abnormally not released. At this time, the monitoring program forcibly releases the Wakelock to avoid power waste.

[0039] In an embodiment of the present invention, the function call sequence is obtained through the past execution process of the application program. Taking the function that applies for Wakelock as the starting point of the process fragment and the function that normally releases or the next function that applies for Wakelock as the end point of the process fragment, the function call process fragment is automatically classified into a normal process fragment and an abnormal process fragment, and the longest common subsequence (LCS) algorithm is used to extract the characteristic process from the process fragment. Then, during the program execution, the similarity between the current program process fragment and the normal characteristic process and the abnormal characteristic process is compared. When the similarity with the abnormal characteristic process is greater than the similarity with the normal characteristic process, it is determined that there is an abnormal call to Wakelock, and Wakelock is forcibly released. The embodiment of the present invention can release Wakelock in time to more effectively reduce the system power consumption and extend the battery life.

[0040] Embodiment 2:

[0041] The present invention also provides an energy-saving terminal device for an Android system, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps in the above method embodiment of Embodiment 1 of the present invention are implemented.

[0042] Further, as an executable solution, the energy-saving terminal device for the Android system may be a mobile phone, a personal digital assistant (PDA), a smartwatch, or other computing devices using the Android system.

[0043] Further, as an executable solution, the processor may be a central processing unit (CPU), or may also be other general-purpose processors. The general-purpose processor may be a microprocessor, or the processor may also be any conventional processor, etc. The processor is the control center of the energy-saving terminal device for the Android system, and connects various parts of the entire energy-saving terminal device for the Android system through various interfaces and lines.

[0044] The memory can be used to store the computer program and / or modules. By running or executing the computer program and / or modules stored in the memory, and calling the data stored in the memory, the processor realizes various functions of the Android system energy-saving terminal device. The memory mainly includes a program storage area and a data storage area. Among them, the program storage area can store the operating system and application programs required for at least one function; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include high-speed random access memory, and can also include non-volatile memory, such as hard disks, memory, plug-in hard disks, smart media cards (SMC), secure digital (SD) cards, flash cards, at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage devices.

[0045] The present invention also provides a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the steps of the above method of the embodiments of the present invention are implemented.

[0046] If the modules / units integrated in the Android system energy-saving terminal device are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above method embodiments of the present invention, it can also be completed by instructing relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution medium, etc.

[0047] Although the present invention is specifically shown and described in conjunction with the preferred embodiments, those skilled in the art should understand that various changes can be made to the present invention in form and detail without departing from the spirit and scope of the present invention defined by the appended claims, and all are within the protection scope of the present invention.

Claims

1. An energy-saving method for Android system, characterized in that, it includes the following steps: S1: Record the function call sequence flow of the application program, and classify the function call sequence flow into two categories, normal flow and abnormal flow, according to whether the application and release of Wakelock are included in the function call sequence flow and the order of application and release of Wakelock, and store them; S2: Compare all normal flows and abnormal flows one by one. After using the LCS algorithm to extract the common subsequence in each pair of normal flow and abnormal flow, take the result after removing the common subsequence from the normal flow as the normal feature, and take the result after removing the common subsequence from the abnormal flow as the abnormal feature, and record the normal feature and the abnormal feature; S3: Compare the function call sequence flow of the application program to be analyzed with the recorded normal feature and abnormal feature respectively in terms of the LCS length. When the LCS length with the abnormal feature is greater than the LCS length with the normal feature, it is determined that there is a situation where the Wakelock of the application program to be analyzed is abnormally not released.

2. The energy-saving method for Android system according to claim 1, characterized in that: The recording process of the function call sequence flow includes the following steps: S101: Obtain the function name called by the application program; S102: Judge whether Wakelock is applied in this function. If so, enter S103; otherwise, enter S104; S103: Judge whether it is in the Wakelock state before applying Wakelock. If so, end the recording of the function call sequence flow, mark it as an abnormal flow, and return to S101; otherwise, start the recording of the function call sequence flow and return to S101; S104: Judge whether Wakelock is released in this function. If so, enter S105; otherwise, return to S101; S105: Judge whether it is in the Wakelock state before releasing Wakelock. If so, end the recording of the function call sequence flow, mark it as a normal flow, and return to S101; otherwise, directly return to S101.

3. The energy-saving method for Android system according to claim 1, characterized in that: The function name called is obtained from the Android underlying API or log.

4. The energy-saving method for Android system according to claim 1, characterized in that: Whether to apply and release Wakelock is obtained from the relevant Android API.

5. An energy-saving terminal device for Android system, characterized in that: It includes a processor, a memory, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

6. A computer-readable storage medium, the computer-readable storage medium stores a computer program, characterized in that: When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Lock holding release control method and device, computer equipment and storage medium

    CN115114035A