CN111949385A - Monitoring control method for terminal process - Google Patents
Monitoring control method for terminal process Download PDFInfo
- Publication number
- CN111949385A CN111949385A CN201910406410.9A CN201910406410A CN111949385A CN 111949385 A CN111949385 A CN 111949385A CN 201910406410 A CN201910406410 A CN 201910406410A CN 111949385 A CN111949385 A CN 111949385A
- Authority
- CN
- China
- Prior art keywords
- processes
- terminal
- running
- control method
- names
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 263
- 230000008569 process Effects 0.000 title claims abstract description 222
- 238000012544 monitoring process Methods 0.000 title claims abstract description 17
- 230000006378 damage Effects 0.000 description 8
- 230000009471 action Effects 0.000 description 4
- 238000004891 communication Methods 0.000 description 4
- 239000011230 binding agent Substances 0.000 description 2
- 238000010276 construction Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000005516 engineering process Methods 0.000 description 2
- 230000003993 interaction Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000000903 blocking effect Effects 0.000 description 1
- 238000010586 diagram Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012545 processing Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
- 230000000007 visual effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/48—Program initiating; Program switching, e.g. by interrupt
- G06F9/4806—Task transfer initiation or dispatching
- G06F9/4843—Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
- G06F9/485—Task life-cycle, e.g. stopping, restarting, resuming execution
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F1/00—Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
- G06F1/26—Power supply means, e.g. regulation thereof
- G06F1/32—Means for saving power
- G06F1/3203—Power management, i.e. event-based initiation of a power-saving mode
- G06F1/3206—Monitoring of events, devices or parameters that trigger a change in power modality
- G06F1/3228—Monitoring task completion, e.g. by use of idle timers, stop commands or wait commands
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Telephone Function (AREA)
Abstract
The invention provides a monitoring control method for a terminal process, which comprises the following steps: s1: adding the newly created package name of the process to the set to form a set containing the package name of the process; s2: counting the number of processes corresponding to the packet names in the set according to the packet names of the processes in the set; s3: when the number of processes corresponding to the packet names in the set exceeds a preset value, acquiring all running processes, and determining n processes which are newly run in all running processes; s4: and destroying other running processes except the n processes which are run latest so as to destroy the processes running in the background in the terminal in batch, and removing the packet names of the destroyed processes contained in the set from the set. The invention sets the process packet name set, traverses all running processes when the trigger condition is met, ensures that the self-starting or associated awakening process can be completely closed under the condition that the self-starting or associated awakening process is not included in the set.
Description
Technical Field
The invention relates to a process monitoring technology of a mobile terminal, in particular to a monitoring control method for a terminal process.
Background
With the great popularization of the intelligent terminal, a user not only pays attention to the appearance and the visual effect of the intelligent terminal, but also pays more and more attention to the performance problem and the power consumption problem of the intelligent terminal, such as the power consumption speed of the terminal, smoothness of running, the memory use condition, the application program starting speed and other performance indexes. The available calculation and storage resources inside the intelligent terminal are usually limited, and when the intelligent terminal interacts with a user, if the terminal opens too many applications, the problems of power consumption, performance and the like of the terminal are influenced.
Moreover, many three-party applications have self-starting and wake-up situations by associated applications. For example, the user does not open the hundred-degree library, but only opens the hundred-degree video, the hundred-degree search, and the like, the user wakes up the hundred-degree library, and even after the user closes the applications, the applications can be woken up by other applications, or actions such as turning on a screen and turning on a screen of a mobile phone. Some applications may default to a timed wake-up service or, when one application exits, send a message to start another application or service. There are many services that do not provide an interface visible or operable to a user, but only run in the background, so that the background services without an interface, and the existing process monitoring technology may not monitor that they are started, and therefore cannot count the background services.
Therefore, in the process of interaction between the user and the intelligent terminal, if the application cannot be actively closed, a large number of processes may be running simultaneously, and some processes hang in the background and occupy system resources, thereby affecting the application interacting with the user and causing problems of high power consumption of the terminal and the like.
Therefore, a method for helping a user actively control the number of processes that a terminal can run simultaneously is needed to improve the user experience of the terminal.
Disclosure of Invention
In order to solve the above problem, the present invention provides a monitoring control method for a terminal process, where the method includes:
s1: adding the newly created package name of the process to the set to form a set containing the package name of the process;
s2: counting the number of processes corresponding to the packet names in the set according to the packet names of the processes in the set;
s3: when the number of processes corresponding to the packet names in the set exceeds a preset value, acquiring all running processes, and determining n processes which are newly run in all running processes;
s4: and destroying other running processes except the n newly running processes, and removing the packet names of the destroyed processes contained in the set from the set.
Further, step S1 specifically includes:
s11: judging whether a package name of a newly created process exists in the set;
s12: and if the process name does not exist, adding the package name of the newly created process to a set to form a set containing the package name of the process.
Further, the data type of the packet name is String, and the set is a set of packet names of processes of which the type is String.
Further, step S4 specifically includes:
s41: traversing all running processes, and acquiring the package name of each running process;
s42: destroying other running processes corresponding to the package names except the n processes running latest according to the acquired package names;
s43: removing from the collection the package names of the destroyed processes contained in the collection.
Further, the basis for determining the preset value in step S3 is at least one of the following: the CPU, memory and terminal system performance of the terminal.
Further, the basis for determining n is at least one of the following: the CPU, memory and terminal system performance of the terminal.
Further, the preset value in step S3 is 8.
Further, n is 4.
The present invention also provides a computer-readable storage medium storing a computer-readable program for implementing the above-described method.
Compared with the prior art, the invention has the following advantages or beneficial effects:
1. the invention defines the time for closing the background running process by setting the process package name set and the trigger condition for closing the process, and the trigger condition can be flexibly set according to the conditions of the CPU, the memory, the terminal system performance and the like of the terminal.
2. According to the method, all running processes are traversed before the background process is closed, and some self-starting or associated awakening applications and services can be ensured to be completely closed even if the applications and services are not contained in the set.
3. When the object is removed from the set, on the premise of whether the action of destroying the process is executed or not, the situation that under the condition of process destruction feedback, part of the process is awakened after destruction and cannot be counted again by the set, and as a result, the packet name of the process is removed from the set, and the process corresponding to the removed packet name is still alive is avoided.
4. The phenomena of large power consumption, overlarge memory occupation, unsmooth mobile phone card and the like in the interaction process of the mobile terminal and the user are reduced, the smoothness of application operation is improved, and the user experience is improved.
Drawings
The scope of the invention will be better understood from the following detailed description of exemplary embodiments when read in conjunction with the accompanying drawings, in which:
fig. 1 is a flowchart of a monitoring control method for a terminal process according to the present invention;
FIG. 2 is a flow diagram of adding a package name of a process to a collection according to an embodiment of the invention;
fig. 3 is a flowchart of a destruction process according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, embodiments of the present invention are described in detail below with reference to the accompanying drawings and examples, so that how to apply technical means to solve technical problems and achieve a technical effect can be fully understood and implemented.
Example one
The application scene of the monitoring control method for the terminal process is arranged on the mobile terminal. Fig. 1 is a flowchart of a monitoring control method for a terminal process according to the present invention, and each step is described in detail below with reference to fig. 1. As shown in fig. 1, the method mainly comprises the following steps:
s1: the newly created package name for the process is added to the collection, forming a collection containing the package names for the process.
In step S1, the set may be a running package name set with String as a data type for storing package names of management processes. Each packet name in the set has a respective number, e.g., the first packet name has a number of 0, the second packet name has a number of 1, and so on. Fig. 2 is a flowchart of adding a package name of a process to a set according to an embodiment of the present invention, and as shown in fig. 2, step S1 specifically includes:
s11: judging whether a package name of a newly created process exists in the set;
s12: and if the process name does not exist, adding the package name of the newly created process to a set to form a set containing the package name of the process.
If a new process is created, the object of the process listener acquires a message of the process creation, the message includes a package name of the process, and stores the package name into the set in step S1, after the application obtains a package name of the String type, it first determines whether the package name exists in the set, and if not, the package name of the String type is added to the set.
S2: and counting the number of the processes corresponding to the packet names in the set according to the packet names of the processes in the set.
S3: and when the number of the processes corresponding to the packet names in the set exceeds a preset value, acquiring all running processes, and determining n processes which are newly run in all running processes.
Specifically, the preset value and n can be determined according to the performances of other terminals such as a CPU, a memory and a terminal system of the terminal and according to actual conditions, so that when the terminal runs processes smaller than the preset value, the running condition is good, and the occurrence of the conditions that the user experience is affected by blocking and the like can be avoided. In the present embodiment, the preset value is 8, and n is 4. When the number of processes run by the terminal is greater than 8, in this embodiment, a getreporting application process method of the ActivityManager may be called to obtain all running processes, and then a getreporting task method of the ActivityManager may be called to determine the latest running 4 processes, that is, the latest running processes of the application or service. All the running processes are acquired here, and it is possible to avoid a situation where a process is created without being monitored during the monitoring process by the object of the listener in step S1.
S4: and destroying other running processes except the n newly running processes, and removing the packet names of the destroyed processes contained in the set from the set. And destroying the background running process in the terminal in batch. Fig. 3 is a flowchart of a destruction process according to an embodiment of the present invention, and as shown in fig. 3, S4 specifically includes:
s41: traversing all running processes, and acquiring the package name of each running process;
s42: destroying other running processes corresponding to the package names except the n processes running latest according to the acquired package names;
s43: removing from the collection the package names of the destroyed processes contained in the collection.
5. In this step, all running processes are traversed, and process information corresponding to the processes is extracted, where the process information includes the packet names of the processes, the numbers of the processes, and other description information. In this embodiment, except for 4 newly running processes, all the other processes execute the forceStopPackage method of ActivityManager according to the package names of the processes to destroy the running of the processes. After each execution of the forceStopPackage method of ActivityManager, the package name of the process contained in the set is removed by a set removal (remove) method, which indicates that the process is destroyed and is not within the statistics. It is worth noting that when the packet name is removed from the set, on the premise that whether the action of destroying the process is executed or not is avoided, under the condition that the feedback is destroyed by the process, part of the process is awakened after being destroyed and cannot be counted again by the set, and as a result, the packet name of the process is removed from the set, and the process corresponding to the removed packet name is still alive.
In the method, the set of packet names of the statistical process only plays a role in counting the number of the processes, and when the number triggering condition is met, the running process is obtained again, and the purpose of doing so is to eliminate the situation that some applications or services are started by themselves but are not counted into the set. By the method, the number of the processes running in the terminal can be strictly controlled within a set interval range, in the embodiment, the interval range is [ 4,8 ], which means that the maximum number of applications capable of running simultaneously is 8, and when the 9 th process is found, a killing condition is triggered, and some processes are closed. The preset value is set mainly according to the comprehensive setting of a terminal CPU, a memory and a mobile phone system, the faster the CPU processes, the strong performance of the terminal is shown, a plurality of applications can be considered simultaneously, the memory is mobile phone resources, each application needs the memory when running, and the larger the memory is, the more applications can be accommodated and run simultaneously; the smoother the terminal system, the faster the logic and speed of processing. The application preset values which can run simultaneously can be flexibly changed according to the actual situation of the terminal equipment and the test verification data, so that the power consumption, the memory and the CPU utilization rate of the terminal are optimized.
Before implementing the present invention, a series of basic constructions have been performed in a system of a mobile terminal, in this embodiment, the mobile terminal uses an Android (Android) system, and the specific construction process is as follows:
1) in a framework layer of an Android system, a process creation identifier can be added to an information file describing a running process, wherein the information file can be a processdocument. The process creation identification may indicate the current state of the process, e.g., true (true) may indicate that the process has been created and false (false) may indicate that the process has been destroyed. When the process is created for the first time, the process creation identifier is set to true, and when the process is destroyed, the process creation identifier is set to false.
2) A process monitor is set in a basic core code block of a frame layer of an Android system, and in this embodiment, the process monitor may be iappprocesslist. The system method interface is provided with a process creating (onNewAppProcessCreated) and destroying (onoldappprocessded). The process monitor can acquire the information created by the process through the system method interface created by the process, and can also acquire the information destroyed by the process through the system method interface destroyed by the process.
3) Communication data exchange rules of process monitor registration and unregistration are added in a client and server method file of management system Binder communication of a framework layer of an Android system, and in the embodiment, the method file can be ActivityManagerNative. The exchange rules may enable mutual communication between processes.
4) The registration and unregistration actions of the process monitor are numbered and registered in an Application Programming Interface (API) file of a frame layer of the Android system, and in this embodiment, the API file of the system may be iactivtymanager.
5) In this embodiment, the activity management service file may be activitymanager service. In which it can be determined whether a process has been created. If the process is created for the first time, calling a process creation notification method (onNewAppProcessCreated) in the process listener, providing application package name information corresponding to the created process, and setting a process creation identifier to true by calling the process creation notification method to indicate that the process is created; if the process is destroyed, a process destruction notification method (onOldAppProcessDied) of the process listener is called in the monitoring code destroyed by the process, an application package name corresponding to the process destruction is provided, and the process creation identifier is set to false by calling the process destruction notification method. When the process is created, if the process is created for the first time, the process mark creation identifier is set to true; if the process is destroyed, the process creation identification is set to false.
6) And creating an object of a process monitor at the application end according to the Binder communication rule, rewriting the two methods to enable the object of the process monitor to be available, and registering the object of the process monitor to be effective, so that the creation and the destruction of the process can be monitored by the object of the monitor at the application end. The object of the process listener can also be used to obtain the package name of the process. If the process is created for the first time, at this time, the process creation identifier is set to true, and the object process of the process listener is notified that the object process has been created; before the process is not destroyed, the process creation identifier is always kept true, the process is invalid after being created again, and at the moment, the object of the process monitor does not need to be notified again; if the process is destroyed, at this point the process creation flag is set to false and the process listener is notified that the object process is destroyed.
By setting the set of the process packet names and the trigger condition for closing the process, when the trigger condition is met, all running processes are traversed by the method, and some self-starting or associated awakening applications and services are ensured to be completely closed without being contained in the set.
Furthermore, the present invention also provides a computer-readable storage medium in which a system program for monitoring control of a terminal process is stored, which when executed by a processor implements the above-described monitoring control method for a terminal process of the present invention. In the specific application: the storage medium can be arranged at a server side or a client side, and can also monitor and control the application of the terminal through a network, so that excessive processes running at the terminal can be closed timely and effectively.
The terminal mentioned in the invention can be a mobile terminal, including a smart phone, a tablet computer, a palm computer and various common portable mobile intelligent terminals. In addition, the processes mentioned in the present invention may include application processes and other services of the terminal.
The above embodiments are only specific embodiments of the present invention. It is obvious that the invention is not limited to the above embodiments, but that many variations are possible. All modifications attainable by one versed in the art from the present disclosure within the scope and spirit of the present invention are to be considered as within the scope and spirit of the present invention.
Claims (9)
1. A monitoring control method for a terminal process is characterized by comprising the following steps:
s1: adding the newly created package name of the process to the set to form a set containing the package name of the process;
s2: counting the number of processes corresponding to the packet names in the set according to the packet names of the processes in the set;
s3: when the number of processes corresponding to the packet names in the set exceeds a preset value, acquiring all running processes, and determining n processes which are newly run in all running processes;
s4: and destroying other running processes except the n newly running processes, and removing the packet names of the destroyed processes contained in the set from the set.
2. The monitoring control method for the terminal process according to claim 1, wherein the step S1 specifically includes:
s11: judging whether a package name of a newly created process exists in the set;
s12: and if the process name does not exist, adding the package name of the newly created process to a set to form a set containing the package name of the process.
3. The snoop control method for terminal processes according to claim 1 or 2, wherein the data type of the packet name is String, and the set is a set of packet names of processes of type String.
4. The monitoring control method for the terminal process according to claim 1, wherein the step S4 specifically includes:
s41: traversing all running processes, and acquiring the package name of each running process;
s42: destroying other running processes corresponding to the package names except the n processes running latest according to the acquired package names;
s43: removing from the collection the package names of the destroyed processes contained in the collection.
5. The interception control method for a terminal process according to claim 1, wherein the predetermined value in the step S3 is determined according to at least one of the following: the CPU, memory and terminal system performance of the terminal.
6. The snoop control method for a terminal process as claimed in claim 5, wherein the basis for determining n is at least one of the following: the CPU, memory and terminal system performance of the terminal.
7. The snoop control method for terminal processes according to claim 1, wherein said preset value in step S3 is 8.
8. The snoop control method for a terminal process as claimed in claim 7, wherein n is 4.
9. A computer-readable storage medium storing a computer-readable program for implementing the method according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910406410.9A CN111949385A (en) | 2019-05-16 | 2019-05-16 | Monitoring control method for terminal process |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910406410.9A CN111949385A (en) | 2019-05-16 | 2019-05-16 | Monitoring control method for terminal process |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111949385A true CN111949385A (en) | 2020-11-17 |
Family
ID=73336638
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910406410.9A Pending CN111949385A (en) | 2019-05-16 | 2019-05-16 | Monitoring control method for terminal process |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111949385A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140229770A1 (en) * | 2013-02-08 | 2014-08-14 | Red Hat, Inc. | Method and system for stack trace clustering |
CN104050035A (en) * | 2014-05-14 | 2014-09-17 | 小米科技有限责任公司 | Processing method and device for application program |
CN106775975A (en) * | 2016-12-08 | 2017-05-31 | 青岛海信移动通信技术股份有限公司 | Process scheduling method and device |
CN107479953A (en) * | 2017-07-31 | 2017-12-15 | 广东欧珀移动通信有限公司 | process management method, device, storage medium and electronic equipment |
-
2019
- 2019-05-16 CN CN201910406410.9A patent/CN111949385A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20140229770A1 (en) * | 2013-02-08 | 2014-08-14 | Red Hat, Inc. | Method and system for stack trace clustering |
CN104050035A (en) * | 2014-05-14 | 2014-09-17 | 小米科技有限责任公司 | Processing method and device for application program |
CN106775975A (en) * | 2016-12-08 | 2017-05-31 | 青岛海信移动通信技术股份有限公司 | Process scheduling method and device |
CN107479953A (en) * | 2017-07-31 | 2017-12-15 | 广东欧珀移动通信有限公司 | process management method, device, storage medium and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105100032B (en) | A kind of method and device for preventing resource from stealing | |
CN110232010A (en) | A kind of alarm method, alarm server and monitoring server | |
KR102094066B1 (en) | Method and device for processing data for mobile games | |
CN109756528B (en) | Frequency control method and device, equipment, storage medium and server | |
CN107943269B (en) | Scheduling job control method, device, terminal equipment and storage medium | |
CN113886193A (en) | Log data processing method and device, electronic equipment and storage medium | |
CN106571933A (en) | Service processing method and device | |
CN113468025A (en) | Data warning method, system, device and storage medium | |
CN112231191B (en) | Log collection method and device | |
CN107704317B (en) | Intelligent device and application management method thereof and device with storage function | |
CN115632827A (en) | Network protection method and device, computer equipment and storage medium | |
CN111949471A (en) | Monitoring control method for terminal process | |
CN111949385A (en) | Monitoring control method for terminal process | |
CN113542256A (en) | Method, device, equipment and storage medium for updating login credentials in client | |
CN113727351A (en) | Communication fraud identification method and device and electronic equipment | |
CN117081844A (en) | Network attack detection method, device, equipment and medium | |
CN115037654A (en) | Flow statistical method and device, electronic equipment and readable storage medium | |
CN114285647A (en) | Method and device for detecting abnormal access of bucket in distributed object storage system | |
CN114281817A (en) | Data cleaning method and device, computer equipment and storage medium | |
CN110688165A (en) | Application wake-up lock management method and device, terminal, storage medium and electronic device | |
CN117294578B (en) | Communication method, system, computer equipment and storage medium | |
CN112261680A (en) | Method, device, equipment and storage medium for adjusting network | |
CN118626234B (en) | Operation response method and operation response device | |
CN109062705B (en) | Method for monitoring interprocess communication, electronic device and readable storage medium | |
CN116185642B (en) | Container memory optimization method and device, storage medium and electronic device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20201117 |
|
RJ01 | Rejection of invention patent application after publication |