Program process management and control method and related equipment

By detecting and setting the background application process to BG grouping or key-BG grouping in an electronic device, the foreground application startup problems caused by background process grouping errors are solved, and the application response speed and stability are improved.

CN119248433APending Publication Date: 2025-01-03HONOR DEVICE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410572961.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2024-04-03
Filing Date
2024-05-09
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In electronic devices such as mobile phones, the application processes running in the background are divided into TA packets or FG packets, resulting in the squeezing of front-end application resources and causing the problems of slow and stuttering of front-end application startup.

Method used

By detecting that the foreground application is running, set its process to a background group (BG grouping), and convert it into a higher priority key-BG group or recorded grouping after a certain period of time to avoid the process running for a long time due to background grouping. The resulting low priority and resource preemption problems.

Benefits of technology

It effectively avoids the foreground application startup delay and lag caused by grouping errors in the background process, and improves the response speed and stability of the foreground application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248433A_ABST
    Figure CN119248433A_ABST
Patent Text Reader

Abstract

The invention provides a program process management and control method and related equipment, and the program process management and control method comprises the steps: setting a first process as a first group when a first application is detected to run in a foreground, and setting the first process as a second group after the first process is managed and controlled as the first group for a period of time; wherein the first group indicates that the first process is a process running in the background, the priority of the second group is higher than that of the first group, and the first process refers to that the first application runs the process controlled to run in the foreground. It can be seen that the first application runs in the foreground to pull the first process to run, the first process belongs to the process running in the background, and the first process is set as the first group indicating that the first process is the process running in the background, namely the background group, so that when the first application is started to run, the first process is prevented from running in the background; however, the problems that foreground application resources are occupied due to the fact that the foreground application is divided into the TA group or the FG group, and foreground applications are started slowly and are blocked are further solved.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on April 3, 2024, with application number 202410408559.1 and invention name “Program process control method and related equipment”, the entire contents of which are incorporated by reference in this application. Technical Field

[0002] The present application relates to the field of program management technology, and in particular to a program process management and control method, electronic device, computer-readable storage medium and computer program product. Background Art

[0003] Mobile phones and other electronic devices are equipped with multiple applications. When the main process of an application is running, the electronic device will also pull up other processes in the background, such as the applet process of the application or the process of other applications. In addition, the electronic device also divides other processes into groups. Some application processes are divided into TA groups, and some application processes are divided into FG groups.

[0004] Since these program processes are in the background, they should belong to the BG group, that is, the background group, but they are divided into the TA group or the FG group and have a higher priority, which leads to the crowding out of the foreground application resources and further causes the problem of slow startup and jamming of the foreground application. Summary of the invention

[0005] The present application provides a program process management method and related equipment, the purpose of which is to avoid the situation where other program processes are in the background when the application is started, but are divided into TA groups or FG groups, which causes the foreground application resources to be squeezed out, further causing the foreground application to start slowly and freeze.

[0006] In order to achieve the above objectives, this application provides the following technical solutions:

[0007] The first aspect of the present application provides a method for controlling a program process, including: when detecting that a first application is running in the foreground, setting the first process to a first group, and after controlling the first process to be the first group for a period of time, setting the first process to a second group; wherein the first group indicates that the first process is a process running in the background, the priority of the second group is higher than that of the first group, and the first process refers to: the process that is controlled to run in the foreground of the first application.

[0008] It can be seen from the above content that: the first application running in the foreground starts the first process to run, and the first process belongs to the process running in the background. The first process is set to indicate that the first process is the first group of processes running in the background, that is, the background group. This can avoid the situation where, when the first application starts running, the first process is in the background, but is divided into a TA group or a FG group, which causes the foreground application resources to be squeezed out, further causing the foreground application to start slowly and freeze.

[0009] Furthermore, after the first process is controlled as the first group for a period of time, it is set to the second group. The priority of the second group is higher than that of the first group. It can also avoid that the first application is stuck in operation due to the first process being continuously controlled as the background group and causing the first process to run slowly since the first process is continuously running in the background and the running priority is low and the running time is prolonged.

[0010] In one possible implementation, setting the first process as the second group includes: setting the first process as a background key group key-BG group, or a group in which the first process is recorded, the group in which the first process is recorded indicates that the first process is a foreground process, and the priority of the key-BG group is higher than that of the first group.

[0011] In a possible implementation, the first process is a small program process of the first application, or a process of the second application, and the process of the second application is controlled to run when the first application runs in the foreground and the second application is not running in the foreground.

[0012] In some scenarios, the main process of the first application is running, and the mini-program process of the first application is pulled up to run in the background. Usually, the mini-program process is also divided into foreground groups such as TA groups or FG groups. In this scenario, when the first application is controlled to run in the foreground, the mini-program process is set as the group indicating background running to avoid the mini-program process occupying the foreground application resources, causing the foreground application to start slowly and freeze.

[0013] In other scenarios, the process of the first application is running, and the process of the second application is also pulled up to run, but the second application is not in the foreground running state, and the process of the second application is also divided into foreground groups such as TA groups or FG groups. In this scenario, the process of the first application is running, and the process of the second application is set as a group indicating background running, so as to avoid the program process of the second application occupying the resources of the foreground application, causing the problem of slow startup and jamming of the foreground application.

[0014] In a possible implementation, after setting the first process as the first group, the method further includes: maintaining the first process as the first group for a period of time. After the first process is set as the first group, in some scenarios, the first process may be switched to other groups, which are usually higher in priority than the first group, thus causing the operation of setting the first process as the first group to become an invalid operation. To avoid this, after setting the first process as the first group, it is also necessary to maintain it in the first group for a certain period of time.

