CN116048679A - Layer processing method, electronic equipment and readable storage medium - Google Patents

Layer processing method, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN116048679A
CN116048679A CN202210707004.8A CN202210707004A CN116048679A CN 116048679 A CN116048679 A CN 116048679A CN 202210707004 A CN202210707004 A CN 202210707004A CN 116048679 A CN116048679 A CN 116048679A
Authority
CN
China
Prior art keywords
application
layer
window
created
frame buffer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210707004.8A
Other languages
Chinese (zh)
Other versions
CN116048679B (en
Inventor
祁长乐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202210707004.8A priority Critical patent/CN116048679B/en
Publication of CN116048679A publication Critical patent/CN116048679A/en
Application granted granted Critical
Publication of CN116048679B publication Critical patent/CN116048679B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application provides a layer processing method, electronic equipment and a readable storage medium, and relates to the technical field of operating systems; the method can traverse the layer resources in the system to obtain the number of the layer resources of each application, and kills the progress of the application with more layer resources under the condition that the application with more layer resources exists, and releases the layer resources of the application after the progress of the application is killed; the window objects in the system can be traversed to obtain the number of window objects of each application, and under the condition that the application with the large number of window objects exists, the process of the application with the large number of window objects is killed, and after the process of the application is killed, the layer resource of the application is released; by the method, the phenomena of application blocking, system restarting and the like caused by the fact that the layer resources are exhausted can be reduced.

Description

Layer processing method, electronic equipment and readable storage medium
Technical Field
The present disclosure relates to the field of operating systems, and in particular, to a layer processing method, an electronic device, and a readable storage medium.
Background
As the degree of intellectualization of electronic devices increases, the electronic devices provide more and more functions. Accordingly, there are more applications installed in electronic devices, and these applications may display functional information to a user through an interface. When the application is used for displaying an application interface through a display screen of the electronic equipment, the application of the layer resource is required.
Currently, some applications are not very canonical at the time of development, or the developer is under other consideration, resulting in the developed application not releasing the corresponding layer resource in the case where the layer resource is applied and is no longer used. In this way, the layer resources in the electronic device may be consumed and used up, which may cause the phenomena of application locking or system restarting.
Disclosure of Invention
The application provides a layer processing method, electronic equipment and a readable storage medium, which can reduce the phenomena of application blocking, system restarting and the like caused by layer consumption.
In order to achieve the above purpose, the present application adopts the following technical scheme:
in a first aspect, the present application provides a method for processing a layer, where the method includes:
detecting that a first application applies for creating a layer resource, wherein the layer resource comprises: a container type layer or a framebuffer type layer;
Searching whether a second application with the number of window objects created by the application being greater than or equal to a first threshold exists;
if the second application with the number of window objects created by the application being greater than or equal to the threshold value corresponding to the window objects is found, killing the process of the second application, wherein the container type layer and the frame buffer type layer of the second application are released in response to the process of killing the second application.
In the application, when an application creates a container type layer or a frame buffer type layer, whether the number of window objects with application in the system is greater than or equal to a threshold corresponding to the window objects can be checked, if the application exists, the application can be regarded as an nonstandard application, and the progress of the application is killed. In addition, the first application and the second application may be the same or different. By searching the non-standard application and killing the searched process of the non-standard application when applying the container type layer or the frame buffer type layer each time, the layer resources of the non-standard application can be released, so that the phenomena of application blocking, system restarting and the like caused by the fact that the layer resources are exhausted are reduced.
As an implementation manner of the first aspect, after detecting that the first application applies to create the layer resource, the method further includes:
searching whether a second application with the number of the container type layers and/or the frame buffer type layers which are created by the application being greater than or equal to a second threshold value exists;
and if the second application with the number of the container type layers and/or the frame buffer type layers created by the application is found to be greater than or equal to a second threshold value, killing the process of the second application.
In this application, the non-canonical application is collectively referred to as a second application. In addition to the non-canonical application being determined by the number of window objects, the non-canonical application may also be determined by the number of layer resources. Of course, the non-canonical application may be determined by the number of container type layers, the non-canonical application may be determined by the number of frame buffer type layers, or the non-canonical application may be determined by the sum of the number of container type layers and frame buffer type layers.
As an implementation manner of the first aspect, before searching whether there is a second application for which the number of window objects created by the application is greater than or equal to the first threshold, the method further includes:
and traversing the applications corresponding to the window objects in the system respectively to obtain the number of window objects created by each application.
In the application, the number of window objects created by each application can be obtained by traversing the application corresponding to the window objects in the system, so that a second application with the number of window objects created by the application being greater than or equal to the first threshold can be searched.
As another implementation manner of the first aspect, before traversing the applications respectively corresponding to the window objects in the system, the method further includes:
and determining that the sum of the numbers of the container type layers and the frame buffer type layers in the system is greater than or equal to a third threshold value, wherein the third threshold value is smaller than the maximum upper limit of the sum of the numbers of the container type layers and the frame buffer type layers allowed by the system.
In the application, by means of the third threshold, when the sum of the number of the container type layers and the number of the frame buffer type layers in the system is greater than or equal to the third threshold, the application corresponding to the window objects in the system is traversed again, so that the traversing frequency can be reduced, and the system power consumption is reduced.
As another implementation manner of the first aspect, the method further includes:
determining that the sum of the number of container type layers and frame buffer type layers in the system is less than a third threshold;
And creating a layer resource created by the first application.
In the application, when the sum of the number of the container type layers and the number of the frame buffer type layers in the system is smaller than the threshold value, the container type layers or the frame buffer type layers created by the first application can be created without traversing the application corresponding to the window objects in the system, so that the traversing frequency is reduced, and the system power consumption is reduced.
As another implementation manner of the first aspect, if a second application with the number of window objects created by the application is found to be greater than or equal to the first threshold, killing a process of the second application includes:
if the second application with the number of window objects created by the application being greater than or equal to the first threshold value is found, recording the identification of the second application;
when interface switching is detected, checking whether the second application runs in the background or not based on the recorded identifier of the second application;
if the second application runs in the background, the process of the second application running in the background is killed.
In the application, when a second application with the number of window objects created by the application being greater than or equal to a first threshold is found, the identification of the second application can be recorded first, and when the second application is waited for running in the background, the application is killed, so that the situation that when the first application is identical to the second application, the process of the second application is killed, and a container type layer or a frame buffer type layer of the application is created for the second application can be avoided.
As another implementation manner of the first aspect, after determining that the sum of the number of container type layers and frame buffer type layers in the system is greater than or equal to the third threshold, the method includes:
judging whether the sum of the number of the container type layers and the number of the frame buffer type layers in the system is smaller than the maximum upper limit;
if the sum of the number of the container type layers and the number of the frame buffer type layers in the system is not smaller than the maximum upper limit, sending out information of creation failure;
if the sum of the number of container type layers and frame buffer type layers in the system is smaller than the maximum upper limit, the layer resource created by the first application is created.
In the application, after determining that the sum of the numbers of the container type layers and the frame buffer type layers in the system is greater than or equal to a third threshold, on one hand, traversing applications corresponding to the window objects in the system to obtain the number of the window objects created by each application, so as to find whether a second application exists, wherein the number of the window objects created by the application is greater than or equal to a first threshold corresponding to the window objects; another convenience can also be taken from the system's native flow: judging whether the sum of the number of container type layers and frame buffer type layers in the system is smaller than the maximum upper limit, thereby creating the applied layer resource or sending out the information of creation failure. Of course, the applications corresponding to the window objects in the system are traversed to obtain the number of the window objects created by each application, so that the process of searching whether the second application with the number of the window objects created by the application being greater than or equal to the first threshold corresponding to the window objects exists or not can be executed in the form of an asynchronous task. When executing with asynchronous task, the execution time of the container type layer and the frame buffer type layer of the application is usually shorter than the execution time of finding the second application and killing the second application, so even if the first application and the second application are the same application, the layer resource of the application is created first, the process of the application is killed, and the situation that the process of some application is killed first and the layer resource is created for the application is avoided.
As another implementation manner of the first aspect, each of the container type layer and the framebuffer type layer includes a layer attribute, and after the layer resource created by the first application is created, the method further includes:
judging whether the currently created layer resource is a frame buffer type layer or not;
if the frame buffer type layer is the frame buffer type layer, setting the layer attribute of the created frame buffer type layer as the process ID of the first application;
and setting the layer attribute of the container type layer as the layer attribute of the created frame buffer type layer based on the upward traversal of the created frame buffer type layer.
In this application, in general, a frame buffer type layer carries an application identifier (for example, a process ID), and a container type layer does not carry an application identifier. Typically, the container type layer is the parent node of the framebuffer type layer, so the upper process ID may also be added to the layer attributes in the container type layer by traversing up.
As another implementation manner of the first aspect, the method further includes:
Determining whether the sum of the numbers of the container type layers and the frame buffer type layers in the system is larger than or equal to a third threshold value or not according to a preset time period, wherein the third threshold value is smaller than the maximum upper limit of the sum of the numbers of the container type layers and the frame buffer type layers allowed by the system;
if the sum of the numbers of the container type layers and the frame buffer type layers in the system is larger than or equal to a third threshold value, traversing the applications corresponding to the window objects in the system respectively to obtain the number of the window objects created by each application;
searching whether a second application with the number of window objects created by the application being greater than or equal to a first threshold exists;
and if the second application with the number of window objects created by the application being greater than or equal to the first threshold value is found, killing the process of the second application.
In the application, a second application (non-standard application) with the number of window objects created by the search application being greater than or equal to a first threshold corresponding to the window objects can be triggered at preset time intervals, so that the processes of the non-standard application are killed, and the layer resources of the non-standard application are released.
As another implementation manner of the first aspect, the method further includes:
Creating a window object, wherein the window object comprises window attributes;
judging whether the currently created window object is a window object corresponding to the window;
if the window object which is currently created is the window object corresponding to the window, setting the window attribute of the window object which is created as the process ID of the current application;
and setting the window attribute of the window object corresponding to the activity as the window attribute of the window object currently created based on upward traversal of the window object currently created.
In the application, the window object includes a window object corresponding to a window and a window object corresponding to an activity. The window object corresponding to the window carries the application identifier, the window object corresponding to the activity does not carry the application identifier, so that the window attribute can be set in the window object, the window attribute of the window object corresponding to the window is set to the corresponding application identifier (process ID), the window object corresponding to the activity is usually the parent node of the window object corresponding to the window, and therefore, the process ID can be added to the window attribute in the window object corresponding to the activity in an upward traversing manner.
As another implementation manner of the first aspect, the number of window objects created by each application is obtained by traversing the applications respectively corresponding to the window objects in the system through the window system in the system.
As another implementation manner of the first aspect, traversing the applications corresponding to the layer resources in the system by the surface system in the system to obtain the number of the layer resources created by each application.
In a second aspect, there is provided an electronic device comprising a processor for executing a computer program stored in a memory, implementing the method of any of the first aspects of the present application.
In a third aspect, there is provided a system on a chip comprising a processor coupled to a memory, the processor executing a computer program stored in the memory to implement the method of any of the first aspects of the present application.
In a fourth aspect, there is provided a computer readable storage medium storing a computer program which when executed by one or more processors performs the method of any of the first aspects of the present application.
In a fifth aspect, the present application provides a computer program product for, when run on a device, causing the device to perform the method of any one of the first aspects of the present application.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
Fig. 1 is a schematic hardware structure of an electronic device according to an embodiment of the present application;
FIG. 2 is a diagram of Activity, window and view relationships provided in an embodiment of the present application;
fig. 3 is an interface schematic diagram of an application scenario provided in an embodiment of the present application;
FIG. 4 is a schematic diagram of layer relationships in the application scenario shown in FIG. 3;
fig. 5 is a flow chart of a layer creation method according to an embodiment of the present application;
fig. 6 is a flow chart of a layer processing method provided in an embodiment of the present application;
FIG. 7 is a flow chart of an embodiment of step S205 in the embodiment shown in FIG. 6;
FIG. 8 is a flowchart illustrating another layer processing method according to an embodiment of the present disclosure;
FIG. 9 is a flowchart illustrating another layer processing method according to an embodiment of the present disclosure;
FIG. 10 is a flowchart illustrating another layer processing method according to an embodiment of the present disclosure;
FIG. 11 is a schematic flow chart of creating a layer according to an embodiment of the present application;
FIG. 12 is a schematic diagram of a relationship between a window object and a layer resource according to an embodiment of the present disclosure;
FIG. 13 is a flowchart illustrating another layer processing method according to an embodiment of the present disclosure;
Fig. 14 is a flowchart of another layer processing method according to an embodiment of the present application;
fig. 15 is a flowchart of another layer processing method according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that in embodiments of the present application, "one or more" means one, two, or more than two; "and/or", describes an association relationship of the association object, indicating that three relationships may exist; for example, a and/or B may represent: a alone, a and B together, and B alone, wherein A, B may be singular or plural. The character "/" generally indicates that the context-dependent object is an "or" relationship.
In addition, in the description of the present application and the appended claims, the terms "first," "second," "third," "fourth," and the like are used merely to distinguish between descriptions and are not to be construed as indicating or implying relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The method for processing the image layer can be applied to electronic equipment such as tablet computers, mobile phones, notebook computers, ultra-mobile personal computer (UMPC), netbooks, personal digital assistants (personal digital assistant, PDA) and the like. The embodiment of the application does not limit the specific type of the electronic equipment.
Fig. 1 shows a schematic structural diagram of an electronic device. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charge 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, an earphone interface 170D, a sensor module 180, keys 190, a motor 191, a camera 193, a display 194, and a subscriber identity module (subscriber identification module, SIM) card interface 195, etc. Among other things, the sensor module 180 may include a pressure sensor 180A, a touch sensor 180K, and the like.
It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer components than shown, or certain components may be combined, or certain components may be split, or different arrangements of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors. For example, the processor 110 is configured to perform the layer processing method in the embodiment of the present application.
The controller may be a neural hub and a command center of the electronic device 100, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to reuse the instruction or data, it may be called directly from memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby improving the efficiency of the system.
The USB interface 130 is an interface conforming to the USB standard specification, and may specifically be a Mini USB interface, a Micro USB interface, a USB Type C interface, or the like. The USB interface 130 may be used to connect a charger to charge the electronic device 100, and may also be used to transfer data between the electronic device 100 and a peripheral device.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions. For example, files such as music, video, etc. are stored in an external memory card.
The internal memory 121 may be used to store computer-executable program code that includes instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store application programs (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system.
In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The charge management module 140 is configured to receive a charge input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charge management module 140 may receive a charging input of a wired charger through the USB interface 130.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like.
In other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charge management module 140 may be disposed in the same device.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The antennas 1 and 2 are used for transmitting and receiving electromagnetic wave signals. Each antenna in the electronic device 100 may be used to cover a single or multiple communication bands. Different antennas may also be multiplexed to improve the utilization of the antennas. For example: the antenna 1 may be multiplexed into a diversity antenna of a wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
The mobile communication module 150 may provide a solution for wireless communication including 2G/3G/4G/5G, etc., applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (low noise amplifier, LNA), etc. The mobile communication module 150 may receive electromagnetic waves from the antenna 1, perform processes such as filtering, amplifying, and the like on the received electromagnetic waves, and transmit the processed electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 can amplify the signal modulated by the modem processor, and convert the signal into electromagnetic waves through the antenna 1 to radiate.
The wireless communication module 160 may provide solutions for wireless communication including wireless local area network (wireless local area networks, WLAN) (e.g., wireless fidelity (wireless fidelity, wi-Fi) network), bluetooth (BT), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field wireless communication technology (near field communication, NFC), infrared technology (IR), etc., as applied to the electronic device 100. The wireless communication module 160 may be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the electromagnetic wave signals, filters the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive a signal to be transmitted from the processor 110, frequency modulate it, amplify it, and convert it to electromagnetic waves for radiation via the antenna 2.
In some embodiments, antenna 1 and mobile communication module 150 of electronic device 100 are coupled, and antenna 2 and wireless communication module 160 are coupled, such that electronic device 100 may communicate with a network and other devices through wireless communication techniques.
The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, an application processor, and the like. Such as music playing, recording, etc.
The audio module 170 is used to convert digital audio signals to analog audio signal outputs and also to convert analog audio inputs to digital audio signals. The audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be disposed in the processor 110, or a portion of the functional modules of the audio module 170 may be disposed in the processor 110.
The speaker 170A, also referred to as a "horn," is used to convert audio electrical signals into sound signals. The electronic device 100 may listen to music, or to hands-free conversations, through the speaker 170A.
A receiver 170B, also referred to as a "earpiece", is used to convert the audio electrical signal into a sound signal. When electronic device 100 is answering a telephone call or voice message, voice may be received by placing receiver 170B in close proximity to the human ear.
Microphone 170C, also referred to as a "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or transmitting voice information, the user can sound near the microphone 170C through the mouth, inputting a sound signal to the microphone 170C. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, and may implement a noise reduction function in addition to listening to voice information. In other embodiments, the electronic device 100 may also be provided with three, four, or more microphones 170C to enable collection of sound signals, noise reduction, identification of sound sources, directional recording functions, etc.
The earphone interface 170D is used to connect a wired earphone. The headset interface 170D may be a USB interface 130 or a 3.5mm open mobile electronic device platform (open mobile terminal platform, OMTP) standard interface, a american cellular telecommunications industry association (cellular telecommunications industry association of the USA, CTIA) standard interface.
The pressure sensor 180A is used to sense a pressure signal, and may convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display screen 194. The pressure sensor 180A is of various types, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, and the like. The capacitive pressure sensor may be a capacitive pressure sensor comprising at least two parallel plates with conductive material. The capacitance between the electrodes changes when a force is applied to the pressure sensor 180A. The electronic device 100 determines the strength of the pressure from the change in capacitance. When a touch operation is applied to the display screen 194, the electronic apparatus 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 may also calculate the location of the touch based on the detection signal of the pressure sensor 180A.
The touch sensor 180K, also referred to as a "touch panel". The touch sensor 180K may be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, which is also called a "touch screen". The touch sensor 180K is for detecting a touch operation acting thereon or thereabout. The touch sensor may communicate the detected touch operation to the application processor to determine the touch event type. Visual output related to touch operations may be provided through the display 194. In other embodiments, the touch sensor 180K may also be disposed on the surface of the electronic device 100 at a different location than the display 194.
The keys 190 include a power-on key, a volume key, etc. The keys 190 may be mechanical keys. Or may be a touch key. The electronic device 100 may receive key inputs, generating key signal inputs related to user settings and function controls of the electronic device 100.
The motor 191 may generate a vibration cue. The motor 191 may be used for incoming call vibration alerting as well as for touch vibration feedback.
The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 194 is used to display images, videos, and the like. In some embodiments, the electronic device 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The camera 193 is used to capture still images or video. In some embodiments, electronic device 100 may include 1 or N cameras 193, N being a positive integer greater than 1.
The SIM card interface 195 is used to connect a SIM card. The SIM card may be inserted into the SIM card interface 195, or removed from the SIM card interface 195 to enable contact and separation with the electronic device 100. The electronic device 100 may support 1 or N SIM card interfaces, N being a positive integer greater than 1.
The embodiment of the present application is not particularly limited to a specific structure of an execution body of the processing method of a layer, as long as the processing can be performed by executing a code recorded with the processing method of a layer according to the embodiment of the present application. For example, the execution body of a layer processing method provided in the embodiments of the present application may be a functional module in an electronic device that can call a program and execute the program, or a processing apparatus, such as a chip, applied in the electronic device.
Before describing particular embodiments of the present application, a relationship between Activity, window and view in an electronic device operating system is first understood.
Activity is an application component that can provide an interface through which a user can interact with human-machine.
Referring to FIG. 2, each Activity has an associated window describing an application window, and each application window has a view contained therein describing a view of the application window. The application window view truly implements interface content and layout. In other words, the interface content and layout for each Activity is implemented by a view inside the window associated with that Activity.
The layer resources in the operating system of the electronic device include: a Container type layer and a frame buffer type layer. When the system initiates an interface, multiple layer resources may be created.
The frame buffer type layer needs to set a drawing buffer area for storing content information on the interface, and the content information can be understood as view.
The container type layer has a container attribute, does not need to set a drawing buffer area and does not need to store content information on an interface for managing the frame buffer type layer.
As an example, referring to (a) in fig. 3, when a user clicks an application icon on a desktop of an electronic device, an application start corresponding to the application icon in the electronic device is triggered. Taking a video application icon as an example, when a user clicks the video application icon, the electronic device may detect an operation of clicking the video icon, and after detecting the operation of clicking the video icon, the video application will be started. After the video application is cold started, a main interface of the video application is displayed. See the main interface of the video application shown in fig. 3 (d).
In some scenarios, to enhance the user experience, a transition window may also be displayed prior to displaying the main interface of the application, e.g., an advertisement page, logo page, blank page, etc., displayed for a period of time (e.g., 1s, 2s, 3s, 4s, 5s, etc.) prior to displaying the main interface. See fig. 3 (b) for an example of a transition window with logo pages.
In other scenarios, a child window may also be displayed when the main interface of the application is displayed. For example, some content is displayed through a sub-window of the main interface, where the content displayed by the sub-window may be interface content related to the application or the main interface, and may also be an advertisement interface. See the recommendation window (for recommending video) displayed above the main interface shown in (c) of fig. 3. The sub-window is closed after the main interface is closed; alternatively, referring to (c) in fig. 3, the user may click on a close control on the child window to trigger the child window to close; referring to (d) in fig. 3, after the user closes the sub-window through the close control on the sub-window, the user can see the main interface of the video application.
Referring to fig. 4, when the video application performs the above cold start, the system creates and starts the Activity1 corresponding to the main interface of the application. In the Activity1 startup process, the creation of container type layer 1, container type layer 2-1, and frame buffer type layer 1 will be applied. The method comprises the steps that an Activity1 application creates an Activity1 corresponding to a container type layer 1, a window1 associated with the Activity1 corresponds to a container type layer 2-1, and a view 1 inside the window1 corresponds to a frame buffer type layer 1.
Continuing to take the scenario shown in fig. 3 as an example, in the Activity1 starting process corresponding to the main interface, window 2 corresponding to the transition window corresponds to the container type layer 2-2, and view 2 inside the window 2 corresponds to the frame buffer type layer 2.
The window 3 corresponding to the child window corresponds to the container type layer 2-3, and the view 3 inside the window 3 corresponds to the frame buffer type layer 3.
Fig. 3 and 4 are only for example to illustrate the creation process of the layers. In practice, some layers may not be created and managed by Activity. By way of example, some of the layers are frame buffer type layers created directly through a surface system. Of course, in practical applications, some layers are a container type layer and a frame buffer type layer created by the window system, which are not exemplified in the present application.
As previously described, a user's operation on an interface displayed by an electronic device may trigger an application to apply for a layer; in practical applications, other triggering conditions may trigger the application program to apply for the layer, for example, when some software needs to pop up an advertisement based on an internal triggering mechanism, the rogue software needs to apply for the layer.
Continuing to take fig. 3 as an example, after the video application is cold started, the electronic device displays a logo page of the video application, after the logo page is displayed for 3 seconds, the electronic device switches from displaying the logo page to displaying a main interface and a sub-window of the video application, and if the sub-window is closed by a user, the electronic device displays the main interface of the video application.
After the electronic device is switched from displaying the logo page to displaying the main interface and the sub-window of the video application, the video application needs to request the system to release the frame buffer type layer 2 corresponding to the logo page, and after the window corresponding to the logo page is destroyed, the video application needs to request the system to release the container type layer 2-2 corresponding to the window of the logo page. I.e., after the logo page is closed or some time after closing, the system needs to release the container type layer 2-2 and the frame buffer type layer 2 in the example shown in fig. 4. Similarly, the video application needs to release the layer corresponding to the child window after or some time after the user closes the child window, for example, needs to release the container type layer 2-3 and the frame buffer type layer 3 in the example shown in fig. 4.
However, in practical applications, some applications do not release the corresponding layers when they are needed for development and design reasons or keep alive considerations. As users use such applications longer or use such applications more and more, the system runs such applications longer or the system starts and runs such applications more and more, resulting in less layer resources in the system being consumed. In practical applications, the layer resources of the system are limited. For example, some systems allow for a maximum of 4096 layers of applied layer resources. After the layer resource of the system is exhausted, the application applying the layer resource will be blocked, forced exit, etc., and even the system may be blocked and restarted. For ease of description, embodiments of the present application refer to this type of application as an unnormalized application.
In order to more clearly understand the layer processing method provided in the embodiment of the present application, a process of applying the layer resource is described first.
Taking an example that a user clicks a control on an interface displayed by the electronic equipment to trigger the electronic equipment to display a new interface, a process of applying the layer resource is described. Referring to fig. 5, a flowchart of a method for applying layer resources is provided in an embodiment of the present application.
In step S101, in response to the operation of the user, the application parses the interface layout to be displayed, and requests the window system to create a window object.
In the embodiment of the application, the operation of the user is used for triggering the electronic equipment to display a new interface. For example, a click operation of the video application icon shown in (a) in fig. 3. Of course, it is also possible to click on some of the controls in (d) in fig. 3 (e.g., the controls corresponding to any of the video assets being hot-cast). Of course, other operations in (d) of fig. 3 are also possible (e.g., a user sliding up from the bottom of the display screen triggers the electronic device to return to the system desktop). The operation of the user in the embodiment of the present application is not exemplified one by one.
The embodiment of the application is described by taking the example that the operation of the user triggers the electronic equipment to display a new interface.
If the electronic device is to display the interface of the application in response to a certain trigger condition, the application analyzes the layout of the interface to be displayed, and if the electronic device is to display the interface of the system in response to a certain trigger condition, the system analyzes the layout of the interface to be displayed.
As an example, if the triggering operation is an operation that the user slides up from the bottom of the display screen to trigger the electronic device to return to the desktop of the system, the desktop launcher (launcher) of the system parses the desktop layout to be displayed. And if the triggering operation is the operation of clicking a certain application icon by the user, analyzing the interface layout of the application to be displayed by the application corresponding to the application icon.
Taking an interface for displaying an application as an example, the application will request the window system to create a window object.
Of course, in practical application, the process of displaying a new interface by the electronic device is complex, however, in the process of switching from an old interface to a new interface by the electronic device, the application corresponding to the new interface needs to create a window object and apply for a layer resource. Wherein the window object is created by a windows system (WMS), and the layer resource is created by a surface system.
In step S102, the window system creates a window object.
Step S103, the window system calls a surface system interface to apply for creating the layer resource.
In practical applications, the application request for creating the layer resource may be an application request for creating a container type layer resource, or may be an application request for creating a frame buffer type layer resource.
The application that applies to create the layer resource may be referred to as a first application.
In step S104, the surface system determines whether the layer resource reaches (is greater than or equal to) the maximum upper limit of the layer number.
In the embodiment of the application, the system sets the maximum upper limit of the number of layers, for example, 4096 layers. The Surface system may check if the number of layer resources is greater than or equal to 4096 and if so, return to create failure.
As an example of checking whether the number of layer resources is greater than or equal to the maximum upper limit:
Figure BDA0003706431510000101
of course, in the embodiment of the present application, the maximum upper limit of the layer resource is 4096 as an example, and in a specific implementation, the maximum upper limit may also be other number due to the system of the electronic device itself or due to the electronic device adopting a different system, which is not limited in this application.
If the number of layers in the system is greater than or equal to the maximum upper limit, step S105 is performed.
If the number of layers in the system is less than the maximum upper limit, step S106 is performed.
In step S105, if the number of layers in the system is greater than or equal to the maximum upper limit, the surface system sends out information of the creation failure.
And step S106, if the number of the layers in the system is smaller than the maximum upper limit, the surface system creates the layer resource.
In practical applications, if the system captures the information of the creation failure, the application applying the layer resource may be blocked or the system may be restarted (when the system applies the layer resource). If the user is currently using the electronic device, the user experience is poor.
In order to reduce application blocking or system restarting caused by layer resource exhaustion and improve user experience, the embodiment of the application provides a layer processing method, and the application layer resource is additionally monitored and managed.
For example, the number of layer resources per application may be analyzed, and in the event that the number of layer resources applied is greater than an application threshold, the application is deemed too many layer resources for that application, which may be an unnormalized application. The application can be stopped forcefully, or the application can be stopped after being switched to the background (the problem that the user experience is poor because the user is forced to stop the application while the user is currently using the application is avoided).
Wherein stopping the application kills the application's process.
When the application layer resources are in specific implementation, the layer resources in the traversal system can be triggered to obtain the number of the layer resources of each application, and then the layer resources of each application are compared with the application threshold value, so that whether the application is an irregular application or not is determined.
As an example, see the schematic flow chart of the layer processing method shown in fig. 6.
In step S101, in response to the operation of the user, the application parses the interface layout to be displayed, and requests the window system to create a window object.
In step S102, the window system creates a window object.
Step S103, the window system calls a surface system interface to apply for creating the layer resource.
The contents of steps S101 to S103 may refer to the description in the embodiment shown in fig. 5, and are not described herein.
Step S204, after receiving the request for applying the layer, the surface system traverses the layer resources in the system to obtain the number of layer resources applied by each application.
It should be noted that, each application applies for a created layer, which indicates that the application triggers the created layer when pulling up the interface. The layer triggered to be created when the application pulls up the interface may include a framebuffer type layer or a container type layer. Therefore, when traversing the layer resources in the system, it is necessary to determine the application to which each layer resource belongs, and then the layer resource is created when which application pulls up the interface, and then which application the layer resource belongs to.
In addition, each application does not represent all applications currently installed (or running) in the electronic device, but rather each application in all applications corresponding to the layer resources in the current system is determined by traversing the layer resources in the system.
As an example, 30 applications are installed in the system, when traversing the layer resources, it may be determined that there are 5 applications corresponding to the layer resources in the current system based on the application to which each layer resource in the current system belongs, and each application in the embodiment of the present application represents all applications in the 5 applications corresponding to the current layer resource in the system determined by traversing the layer resources. Wherein the numerals 30 and 5 are for illustration only.
Of course, in an actual application, if the traversed layer resource is one of the layer resources, each application represents each application of all applications corresponding to the traversed layer resource of the type.
In the subsequent embodiment, if the traversed window object is taken as an example, each application represents each application in all applications corresponding to the traversed window object.
In step S205, the surface system may determine whether the number of layer resources applied by each application is less than the application threshold.
If there are applications (which may be referred to as non-canonical applications) whose number of applied layer resources is greater than or equal to the application threshold, step S206 is performed.
If the number of layer resources of each application is smaller than the application threshold, the steps S104 to S105 (or step 106) are continuously performed.
Step S206, forcibly stopping the non-standard application or recording the non-standard application (application for which the number of application layer resources is greater than or equal to the application threshold).
In practical applications, applications for which the number of application layer resources is equal to the application threshold may not be classified as non-standard applications. Can be set according to actual conditions, and the embodiment of the application does not limit the setting.
In the application, the surface system may record an application (may be referred to as an unnormalized application or a second application) whose number of layer resources is greater than or equal to an application threshold, and may stop the application through the system of the electronic device when the unnormalized application is running in the background.
Of course, after the non-canonical application is forcibly stopped or recorded, steps S104 to S105 (or step S106) may be continuously performed.
By adding steps S204 to S206 on the basis of the system native logic (between steps S103 to S104), the system native logic can be kept as small as possible.
In a specific implementation, after the surface system obtains the number of layer resources of each application, it may be determined by the method shown in fig. 7 whether the number of layer resources of each application is smaller than the application threshold. I.e. step S205 may be realized by the following steps.
After step S204, it includes:
in step A1, the surface system assigns i a value of 1 (i=1).
And A2, the surface system judges whether the number of the layer resources of the ith application is larger than or equal to an application threshold value.
If the number of layer resources of the ith application is greater than or equal to the application threshold, step A3 is performed to record the application into a stopped application list (in which application identifiers recorded as non-canonical applications in the embodiment of the present application are recorded).
If the number of layer resources applied by the ith application is less than the application threshold, step A4 is executed to add 1 to the value of i, so as to continuously determine whether the number of layer resources applied by the next application is greater than or equal to the application threshold.
And step A3, if the number of the layer resources of the ith application is greater than or equal to the application threshold, recording the ith application into a stop application list by the surface system.
In step A4, the surface system adds 1 to the value of i (i=i+1).
And step A5, the surface system judges whether the current i is less than or equal to N.
If i is less than or equal to N (the total number of applications applying the layer resources), step A2 is continued to determine whether the number of layer resources applied by the next application is greater than or equal to the application threshold.
If i is greater than N, the number of layer resources applied for each application applying layer resources has been compared with the application threshold, and step A6 is performed.
And step A6, if the i is larger than the N, judging whether the application exists in the application stopping list by the surface system.
If there is an application in the stopped application list, step S206 is performed to forcibly stop the application in the stopped application list or store the stopped application list.
If no application exists in the application stopping list, the application indicating the current application layer resource does not belong to the non-standard application, or even if the application possibly belongs to the non-standard application, however, the number of layer resources applied by the non-standard application is still relatively small, and the number of layer resources applied by the non-standard application is insufficient to threaten the layer resources of the system. Step S104 is performed. To continue applying for layer resources.
However, when the forced stop application scheme is adopted in step S206 in this embodiment, the following may occur:
The application of the layer resource of the current application and the application which needs to be forcedly stopped are the same application. After the application is forcibly stopped, the application layer resource needs to be continuously applied to the application, which is obviously unreasonable and can cause abnormal application or abnormal system. Thus, embodiments of the present application may also perform the added steps in an asynchronous task manner.
As an example, referring to fig. 8, between step S103 to step S104, an asynchronous task may be triggered. After the surface system receives the request for applying the layer resources, on one hand, the asynchronous task is triggered, and on the other hand, whether the layer resources reach the maximum upper limit of the layer number is judged.
The asynchronous task may be understood as a task that is executed in synchronization with step S104 to step S105 (or step S106), and includes the steps of:
step S301, traversing the layer resources in the system by the surface system to obtain the number of the layer resources of each application.
In step S302, the surface system determines whether the number of layer resources applied by each application is smaller than the application threshold.
If the number of the layer resources of each application is smaller than the application threshold value, ending the asynchronous task;
if there are applications (which may be referred to as non-canonical applications) whose number of applied layer resources is greater than or equal to the application threshold, step S303 is performed.
Step S303, forcibly stopping or recording the application as an unnormalized application (an application for which the number of layer resources is greater than the application threshold).
After step S303, the asynchronous task is ended.
The descriptions of steps S301 to S303 may refer to the descriptions of steps S204 to S206, and are not described herein.
By adding the asynchronous task on the basis of the system native logic, the native logic of the system can not be changed, the stability of the system is maintained, and the asynchronous task added in the embodiment of the application is convenient to optimize and upgrade subsequently; in addition, since the execution duration of steps S104 to S105 (or step S106) is generally less than the processing duration of the asynchronous task, that is, "the duration from the time when it is determined whether the system layer resource is greater than the maximum upper limit of the layer number to the time when it is established that the layer resource is terminated for an application" is less than the time when it is started to execute the asynchronous task and the time when the application is forcibly stopped ", a layer is established for the application and the application that needs to be forcibly stopped is forcibly stopped, and then the application is forcibly stopped, even if the application that is currently applying the layer resource and the application that needs to be forcibly stopped are the same application. Therefore, the situation that the application is forcibly stopped and then the layer resource is applied for the application is avoided.
In another embodiment of the present application, the surface system may be triggered to execute the step of traversing the layer resources in the system in a preset time period to obtain the number of layer resources of each application.
As an example, referring to fig. 9, the following steps are added to the embodiment shown in fig. 5:
step S401, triggering and executing step S301 with a preset time period. The value of the time period can be set according to the specific situation. For example, a constant value may be set, and may be set as follows:
if an application that was deemed to belong to an unnormalized application is started, the time period may be set relatively small, and if an application that was deemed to be an unnormalized application is not included in the currently running application, the time period may be set relatively large.
Step S301, traversing the layer resources in the system to obtain the number of the layer resources applied by each application.
Step S302, judging whether the number of the layer resources of each application is smaller than an application threshold value.
In step S303, if there are applications whose number of applied layer resources is greater than or equal to the application threshold, the application non-standard application (applications whose number of applied layer resources is greater than or equal to the application threshold) is forcibly stopped or recorded. And ends.
Step S304, if the number of layers of each application is smaller than the application threshold, ending.
By adding another periodic task execution mode in the system, the native logic of the system can not be changed; and the situation that the application is stopped forcedly and then the layer resource is applied for the application is avoided. Of course, in the embodiment shown in fig. 9, the execution subject of the task of step S401 to step S303 may be any module having the execution capability of the task in the operating system.
As another embodiment of the present application, the application threshold value corresponding to each application may be the same or different.
If the application threshold value corresponding to each application is the same, after the number of the layer resources of each application is obtained, the applications can be ordered from high to low according to the number of the layer resources of each application. After the ranking, the 1 st application is the application with the largest number of application layer resources. After traversing to an application where the number of layer resources is less than the application threshold, according to the embodiment shown in fig. 7, step A6 is performed. I.e. without the need to continue traversing the later applications.
If the application thresholds corresponding to the applications may be different, the sorting operation is not required. In specific implementation, different application thresholds are set for each application, and applications in different categories (groups) can be classified (or grouped), and application thresholds corresponding to applications in the same category (group) are the same.
In the above embodiment, the following may also occur:
the layer resources in the system are traversed frequently to obtain the number of layers per application.
For example, in the embodiments shown in fig. 6 and 8, each time a layer resource is applied, an operation of traversing the layer resource is performed. In the embodiment shown in fig. 9, the operation of traversing the layer resource is performed every time a predetermined period of time elapses.
In the embodiment of the application, a traversal threshold (which may be denoted as a third threshold) may also be set, where the traversal threshold is smaller than the maximum upper limit of the number of layers allowed by the system. And under the condition that the layer resource in the system is larger than the traversing threshold value, executing the operation of traversing the layer resource, thereby reducing the system power consumption.
As an example, if the maximum upper limit of the number of layers allowed by the system is 4096, the traversal threshold may be a×4096. The a may be 0.5, 0.6, 0.7, 0.8, etc.
Taking a as an example of 0.8, the traversal threshold is 4096×0.8≡3277. I.e. only after the number of layers in the system reaches 3277, the traversing of the layers in the system is started again to obtain the number of layers of each application.
As an embodiment, on the basis of the embodiment shown in fig. 6, before step S204, the steps are added:
And judging whether the number of the layer resources in the system is larger than or equal to a traversal threshold.
If the traversal threshold is greater than or equal to the traversal threshold, step S204 is executed;
if the traversal threshold is smaller, step S104 is performed.
Of course, in practical application, if the traversal threshold is smaller than the traversal threshold, step S106 may be directly performed. However, this approach requires modification to the system's native logic.
As another embodiment, referring to fig. 10, in the embodiment shown in fig. 8, the following steps are added before step S104 and step S301:
in step S501, the Surface system determines whether the number of layer resources is greater than or equal to a traversal threshold.
If the threshold value is greater than or equal to the traversal threshold value, on the one hand, triggering an asynchronous task, and starting to execute the step S301 and the step S104; on the other hand, step S104 is performed.
If the traversal threshold is smaller, step S104 is performed. Of course, in practical application, step S106 may also be directly executed.
In this way, whether the number of layer resources is greater than or equal to the traversal threshold, it is necessary to continue to step S104 to create the layer resources (possibly also failed to create). The asynchronous task need only be triggered after the layer resources are greater than or equal to the traversal threshold. The frequency of executing the layer resources in the traversing system to obtain the number of layers of each application is reduced, so that the system power consumption is reduced.
As another embodiment of the present application, in the embodiment shown in fig. 9, step S401 may be modified as follows:
judging whether the number of layer resources in the system is greater than or equal to a traversal threshold according to a preset time period.
If the traversal threshold is greater than or equal to the traversal threshold, triggering and executing step S301;
if the traversal threshold is smaller than the traversal threshold, ending.
As described in the previous embodiments, the layer resources in the system may be traversed to obtain the number of layer resources per application. As previously illustrated, the types of layer resources include a container type layer and a framebuffer type layer. Therefore, in the embodiments shown in fig. 6 to 10, the number of layer resources of the application is counted as follows: the sum of the number of layers of all container types and all frame buffers types.
In practical applications, the number of layer resources per application is counted, and the purpose of setting the application threshold is to identify non-canonical applications. In practical applications, the number of layer resources of non-canonical application applications is typically much greater than the number of layer resources of other application applications. Therefore, in practical application, the number of container type layers of each application may also be counted, and the number of container type layers and the set application threshold (which may be different from the value of the application threshold in the previous embodiment) are compared to determine whether the application belongs to an irregular application. The number of frame buffer type layers of each application may also be counted, and the number of frame buffer type layers and the set application threshold (which may be different from the application threshold in the previous embodiment) may be compared to determine whether the application belongs to an irregular application.
Of course, since the application threshold is a manually set threshold, the matching threshold may be set according to the type of layer counted when counting the number of applied layer resources.
As an example, if the sum of the number of container type layers and frame buffer type layers per application is counted, the application threshold a may be set.
If the number of container type layers per application is counted, an application threshold B may be set.
If the number of frame buffer type layers applied for each application is counted, an application threshold C may be set.
Wherein the application threshold A is greater than the application threshold B, and the application threshold A is greater than the application threshold C. The application threshold B may be greater than the application threshold C.
In practical applications, the container type layer typically does not carry the application to which it belongs. The frame buffer type layer typically carries the application to which it belongs.
Thus, in the case where the created layer is a frame buffer type layer, an application identifier (e.g., an application packet name, a process ID, etc.) may be obtained based on the frame buffer type layer, and then based on the layer structure shown in fig. 4, the container type layer is traversed upward based on the frame buffer type layer, and the application identifier is added in the form of a field in the container type layer. Of course, for the sake of statistics, the same field may be added to the frame buffer type layer to record the application to which it belongs. Reference is specifically made to the flow diagram shown in fig. 11.
After the surface system creates the layer resources at step 106, the following steps are performed:
in step S601, the created layer resource is added with the layer attribute.
It should be noted that, in order to facilitate traversing all layer resources in the system, layer attributes may be added in the container type layer and the frame buffer type layer with the same fields. Thus, the created layer resources, whether they be container type layers or framebuffer type layers, require the addition of layer properties. The layer attribute is used to represent the application to which it belongs. The application packet name may be populated, or the Process ID (PID) of the application may be populated.
Step S602, judging whether the created layer resource is a frame buffer type layer resource.
And ending the flow when the created layer resource is not the frame buffer type layer resource.
In general, in the case that a newly created layer belongs to a container type layer, an application identifier needs to be determined by a frame buffer type layer of a subsequent node of the container type layer to determine an application to which the container type layer belongs. Therefore, the application identifier can be added in the layer attribute when the subsequent frame buffer type layer is created, and the subsequent embodiment can be referred to specifically.
In case the created layer resource is a frame buffer type layer resource, step S603 is performed.
In step S603, the layer attribute of the created frame buffer type layer resource is the application identifier of the current application.
Firstly, adding an application identifier of the current application into the layer attribute of the newly created frame buffer type layer to be used as the layer identifier of the layer.
Step S604, traversing upwards, setting the layer attribute of the parent container type layer resource of the newly created frame buffer type layer resource as the layer identifier of the currently newly created frame buffer type layer resource.
It should be noted that it is necessary to traverse up to the root container type layer resource. For example, the upward traversal process ends when traversing to a container type layer resource where there is no parent layer resource.
As an example of native layer resources that do not carry layer properties:
Figure BDA0003706431510000151
as an example of a layer resource carrying a layer attribute provided in an embodiment of the present application:
class Layer{
const std::string mName;
FloatRect mBounds;
FloatRect mScreenBounds;
wp<Layer>mCurrentParent;
uid_t mOwnerUid;
pid_t mOwnerPid;
pid_ t mRealCallingPid; the application process ID is added as a layer identification.
If the container type layer and the frame buffer type layer in the system both carry layer identifiers (i.e. contents in layer attributes), applications to which each layer belongs can be determined in a traversal manner, and then the total number of layers of each application is counted.
In particular implementations, adding a layer attribute to each layer in this manner and adding a layer identifier to the layer attribute consumes system memory.
As described above, since the purpose of obtaining the total number of layers of each application in the embodiment of the present application is not to accurately determine the number of layers actually applied by each application, it is required to determine whether the application belongs to an irregular application according to the number of layers applied. Therefore, in practical application, only one type of layer can be counted. As an example, only the framebuffer type layer may be counted.
As mentioned above, in practical applications, the number of container type layers may also be counted. Although the container type layer does not contain an application identification. However, the number of container type layers may be counted in other ways.
Referring to fig. 12, a schematic diagram of a relationship between management of a window object by a window system and management of a layer resource by a surface system is provided for an embodiment of the present application.
As shown in step S102 in the embodiment of fig. 5, each interface, when created, requires the window system to create a window object, which is also a tree structure.
Take the embodiment shown in fig. 3 as an example. The window object corresponding to the Activity1 corresponding to the main interface of the video application is the window object 1 in fig. 12. The main interface window corresponding to the Activity1 is a window object 2-1 in fig. 12, the start window is a window object 2-2 in fig. 12, and the child window is a window object 2-3.
Referring to fig. 12, a window object 1 in a window system corresponds to a container type layer 1 in a layer system, a window object 2-1 in the window system corresponds to a container type layer 2-1 in the layer system, a window object 2-2 in the window system corresponds to a container type layer 2-2 in the layer system, and a window object 2-3 in the window system corresponds to a container type layer 2-3 in the layer system.
In practical application, one window object in the window system corresponds to one container type layer in the layer system. And window objects in the window system have application identifications. Therefore, in practical application, the number of container type windows of each application can be counted through the window system, and the step of traversing the container type layer upwards based on the frame buffer type layer and adding the application identifier in the container type layer is not needed to be executed in this way. Thereby reducing power consumption.
As another embodiment of the present application, the traversing of the layer resources in the system to obtain the number of layer resources of each application in the above embodiment may be traversing of window objects in the system to obtain the number of window objects of each application, determining the number of window objects of each application and the size of the application threshold, where the value of the application threshold is an application threshold B (which may be denoted as a third threshold) corresponding to the container type layer resources.
For a clearer understanding, refer to the flow chart of the application layer in the embodiment shown in fig. 13.
In this embodiment, the number of window objects per application is counted by the window system. The following steps may be performed after the window system creates a window object at step S102:
step S701, the window system traverses the layer resources in the system to obtain the number of window objects of each application.
In step S702, the window system determines whether the number of window objects of each application is less than the application threshold.
In the case where the number of application window objects is greater than or equal to the application threshold, step S703 is performed.
Step S703, forcibly stopping or recording the unnormalized application (application in which the number of application window objects is greater than or equal to the application threshold).
In actual application, the windowing system may notify other modules in the operating system (e.g., ATMS) to implement forced stopping of the non-canonical application. After step S703, step S103 is performed.
In the case where the number of window objects of each application is smaller than the application threshold, step S103 is performed.
Step S103, the window system calls a surface system interface to apply for creating a layer.
The contents of step S104 to step S106 can be described with reference to the above embodiments.
In the embodiment shown in FIG. 13, after the window system creates the window object, a determination may be made as to whether an unnormalized application exists. And then calling a surface system interface to apply for creating the layer resource.
Of course, in actual application, after the window system creates the window object, the surface system interface may be called first to apply for creating the layer resource, and then the surface system notifies the window system to traverse the window object in the system, and the window object further determines whether there is an irregular application, and whether there is any irregular application, step S104 needs to be executed.
As another embodiment of the present application, the application threshold may also be increased in order to reduce the frequency of traversing system window objects. See fig. 14.
Steps S101 to S102 may be described with reference to the above embodiments.
Step S103, the window system calls a surface system interface to apply for creating the layer resource.
Step S501, after receiving an application request of the layer resource, the surface system judges whether the layer resource reaches a traversing threshold.
In the event that it is determined that the layer resource reaches the traversal threshold, the window system is notified to traverse window objects in the system to determine whether an irregular application exists.
In the case where it is determined that the layer resource does not reach the traversal threshold, step S104 is performed to create the layer resource.
Also, in the case where it is determined that the layer resource does not reach the traversal threshold, step S106 may be performed.
As another embodiment of the application, the step of judging whether the nonstandard application exists by the window system can be executed in a preset time period, and the step of executing the application in an asynchronous task mode is not exemplified.
As another embodiment of the present application, referring to fig. 15, a flowchart of a method for managing layer resources in a manner of providing asynchronous tasks in an embodiment of the present application is shown. The embodiment shown in fig. 15 differs from the embodiment shown in fig. 10 in that: asynchronous tasks differ.
In the embodiment shown in fig. 15, the asynchronous task is:
step S701, traversing window objects in the system to obtain the number of window objects of each application.
Step S702, determining whether the number of window objects of each application is smaller than the application threshold.
In the case where the number of application window objects is greater than or equal to the application threshold, step S703 is performed.
Step S703, forcibly stopping or recording the unnormalized application (application in which the number of application window objects is greater than or equal to the application threshold).
In practical applications, the execution module (window system) of the asynchronous task may trigger other modules in the operating system to implement forced stopping of the non-canonical application. After step S703, the asynchronous task ends.
And ending the asynchronous task under the condition that the number of window objects of each application is smaller than an application threshold value.
Of course, in practical applications, the steps (step S701 to step S703) in the asynchronous task may also be performed periodically. As an example, steps S701 to S703 may be performed every interval of a preset period.
In the above embodiment, the number of window objects created by the statistical application may also be window objects of the type of window object 1 corresponding to the Activity, or window objects of the type of window object 2 corresponding to the window. Of course, it is also possible to: a window object of a window object 1 type corresponding to the Activity and a window object of a window object 2 type corresponding to the window.
In practical application, the window object corresponding to the window may obtain the application identifier, or may simply count the window object corresponding to the window created by each application, so as to compare with a preset threshold.
Or after the window system creates the window object, adding a window attribute in the window object, judging the type of the currently created window object, if the window object is the window object corresponding to the window, updating the window attribute in the window object corresponding to the window as an application identifier, and traversing the window object corresponding to the activity upwards to add the application identifier in the window object corresponding to the newly created window into the window attribute of the window object corresponding to the corresponding parent node activity. In this way, application identifications can be added to the window objects, and the number of window objects of each application can be determined when traversing the window objects. Specific embodiments may refer to the description of adding the application identifier in the layer resource shown in fig. 11, which is not described herein.
Similarly, the window object for each application represents a window object that triggers creation when the application pulls up the interface. The window object triggered and created when the application pulls up the interface can comprise a window object corresponding to the Activity or a window object corresponding to the window. Therefore, when traversing window objects in the system, it is necessary to determine the application to which each window object belongs, and then the window object is created when which application pulls up the interface, and then which application the window object belongs to.
As previously described, after an unnormalized application may be determined from a layer resource or window object, the unnormalized application may need to be recorded. To stop the non-canonical application after it switches to the background.
In a specific implementation, a stop application list may be set, where an application (specifically, a process ID of the application may be stored) that determines that the layer resource is greater than the application threshold a or that the window object is greater than the application threshold B is stored in the stop application list.
When the WMS in the system receives the interface switching instruction, the stopping application list can be queried to determine whether the application in the stopping application list runs in the background, and if the application in the stopping application list has the background application, the ATMS can be informed to stop the application of the switching background. Of course, in stopping a certain application in the stopped application list, an application that has been stopped may be deleted from the stopped application list.
In the above embodiment, the frame buffer type layer in the system may be traversed to obtain the number of frame buffer type layers created by each application; the container type layers in the system can be traversed to obtain the number of the container type layers created by each application; the container type layer and the frame buffer type layer in the system can be traversed to obtain the sum of the numbers of the container type layer and the frame buffer type layer created by each application; the objects traversed may differ, and the thresholds at which non-canonical applications are determined may differ.
As an example, the threshold value of determining nonstandard application may be denoted as a second threshold value when traversing the layer resources. If the container type layer is traversed, the second threshold may be a first value, if the frame buffer type layer is traversed, the second threshold may be recorded as a second value, and if the container type layer and the frame buffer type layer are traversed, the second threshold may be a third value. I.e. the second threshold value comprises a first value, a second value and a third value.
Similarly, the window objects in the system can be traversed to obtain the number of window objects created by each application. The corresponding thresholds may also be different when traversing different types of window objects to determine non-canonical applications.
As an example, a window object may be traversed, a threshold value of determining an nonstandard application may be recorded as a first threshold value, if the window object corresponding to the Activity is traversed, the first threshold value is a fourth value, if the window object corresponding to the window is traversed, the first threshold value is a fifth value, and if the window object corresponding to the Activity and the window object corresponding to the window are traversed, the first threshold value is a sixth value.
Of course, all window objects may be traversed, and the corresponding threshold may be noted as a second threshold. The thresholds corresponding to different window objects are not exemplified one by one.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
The embodiments of the present application also provide a computer readable storage medium storing a computer program, where the computer program can implement the steps in the above-mentioned method embodiments when executed by a processor.
The present application also provides a computer program product enabling a first device to carry out the steps of the method embodiments described above when the computer program product is run on the first device.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, where the computer program, when executed by a processor, may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, executable files or in some intermediate form, etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a first device, a recording medium, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The embodiments of the present application also provide a chip system, where the chip system includes a processor, the processor is coupled to a memory, and the processor executes a computer program stored in the memory to implement the steps of any of the method embodiments of the present application. The chip system can be a single chip or a chip module composed of a plurality of chips.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the elements and method steps of the examples described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (14)

1. A method for processing a layer, comprising:
detecting that a first application applies for creating a layer resource, wherein the layer resource comprises: a container type layer or a framebuffer type layer;
searching whether a second application with the number of window objects created by the application being greater than or equal to a first threshold exists;
and if the second application with the number of window objects created by the application being greater than or equal to the first threshold value is found, killing the process of the second application, wherein the container type layer and the frame buffer type layer of the second application are released in response to the process of killing the second application.
2. The method of claim 1, wherein after detecting that the first application applies to create a layer resource, the method further comprises:
searching whether a second application with the number of the container type layers and/or the frame buffer type layers which are created by the application being greater than or equal to a second threshold value exists;
and if the second application with the number of the container type layers and/or the frame buffer type layers created by the application is found to be greater than or equal to the second threshold value, killing the process of the second application.
3. The method of claim 1 or 2, wherein prior to finding whether there is a second application for which the number of window objects created by the application is greater than or equal to the first threshold, the method further comprises:
Traversing the applications corresponding to the window objects in the system respectively to obtain the number of the window objects created by each application.
4. The method of claim 3, wherein prior to traversing the application to which the window objects in the system respectively correspond, the method further comprises:
determining that the sum of the numbers of the container type layers and the frame buffer type layers in the system is greater than or equal to a third threshold, wherein the third threshold is smaller than the maximum upper limit of the sum of the numbers of the container type layers and the frame buffer type layers allowed by the system.
5. The method of claim 4, wherein the method further comprises:
determining that a sum of the number of container type layers and the frame buffer type layers in the system is less than the third threshold;
and creating the layer resource created by the first application.
6. The method according to any one of claims 1 to 5, wherein if a second application, in which the number of window objects created by the presence application is greater than or equal to a first threshold, is found, killing a process of the second application, includes:
if a second application with the number of window objects created by the application being greater than or equal to the first threshold value is found, recording the identification of the second application;
When interface switching is detected, checking whether the second application runs in the background or not based on the recorded identifier of the second application;
and if the second application runs in the background, killing the process of the second application running in the background.
7. The method of claim 4, wherein after determining that the sum of the number of container type layers and the frame buffer type layers in the system is greater than or equal to a third threshold, the method comprises:
judging whether the sum of the number of the container type layers and the frame buffer type layers in the system is smaller than the maximum upper limit;
if the sum of the number of the container type layers and the number of the frame buffer type layers in the system is not smaller than the maximum upper limit, sending out information of creation failure;
and if the sum of the number of the container type layers and the number of the frame buffer type layers in the system is smaller than the maximum upper limit, creating the layer resource created by the first application.
8. The method of claim 5 or 7, wherein each of the container type layer and the frame buffer type layer includes a layer attribute, and wherein after the creating the layer resource created by the first application, the method further comprises:
Judging whether the currently created layer resource is a frame buffer type layer or not;
if the frame buffer type layer is the frame buffer type layer, setting the layer attribute of the created frame buffer type layer as the process ID of the first application;
and setting the layer attribute of the container type layer as the layer attribute of the created frame buffer type layer based on the upward traversal of the created frame buffer type layer.
9. The method of any one of claims 1 to 7, further comprising:
determining whether the sum of the numbers of the container type layers and the frame buffer type layers in a system is greater than or equal to a third threshold value in a preset time period, wherein the third threshold value is smaller than the maximum upper limit of the sum of the numbers of the container type layers and the frame buffer type layers allowed by the system;
if the sum of the numbers of the container type layers and the frame buffer type layers in the system is greater than or equal to the third threshold value, traversing the applications respectively corresponding to the window objects in the system to obtain the number of the window objects created by each application;
searching whether a second application with the number of the window objects created by the application being greater than or equal to the first threshold exists;
And if the second application with the number of the window objects created by the application being greater than or equal to the first threshold value is found, killing the process of the second application.
10. The method of any one of claims 1 to 7, further comprising:
creating a window object, wherein the window object comprises window attributes;
judging whether the currently created window object is a window object corresponding to the window;
if the currently created window object is the window object corresponding to the window, setting the window attribute of the created window object as the process ID of the current application;
and setting the window attribute of the window object corresponding to the activity as the window attribute of the window object currently created based on upward traversal of the window object currently created.
11. The method of claim 3, wherein the number of window objects created by each application is obtained by traversing the applications respectively corresponding to the window objects in the system through a window system in the system.
12. The method of claim 2, wherein the number of layer resources created by each application is obtained by traversing the applications respectively corresponding to the layer resources in the system through a surface system in the system.
13. An electronic device comprising a processor for executing a computer program stored in a memory to cause the electronic device to implement the method of any one of claims 1 to 12.
14. A computer readable storage medium, characterized in that it stores a computer program which, when run on a processor, implements the method according to any of claims 1 to 12.
CN202210707004.8A 2022-06-21 2022-06-21 Layer processing method, electronic equipment and readable storage medium Active CN116048679B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210707004.8A CN116048679B (en) 2022-06-21 2022-06-21 Layer processing method, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210707004.8A CN116048679B (en) 2022-06-21 2022-06-21 Layer processing method, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN116048679A true CN116048679A (en) 2023-05-02
CN116048679B CN116048679B (en) 2023-10-20

Family

ID=86122631

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210707004.8A Active CN116048679B (en) 2022-06-21 2022-06-21 Layer processing method, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN116048679B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107179950A (en) * 2017-06-29 2017-09-19 努比亚技术有限公司 A kind of application process processing method, mobile terminal and computer-readable recording medium
CN107360317A (en) * 2017-06-29 2017-11-17 努比亚技术有限公司 The detection method and mobile terminal, storage medium of application resource leakage
CN114253687A (en) * 2021-12-17 2022-03-29 深圳市中兴移动软件有限公司 Multi-window leakage processing method and device and computer readable storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107179950A (en) * 2017-06-29 2017-09-19 努比亚技术有限公司 A kind of application process processing method, mobile terminal and computer-readable recording medium
CN107360317A (en) * 2017-06-29 2017-11-17 努比亚技术有限公司 The detection method and mobile terminal, storage medium of application resource leakage
CN114253687A (en) * 2021-12-17 2022-03-29 深圳市中兴移动软件有限公司 Multi-window leakage processing method and device and computer readable storage medium

Also Published As

Publication number Publication date
CN116048679B (en) 2023-10-20

Similar Documents

Publication Publication Date Title
US20220159453A1 (en) Method for Using Remote SIM Module and Electronic Device
US20220358089A1 (en) Learning-Based Keyword Search Method and Electronic Device
CN116126201B (en) Application starting method, electronic device and readable storage medium
CN108322602B (en) Method, terminal and computer readable storage medium for processing application no response
CN111262870B (en) Video call switching method and device, storage medium and terminal
CN116048679B (en) Layer processing method, electronic equipment and readable storage medium
CN109889660B (en) Temporary information recording method, storage medium and mobile terminal
CN108900696B (en) Data processing method, terminal and computer readable storage medium
CN108028810A (en) Establish the method and device of service connection
CN116049820A (en) Rogue application detection method, electronic equipment and communication system
CN110278402B (en) Dual-channel audio processing method and device and computer readable storage medium
CN109799994B (en) Terminal component generation method and device
CN114265662B (en) Information recommendation method, electronic device and readable storage medium
US20230350848A1 (en) File Application Method and Apparatus
CN113039524A (en) Audio resource processing method and device, computer readable storage medium and electronic equipment
CN115437783B (en) Searching and killing method, electronic equipment and readable storage medium
CN115543470B (en) Application starting method, electronic device and readable storage medium
CN115562742B (en) Application starting method, electronic device and readable storage medium
EP4276622A1 (en) Task scheduling method, electronic device, chip system, and storage medium
CN116708659B (en) Electronic equipment and call processing method thereof
CN110162349B (en) Method, terminal and storage medium for accelerating starting of desktop starter
CN114879873A (en) Application program control method, intelligent terminal and storage medium
CN117130826A (en) Data backup method, electronic equipment, data backup system and storage medium
CN113114846A (en) Processing method, mobile terminal and storage medium
CN113805767A (en) Information processing method, mobile terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant