Application program information processing method, electronic equipment and readable storage medium
By monitoring and adjusting the resource allocation priority of application processes, the problem of resource waste in electronic devices is solved, and the rational allocation and conservation of resources are achieved, thereby improving device performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-10-26
- Publication Date
- 2026-04-28
AI Technical Summary
As applications become more feature-rich and the number of processes increases, the resource consumption of electronic devices increases significantly, and resource allocation becomes unreasonable. In particular, non-main processes, such as mini-programs, occupy high-level resources unnecessarily, resulting in waste.
By monitoring the changes in the running status of the first process, its resource allocation priority is dynamically adjusted, either by lowering or raising the resource allocation priority, so as to rationally allocate the resources of electronic devices and ensure that critical processes obtain the resources they need.
While meeting the rich functional requirements of applications, it saves the resource consumption of electronic devices, avoids unnecessary waste of resources by unnecessary processes, and improves the rationality of resource allocation and device performance.
Smart Images

Figure CN121934992A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for processing application information, an electronic device, and a readable storage medium. Background Technology
[0002] With the development of computer and terminal technologies, applications running on electronic devices are becoming increasingly diverse, and their functions are becoming more and more abundant. To support these diverse functions, multiple processes need to be launched during application execution to perform different tasks. Simultaneously, the number of processes increases with the increase in application functionality, and the resources consumed by electronic devices to run these processes also increase significantly. Summary of the Invention
[0003] This application provides a method for processing application information, an electronic device, and a readable storage medium, which can save the resource consumption of electronic devices while meeting the needs of applications to achieve rich functions. The technical solution of the embodiments of this application is as follows:
[0004] In a first aspect, a method for processing application information is provided, comprising: running the first process according to the first priority when the resource allocation priority of the first process of the target application is a first priority; the first process is a non-main process of the target application; obtaining running state change information of the first process of the target application; the running state change information is used to indicate that the running state of the first process has changed from a first running state to a second running state; changing the resource allocation priority of the first process to a second priority according to the running state change information of the first process; the resource allocation priority is used to allocate resources of electronic devices to the first process.
[0005] The above method can be executed during the running of the target application. In this embodiment, the first process can also be started before running the first process. After the first process is started, it can be in a foreground running state or a non-foreground running state. For example, the first process is a mini-program process. The user can click the mini-program icon on the desktop, and the electronic device responds to the user's click on the mini-program icon and starts the mini-program process. In the case of directly starting the first process, the first process and the main process of the target application may be started at the same time, with the main process starting the first process. In this case, the first process is in a foreground running state.
[0006] In the embodiments of this application, the initiation of a process can also be referred to as the creation of a process, which can refer to the transformation of a process from a state where it is not running on an electronic device to a state where it is running on an electronic device.
[0007] The first process of the target application can be started by the main process of the target application. A non-main process, also known as a child process of the main process of the target application, can belong to the target application but be a process other than the main process.
[0008] Both the first running state and the second running state described above refer to the running state of the first process. That is, in both the first and second running states, the first process is running and has not been shut down. The first and second running states may meet one of the following conditions.
[0009] Scenario 1: In the first running state and the second running state, the urgency of the first process responding to user operations is different.
[0010] For example, in the first running state, the first process may need to respond to user actions immediately, while in the second running state, the first process may not need to respond to user actions immediately, or vice versa.
[0011] Scenario 2: The real-time nature of user interaction with the first process differs between the first and second running states. For example, in the first running state, the user interacts with the first process in real time, while in the second running state, the user does not directly interact with the first process in real time.
[0012] Scenario 3 differs between the first and second running states depending on whether the user directly interacts with the first process. If the first process directly interacts with the user, an interface for displaying information about the first process is created on the electronic device's screen, and this interface is located at the forefront of the electronic device's screen. If the first process does not directly interact with the user, no interface for displaying information about the first process is created on the electronic device, or the interface for displaying information about the first process is not located at the forefront of the electronic device's screen.
[0013] If the interface used to display information about the first process is located at the very front of the electronic device's display screen, the user can directly view the window used to display the information about the first process.
[0014] Scenario 4: In the first and second running states, the tasks handled by the first process are of different importance.
[0015] In a specific implementation, the importance of the task handled by the first process can be determined based on whether the user needs the first process to perform the corresponding user operation. Alternatively, the importance of the task handled by the first process can be determined based on whether the user can directly operate on the first process (or whether the first process can directly receive user operation information).
[0016] Scenario 5: In the first and second running states, the first process's need to utilize high-level resources in real time differs. For example, in the first running state, the first process needs to utilize higher-level resources in real time to process tasks quickly. In the second running state, the first process does not need to utilize higher-level resources in real time, nor does it need to process tasks quickly.
[0017] Scenario 6: In the first and second running states, the window size displayed on the screen by the first process differs. For example, in the second running state, the window displayed by the first process is a full-screen window, while in the first running state, the window displayed by the first process is a floating window.
[0018] Even after obtaining information about changes in the running state of the first process, the first process remains running. During the execution of the target application, the running state of the first process can change.
[0019] In this embodiment of the application, after changing the resource allocation priority of the first process, software resources and / or hardware resources of the electronic device are allocated to the first process according to the second priority.
[0020] In this embodiment of the application, when the running state changes during the operation of the first process, the resource allocation priority of the electronic device allocated to the first process can be adjusted according to the change in running state. In this way, when the first process does not need to occupy a high resource allocation priority in real time, the resource allocation priority of the first process can be reduced. When the resource demand of the electronic device is large, resources can be allocated more preferentially to the process that needs to occupy a high resource allocation priority in real time, thereby improving the rationality of resource allocation of the electronic device.
[0021] In one embodiment, the first running state and the second running state satisfy any one of the following: the first running state is a foreground running state and the second running state is a background running state; the first running state is a background running state and the second running state is a foreground running state; the first running state is a foreground running state and the second running state is not a foreground running state.
[0022] In this embodiment of the application, in addition to the foreground running state and the background running state, the first running state and the second running state may also include other running states. For example, the first running state is a state of full-screen running and foreground running, and the second running state is a state of foreground running but not full-screen running.
[0023] In possible implementations, the first operating state can be a state with a high level of resource demand, and the second operating state can be a state with a low level of resource demand, or vice versa.
[0024] The aforementioned "higher resource requirement level" refers to resources that require high processing speed and computing power. The "lower resource requirement level" refers to resources that do not require high processing speed or computing power.
[0025] In one embodiment, changing the resource allocation priority of the first process to a second priority based on the running state change information of the first process includes: when the running state change information indicates a change from a foreground running state to a background running state, changing the second priority to a priority used to indicate a reduction in the allocation of electronic device resources to the first process.
[0026] When the first process is running in the background, users often do not need to interact with the interface of the first process in real time, nor do they need the first process to process tasks more quickly. Therefore, the first process may not need higher-level resources.
[0027] In this embodiment of the application, when the first process changes from a foreground running state to a background running state, the resource allocation priority of the first process is reduced, thereby releasing the high-level resources of the electronic device and providing the resources of the electronic device to the process that needs resources more.
[0028] In one embodiment, changing the second priority to indicate a reduction in the priority of allocating electronic resources to the first process includes any one of the following: reducing the resource grouping level and the resource scheduling level in the second priority when the resource scheduling level in the second priority is a first target level and the resource grouping level in the second priority is a second target level; reducing the resource grouping level in the second priority when the resource scheduling level in the second priority is not the first target level and the resource grouping level in the second priority is the second target level; and reducing the resource scheduling level in the second priority when the resource scheduling level and the resource grouping level in the second priority are both the first target level and the second target level.
[0029] In this embodiment, the resource scheduling level may include multiple levels of priority. A higher priority level may include a lower priority level. For example, the resource scheduling level may include a first level, a second level, and a third level. At the first level, the resource scheduling level includes a first level, a second level, and a third level. At the second level, the first level includes a first sub-level and a second sub-level, the second level includes a third sub-level, and the third level includes a fourth sub-level. Furthermore, at the third level, the first sub-level may also include multiple lower sub-levels.
[0030] Within each level, different levels have varying priorities. For example, in the first level, the first level has a higher priority than the second level, and the second level has a higher priority than the third level. The child levels within a higher parent level all have higher priorities than the child levels within a lower parent level.
[0031] Through the above embodiments, resources can be allocated to the first process according to multiple priorities, thereby improving the accuracy of resource allocation.
[0032] In one embodiment, changing the resource allocation priority of the first process to a second priority based on the running state change information of the first process includes: when the running state change information is a change from a background running state to a foreground running state, changing the second priority to a priority used to indicate an increase in the allocation of electronic device resources to the first process.
[0033] When the first process is running in the foreground, it often needs to interact with the user in real time. In this case, providing the first process with higher-level resources and allocating resources to it with higher priority can ensure that the first process can process the user interaction information and tasks received by the front-end interface in a timely manner.
[0034] Through the above embodiments, when the running state of the first process changes from background running to foreground running, the resource allocation priority of the first process can be improved, thereby allocating higher-level resources to the first process when needed, ensuring the normal operation of the first process.
[0035] In one embodiment, when the running state change information indicates a change from a background running state to a foreground running state, changing the second priority to indicate an increased priority for allocating electronic device resources to the first process includes any one of the following: when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a fourth target level, increasing the resource grouping level in the second priority and increasing the resource scheduling level in the second priority; when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a fourth target level, increasing the resource grouping level in the second priority; when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a second target level, increasing the resource scheduling level in the second priority.
[0036] In this embodiment of the application, the resource allocation level can be determined through at least two levels, thereby improving the accuracy of resource allocation.
[0037] In one embodiment, the method for processing application information further includes: starting a first process of the target application; determining the initial running state of the first process; the initial running state being either a foreground running state or a background running state; and determining the resource allocation priority of the first process based on the initial running state.
[0038] In this embodiment, the initial running state may refer to the running state of the first process when the main process is started. If the electronic device starts the first process directly according to the user's instructions, the initial running state of the first process may be a foreground running state. If the electronic device starts the main process of the application based on the user's instructions, the first process may be in a background running state after the main process is started.
[0039] The aforementioned initial running state can refer to the running state before the first running state change information is generated after the first process starts.
[0040] Using the above method, the electronic device can determine the corresponding resource allocation priority based on the initial running state of the first process, thus avoiding the target application from automatically configuring the first process to a higher resource allocation priority in advance when the first process does not require higher-level resources.
[0041] In one embodiment, the method further includes: starting a second process of the target application; the second process always being in the same running state during operation; and setting the resource allocation priority of the second process according to a pre-set correspondence.
[0042] In one embodiment, the first process of the target application is a non-main process of the target application.
[0043] In one embodiment, the first process of the target application is a mini-program process or a mini-game process.
[0044] Under normal circumstances, the target application pre-configures a high resource allocation priority for the mini-program or mini-game process, and the mini-program or mini-game process runs automatically after the target application's main process starts. Therefore, even when the mini-program or mini-game is not running, the mini-program or mini-game process may occupy a high level of electronic device resources for an extended period, resulting in unnecessary resource waste. The method described above allows for setting a more appropriate resource allocation priority for the mini-program or mini-game process based on its initial running state, avoiding unnecessary resource waste.
[0045] In one embodiment, when the target application's mini-program or mini-game launches a running window on the electronic device's display screen, the mini-program process or mini-game process runs in the foreground; when the target application's mini-program or mini-game closes its running window on the electronic device's display screen, the mini-program process or mini-game process runs in the background.
[0046] In one embodiment, the method for processing application information further includes: when the mini-program process generates a start message, a main process start message, a restart message, or a main process restart message, the running state change information is used to indicate a change from a background running state to a foreground running state; when the mini-program process generates a pause message, the running state change information is used to indicate a change from a foreground running state to a background running state.
[0047] In this embodiment of the application, the background running state may not include the state of the process being closed.
[0048] Secondly, embodiments of this application provide an electronic device, which includes a processor and a memory;
[0049] The memory is used to store a program for an electronic device to perform the method provided in any embodiment of the present application, and to store data related to implementing the method provided in any embodiment of the present application;
[0050] The processor is configured to execute programs stored in memory.
[0051] Optionally, there may be one or more processors and one or more memories.
[0052] Alternatively, the memory can be integrated with the processor, or the memory can be set up separately from the processor.
[0053] The processing device in the second aspect above can be a chip. The processor can be implemented in hardware or software. When implemented in hardware, the processor can be a logic circuit, integrated circuit, etc. When implemented in software, the processor can be a general-purpose processor that reads software code stored in memory. The memory can be integrated into the processor or located outside the processor and exist independently.
[0054] In the specific implementation process, the memory can be a non-transitory memory, such as read-only memory (ROM), which can be integrated with the processor on the same chip or set on different chips. This application does not limit the type of memory or the way the memory and processor are set.
[0055] Thirdly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, enable the computer to perform the method described in the first aspect.
[0056] Fourthly, embodiments of this application provide a computer program product that, when run on a computer, causes the computer to perform any of the possible implementations of the first aspect.
[0057] Fifthly, embodiments of this application also provide a processor, including: an input circuit, an output circuit, and a processing circuit. The processing circuit is used to receive signals through the input circuit and transmit signals through the output circuit, causing the processor to execute the method in any of the embodiments of the first aspect described above.
[0058] In specific implementation, the processor can be a chip, the input circuit can be input pins, the output circuit can be output pins, and the processing circuit can be transistors, gate circuits, flip-flops, and various logic circuits. The input signal received by the input circuit can be received and input by, for example, but not limited to, a receiver, and the signal output by the output circuit can be, for example, but not limited to, output to and transmitted by a transmitter. Furthermore, the input circuit and the output circuit can be the same circuit, which is used as both the input circuit and the output circuit at different times. This application does not limit the specific implementation of the processor and various circuits.
[0059] The technical effects achieved by the second, third, fourth, and fifth aspects mentioned above are similar to those achieved by the corresponding technical means in the first aspect mentioned above, and will not be repeated here. Attached Figure Description
[0060] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0061] Figure 2 This is a schematic diagram of the software architecture of an electronic device according to an embodiment of this application;
[0062] Figure 3 This is a schematic diagram illustrating an application scenario according to an embodiment of this application;
[0063] Figure 4 This is a schematic diagram illustrating another application scenario of an embodiment of this application;
[0064] Figure 5 This is a schematic diagram of an information processing method for an application according to an embodiment of this application;
[0065] Figure 6This is a schematic flowchart illustrating a method for processing application information according to another embodiment of this application.
[0066] Figure 7 This is a schematic diagram of a method for processing application information according to another embodiment of this application;
[0067] Figure 8A This is a schematic diagram illustrating an example of a method for processing application information according to an embodiment of this application;
[0068] Figure 8B This is a schematic diagram illustrating an example of a method for processing application information according to an embodiment of this application;
[0069] Figure 9A This is a schematic diagram of a method for processing application information in one example of this application;
[0070] Figure 9B This is a schematic diagram of an application information processing method in one example of this application;
[0071] Figure 10 This is a schematic diagram of the structure of an information processing device for an application provided in an embodiment of this application. Detailed Implementation
[0072] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details.
[0073] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof. The terms "comprising," "including," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0074] It should be understood that "one or more" as mentioned in this application refers to one, two, or more, and "multiple" as mentioned in this application refers to two or more. In the description of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.
[0075] Furthermore, to facilitate a clear description of the technical solutions of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that the terms "first" and "second" do not necessarily imply that they are different.
[0076] The terms "one embodiment" or "some embodiments" used in this application mean that one or more embodiments of this application include the specific features, structures, or characteristics described in that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this application do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized.
[0077] The display method provided in this application can be applied to electronic devices. These electronic devices can be mobile phones, tablets, wearable devices, digital cameras, in-vehicle devices, augmented reality (AR) devices, virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), laptops, etc., and this application does not limit the specific application to these devices.
[0078] First, the possible structures of the electronic devices in the embodiments of this application will be introduced.
[0079] Figure 1 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0080] See Figure 1The electronic device 1000 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0081] It should be noted that, Figure 10 The structure shown does not constitute a specific limitation on the electronic device 1000. In other embodiments of this application, the electronic device 1000 may include more than Figure 10 The components shown may include more or fewer components, or the electronic device 1000 may include... Figure 10 The components shown may be a combination of certain components, or the electronic device 1000 may include... Figure 10 The components shown are sub-components of certain components. For example, Figure 10 The proximity sensor 180G shown is optional. Figure 10 The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0082] Processor 110 may include one or more processing units. For example, processor 110 may include at least one of the following processing units: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, video codec, digital signal processor (DSP), baseband processor, and neural network processing unit (NPU). These different processing units may be independent devices or integrated devices.
[0083] The controller can generate operation control signals based on the instruction opcode and timing signals to complete the control of instruction fetching and execution.
[0084] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0085] Figure 1 The connection relationships between the modules shown are merely illustrative and do not constitute a limitation on the connection relationships between the modules of the electronic device 1000. Optionally, the modules of the electronic device 1000 may also adopt a combination of various connection methods described in the above embodiments.
[0086] Electronic device 1000 can implement display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0087] The display screen 194 can be used to display images or videos. In some embodiments, the electronic device 1000 may include one or N display screens 194, where N is a positive integer greater than 1.
[0088] Electronic device 1000 can achieve shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0089] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits the electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can perform algorithmic optimization of image noise, brightness, and color. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0090] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then passed to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into image signals in standard red-green-blue (RGB) formats, luminance, and chrominance (YUV). In some embodiments, the electronic device 1000 may include one or N cameras 193, where N is a positive integer greater than 1.
[0091] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 1000 is selecting a frequency, the DSP is used to perform Fourier transforms on the frequency energy.
[0092] Video codecs are used to compress or decompress digital video. Electronic device 1000 may support one or more video codecs. Thus, electronic device 1000 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG 2, MPEG 3, and MPEG 4.
[0093] An NPU (Neural Processing Unit) is a processor that borrows from the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, to rapidly process input information and continuously learn. NPUs can enable intelligent cognitive functions in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.
[0094] Electronic device 1000 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0095] The distance sensor 180F is used to measure distance. The electronic device 1000 can measure distance via infrared or laser. In some embodiments, such as in a shooting scenario, the electronic device 1000 can utilize the distance sensor 180F to measure distance for rapid focusing.
[0096] Button 190 includes a power button and volume buttons. Motor 191 can generate vibration when the electronic device receives information. Motor 191 can be used to display notification information.
[0097] exist Figure 1 Based on the electronic device shown, the user can control the camera 193 to capture images or videos via button 190 or display screen 194.
[0098] Figure 1 The electronic device shown can be configured with a certain software architecture. Figure 2 This is a schematic diagram of an architecture (including a software system and some hardware) applied in an embodiment of this application. Figure 2 As shown, the architecture of an electronic device is divided into several layers, each with a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the application architecture can be divided into five layers, from top to bottom: application layer, application framework layer, hardware abstraction layer (HAL), driver layer, and hardware layer.
[0099] The hardware abstraction layer includes a camera and a touch screen; the kernel layer includes multiple hardware driver modules, such as a camera driver module, a display driver module, a touch screen driver module, and an audio driver module; the application framework layer includes a trigger event detection module and an application management module; and the application layer includes terminal applications, including but not limited to social applications, chat applications, payment applications, video viewing applications, shopping applications, and camera applications.
[0100] Application-layer applications can launch the main process of the application during its runtime, and also launch non-main processes as needed. Application-layer applications can also generate or modify the window view corresponding to the application based on information received from the network and user actions detected by the electronic device.
[0101] At the application framework layer, there may be an Activity Manager Service (AMS), an Application Manager Service (AMS), and a Window Manager Service (WMS). AMS is responsible for managing the application's lifecycle, handling application startup, shutdown, and restart operations, and maintaining the activity stack information.
[0102] In this embodiment, an activity can refer to a container used to provide an activity interface to the user. Each application can contain multiple activities, and each activity represents a single screen. When a user opens an application, they are actually launching an activity, which becomes the current focus, and the process information is displayed to the user for interaction through the foreground view.
[0103] The focus mentioned above can be used to indicate which view the user is currently interacting with. When a user taps or touches a view on the screen, that view gains focus. Focus can enable a view to have specific behaviors, such as responding to key events or receiving text input.
[0104] WMS can be used to manage windows and information about user touch control events on electronic devices. Based on this information, windows can be created, modified, or destroyed.
[0105] The system layer includes the core libraries and the runtime.
[0106] The kernel layer is the layer between hardware and software. The kernel layer's hardware driver module drives the hardware in the hardware abstraction layer based on user touch events that control the electronic device. In other words, the kernel layer can drive hardware devices in the hardware abstraction layer, such as the display screen and camera, based on user touch events.
[0107] In this embodiment, the kernel layer includes a control group module for implementing a control group mechanism and generating control group information for processes. This control group mechanism can be a feature of the Linux kernel used to limit, control, and isolate the resources (such as CPU, memory, disk I / O, etc.) of a process group.
[0108] Figure 3 This illustrates one application scenario of an embodiment of this application. Figure 3 In the scenario shown, the electronic device is running multiple applications. The device's desktop displays icons for these applications, which are used to launch the corresponding application. (See reference...) Figure 3As shown in (a), the electronic device's applications may include a video platform application 31, a chat application 32, and a payment application 33. Users can view multiple online videos through the video platform application 31. When a user clicks the icon of the video platform application 31, the electronic device can respond to the user's click by launching the video platform application and displaying, for example... Figure 3 The interface shown in (b) is as follows. When an electronic device launches the video platform application, the main process of the video platform application can start and begin running.
[0109] The main process can refer to the process that implements the main functions of an application. In an electronic device, when each application starts, its corresponding main process runs. The main process is responsible for managing the overall operation and resource allocation of the application, as well as the interaction between the application and the user, and communication between the application's processes and those of other applications. The main process can be the core of an application. When the electronic device starts the video platform application 31, the video platform application 31 can also automatically start its non-main processes. These non-main processes can include mini-program processes and mini-game processes. In this embodiment, a mini-program can also be called a mini-program application. A mini-program can refer to an application that can run without installation or download. Furthermore, after using a mini-program, the user can close it directly without uninstalling it. In this embodiment, a mini-game can refer to a game-type mini-program. In this embodiment, the mini-program and mini-game are embedded within the application and run while the application is running.
[0110] In this embodiment, a process can be an instance of an application running in an electronic device. Each process has its own memory space and system resources and can execute tasks independently. A process is the basic unit for resource allocation and scheduling by the operating system. An instance includes a collection of program code that may have dynamic storage space.
[0111] Electronic devices through Figure 3 The interface shown in (b) displays online video data to the user. Users can... Figure 3 Operate using the interface shown in (b) to launch the mini-program or mini-game of the video platform application 31. Figure 3 The interface shown in (b) also includes a first function control 34, which is used to display a small program of the video platform application 31. (This is on the electronic device display.) Figure 3In the case of the interface shown in (b), the user can click the first function control 34 in the interface. The video platform application 31 responds to the user's click on the first function control 34 by displaying, as shown in (b). Figure 3 The functional control list 35 is shown in (c). The functional control list 35 includes frequently used mini-program cards 36, which can be used to display icons for frequently used mini-programs. These icons are used to launch frequently used mini-programs or mini-games.
[0112] For example, in Figure 3 The list of functional controls 35 shown in (c) includes Mini Program 1 and Mini Game 1. When the user clicks the icon of Mini Program 1, the video platform application responds to the user's click operation by launching Mini Program 1, generating the interface view of Mini Program 1, calling the mini program process of Mini Program 1, and using the interface view of Mini Program 1 to cover the running interface of the video platform application 31, such as... Figure 3 As shown in (d) in the figure. Figure 3 In the interface view of mini-program 1 shown in (d), the electronic device can display visual information during the operation of the mini-program, as well as the functional controls of mini-program 1. The functional controls of mini-program 1 may include: a close function control 37. The close function control 37 is used to close mini-program 1. When the user no longer needs to use mini-program 1, they can click the close function control 37. In response to the user's click on the close function control 37, the video platform application closes the interface view of the mini-program and redisplays the running interface of the video platform application.
[0113] Figure 3 It demonstrates how to launch a mini-program within an application. Besides... Figure 3 In addition to the launch methods shown, users can also launch the mini-program by scanning an identification code. For example, in Figure 3 Based on the interface shown in (a), the user can click the icon of the chat application 32. In response to the user's click on the icon, the electronic device displays the interface of the chat application 32, such as... Figure 4 As shown in (a) in the diagram. Figure 4 The interface shown in (a) includes multiple cards, each containing different functional controls. At least one card in the chat application's interface includes a scanning control. For example, in... Figure 4The interface shown in (a) includes a chat card, a contacts card, a discover card, and a me card. The chat card includes a second function control 41. When the user clicks the second function control 41, the chat application responds by displaying a function control drop-down list 42. The function control drop-down list 42 includes a scan control. The user can click the scan control to activate the scan function, and the chat application responds by displaying... Figure 4 The scanning interface is shown in (b) above. The scanning interface includes a preview area for the object being scanned, where the user sees a preview of the object being scanned. For example... Figure 4 As shown in (c), the chat application detects objects in the scanned object preview area in real time. When the chat application recognizes an identification code in the scanned object preview area, it parses the identification code and, based on the result of the parsing, launches the corresponding mini-program and displays its interface. The interface of the mini-program displayed in the chat application may differ from the actual interface. Figure 3 The interface of the mini-program shown in (d) is similar.
[0114] At the same time, users can also Figure 4 Based on the interface shown in (a), a swipe-down operation is performed. The chat application responds to the swipe-down operation by displaying the mini-program launch interface, as shown in (a). Figure 4 As shown in (d) above. The mini-program launch screen includes a list of recently used mini-programs and a list of recommended mini-programs. Both lists display icons for multiple mini-programs, which users can click to launch. The chat application responds to the click on the mini-program icon by launching the corresponding mini-program.
[0115] Apart from Figure 3 , Figure 4Beyond the scenarios shown, users can launch mini-programs in other ways. For example, users can enter the mini-program name in the mini-program search box, search for the mini-program, and launch it. When a mini-program or mini-game is launched within an application, the application's main process runs the corresponding mini-program process. In this embodiment, the process used to run a mini-program can also be called a mini-program process, and the process used to run a mini-game can be called a mini-game process. Both mini-program processes and mini-game processes can cause more unnecessary resource consumption on electronic devices. Taking the mini-program process as an example, in some applications, in order to quickly provide resources when the mini-program is running, the application's main process will launch the mini-program process when the application's main process is running, regardless of whether the user launches the mini-program. Furthermore, the mini-program process is in a running state when the application is running a mini-program, and may still be running even after the application closes the mini-program in response to the user's closing action. These mini-program processes that do not run in the foreground and interact with the user in real time may consume the electronic device's resources, making it difficult for processes running in the foreground or interacting with the user in real time to be allocated resources in a timely manner, leading to inappropriate allocation of electronic device resources.
[0116] Besides mini-program and mini-game processes, other non-main processes of the application may also consume a lot of electronic device resources unnecessarily.
[0117] Therefore, embodiments of this application provide a method for processing application information, which can reasonably allocate resources to the processes of applications. Embodiments of this application can be applied to various electronic devices. When the electronic device is a mobile terminal, the method provided in this application can be used to process application process-related information. When the electronic device is a fixed terminal, the method provided in this application can be used to process software and webpage startup process-related information of the electronic device. In one embodiment of this application, the method for processing application information may include, for example... Figure 5 The steps are shown. In Figure 5 In the illustrated embodiment, the application is equivalent to the target application in the foregoing embodiment, and is one of a plurality of applications configured for the electronic device.
[0118] Step S51: The electronic device starts the main process of the application.
[0119] In this embodiment, the application may launch at least one process upon startup. Furthermore, the application may launch multiple processes, including a main process and non-main processes. When multiple processes are launched, each process has its own independent memory space and system resources to ensure the program's independence and security.
[0120] Users can launch application processes by performing different operations on different electronic device operating systems. For example, a user can click or double-click an application icon. In response to this action, the electronic device can check if the application has a running process. If the electronic device does not have any running application process, it creates a new process to receive, send, and process application information. In some possible implementations, when launching an application and creating a new process for it, this new process becomes the application's main process. In other words, the main process might be the first process created by the electronic device after the application is launched.
[0121] In one possible implementation, the application's main process can be a process that can launch other processes of the application, or it can be a process initially created by the electronic device when the application starts.
[0122] In some possible implementations, the name of the application's main process may be determined based on the application's name. For example, if the application's name is name1, the name of the application's main process might be com.name1.mm. The name of the application's main process can be determined by the application provider. Furthermore, the name of the main process can be the name of the application's runtime file package.
[0123] In some other possible implementations, the name of the application's main process may not need to be determined based on the application's name.
[0124] In some possible implementations, the name of the application's main process may be included in the name of the application's non-main process.
[0125] For example, assuming the application's main process is named com.name1.mm, there may be multiple first processes, and their names may include com.name1.mm.appband0, com.name1.mm.appband1, and com.name1.mm.push. Alternatively, assuming the application's main process is named com.ss.android.ugc.aweme, there may be multiple first processes, and their names may include com.ss.android.ugc.aweme.push, com.ss.android.ugc.aweme.miniappX, and com.ss.android.ugc.aweme.minigame.
[0126] In some possible implementations, the steps to start the application's main process may include at least one of the following.
[0127] In scenario one, after the electronic device's system boots up, the application has not yet started, or the application has started and closed in response to user actions. In this case, the electronic device creates the application's main process.
[0128] Scenario 2: After the electronic device's system boots up, it launches an application in response to user input, and then closes the application without responding to user input. However, due to a malfunction or meeting the application's kill criteria, the electronic device closes the application. In this case, the electronic device creates the application's main process.
[0129] Scenario 3: When the electronic device's system starts up, the application is automatically launched due to system configuration, and the application's main process is created.
[0130] In possible implementations, the application in step S51 may be an application configured in the operating system of the electronic device, or an application provided by a third party to the electronic device.
[0131] Step S52: The application's main process starts the application's first process.
[0132] In step S52, the main process of the application starts the first process of the application, which can refer to creating the first process when the electronic device is not running the first process of the application.
[0133] In this embodiment of the application, the first process of the application may be a child process of the main process of the application.
[0134] In one possible implementation, if a process of the application is not the main process of the application, this process may be the first process of the application.
[0135] In possible implementations, the first process of the application is any one or more of the following: a mini-program process, a mini-game process, or a communication process.
[0136] The aforementioned communication process may be a push process, which can be used for real-time communication between different objects within an application, as well as between the application and other objects. Push processes can also be used to send data, messages, etc., to a server.
[0137] In step S52, the main process may start one first process or multiple first processes.
[0138] In other possible implementations, the electronic device can also automatically launch the application's first process simultaneously with the application's main process, based on the application's configuration. That is, both the main process and the first process can be launched based on the application's startup event. When the first process is launched by the application's main process, it can also be called a child process of the main process.
[0139] In possible implementations, child processes of the main process have their own address spaces, and changing variables in a child process will not affect the main process. Child processes inherit certain attributes from the main process, such as environment variables. Multiple child processes can run concurrently (simultaneously), and the child processes and the main process can run independently.
[0140] In one possible implementation, the main process can launch the first process in response to a user's launch action. Alternatively, the main process can also launch the first process automatically based on the application's configuration.
[0141] Step S53: The electronic device determines the initial running state of the first process; the initial running state is either a foreground running state or a background running state.
[0142] In the embodiments of this application, the initial running state of the first process can refer to the initial running state after the first process is started or created. Alternatively, the initial running state of the first process can refer to the running state of the first process before the first change of running state after the first process is started.
[0143] In this embodiment, if the first process creates an activity, the electronic device can determine that the first process is running in the foreground. If the first process does not create an activity, the electronic device can determine that the first process is running in the background.
[0144] In this embodiment, the foreground running state refers to the state where the process is at the forefront of the user interface and the user can directly interact with it. In the foreground running state, the process window is visible on the screen, and the user can intuitively see the program's interface. The user can interact directly with the process using input devices such as a keyboard and mouse, such as clicking buttons or entering text. The process window typically has focus, meaning that user input (such as keyboard input) is directly sent to the foreground running process.
[0145] In this embodiment, the background running state can refer to a process executing or running without occupying the foreground of the user interface. Background running processes are typically not directly displayed on the screen, nor do they receive direct user input (such as keyboard or mouse events). However, background running processes may still be performing important tasks, such as data synchronization, file downloads, system updates, etc.
[0146] In this embodiment, the application can be running in the foreground or in the background. The running state of the application may or may not be related to the running state of the first process. When the application is running in the foreground, the application's main process may also be running in the foreground. When the application is running in the background, the application's main process may also be running in the background. The foreground and background running states of the application can have the same meaning as the foreground and background running states of the process.
[0147] Step S53 can be executed by the electronic device's system or by the application program.
[0148] Step S54: The electronic device determines the resource allocation priority of the first process as the first priority based on the initial operating state.
[0149] In this embodiment, the resource allocation priority of the first process can refer to the degree or order in which resources of the electronic device are allocated to the first process. During operation, the first process may consume software or hardware resources of the electronic device. Resources allocated by the electronic device to the first process may include: central processing unit (CPU) resources, memory resources, file descriptor resources, network resources, external device resources, user permission resources, process identifier resources, and other resources.
[0150] The CPU resources mentioned above can include both large and small core resources. The file descriptor resources mentioned above can be used to access files and devices. Processes can open files, read data, and write data; each opened file or device has a corresponding file descriptor. The process identifier resources mentioned above refer to the unique identifier assigned to a process by an electronic device. This unique identifier is called the process identifier, which is used by the electronic device to identify and track processes within the operating system.
[0151] In other embodiments of this application, the resource allocation priority of the first process can also be determined based on pre-set information. In possible implementations of this application, the whitelist configuration method may include at least one of the following methods.
[0152] Method 1: A whitelist can be pre-set in the electronic device. The whitelist can include the resource allocation priority of the first process in each application under different initial running states.
[0153] When configuring a whitelist using the method described above, an example of a whitelist can be shown in Table 1 below.
[0154]
[0155]
[0156] Table 1
[0157] Method 2: A whitelist can be pre-configured in the application's configuration file. The whitelist can include the resource allocation priority of the application's first process in different initial running states.
[0158] When configuring a whitelist using Method 2 above, an example of a whitelist can be the list portion for a single application, as shown in Table 1.
[0159] Method 3: Pre-set a whitelist in the electronic device. The whitelist can include the resource allocation priority of each application in its initial running state.
[0160] Method 4: Pre-set a whitelist in the application's configuration file. The whitelist can include the resource allocation priority of each application in its initial running state.
[0161] For a single application, the initial running state of all its processes is generally determined. For example, the main process of an application is necessarily running in the foreground. However, since the interface displayed when an application starts is often the application's main interface rather than a mini-program interface, the mini-program process of the application is generally running in the background initially. Therefore, in other possible implementations of this application, a whitelist can be set in the configuration file of the electronic device or application, directly recording the resource allocation priority of each process in its initial running state.
[0162] Table 2 below shows an example of pre-setting a whitelist in the configuration file of application 1 using method four.
[0163] process Resource allocation priority Process 1 Priority 1 Process 2 Priority 2 Process 3 Priority 3
[0164] Table 2
[0165] Method 5: A whitelist can be set in the configuration file of the electronic device or application. The whitelist includes processes whose resource allocation priority is set to the specified target priority in the initial running state. For example, for application 1, the processes with resource allocation priority set to priority 1 in the initial running state include: process 1, process 2, and process 3.
[0166] In this embodiment of the application, for mini-programs with low timeliness, electronic devices can set the resource allocation priority to a lower priority in the initial running state.
[0167] Step S54 can be executed by the electronic device's system or by the application program.
[0168] Step S55: The electronic device allocates resources to the first process according to the first priority to run the first process of the application; the first process is the non-main process of the application.
[0169] When an electronic device is running the first process of an application, it can use certain resources to run that first process. These resources can be determined based on the resource allocation priority of the first process.
[0170] In this embodiment, a non-main process of an application can be a process created by the main process of the application. That is, a non-main process of an application can be a child process of the main process of the application. When a non-main process of an application is running on an electronic device, the main process of the application may be in a foreground running state, a background running state, or a non-running state.
[0171] In step S55, when the electronic device runs the first process, the electronic device can obtain resources according to the resource allocation priority determined in step S54, and use the obtained resources to run the first process.
[0172] Step S56: The electronic device obtains the running state change information of the first process of the application; the running state change information is used to indicate that the running state of the first process changes from the foreground running state to the background running state, or the running state of the first process changes from the background running state to the foreground running state.
[0173] In this embodiment, the electronic device can monitor the activity of the first process based on the identifier of the first process. When the first process creates or destroys an activity, the electronic device determines that the running state of the first process has changed and obtains information about the creation or destruction of the activity. The information about the change in running state may include information about the creation or destruction of the activity.
[0174] When a mini-program or mini-game of the application is launched and running on the electronic device's screen, the mini-program or mini-game process runs in the foreground; when the mini-program or mini-game is closed on the electronic device's screen, the mini-program or mini-game process runs in the background. When the electronic device closes the application's mini-program or mini-game window, the activity of the mini-program or mini-game process is destroyed. When the electronic device creates a mini-program or mini-game window, the activity of the mini-program or mini-game process is created.
[0175] In another possible implementation, the runtime state change information may also include other situations. For example, in one possible example, the application or electronic device may close the mini-program window or mini-game window in response to the user clicking the close control, and then close the mini-program process or mini-game process. In this case, the runtime state change information may also include: a change from a foreground running state to a non-running state. In a possible implementation, the non-running state may refer to a non-main process being closed while the main process is running.
[0176] Step S57: The electronic device allocates the resources required for the first process to run according to the resource allocation priority.
[0177] Accordingly, the first process begins to run based on the resources allocated to the electronic device.
[0178] Step S58: Based on the running status change information of the first process, change the resource allocation priority of the first process to the second priority; the resource allocation priority is used to allocate electronic device resources to the first process.
[0179] In the embodiments of this application, changing the resource allocation priority of the first process can refer to increasing the resource allocation priority of the first process, so that the electronic device allocates resources to the first process with greater priority. Changing the resource allocation priority of the first process can also refer to decreasing the resource allocation priority of the first process, so that the electronic device allocates resources to the first process with less priority (non-priority).
[0180] In possible implementations, resource allocation priority can include multiple priority levels to achieve finer-grained differentiation of resource allocation priorities. Resource allocation priority can include resource grouping level and resource scheduling level. The resource scheduling level is a sub-priority of the resource grouping level. When resource grouping levels are the same, the electronic device can further determine the priority of allocating resources to processes based on the resource scheduling level.
[0181] In other possible implementations, the multi-level priorities included in resource allocation priorities can be divided in different ways or expressed using different information.
[0182] In one implementation, changing the resource allocation priority of the first process to a second priority based on the running state change information of the first process includes: when the running state change information indicates a change from a foreground running state to a background running state, changing the second priority to a priority used to indicate a reduction in the allocation of electronic device resources to the first process.
[0183] In one implementation, changing the second priority to indicate a reduction in the priority of allocating electronic resources to the first process includes any one of the following: when the resource scheduling level in the second priority is a first target level and the resource grouping level in the second priority is a second target level, reducing the resource grouping level in the second priority and reducing the resource scheduling level in the second priority; when the resource scheduling level in the second priority is not the first target level and the resource grouping level in the second priority is the second target level, reducing the resource grouping level in the second priority; when the resource scheduling level in the second priority is the first target level and the resource grouping level in the second priority is the second target level, reducing the resource scheduling level in the second priority.
[0184] In one implementation, changing the resource allocation priority of the first process to a second priority based on the running state change information of the first process includes: when the running state change information indicates a change from background running to foreground running, changing the second priority to a priority used to indicate an increase in the allocation of electronic device resources to the first process.
[0185] In one implementation, when the running state change information indicates a change from background running to foreground running, changing the second priority to indicate an increased priority for allocating electronic device resources to the first process includes any one of the following: when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a fourth target level, increasing the resource grouping level in the second priority and increasing the resource scheduling level in the second priority; when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a fourth target level, increasing the resource grouping level in the second priority; when the resource scheduling level in the second priority is a third target level and the resource grouping level in the second priority is a second target level, increasing the resource scheduling level in the second priority.
[0186] Step S59: The electronic device allocates the resources required for the first process to run according to the changed resource allocation priority.
[0187] Many third-party applications on electronic devices support mini-program functionality and can run mini-program applications. Generally, the electronic device's system settings are configured based on the third-party application's settings for the mini-program. The electronic device may, based on these settings, allocate higher resource priority to processes running in the background or with low timeliness, leading to a waste of software and / or hardware resources and a decrease in overall performance. The method provided in this application determines resource allocation priority based on the specific initial running state of the application (not the main process), preventing background processes or those with low timeliness from consuming excessive electronic device resources, thus making resource allocation more rational.
[0188] Then, the method provided in this application embodiment changes the resource allocation priority according to the change information of the running state when the running state of a non-main process changes, so that the resource allocation priority adapts to the change of the running state of the process.
[0189] Figure 6 This application demonstrates an implementation of a method for processing application information according to another embodiment of the present application. Figure 6 In the illustrated embodiment, the electronic device always determines the resource allocation priority of the first process based on whether the first process is running in the foreground or in the background at any given time.
[0190] At the same time, Figure 6 In the illustrated embodiment, resource grouping levels can include top grouping, foreground grouping, and background grouping. Resource grouping levels can be used to indicate whether a process is running in the foreground or background. When the first process is running in the foreground, its resource allocation priority is increased. When the first process is running in the background, its resource allocation priority is decreased. Resource scheduling levels can be used to indicate the level of further resource allocation for a process running in the foreground. Resource scheduling levels can include starting a critical state (static VIP) or canceling a critical state. A critical state indicates that, when running in the foreground, the process needs further priority in resource allocation. Compared to processes canceled from critical states, starting a critical state indicates priority in resource allocation. That is, when both processes are running in the foreground, the resource allocation priority of a process started from a critical state is higher than that of a process canceled from a critical state.
[0191] exist Figure 6In the illustrated embodiment, control groups (cgroups) can be used to represent resource grouping levels. A cgroup is a kernel-level cgroup module in an electronic device. This module can be used to limit, control, and separate resource usage by process groups. In implementing its function, the cgroup module analyzes process information and generates cgroup groups for each process. This embodiment can use cgroup groups to represent the resource grouping level of a process, changing the process's resource grouping level depending on whether the process is running in the foreground or background.
[0192] In this embodiment, cgroup can be a resource management and restriction mechanism provided by the Linux kernel. Groups formed using the cgroup mechanism can be called cgroup groups. cgroups allow processes in an electronic device's system to be grouped, and specific system resources (such as CPU, memory, disk input / output (I / O)) to be allocated to each group. By restricting resources for groups, the electronic device's system can better manage process resource usage, improving system stability and performance. For example, cgroup groups can include top (or top-app), foreground, and background groups. The resource allocation priority of the top group can be higher than that of the foreground group, and vice versa.
[0193] In one possible implementation, when a process creates a child process, the child process is placed in the same cgroup group as the parent process by default. If the first process is a child process of the main process, the main process can be the parent process of the first process.
[0194] In the operating system of an electronic device, cgroups can be executed by system-level processes or applications with appropriate permissions. Therefore, in this embodiment, a first service can be configured in the application framework layer to implement the method of this embodiment, or a first application can be configured in the application layer to implement the method of this embodiment. The processes or applications added in this embodiment can modify or retain cgroups within the cgroup grouping mechanism of the electronic device. The modified or retained cgroups represent resource grouping levels in resource allocation priority.
[0195] exist Figure 6In the illustrated embodiment, functional modules can be configured in the electronic device kernel layer and / or application framework layer to monitor the running status of the mini-program process. If the mini-program is running in the background, the cgroup group of the mini-program application process can be changed to a lower level, or the resource scheduling level can be set to the important state cancellation, thereby releasing unnecessary resources occupied by the mini-program application, increasing the resources allocated to other processes of the electronic device, and avoiding waste of electronic device resources.
[0196] Figure 7 This application demonstrates another embodiment of a method for processing application processing information. Figure 7 In the illustrated embodiment, the electronic device is equipped with an out-of-memory (OOM) killer module. Employing an out-of-memory (OOM) mechanism, it kills at least one process when memory is insufficient. In the OOM mechanism, the electronic device calculates the OOM score for each process based on a series of algorithms and strategies, and selects the process with the higher OOM score for termination. The OOM score may be influenced by several factors, including the amount of memory used by the process, the process's priority, and the process's most recent memory requests. Some system processes or critical processes may be pre-marked as non-terminating to prevent them from being accidentally terminated by the OOM killer. Figure 7 The illustrated embodiment includes the following steps.
[0197] Step S71: The OOM elimination module calculates the initial OOM score (OOM adjustment, OOMMadj) for each process.
[0198] In this embodiment, the OOM removal module can calculate the initial priority of each process based on the startup operation of each process. The initial OOM score can refer to the OOM score calculated by the OOM removal module for the first time after the process starts. Since the startup time of each process is different, the time at which the OOM removal module calculates the initial OOM score of each process is also different. That is to say, the execution time of step S71 may be different for different processes. The OOM score can also be called the OOM adjustment value.
[0199] Step S72: The OOM removal module updates the OOM score of each process.
[0200] In this embodiment of the application, the OOM elimination module can call the updateoomadjlocked method to update the resource configuration priority.
[0201] In this embodiment, the `updateOOMadjlocked` method can be a method called by the AMS (Automatic Management System) in the electronic device's system. `updateOOMadjlocked` is used to update the OOMadj value of a process. The `updateOOMadjlocked` method is typically called when the process's state changes, such as when the process becomes a foreground process, a background process, or a service process. For example, the `updateOOMadjlocked` method can update the OOM (Out of Memory) score of each process in the least recently used (LRU) cache of the electronic device.
[0202] For example, in step S72, the main content of the `updateOOMAdjLSP` function is: to check if an update is in progress; if not, to set the `OOMadj update ongoing` flag to `true`, indicating that the `adj` update has officially started, and then to call the `performUpdateOOMAdjLSP` method. After the above checks, when the `performUpdateOOMAdjLSP` method is implemented, it can be considered that the update of `adj` has officially started. The `performUpdateOOMAdjLSP` method can clear the processes to be updated, obtain the process `topApp` where the current Top application resides, and call the `OOMadj InnerLSP` method to continue the update, and then proceed to step S73.
[0203] Step S73: The OOM kill module calculates the process grouping strategy.
[0204] In this embodiment, the OOM removal module can call the OOM score calculation interface (computeOOMadjLSP) method to calculate the process grouping strategy. The grouping strategy calculated by the computeOOMadjLSP method can include the OOM score and the process status.
[0205] For example, the process of calculating the grouping strategy by the computeOOMadjLSP method may include the following steps (1) to (8).
[0206] (1) Check the loop calculation: First, check whether the current process has already participated in the adjustment of OOMadj. If so, decide whether to continue the calculation based on whether the adjustment has been completed.
[0207] (2) Initialize the process state record: Perform some initialization operations on the process state record (ProcessStateRecord), including setting whether freezing is allowed by default.
[0208] (3) Get the state before adjustment: Get the OOMadj value, procState and other state information of the process before adjustment.
[0209] (4) Adjust according to conditions: Adjust the adj value and procState of the process according to the type of process (such as system service, resident process, top application, process playing remote animation, etc.), current activity status, resource usage, etc.
[0210] The aforementioned top application can be expressed as a top application (top APP).
[0211] The aforementioned procState can be a variable, referring to a state value defined in AMS, used to evaluate process state and influence the system's memory control strategy for electronic devices.
[0212] (5) Update process state record: Update the adjusted OOMadj value, procState and other state information to ProcessStateRecord.
[0213] (6) Set the sequence number for OOMadj adjustment: Each OOMadj adjustment will set a sequence number to identify the uniqueness of the current adjustment.
[0214] (7) Handling dependencies: For processes such as service processes and content provider processes, calculate the OOMadj value of the peer of the process and update the dependencies.
[0215] The counterpart to the aforementioned service process and content provider process can refer to the application-side process that interacts with the service process and content provider process.
[0216] (8) Return the adjustment result: If the adjustment is successful (i.e. the process's adj value or procState has changed), return yes; otherwise, return no (false).
[0217] Step S74: Use the calculated grouping strategy.
[0218] After calculating OOMadj, the calculated grouping strategy is assigned by applying the OOMadj(applyOOMAdjLSP) method.
[0219] Step S75: For the mini-program's process, after the initial cgroup grouping is determined, increase or decrease the resource allocation priority according to the calculated grouping strategy.
[0220] Before step S75, after the mini-program process is started, the initial resource allocation priority of the mini-program is determined according to the cgroup group of the mini-program process.
[0221] Before launching a mini-program, the application's main process is launched first. When launching the application, the electronic device creates an instance of the activity thread, also known as the user interface (UI) thread. The activity thread is used to create activities and the application's main process. After creating the activity thread, the electronic device's activity thread calls the activity thread's main method to create the application's main process.
[0222] In step S75, the initial cgroup group of the mini-program process can be the default foreground group.
[0223] Step S75 may include steps S751 to S754 as described below.
[0224] Step S751: Determine whether the process scheduling group identifier of the mini-program process is SCHED_GROUP_TOP_APP, and whether the initial cgroup group is top-app. If yes, proceed to step S752.
[0225] SCHED_GROUP_TOP_APP is a constant in the Android system used to identify process scheduling groups, representing the highest priority process scheduling group.
[0226] In the specific example of this application, the electronic device system can group processes in multiple different dimensions, among which SCHED_GROUP_TOP_APP and cgroup grouping are two different types of grouping. SCHED_GROUP_TOP_APP can represent process scheduling grouping, while cgroup grouping can represent process management grouping. SCHED_GROUP_TOP_APP typically refers to a scheduling group considered to be top-level application processes. These processes usually have high priority and require more CPU resources to ensure their smooth operation. cgroup grouping allows setting resource usage limits, weights, and other parameters for each process within the group, enabling fine-grained management of process resources. In other words, based on cgroup grouping, SCHED_GROUP_TOP_APP is further used to limit the top-app process scheduling grouping.
[0227] For example, the above-mentioned SCHED_GROUP_TOP_APP can be a factor considered in determining the resource scheduling group in the foregoing embodiments.
[0228] Step S752: Determine the resource allocation priority of the mini-program process as follows: the resource grouping level is top-app, and the resource scheduling level is critical state start.
[0229] Step S753: Determine if the cgroup group of the mini-program process is top-app. If yes, proceed to step S754.
[0230] Step S754: Set the resource allocation priority of the mini-program process as follows: resource grouping level is top-app, and resource scheduling level is important and canceled.
[0231] exist Figure 7 In the example shown, the mini-program process can also be the mini-game process.
[0232] In another example of this application, in the system of an electronic device, a first service can be configured at the application framework layer to execute the application information processing method provided in the embodiments of this application. The first service can calculate the cgroup grouping and scheduling policy of the mini-program. When calculating the cgroup grouping and scheduling policy of the mini-program process, the first service can determine whether it is a foreground process. If it is not a foreground process, the cgroup grouping is set to background, and the scheduling policy is no longer set to high priority. When the mini-program process is created, depending on whether it is a top-app process, if not, the first service can set the initial resource allocation priority of the mini-program process to: resource grouping level as background, and notify and set the corresponding cgroup grouping and resource scheduling level (in the background group, the resource scheduling level can default to: important state canceled; similarly, in the foreground group, the resource scheduling level can also default to important state canceled). When the Activity corresponding to the mini-program process is created and destroyed, depending on the foreground or background running state of the mini-program process, the corresponding cgroup grouping and resource scheduling level are notified and set.
[0233] In one example, the first service mentioned above could be AMS. Figure 8A and Figure 8B A schematic diagram illustrating another example of how application information is processed, as shown in this application. Figure 8A As shown, the method provided in the embodiments of this application can be executed by AMS, which is set in the application framework layer. After the applet process starts, the following steps are performed.
[0234] Step S81: AMS obtains information about process startup and determines the initial resource allocation priority of the process.
[0235] Step S82: AMS determines whether the launched process is a mini-program process. If so, proceed to step S83.
[0236] Step S83: AMS determines whether the mini-program process is running in the foreground. If not, proceed to step S84. If yes, retain the initial resource allocation priority.
[0237] Because some applications automatically launch mini-program processes by default when the main process starts, and depending on the application's settings, the mini-program process always has a high resource allocation priority after startup, a user may only open the application without opening the mini-program. In other words, the mini-program is not running in the foreground, but its process is always running and configured with a high resource allocation priority. In this situation, the mini-program process consumes a significant amount of the electronic device's resources, resulting in unreasonable resource allocation.
[0238] Step S84: AMS lowers the resource allocation priority of the mini-program process to: resource grouping level is background.
[0239] Through the above example, when the mini-program process is started but running in the background, the resource allocation level of the mini-program process is reduced. When allocating resources, resources are prioritized to processes with higher resource allocation levels. Processes with higher resource allocation levels may be running in the foreground, and the tasks performed by processes with higher resource allocation levels may be of higher importance, thereby saving unnecessary resource consumption and improving the rationality of resource allocation.
[0240] In possible implementations of this application, if the determination in step S83 is yes, the initial priority that is retained may also be a lower priority.
[0241] After step S84, if the mini-program process responds to the user's operation and enters the foreground running state, and then responds to the user's operation and enters the background running state, then the following steps S85 to S810 will be executed to set the initial priority of the mini-program process.
[0242] Step S85: When the mini-program is launched, the mini-program process starts running and generates a startup message (on start).
[0243] In a possible implementation, the aforementioned startup message can be generated when the mini-program process calls the `handlestartactivity` method. During the application's startup lifecycle, when the mini-program starts, its process is in the foreground running state. The mini-program process calls the `handlestartactivity` method, which handles the mini-program's activity startup request. Besides the startup message, steps S86 to S89 can also be triggered when any of the following messages are detected.
[0244] Message 1: Main process started message.
[0245] The main process start message can be a message generated by the application's main process calling the initialization method (handlelaunchactivity). When the main process transitions from a never-started state to a foreground running state, handlelaunchactivity can be called to handle the main process's activity initialization requests.
[0246] Message 2, Restart message.
[0247] After a mini-program closes its foreground running state and switches to a background running state, it then restarts its foreground running state. The mini-program process calls the restart method (handleresumeactivity) to handle the mini-program process's activity requests.
[0248] Message 3: Main process restart message.
[0249] The main process restart message is a message generated when the application's main process calls the `handlerestartactivity` method. After the main process closes its foreground state and transitions to a background state, and then restarts in the foreground, the mini-program process calls the `handlerestartactivity` method to handle the main process's activity requests.
[0250] Step S86: The mini-program process will start the message passing service to the application framework layer.
[0251] For example, the startup message can be passed to the service at the application framework layer through the inter-process communication mechanism (binder mechanism) of the electronic device's system.
[0252] Step S87: AMS sets the resource allocation priority of the mini-program process to a higher priority.
[0253] In step S87, AMS can set the resource allocation priority to any of the following levels.
[0254] Level 1: The resource grouping level is foreground.
[0255] Level 2: The resource grouping level is top-app, and the resource scheduling level is critical state startup.
[0256] Level 3: Resource grouping level is top-app, resource scheduling level is critical status canceled.
[0257] Step S88: In response to the user's action of closing the mini program, the mini program process is closed, and the mini program process generates a stop message (on pause).
[0258] Step S89: The mini-program process will stop sending messages to AMS.
[0259] Step S810: AMS lowers the resource allocation priority to: resource grouping level is background.
[0260] pass Figure 8A as well as Figure 8B As shown in the example, AMS can further adjust the resource allocation priority of the mini-program process based on the startup and shutdown of the mini-program, after determining the initial resource scheduling priority, so that the resources of the electronic device are allocated more reasonably.
[0261] In another example of this application, refer to Figure 9A and Figure 9B As shown, the first service used to execute the methods in this example is still set up at the application framework layer. Figure 9A and Figure 9B In the example shown, the method for processing application information includes the following steps.
[0262] Step S91: AMS obtains information about process startup and determines the initial resource allocation priority of the process.
[0263] Step S92: AMS determines whether the resource allocation priority setting function is enabled. If so, proceed to step S93.
[0264] In other possible implementations, step S91 can be followed directly to step S93, and step S92 can be skipped.
[0265] Step S93: AMS determines whether the launched process is a mini-program process. If so, proceed to step S94.
[0266] Step S94: AMS determines whether the initial priority of the mini-program process is top-app. If so, proceed to step S95.
[0267] Before step S94 and after step S93, the process may further include: AMS determining whether the display area corresponding to the mini-program process meets preset requirements. If so, proceed to step S94.
[0268] In other possible implementations, step S94 can be omitted, and the priority of the mini-program process can be determined directly based on whether the mini-program process is launching an activity.
[0269] For example, the above preset requirements may include: full screen, split screen, or occupying more than a set ratio of the display screen.
[0270] Step S95: AMS determines whether the mini-program process is launching an activity. If not, proceed to step S96. If yes, retain the initial resource allocation priority of the mini-program process.
[0271] In this embodiment of the application, the mini-program process is launching an activity, which indicates that the mini-program process is running in the foreground.
[0272] Step S96: AMS reduces the resource allocation priority of the mini-program process to: resource grouping level is background.
[0273] In step S93, if it is determined that the started process is a mini-program process, then after step S96, the mini-program process may enter the foreground running state in response to user operation, and then enter the background running state in response to user operation. During this process, the electronic device can execute the following steps S97 to S912.
[0274] Step S97: When the user performs the operation of opening the applet, the hardware layer transmits the received opening operation information to AMS.
[0275] Step S98: AMS sets the resource allocation priority of the mini-program process to a higher priority.
[0276] Step S99: When the user closes the mini-program, the hardware layer transmits the received closing operation information to AMS.
[0277] Step S910: AMS sets the resource allocation priority of the mini-program process to a lower priority.
[0278] This application embodiment also provides an application information processing apparatus, such as... Figure 10 As shown, it includes: a first process running module, a running status change information acquisition module, and a resource allocation priority adjustment module.
[0279] The first process running module is used to run the first process of the application; the first process is the non-main process of the application.
[0280] The running state change information acquisition module is used to acquire the running state change information of the first process of the application; the running state change information is used to indicate that the running state of the first process changes from the foreground running state to the background running state, or the running state of the first process changes from the background running state to the foreground running state.
[0281] The resource allocation priority adjustment module is used to change the resource allocation priority of the first process to a second priority based on the running status change information of the first process; the resource allocation priority is used to allocate resources of electronic devices to the first process.
[0282] The application information processing apparatus provided in this application embodiment can be used to perform, for example... Figures 5 to 9B The steps of the method provided in any embodiment and any related embodiment.
[0283] This application also provides an electronic device having a processing apparatus for application information provided in any embodiment of this application.
[0284] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0285] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0286] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps in the above-described method embodiments.
[0287] This application also provides a computer program product that, when run on an electronic device, enables the electronic device to perform the steps described in the various method embodiments above.
[0288] This application also provides a chip system, which includes a processor coupled to a memory. The processor executes a computer program stored in the memory to implement the steps of any method embodiment of this application. The chip system can be a single chip or a chip module composed of multiple chips.
[0289] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line, DSL) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer, or a data storage device such as a server or data center that integrates one or more available media. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).
[0290] The above-described embodiments are optional embodiments provided by this application and are not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the technical scope disclosed in this application should be included within the protection scope of this application.
Claims
1. A method for processing application information, characterized in that, include: If the resource allocation priority of the first process of the target application is first priority, then the first process is run according to the first priority; The first process is a non-main process of the target application; the resource allocation priority is used to allocate resources of the electronic device to the first process; Obtain the running state change information of the first process of the target application; the running state change information of the first process is used to indicate that the first process changes from a first running state to a second running state; Based on the information about the change in the running status of the first process, the resource allocation priority of the first process is changed to the second priority.
2. The method according to claim 1, characterized in that, The first operating state and the second operating state satisfy any one of the following: The first running state is the foreground running state, and the second running state is the background running state; The first running state is a background running state, and the second running state is a foreground running state; The first running state is the foreground running state, and the second running state is not the foreground running state.
3. The method according to claim 1, characterized in that, The step of changing the resource allocation priority of the first process to a second priority based on the running status change information of the first process includes: When the running status change information indicates a change from a foreground running state to a background running state, the second priority is changed to indicate a reduction in the priority of allocating electronic device resources to the first process.
4. The method according to claim 3, characterized in that, The change of the second priority to indicate a reduction in the priority of allocating electronic resources to the first process includes any one of the following: When the resource scheduling level in the second priority is the first target level and the resource grouping level in the second priority is the second target level, the resource grouping level in the second priority is reduced, and the resource scheduling level in the second priority is also reduced. If the resource scheduling level in the second priority is not the first target level, and the resource grouping level in the second priority is the second target level, then the resource grouping level in the second priority shall be reduced. If the resource scheduling level in the second priority is the first target level and the resource grouping level in the second priority is the second target level, then the resource scheduling level in the second priority is reduced.
5. The method according to any one of claims 1-4, characterized in that, The step of changing the resource allocation priority of the first process to a second priority based on the running status change information of the first process includes: When the running status change information indicates a change from background running to foreground running, the second priority is changed to indicate an increased priority for allocating electronic device resources to the first process.
6. The method according to claim 5, characterized in that, When the running state change information indicates a change from background running to foreground running, changing the second priority to indicate an increased priority for allocating electronic device resources to the first process includes any one of the following: If the resource scheduling level in the second priority is the third target level and the resource grouping level in the second priority is the fourth target level, then the resource grouping level in the second priority is increased, and the resource scheduling level in the second priority is also increased. If the resource scheduling level in the second priority is the third target level and the resource grouping level in the second priority is the fourth target level, then the resource grouping level in the second priority is increased. If the resource scheduling level in the second priority is the third target level and the resource grouping level in the second priority is the second target level, then the resource scheduling level in the second priority is increased.
7. The method according to any one of claims 1-6, characterized in that, The method further includes: Start the first process of the target application; Determine the initial running state of the first process; the initial running state is either a foreground running state or a background running state; Based on the initial running state, the resource allocation priority of the first process is determined.
8. The method according to any one of claims 1-7, characterized in that, The method further includes: The second process of the target application is launched; the second process remains in the same running state throughout its operation. According to the pre-set correspondence, the resource allocation priority of the second process is set.
9. The method according to any one of claims 1-8, characterized in that, The first process of the target application is a non-main process of the target application.
10. The method according to any one of claims 1-9, characterized in that, The first process of the target application is a mini-program process or a mini-game process.
11. The method according to claim 10, characterized in that, When the target application's mini-program or mini-game launches a running window on the electronic device's display screen, the running status change information is used to indicate a change from background running to foreground running; when the mini-program process generates a pause message, the running status change information is used to indicate a change from foreground running to background running.
12. The method according to claim 11, characterized in that, The method further includes: If the mini-program process generates a start message, main process start message, restart message, or main process restart message, the running state of the mini-program process is determined to be a foreground running state. If a pause message is detected in the mini-program process, the running state of the mini-program process is determined to be running in the background.
13. An electronic device, characterized in that, The electronic device includes: a processor and a memory; The memory is used to store a program for the electronic device to perform the method as described in any one of claims 1-12, and to store data related to implementing the method as described in any one of claims 1-12; The processor is configured to execute programs stored in the memory.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-12.