[0015] In a possible implementation, maintaining the first process as the first group for a period of time includes: maintaining the first process as the first group for a period of time by setting a mark bit for the first process. The mark bit is used to indicate that the group of the first process is not adjusted. Therefore, maintaining the first process as the first group for a period of time can be achieved based on the mark bit.

[0016] In a possible implementation, after controlling the first process as the first group for a period of time and before setting the first process as the second group, it also includes: detecting that the first process is not switched to the foreground.

[0017] In a possible implementation, the method further includes: detecting that the first process is switched to the foreground, setting the first process to a third group, wherein the third group indicates that the first process is the process running in the foreground.

[0018] In the above possible implementation manner, the first process is switched to the foreground, and the first process is set to indicate that the first process is the foreground process, thereby ensuring the synchronization of the grouping and running status of the first process, and also ensuring the synchronization of the running priority and running status of the first process.

[0019] In a possible implementation manner, after the first process is set to the third group, the method further includes: canceling the control operation of setting the first process to the second group after being set to the first group for a period of time.

[0020] In one possible implementation, canceling the control operation of setting the first process to the second group after being set to the first group for a period of time includes: deleting the first message, where the first message is used to control the first process to be set to the second group after being set to the first group for a period of time.

[0021] In a possible implementation manner, after setting the first process as the first group, the method further includes: setting the first process to a management and control state.

[0022] In a possible implementation, after setting the first process to the third group, the method further includes: setting the first process to a control end state.

[0023] The second aspect of the present application provides an electronic device, including: a memory and at least one processor. The memory is used to store programs, and the at least one processor is used to run programs, so that the electronic device implements the program process control method provided in the first aspect of the present application and any one of its possible implementations.

[0024] The third aspect of the present application provides a computer storage medium for storing a computer program. When the computer program is executed, it is used to implement the program process management and control method provided in the first aspect of the present application and any one of its possible implementation modes.

[0025] The fourth aspect of the present application provides a computer program product, characterized in that when the computer program product runs on a computer, it enables the computer to execute the program process management and control method provided in the first aspect of the present application and any one of its possible implementation modes. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A flowchart of a method for controlling a program process disclosed in an embodiment of the present application;

[0027] Figure 2 A flowchart of a method for setting the grouping of mini-program processes for a Handler disclosed in an embodiment of the present application;

[0028] Figure 3 A diagram showing the control status of the mini-program process disclosed in the embodiment of the present application;

[0029] Figure 4 This is a diagram showing the effect of controlling the program process disclosed in the embodiment of the present application;

[0030] Figure 5 A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application;

[0031] Figure 6 A software framework diagram of the electronic device disclosed in the embodiment of the present application. DETAILED DESCRIPTION

[0032] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. The terms used in the following embodiments are only for the purpose of describing specific embodiments and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind", "said", "above", "the" and "this" are intended to also include expressions such as "one or more", unless there is a clear contrary indication in the context. It should also be understood that in the embodiments of the present application, "one or more" refers to one, two or more; "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist; for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship.

[0033] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in some embodiments", "in some other embodiments", "in some other embodiments", etc. appearing at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in another way. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in another way.

[0034] The multiple involved in the embodiments of the present application means greater than or equal to two. It should be noted that in the description of the embodiments of the present application, the words "first", "second", etc. are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying an order.

[0035] Mobile phones and other electronic devices are equipped with multiple applications. Take WeChat, an instant messaging application, as an example. After the WeChat application is started, its main process runs. During the operation of the main process of the WeChat application, the electronic device will also pull up multiple mini-program processes in the background to support the mini-program process to respond faster. In addition, the electronic device also divides the mini-program processes into groups. Some mini-program processes are divided into TA groups, and some mini-program processes are divided into FG groups. Both TA groups and FG groups can be understood as foreground groups, and the priority of TA groups is higher than that of FG groups.

[0036] Exemplarily, the applet process AppBrand1 is pulled up through the binding service (bindService), and the applet process AppBrand1 is set with a mark bit to indicate that it is divided into TA groups; the applet process AppBrandX is in FG groups, where X refers to a value other than 1.

[0037] Since these mini-program processes are in the background, they should belong to the BG group, but they are divided into the TA group or FG group, which is at a higher priority, resulting in the crowding out of the foreground application resources, further causing the foreground application to start slowly and freeze. For example, after the WeChat application is started, the user will enter the chat box and the click response will be slow.

[0038] The small program processes of the TA group or FG group occupy the foreground application resources, which can be understood as the small program processes of the TA group or FG group occupying the processor resources of the electronic device, resulting in a reduction in the processor resources allocated by the electronic device to the program processes of the TA group running in the foreground.

[0039] Based on this, an embodiment of the present application provides a method for managing program processes to achieve grouping management of small program processes running in the background, avoiding them from being divided into TA groups or FG groups, occupying foreground application resources, and further causing problems of slow startup and jamming of foreground applications.

[0040] The following article also uses the WeChat application as an example for introduction.

[0041] Before introducing the program process control method provided in the embodiment of the present application, some basic concepts are first introduced.

[0042] The mini-program process defines three states: uncontrolled state (UNCONTROLLED), controlled state (UNDER_CONTROL), and controlled end state (END_CONTROL). When the mini-program process is started and run, it is first set to the uncontrolled state (UNCONTROLLED). In some embodiments, the three states of the mini-program process are respectively indicated by state values. The electronic device identifies the mini-program process with three states, which can realize clear and convenient control of the mini-program process based on the state of the mini-program process.

[0043] The electronic device is configured with a control time T during which the applet process is in a control state. In some embodiments, the control time is a default value, such as T = 4 seconds. In other embodiments, the electronic device calculates the control time T during which the applet process is in a control state based on the current CPU load, T = (1 + m) * T (默认) (Formula 1); Exemplarily, T (默认) The default value of coefficient m is 0. The current CPU load is between 60 and 80, and the coefficient m is 0.2. The current CPU load is above 80, and the coefficient m is 0.5.

[0044] The following combination Figure 1 , the program process control method provided in the embodiment of the present application is introduced.

[0045] like Figure 1 As shown, the program process control method provided in the embodiment of the present application includes:

[0046] S101. Determine whether the feature switch is not turned on or is not a WeChat applet process.

[0047] Among them, the characteristic switch can be understood as being used to indicate whether the electronic device is configured with the processing flow of the method for controlling the program process provided in the embodiment of the present application, or whether the electronic device has the method for controlling the program process provided in the embodiment of the present application that can execute. If the characteristic switch is not turned on, it means that the electronic device is not configured with the processing flow of the method for controlling the program process provided in the embodiment of the present application. If the characteristic switch is turned on, it means that the electronic device is configured with the processing flow of the method for controlling the program process provided in the embodiment of the present application.

[0048] Since there are many types of electronic devices and many versions, some versions may not support the control method for executing the program process provided in the embodiment of the present application. Therefore, judging whether the characteristic switch is not turned on is only to detect whether the electronic device can execute the control method for the program process provided in the embodiment of the present application. In some embodiments, it is not necessary to judge whether the characteristic switch is not turned on in this step.

[0049] As mentioned above, taking the WeChat application as an example, the WeChat application is started, and some small program processes of the WeChat application are pulled up and run. Of course, the electronic device will also run other applications at the same time, and the small program processes of other applications are also in a running state. Based on this, step S101 is used to screen whether the small program process in the running state is a WeChat small program process. In addition, the electronic device executes the judgment of non-WeChat small program processes in step S101, which can be understood as: the electronic device periodically judges whether the small program process in the running state is a non-WeChat small program process.

[0050] Determine whether it is a non-WeChat applet process, that is, identify whether a small program process is a non-WeChat applet process, so as to clarify whether to execute the following steps. Because this embodiment is introduced by taking the WeChat application as an example, step S101 determines whether it is a non-WeChat applet process. But this is not enough to limit this case. In some embodiments, it can also be determined whether it is a small program process of other applications, or other application processes.

[0051] In some embodiments, the method of identifying whether a mini-program process is a non-WeChat mini-program process is as follows: during the initialization of the mini-program process, the type of the mini-program process can be identified based on the package name of the mini-program process. If the mini-program process is identified as a mini-program process of the WeChat application based on the package name of the mini-program process, it can be said that the mini-program process is a WeChat mini-program process, otherwise it is a non-WeChat mini-program process.

[0052] If it is determined that the feature switch is not turned off and the mini-program process is a WeChat mini-program process, the following step S102 is executed. Otherwise, the process provided by the embodiment of the present application is terminated and the native process of the conventional technology is executed.

[0053] S102. Identify the state of the mini program process, that is, identify AppbrandState.

[0054] From the above content, we can know that the applet process is divided into three states, and of course each state corresponds to a state value.

[0055] In some embodiments, the application framework layer of the electronic device includes: a system service (SystemService), which stores the status value of the mini-program process. In addition, the WeChat application is started, the mini-program process of the WeChat application runs, and the system service initializes and sets the mini-program process to an uncontrolled state (UNCONTROLLED).

[0056] In some embodiments, the system service reads the status value of the applet process to clarify the status of the applet process.

[0057] Among them, when the status value of the current mini-program process is the status value corresponding to UNCONTROLLED, that is, when the mini-program process is in a non-controlled state, step S103 is executed. When the status value of the current mini-program process is the status value corresponding to UNDER_CONTROL, that is, when the mini-program process is in a controlled state, step S108 is executed. When the status value of the current mini-program process is the status value corresponding to END_CONTROL, that is, when the mini-program process is in a controlled end state, the process provided by the embodiment of the present application is terminated, and the native process of the conventional technology is executed.

[0058] S103: Identify whether the WeChat application is the foreground application.

[0059] It can be understood that identifying whether the WeChat application is a foreground application can also refer to identifying whether the electronic device is running the WeChat application in the foreground. The WeChat application is a foreground application including: the interface of the WeChat application is the user's focus interface, that is, the interface visible to the user. The user's focus interface includes but is not limited to: the interface of the WeChat application is displayed in full screen, or displayed in a small window. Of course, the interface of the WeChat application mentioned here can refer to any interface of the WeChat application, such as the address book interface, the video call interface, etc.

[0060] In some embodiments, the application framework layer of the electronic device includes: an application management service (ActivityManagerService, AMS), which is used to identify the status of the application running on the electronic device, that is, to know whether the application is the foreground application. In some embodiments, the AMS can know whether the WeChat application is the foreground application, that is, the application focused by the user, by whether the WeChat application is the top stack.

[0061] If the current process is a mini-program process and the WeChat application is the foreground application, execute S104.

[0062] S104, perform the following operations:

[0063] 1. Set the applet process group to BG group;

[0064] 2. Set the control to end after T seconds and restore to the key-BG group;

[0065] 3. Set the applet process status to UNDER_CONTROL;

[0066] 4. Set the message adding flag of BG group, which is the flag of THREAD_GROUP_DEFAULT, to prevent the applet process from switching to other groups after dividing the BG group, such as switching to key-BG group.

[0067] In some embodiments, the method of setting the mini-program process group as a BG group in operation 1 includes:

[0068] The system service sends a message to the Handler, which instructs the setting of the mini-program process group as the BG group. After the Handler receives the message, it can set the mini-program process as the BG group in response to the message. In this way, the mini-program process can be prevented from being divided into TA groups or FG groups, and further prevented from being divided into TA groups or FG groups, which will occupy the foreground application resources and further cause the foreground application to start slowly and freeze.

[0069] It should be noted that Handler can be understood as a module of the application framework layer of the electronic device, which belongs to the system service and is used to group the mini-program processes. Based on this, the system service sending a message to Handler can be understood as a module in the system service sending a message to Handler. Of course, a module in the system service can refer to a module that executes the aforementioned steps S101 to S104, and the execution of step S103 by the module can be understood as identifying whether the WeChat application is the foreground application through AMS.

[0070] Operation 3: Setting the applet process state from UNCONTROLLED to UNDER_CONTROL state. In some embodiments, the system service adjusts the state value of the applet process so that the applet process is adjusted from UNCONTROLLED to UNDER_CONTROL state.

[0071] In some embodiments, the method of setting operation 2 to end control and restore to key-BG group after T seconds includes:

[0072] The system service sends another message to the Handler, which indicates that the control of the mini-program process will end after T seconds and restore it to the key-BG group. After receiving the message, the Handler can delay execution based on T seconds to restore the mini-program process to the key-BG group. The priority of the key-BG group is higher than the BG group. In some embodiments, T seconds defaults to 4 seconds, and 4 seconds is an exemplary value. In other embodiments, as described above, based on the CPU load, T is calculated using the aforementioned formula 1. In some embodiments, the module of the kernel layer of the electronic device can obtain the CPU load information and upload it to the application framework layer to the system service through socket inter-process communication.

[0073] In some embodiments, the sending of messages to the Handler involved in Operation 1 and Operation 2 has no strict execution order and can be performed in parallel.

[0074] After the mini-program process is grouped into the BG group, it may be switched to other groups based on the native process, such as the key-BG group, which will make the setting of the mini-program process as the BG group through operation 1 invalid. Based on this, through operation 4, the flag bit (THREAD_GROUP_DEFAULT) is set to prevent the mini-program process from being switched to other groups based on the native process after being grouped into the BG group.

[0075] In some embodiments, operation 4 and operation 1 are the same message indication. After receiving the message, the Handler may not execute the native process to perform the group switching process based on the THREAD_GROUP_DEFAULT flag bit indicated by the message, and maintain the applet process as the BG group.

[0076] In some embodiments, in the scenario where the impact of the mini-program process being switched to another group due to the native process is not considered, operation 4 may not be performed.

[0077] It should be noted that, in some other embodiments, the setting in operation 2 to end the control and restore to the key-BG group after T seconds may also be the setting to end the control and restore to the recorded group after T seconds.

[0078] Among them, the grouping of the mini-program process is understood as follows:

[0079] When the WeChat application starts running, its mini-program process is grouped into TA groups or FG groups through conventional technology. Based on this, the groups into which the mini-program processes are divided based on conventional technology can be recorded. After the mini-program process is controlled by setting its group to BG group for T seconds, it can also be restored to its recorded group.

[0080] Compared with restoring the mini-program process to the recorded group, restoring the mini-program process to the key-BG group, because the priority of the key-BG group is lower than the FG group, and even lower than the TA group, another group control of the mini-program process is achieved. However, after this group control, since the flag is not set, the native process can be continued. The mini-program process may be quickly switched from the key-BG group based on the native process, or it may take a long time to switch the group.

[0081] It should also be noted that after the mini-program process is controlled as a BG group for T seconds, it will be restored to the key-BG group or the group in which the mini-program process is recorded, and the native process will be restored. The native process will involve the switching of the mini-program process. The purpose is: the operation of the main process of the WeChat application depends on some mini-program processes. In some cases, the main process of the WeChat application can only be continued after some mini-program processes are executed. If the mini-program process is always controlled as a BG group, the main process of the WeChat application will not be able to continue running, causing the main process of the WeChat application to run stuck.

[0082] S105, return true.

[0083] It is understandable that return true belongs to the programming language, which is equivalent to an execution symbol, meaning to continue to execute the following process. In the implementation process of the method of introducing the program process through the process, this step is not critical and can be ignored.

[0084] S106. Determine whether the last grouping of the mini-program process was a BG grouping.

[0085] During the operation of the WeChat application, some small program processes are pulled up and run in the background and divided into BG groups. This is a normal grouping and will not occupy the foreground application resources, causing the foreground application to start slowly and freeze. Therefore, the program process control method provided in the embodiment of the present application does not need to control such small program processes.

[0086] Therefore, the electronic device determines whether the last grouping of the mini-program process is a BG grouping through step S106. If it is determined that the mini-program process is not a BG grouping, step S107 is executed. Otherwise, the process provided by the embodiment of the present application is terminated and the native process of the conventional technology is executed.

[0087] S107, respond to the following operations:

[0088] 1. Set the applet process group to BG group;

[0089] 2. Set the control to end after T seconds and restore to the key-BG group;

[0090] 3. Set the applet process status to UNDER_CONTROL;

[0091] 4. Set the message adding flag of BG group, which is the flag of THREAD_GROUP_DEFAULT, to prevent the applet process from switching to other groups after dividing the BG group, such as switching to key-BG group.

[0092] It can be understood that the execution of step S104 belongs to the above four operations that are only set but not effective, and the execution of step S107 belongs to controlling the effectiveness of the four operations. Among them, the setting of the applet process group as a BG group in step S104 can be understood as generating a message to set the applet process group as a BG group, but the Handler does not respond to the message, and responds only after step S106 determines that the last grouping of the applet process was a BG group. Similarly, the setting of the state of the applet process as a control state in step S104 is also responded after step S106 determines that the last grouping of the applet process was a BG group. The setting in step S104 to end control after T seconds and restore to key-BG grouping can be understood as generating a message indicating that the control will end after T seconds and restore the applet process to a key-BG grouping, but the Handler does not respond to the message, and it is sent to the Handler only after step S106 determines that the last grouping of the applet process was a BG grouping, and the Handler ends the control and restores the applet process to a key-BG grouping after determining that the control duration of the applet meets T seconds. The message for setting the BG group in step S104 is marked with a flag, and is responded to only after it is determined in step S106 that the last grouping of the mini-program process was a BG group.

[0093] It should be noted that steps S104 to S107 can be understood as:

[0094] When the electronic device determines that the mini-program process does not belong to the BG group, it controls the grouping of the mini-program process to be the BG group, and maintains the grouping of the mini-program process within T seconds without switching to other groups; adjusts the state of the mini-program process to the control state; after controlling the mini-program process to be the BG group for T seconds, ends the control of the mini-program process grouping and controls the grouping of the mini-program process to be the key-BG group or the recorded group. When the electronic device determines that the mini-program process belongs to the BG group, it controls the grouping of the mini-program process to be the BG group.

[0095] In the embodiment of the present application, the electronic device identifies that the applet process is in the control state through step S102. Usually, after the electronic device sets the applet process to the control state through steps S104 to S107, the applet process once again performs the method provided in the embodiment of the present application and enters step S102. In this case, the applet process is in the control state.

[0096] S108. Determine whether the mini-program process has a foreground Activity. If so, proceed to step S109; otherwise, proceed to step S110.

[0097] During the running of WeChat application, the user calls a small program to run. This small program can be understood as a small program attached to the WeChat application. Based on the running of the small program, the small program process has a foreground activity, and the small program process becomes the foreground process. In this case, the small program process should be set to TA group.

[0098] S109, perform the following operations:

[0099] 1. Remove the message of setting key-BG grouping in T seconds;

[0100] 2. End the control in advance and set the status of the mini program process to the control end status END_CONTROL.

[0101] One implementation of operation 1 in step S109 is that the system service sends a message to the Handler to remove the key-BG grouping set for T seconds, that is, after T seconds, the applet process is not set as the key-BG group. Based on the message, the Handler determines the applet process corresponding to the message and deletes the message of setting the key-BG grouping for T seconds corresponding to the applet process.

[0102] In addition, the Handler can also end the control of the mini-program process in advance and set the state of the mini-program process to the control end state. In some embodiments, the Handler ending the control of the mini-program process in advance can be understood as: changing the mini-program process from the BG group to other groups, such as the foreground group such as the TA group.

[0103] If the status of the mini-program process is UNDER_CONTROL and there is no foreground Activity, the interception continues directly through step S110, that is, the mini-program process continues to be maintained in the control status of the BG group until T seconds are reached.

[0104] After the mini-program process is set as a BG group for T seconds and is controlled as a key-BG group or a recorded group, the electronic device determines that the mini-program process has a foreground Activity, and sets the mini-program process as a foreground group.

[0105] S110, return false.

[0106] It is understandable that return true belongs to the programming language and is equivalent to a terminator. In the implementation process of the method of introducing the program process through the process, this step is not critical and can be ignored.

[0107] The following combination Figure 2 , the method for setting the grouping of mini-program processes by the Handler provided in the embodiment of the present application is introduced.

[0108] like Figure 2 As shown, the method for Handler to set the grouping of applet processes includes:

[0109] S201. Determine whether it is a message that the mini program process will end control after T seconds.

[0110] Handler is used to set the grouping of the mini-program process. Therefore, Handler can receive messages sent by the system service, which are usually messages for setting the grouping of the mini-program process. As described in the aforementioned embodiment, the message sent by the system service to end the control and restore to the key-BG grouping after T seconds is different from other groupings for setting the mini-program process. Therefore, after receiving the message sent by the system service, step S201 can be used to determine whether the message is a message that ends the control and restores to the key-BG grouping after T seconds (referred to as the message that ends the control after the mini-program process TS). As mentioned above, T can be a default value or a calculated value of the electronic device based on the CPU load.

[0111] In some embodiments, the Handler can parse the received message and determine whether the message is a message indicating that the mini-program process will end management after T seconds based on the parsed content.

[0112] Among them, if the Handler determines that the message belongs to the message that the control of the mini program process will end after T seconds, then execute step S206, otherwise execute S202.

[0113] S202: Determine whether it is a message for the applet process to set a BG group.

[0114] The Handler determines that the message does not belong to the message that the mini-program process ends control after T seconds, and then determines whether the message is a message for setting a BG group for the mini-program process through step S202. If it is determined that the message belongs to the message for setting a BG group for the mini-program process, step S203 is executed. Otherwise, the process provided by the embodiment of the present application is terminated and the native process of the conventional technology is executed. It can be seen that the native process of the conventional technology will set the grouping of the mini-program process by the Handler based on the received message.

[0115] In some embodiments, step S202 may not be executed, and the Handler determines that the message does not belong to the message that the mini-program process ends control after T seconds, and then sets the grouping of the mini-program process based on the message. In some embodiments, the message may indicate the identification of the mini-program process and the set grouping, so the Handler records the grouping set for the mini-program process corresponding to the identification of the mini-program process.

[0116] S203. Set the mini program process group to BG group and set it to control state.

[0117] The Handler determines in step S202 that the message belongs to the message for setting the BG group for the mini-program process, and then sets the mini-program process to the BG group based on the message. In addition, the mini-program process is also recorded as being in the control state.

[0118] In some embodiments, the message of setting the applet process as a BG group may indicate the identifier of the applet process and the information of the BG group, so the Handler records that the applet process corresponding to the identifier of the applet process is a BG group.

[0119] It should be noted that after the Handler sets the mini-program process group to the BG group and it is in the control state, the timer can also be used to obtain the duration for which the mini-program process is set to the BG group.

[0120] S204: Whether the message includes a flag indicating that the key-BG group is not to be cut.

[0121] In some embodiments, after the Handler sets the mini-program process to the BG group, it can determine whether the message includes a mark for not cutting the group after setting the BG group, that is, THREAD_GROUP_DEFAULT. If so, execute step S205 to end. Otherwise, end the process provided by the embodiment of the present application and execute the native process of the conventional technology.

[0122] S205. Maintain the mini-program process grouping as BG grouping.

[0123] Among them, the Handler maintains the applet process grouping as BG grouping until the T second requirement is met.

[0124] In some embodiments, the Handler maintains the applet process grouping into BG groups as follows:

[0125] After monitoring the message of switching the applet process group, the message is identified as switching the applet process to other BG groups, that is, non-BG groups, and the message is discarded, and the message is not responded to to switch the applet process group. Of course, the Handler can also determine the group of the applet process that is used to switch the key-BG group based on the message of switching the applet process group. And, it is determined that the message is detected within T seconds after the applet process is set to the BG group.

[0126] S206. When the control time of the mini-program process reaches TS, the mini-program process is set to end control state.

[0127] After the Handler determines that the received message is a message indicating that the control of the mini-program process ends after TS, it can obtain the timing duration of the mini-program process set to the BG group. Based on the timing duration, when it is determined that the control time of the mini-program process reaches TS, the mini-program process is set to the end of control state.

[0128] In some embodiments, the Handler records the status value corresponding to the end control state of the mini-program process to achieve setting the mini-program process to the end control state.

[0129] S207. Set the applet process to the key-BG group.

[0130] As described in step S206, after the Handler determines that the received message is a message for ending control after the mini-program process TS, it determines that the control time of the mini-program process reaches TS based on the timing duration of the mini-program process set as the BG group. In addition to setting the mini-program process to the end of control state, it also sets the mini-program process to the key-BG group.

[0131] It should be noted that, as described in the aforementioned step S104, the message sent by the system service to the Handler may also be a message that the mini-program process ends control after T seconds and switches to a recorded group. Based on this message, the Handler sets the mini-program process to a recorded group through step S207.

[0132] Figure 2 An execution order of step S206 and step S207 is shown, but this does not constitute a limitation on the execution order of step S206 and step S207.

[0133] The following combination Figure 3 This article introduces the control cycle of the mini program process.

[0134] like Figure 3As shown, the mini program process includes three states, and each state corresponds to a state value. Taking the mini program process of the WeChat application as an example, the mini program process includes: uncontrolled state (UNCONTROLLED), controlled state (UNDER_CONTROL), and control end state (END_CONTROL).

[0135] After a Mini Program process is created, it is first in an uncontrolled state (UNCONTROLLED), running in the foreground of the WeChat application. During the control period of 4S (4S is used as an example), the Mini Program process is in a controlled state (UNDER_CONTROL). After 4S, or when the Mini Program process is switched to the foreground, the Mini Program process is in an ended control state (END_CONTROL).

[0136] The following combination Figure 4 This can illustrate the advantage of the solution provided by the embodiment of the present application in shortening the time consumption.

[0137] Figure 4 The above figure shows that the mini program process is not controlled. It takes time to execute multiple rounds of WeChat application startup to enter the chat box. Figure 4 The following figure shows the time taken to start multiple rounds of WeChat application and enter the chat box by controlling the mini program process. The average time taken by multiple rounds is compared and it is found that the time taken is increased by 25.45%. It can be verified that the mini program process can be controlled by the program process control method provided in the embodiment of the present application, which can reduce the running time of the WeChat application main process and alleviate the problems of slow startup and jamming.

[0138] It should be noted that the inventors further studied the application scenarios of the application process control solution provided in the embodiments of the present application and found that it can also be applied to other scenarios, not limited to WeChat applications.

[0139] In some scenarios, when the main process of an application is running, its mini-program process will also be started and run in the background. The mini-program process of this type of application can also be managed using the application process management method proposed in the above content.

[0140] Based on this, the electronic device can also use the application process control method adopted in the above embodiment to control the mini-program process launched by the application.

[0141] The electronic device determines that the first application starts running. The first application can be understood as an application whose mini-program process will also run when the main process runs. The current status of each mini-program process and the first application is identified, and it is determined whether the grouping of the mini-program process matches the current status of the first application; wherein, the grouping of the mini-program process does not match the current status of the first application, which may refer to: the current application is running in the foreground, the mini-program process is running in the background, and the grouping is a foreground grouping such as a TA grouping or an FG grouping. For mini-program processes whose grouping does not match the current status of the first application, the grouping is dynamically adjusted through the grouping strategy.

[0142] In some embodiments, the grouping strategy includes: setting the mini-program process to a BG group.

[0143] In other embodiments, in the scenario where the main process depends on the mini-program process, in order to avoid the mini-program process being always set to the BG group, causing the main process to run slowly or freeze, the grouping strategy also includes: when the mini-program process is set to the BG group for T seconds, the mini-program process is adjusted from the BG group to the key-BG group or the recorded group; wherein the recorded group refers to: when the first application is running, the mini-program process is set to the group when it is pulled up by the background to run. Because the mini-program process is set to the key-BG group or the recorded group after being set to the BG group for T seconds, it can be understood that the mini-program process is uncontrolled, and the mini-program process can run according to the priority corresponding to the key-BG group or the recorded group, without being restricted by the BG group, which is the lowest priority, and can shorten the running time of the mini-program process, shorten the time the main process is hindered by the running of the mini-program process, and alleviate or even avoid the problem of the main process running freeze or freeze.

[0144] In other embodiments, in order to achieve convenient control over the mini-program process, the mini-program process is set to a BG group, and its state can also be set to a control state. Of course, when the mini-program process is set to a key-BG group or a recorded group, the state of the mini-program process is adjusted to a control-end state. When the mini-program process has not been controlled, its state is an uncontrolled state, that is, the initial state of the mini-program process is an uncontrolled state.

[0145] In other embodiments, after setting the applet process as a BG group, it can also be locked as a BG group for a period of time by setting a flag. The method and effect of setting the flag can refer to the content of step S104 in the above embodiment, which will not be repeated here.

[0146] Furthermore, when the mini-program process is in a controlled state, the electronic device determines that the mini-program process has a foreground Activity and may also execute the contents of step S109 in the aforementioned embodiment, which will not be repeated here.

[0147] Furthermore, the inventor has also found that when some applications in the electronic device are running, the electronic device will start the processes of other applications in the background. Of course, these applications are independent of each other.

[0148] Based on this, the electronic device can also control the application process based on the application process control method provided in the embodiment of the present application.

[0149] The electronic device determines that the second application starts running, wherein when the process of the second application is running, the process of the third application is controlled to run, and of course the third application can be one or more. The electronic device identifies the grouping of the process of the third application, the current status of the third application and the second application, and determines whether the grouping of the process of the third application matches the current status of the second application; wherein, the mismatch between the grouping of the process of the third application and the current status of the second application can refer to: the second application is running in the foreground, the third application is not running in the foreground, the program process of the third application is running in the background, and the grouping is a foreground grouping such as a TA grouping or an FG grouping. For the process of the third application whose grouping does not match the current status of the second application, the grouping is dynamically adjusted through the grouping strategy.

[0150] In some embodiments, the grouping strategy includes: setting the process of the third application as a BG group; it may also include: the duration of setting the process of the third application to the BG group reaches T seconds, and regulating the process of the third application from the BG group to the key-BG group or the recorded group; wherein the recorded group refers to: when the second application is running, the process of the third application is pulled up in the background and the group is set; it may also include: setting three states of the process of the third application; it may also include locking the set group of the process of the third application by setting a flag; it may also include that when the process of the third application is in a control state, when the electronic device determines that the process of the third application has a foreground Activity, it cancels the control of the process of the third application, sets it to the control end state, and deletes the message of setting it to the key-BG group or the recorded group for T seconds.

[0151] Of course, the specific content of the grouping strategy can be found in the corresponding Figure 1 and Figure 2 The contents of the embodiments are not shown here.

[0152] It should also be noted that the program process control method provided in the embodiments of the present application can be applied to mobile phones, and can also be applied to electronic devices such as tablet computers, personal digital assistants (PDAs), desktops, laptops, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, and wearable devices.

[0153] Take mobile phones as an example. Figure 5 This is an example of the composition of an electronic device provided in an embodiment of the present application. Figure 5 As shown, the electronic device 500 may include a processor 510, an internal memory 520, a camera 530, a display screen 540, a mobile communication module 550, a wireless communication module 560, a sensor module 570, and the like.

[0154] It is to be understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 500. In other embodiments, the electronic device 500 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0155] The processor 510 may include one or more processing units, for example, the processor 510 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, a smart sensor hub (sensor hub) and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0156] The processor 510 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 510 is a cache memory. The memory may store instructions or data that the processor 510 has just used or cyclically used. If the processor 510 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 510, and thus improves the efficiency of the system.

[0157] The internal memory 520 can be used to store computer executable program codes, which include instructions. The processor 510 executes various functional applications and data processing of the electronic device 500 by running the instructions stored in the internal memory 520. In some embodiments, the internal memory 520 stores codes for executing the control method of the application process.

[0158] The electronic device implements the display function through the GPU, the display screen 540, and the application processor. The GPU is a microprocessor for image processing, connecting the display screen 540 and the application processor. The GPU is used for image rendering by performing mathematical and geometric calculations.

[0159] The display screen 540 is used to display images, video interfaces, etc. The display screen 540 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oled, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device may include 1 or N display screens 540, where N is a positive integer greater than 1.

[0160] The wireless communication function of the electronic device 500 can be implemented through the antenna 1, the antenna 2, the mobile communication module 510, the wireless communication module 560, the modem processor and the baseband processor.

[0161] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 500 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network.

[0162] The mobile communication module 550 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 500. The mobile communication module 550 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 550 can receive electromagnetic waves from the antenna 1, and filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 510 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1.

[0163] The wireless communication module 560 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 500. The wireless communication module 560 can be one or more devices integrating at least one communication processing module. The wireless communication module 560 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and filters it, and sends the processed signal to the processor 510. The wireless communication module 550 can also receive the signal to be sent from the processor 510, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0164] In the sensor module 570, the pressure sensor 570A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 570A can be set on the display screen 540. There are many types of pressure sensors 570A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. A capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 570A, the capacitance between the electrodes changes. The electronic device determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 540, the electronic device detects the intensity of the touch operation based on the pressure sensor 570A. The electronic device can also calculate the position of the touch based on the detection signal of the pressure sensor 570A.

[0165] The touch sensor 570B is also called a "touch control device". The touch sensor 570B can be set on the display screen 540, and the touch sensor 570B and the display screen 540 form a touch screen, also called a "touch control screen". The touch sensor 570B is used to detect a touch operation acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 540.

[0166] In addition, an operating system runs on the above components, such as an iOS operating system, an Android operating system, a Windows operating system, etc. Application programs can be installed and run on the operating system.

[0167] Figure 6 It is a software structure block diagram of the electronic device according to an embodiment of the present application.

[0168] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.

[0169] The application layer can include a series of application packages. Figure 6 As shown, the application package may include applications such as camera, gallery, WeChat, settings, etc.

[0170] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions. In some embodiments of the present application, Figure 6 As shown, the application framework layer may include system services, and the system services include at least modules such as Handler, and the functions of the system services and Handler may refer to the contents of the aforementioned embodiments.

[0171] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0172] The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0173] The system library can include multiple functional modules. The kernel layer is the layer between hardware and software.

[0174] It should be noted that although the embodiments of the present application are described using the Android system as an example, its basic principles are also applicable to electronic devices based on operating systems such as iOS and Windows.

[0175] Another embodiment of the present application further provides a computer-readable storage medium, which stores instructions, and when the computer-readable storage medium is executed on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

[0176] The computer-readable storage medium may be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0177] Another embodiment of the present application further provides a computer program product including instructions. When the computer program product is run on a computer or a processor, the computer or the processor executes one or more steps in any of the above methods.

[0178] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person of ordinary skill in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for controlling a program process, characterized in that: include: When detecting that the first application is running in the foreground, setting the first process to the first group, and after controlling the first process to be the first group for a period of time, setting the first process to the second group; wherein, the first group indicates that the first process is a process running in the background, the priority of the second group is higher than that of the first group, and the first process refers to: the process that is controlled to run in the foreground of the first application.

2. The method according to claim 1, characterized in that The step of setting the first process as the second group includes: The first process is set as a background key group key-BG group, or a group in which the first process is recorded, wherein the group in which the first process is recorded indicates that the first process is a process running in the foreground, and the priority of the key-BG group is higher than that of the first group.

3. The method according to claim 1 or 2, characterized in that: The first process is a small program process of the first application, or a process of the second application, and the process of the second application is controlled to run when the first application runs in the foreground and the second application is not run in the foreground.

4. The method according to any one of claims 1 to 3, characterized in that: After the first process is set as the first group, the method further includes: The first process is maintained as the first group for a period of time.

5. The method according to claim 4, characterized in that The maintaining the first process as the first group for a period of time includes: The first process is maintained as the first group for a period of time in a manner of setting a mark bit for the first process.

6. The method according to any one of claims 1 to 5, characterized in that: After controlling the first process as the first group for a period of time, before setting the first process as the second group, the method further includes: It is detected that the first process is not switched to the foreground.

7. The method according to claim 6, characterized in that Also includes: It is detected that the first process is switched to the foreground, and the first process is set to a third group, where the third group indicates that the first process is the process running in the foreground.

8. The method according to claim 7, characterized in that After setting the first process as the third group, the method further includes: Cancel the control operation of setting the first process as the first group and then setting it as the second group for a period of time.

9. The method according to claim 8, characterized in that The control operation of canceling the setting of the first process as the first group and then setting it as the second group after a period of time includes: The first message is deleted, where the first message is used to control the first process to be set to the second group after being set to the first group for a period of time.

10. The method according to any one of claims 1 to 8, characterized in that: The step of setting the first process as the first group further includes: Set the first process to a control state.

11. The method according to any one of claims 7 to 9, characterized in that: After setting the first process as the third group, the method further includes: Set the first process to a control end state.

12. An electronic device, characterized in that: include: Memory for storing computer programs or computer instructions; A processor, configured to execute a computer program or computer instruction stored in the memory, so that the electronic device executes the method according to any one of claims 1 to 11.

13. A computer storage medium, characterized in that: Used to store a computer program, which, when executed, is used to implement the method according to any one of claims 1 to 11.

14. A computer program product, characterized in that When the computer program product runs on a computer, the computer is caused to execute the method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Management method and device of applications in background of terminal

    CN107783833A

  • Method and device for application maintenance

    CN108920263A

  • Resource scheduling method and electronic equipment

    CN114911587A

  • Network acceleration method and electronic equipment

    CN116744329A

  • Application Process Management Method And Terminal Device

    US20190205160A1