WO2022127632A1 - Resource management and control method, and device - Google Patents

Resource management and control method, and device Download PDF

Info

Publication number
WO2022127632A1
WO2022127632A1 PCT/CN2021/135662 CN2021135662W WO2022127632A1 WO 2022127632 A1 WO2022127632 A1 WO 2022127632A1 CN 2021135662 W CN2021135662 W CN 2021135662W WO 2022127632 A1 WO2022127632 A1 WO 2022127632A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
electronic device
foreground
resource management
resources
Prior art date
Application number
PCT/CN2021/135662
Other languages
French (fr)
Chinese (zh)
Inventor
赵凡凡
黄文�
赵京
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2022127632A1 publication Critical patent/WO2022127632A1/en

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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • 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/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Definitions

  • the embodiments of the present application relate to the field of electronic technologies, and in particular, to a resource management and control method and device.
  • the mobile operating system provides a method for resource limitation on the process of the application.
  • the process of an application running in the background is usually reduced its priority to limit the use of its resources, so as to provide more resources for the process of the application running in the foreground, and improve the operation efficiency of the foreground application.
  • the process of the foreground application is usually not controlled.
  • the embodiments of the present application provide a resource management and control method and device, which can perform fine-grained management and control of resource usage according to process types in foreground applications, and can reduce unnecessary system overhead and reduce the cost of electronic devices while ensuring services. Power consumption, while ensuring the experience of foreground process resource usage.
  • an embodiment of the present application provides a resource management and control method, which is applied to an electronic device and includes: determining a first application program in a foreground running state. A first process of the first application is determined, wherein the first process is a non-critical process. Get the first number of times the first process was called by other processes. When the first number of times is less than or less than or equal to the first threshold, perform resource management and control on the first process.
  • the electronic device can perform fine-grained control on the resource usage of the process according to the process type in the foreground application, thereby reducing unnecessary system overhead while ensuring services, and ensuring the experience of using resources of the foreground process.
  • the first number of times the first process is called by other processes may be the first number of times the first process is called by other processes within the first time after the first application switches to the foreground running state and starts counting the first times. ; or the first process counts the first number of times it is called by other processes within the first time since its creation. Wherein, the first time is greater than or equal to the first time threshold.
  • acquiring the first number of times that the first process is called by other processes includes: the electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
  • the electronic device can identify and record the number of times the first process is called by other processes in the kernel Binder driver, so that the process can be managed and controlled subsequently according to the number of times of being called.
  • the first process is a non-critical process, including: the first process is a non-foreground business process of the first application, or the first process is an imperceptible process of the first application, or the first process It is an imperceptible process in the non-foreground business process of the first application.
  • the non-foreground business process is a process that does not run UI components and will not be called by the foreground UI thread
  • an imperceptible process is a process that does not include target features.
  • the target features are preset, or the features obtained by electronic equipment training.
  • the management and control of the imperceptible process in the non-foreground service process can reduce the resource consumption of the first application and the power consumption of the electronic device without affecting the user experience.
  • Resource management and control for non-foreground business processes and imperceptible processes can further reduce resource consumption and power consumption, and at the same time, try to make the functions and services of the first application run normally, and try not to affect the user experience.
  • the target features include periodic Alarm heartbeats, integration of third-party push service SDKs, network permissions, long TCP connections, and periodic sending and receiving of data packets. , one or more of notification bar, sound, and vibration; or, when the imperceptible process is an alarm clock process, the target features include setting a periodic Alarm clock timer, sound, vibration, daily One or more items that are started at least once and automatically start to the foreground; or, when the imperceptible process is an upload and download process, the target features include network permissions, TCP long connections, data packet sending and receiving, and resident notification bar , one or more of input and output operations; or, when the imperceptible process is an audio playback process, the target features include continuous sound playback, network, resident notification bar, and input and output operations.
  • the target characteristics include one or more of GPS request, intermittent sound, network, resident notification bar, integrated map SDK; or , when the imperceptible process is a recording process, the target feature includes one or more of audio input, resident notification bar, and input and output operations.
  • determining the first application program in the foreground running state includes: the touch focus of the application UI layer presented by the display screen of the electronic device changes, and the application of the layer where the current focus is located is obtained as the visible application. program, if the interface component of the application is in the running state, determine that the application is the first application in the foreground running state; or when the electronic device is unlocked, obtain the currently visible application, if the interface component of the application is running state, it is determined that the application is the first application in the foreground running state.
  • performing resource management and control on the first process includes: restricting the use of resources by the first process, thereby reducing resource consumption of the first application and power consumption of the electronic device.
  • the resources include: location positioning resources, network resources, Bluetooth resources, transmission control protocol TCP connection resources, audio resources, modem resources, timed alarm clock resources, wake-up lock resources, broadcast resources, and delay processing resource, or one or more of the service resources.
  • the method further includes: stopping resource management and control on the first process to avoid affecting the user experience.
  • stopping the resource management and control of the first process includes: when the first application is a non-instant messaging application, when it is detected that the first process receives a broadcast, receives a broadcast ANR, and a service ANR occurs, When one or more of the input ANR and the Binder call occur, stop the resource management and control of the first process; or, when the first application is an instant messaging application, when it is detected that the first process receives a message from the network side When the data packet is received, stop the resource management and control of the first process.
  • embodiments of the present application provide an electronic device, including: a screen for displaying an interface; one or more processors; and a memory, where codes are stored in the memory.
  • the electronic device When the code is executed by the electronic device, the electronic device is caused to perform the following steps: determining the first application program in the foreground running state. A first process of the first application is determined, wherein the first process is a non-critical process. Get the first number of times the first process was called by other processes. When the first number of times is less than or less than or equal to the first threshold, perform resource management and control on the first process.
  • the first number of times the first process is called by other processes may be the first number of times the first process is called by other processes within the first time after the first application switches to the foreground running state and starts counting the first times. ; or the first process counts the first number of times it is called by other processes within the first time since its creation. Wherein, the first time is greater than or equal to the first time threshold.
  • acquiring the first number of times that the first process is called by other processes includes: the electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
  • the first process is a non-critical process, including: the first process is a non-foreground business process of the first application, or the first process is an imperceptible process of the first application, or the first process It is an imperceptible process in the non-foreground business process of the first application.
  • the non-foreground business process is a process that does not run UI components and will not be called by the foreground UI thread
  • an imperceptible process is a process that does not include target features.
  • the target feature is preset, or the feature obtained by the training of the electronic device.
  • the target features include periodic Alarm heartbeats, integration of third-party push service SDKs, network permissions, long TCP connections, and periodic sending and receiving of data packets. , one or more of notification bar, sound, and vibration; or, when the imperceptible process is an alarm clock process, the target features include setting a periodic Alarm clock timer, sound, vibration, daily One or more items that are started at least once and automatically start to the foreground; or, when the imperceptible process is an upload and download process, the target features include network permissions, TCP long connections, data packet sending and receiving, and resident notification bar , one or more of input and output operations; or, when the imperceptible process is an audio playback process, the target features include continuous sound playback, network, resident notification bar, and input and output operations.
  • the target characteristics include one or more of GPS request, intermittent sound, network, resident notification bar, integrated map SDK; or , when the imperceptible process is a recording process, the target feature includes one or more of audio input, resident notification bar, and input and output operations.
  • determining the first application program in the foreground running state includes: the application UI layer presented by the display screen of the electronic device changes the touch focus, and obtaining the application of the layer where the current focus is located as the visible application program, if the interface component of the application is in the running state, determine that the application is the first application in the foreground running state; or when the electronic device is unlocked, obtain the currently visible application, if the interface component of the application is running state, it is determined that the application is the first application in the foreground running state.
  • performing resource management and control on the first process includes: restricting the use of resources by the first process, thereby reducing resource consumption of the first application and power consumption of the electronic device.
  • the resources include: location positioning resources, network resources, Bluetooth resources, transmission control protocol TCP connection resources, audio resources, modem resources, timed alarm clock resources, wake-up lock resources, broadcast resources, and delay processing resource, or one or more of the service resources.
  • the method further includes: stopping resource management and control on the first process to avoid affecting the user experience.
  • stopping the resource management and control of the first process includes: when the first application is a non-instant messaging application, when it is detected that the first process receives a broadcast, receives a broadcast ANR, and a service ANR occurs, When one or more of the input ANR and the Binder call occur, stop the resource management and control of the first process; or, when the first application is an instant messaging application, when it is detected that the first process receives a message from the network side When the data packet is received, stop the resource management and control of the first process.
  • an embodiment of the present application provides a resource management and control apparatus, and the apparatus is included in an electronic device.
  • the apparatus has the function of implementing the behavior of the electronic device in any of the above aspects and possible designs. This function can be implemented by hardware or by executing corresponding software by hardware.
  • the hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, detecting modules/units, determining modules/units, and managing and controlling modules/units, etc.
  • an embodiment of the present application provides a computer storage medium, including computer instructions, which, when the computer instructions are executed on an electronic device, enable the electronic device to execute the resource management and control method in any possible design of the foregoing aspects.
  • embodiments of the present application provide a computer program product, which, when the computer program product runs on a computer, enables the computer to execute the resource management and control method in any of the possible designs of the foregoing aspects.
  • FIG. 1 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a software structure of an electronic device provided by an embodiment of the present application.
  • FIG. 3 is a flowchart of a resource management and control method provided by an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a group of interfaces provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of determining a perceptible process and an imperceptible process according to process characteristics according to an embodiment of the present application
  • Fig. 6 is the principle schematic diagram of inter-process communication of Android operating system
  • Fig. 7 is a schematic diagram of an inter-process calling relationship of an application
  • FIG. 8 is a schematic diagram of the mutual calling relationship between the processes of two application programs.
  • first and second are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implying the number of indicated technical features.
  • a feature defined as “first”, “second” may expressly or implicitly include one or more of that feature.
  • plural means two or more.
  • Electronic device a device that can install various application programs and can display objects provided in the installed application programs.
  • the electronic device may include a device capable of implementing data processing functions (such as a processor or an image processor or other processors), and a device capable of displaying a user interface (such as a display screen).
  • the electronic device can be mobile or fixed.
  • electronic devices may include cell phones, foldable electronic devices, tablet computers, desktop computers, laptop computers, handheld computers, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, cell phones, Personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, intelligent At least one of home equipment and smart city equipment.
  • the embodiments of the present application do not specifically limit the specific type of the electronic device.
  • OS Operating system
  • OS It is the most basic system software running on electronic devices, such as system, android system, system. Taking a smartphone as an example, the operating system may be an Android system or an IOS system. The embodiments of the present application mainly take the Android system as an example for introduction. Those skilled in the art can understand that in other operating systems, similar algorithms can also be used for implementation.
  • Application can be referred to as an application, which is a computer program that can perform one or more specific functions. It may have a visual display interface and can interact with users, such as settings, electronic maps, browsers, etc.; or, it may not have a visual display interface and cannot interact with users.
  • applications can be divided into third-party applications and system applications, where a third-party application can be understood as an application installed by a user, such as even me etc.; system applications can be understood as applications preset by the operating system, such as settings, dialing, and information.
  • a process is a running activity of a program in a computer on a certain data set, and is the basic unit of resource allocation and scheduling in the system.
  • An application can create multiple processes during running, and each process can apply for resources according to its own business needs.
  • An application can create multiple processes during running, and each process can apply for resources according to its own business needs.
  • the resources requested by the process of the application program may include hardware resources and software resources.
  • the hardware resources may include location positioning resources, network resources, Bluetooth (bluetooth, BT) resources, transmission control protocol TCP connection resources, audio resources or modem resources, and the like.
  • the location positioning resources may include global positioning system (GPS) resources, global navigation satellite system (GLONASS) resources, Beidou navigation satellite system (BDS) resources, quasi-sky Quasi-zenith satellite system (QZSS) resources and/or satellite-based augmentation systems (satellite based augmentation systems, SBAS) resources, etc.
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-sky Quasi-zenith satellite system
  • SBAS satellite-based augmentation systems
  • Network resources refer to resources that can be used for Internet access, such as operator mobile data service (2G/3G/4G/5G) resources or wireless fidelity (wireless fidelity, Wi-Fi) resources.
  • a TCP connection can exchange information through a socket link.
  • Audio resources are used to implement audio playback, such as speaker resources or audio codec resources.
  • the software resources may include a timed alarm (Alarm) resource, a wakelock (Wakelock) resource, a broadcast resource, a delayed processing (Job) resource or a service (Service) resource, and the like.
  • the Alarm resource can be used for system-level prompting according to the set time or period.
  • the Wakelock resource can be used to prevent the processor from sleeping.
  • Broadcast resources can be used for information transfer between different applications or different components.
  • a Job resource is a resource in a library that can perform delayed processing in the background.
  • a Service resource is an application component that can perform long-running operations in the background without a user interface.
  • the embodiment of the present application provides a resource management and control method, which can be applied to any electronic device installed with an application program.
  • the electronic device can precisely control the resource usage of the process according to the process type in the foreground application. For some processes in the foreground application, control the use of their resources, reduce unnecessary system overhead and ensure the resource usage experience of other processes in the foreground while ensuring the business.
  • FIG. 1 is a schematic structural diagram of an electronic device 100 .
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone connector 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on.
  • SIM Subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
  • the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different 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, for example, 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), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processor
  • ISP image signal processor
  • controller video codec
  • digital signal processor digital signal processor
  • baseband processor baseband processor
  • neural-network processing unit neural-network processing unit
  • the processor 110 may generate an operation control signal according to the instruction operation code and the timing signal, and complete the control of fetching and executing the instruction.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in the processor 110 may be a cache memory.
  • the memory may store instructions or data that are used by the processor 110 or are frequently used. If the processor 110 needs to use the instructions or data, it can be called directly from this memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
  • the processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc.
  • the processor 110 may be connected to modules such as a touch sensor, an audio module, a wireless communication module, a display, a camera, and the like through at least one of the above interfaces.
  • the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 .
  • the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
  • the USB connector 130 is a connector that conforms to the USB standard specification, and can be used to connect the electronic device 100 and peripheral devices, specifically a Mini USB connector, a Micro USB connector, a USB Type C connector, and the like.
  • the USB connector 130 can be used to connect to a charger, so that the charger can charge the electronic device 100, and can also be used to connect to other electronic devices, so as to transmit data between the electronic device 100 and other electronic devices. It can also be used to connect headphones to output audio stored in electronic devices through the headphones.
  • This connector can also be used to connect other electronic devices, such as VR devices, etc.
  • the standard specification of USB may be USB1.x, USB2.0, USB3.x, or USB4.
  • the charging management module 140 is used for receiving charging input from the charger.
  • the charger may be a wireless charger or a wired charger.
  • the charging management module 140 may receive charging input from the wired charger through the USB connector 130 .
  • the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , the electronic device 100 can also be powered by the power management module 141 .
  • the power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 .
  • the power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the like.
  • the power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance).
  • the power management module 141 may also be provided in the processor 110 .
  • the power management module 141 and the charging management module 140 may also be provided 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, the modulation and demodulation processor, the baseband processor, and the like.
  • Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals.
  • Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization.
  • the antenna 1 can be multiplexed as a diversity antenna of the 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 wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 .
  • the mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like.
  • the mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation.
  • the mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 .
  • at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
  • the modem processor may include a modulator and a demodulator.
  • the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal.
  • the demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
  • the low frequency baseband signal is processed by the baseband processor and passed to the application processor.
  • the application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 .
  • the modem processor may be a stand-alone device.
  • the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
  • the wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), bluetooth low power power consumption (bluetooth low energy, BLE), ultra wide band (UWB), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions.
  • the wireless communication module 160 may be one or more devices integrating at least one communication processing module.
  • the wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 .
  • the wireless communication module 160 can also receive the signal to be sent from the processor 110, perform frequency modulation on it, amplify it, and convert it into an electromagnetic wave for radiation through the antenna 2.
  • the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other electronic devices through wireless communication technology.
  • the wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technology, etc.
  • the GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi- zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
  • GPS global positioning system
  • GLONASS global navigation satellite system
  • BDS Beidou navigation satellite system
  • QZSS quasi-zenith satellite system
  • SBAS satellite based augmentation systems
  • the electronic device 100 may implement a display function 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 screen 194 and the application processor.
  • the GPU is used to perform mathematical and geometric calculations and graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
  • Display screen 194 is used to display images, videos, and the like.
  • Display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light).
  • LED diode AMOLED
  • flexible light-emitting diode flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on.
  • electronic device 100 may include one or more display screens 194 .
  • the electronic device 100 may implement a camera function through a camera module 193, an ISP, a video codec, a GPU, a display screen 194, an application processor AP, a neural network processor NPU, and the like.
  • the camera module 193 can be used to collect color image data and depth data of the photographed object.
  • the ISP can be used to process the color image data collected by the camera module 193 .
  • the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin tone. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be provided in the camera module 193 .
  • the camera module 193 may be composed of a color camera module and a 3D sensing module.
  • the photosensitive element of the camera of the color camera module may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
  • CCD charge coupled device
  • CMOS complementary metal-oxide-semiconductor
  • the photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal.
  • the ISP outputs the digital image signal to the DSP for processing.
  • DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
  • the 3D sensing module may be a time of flight (TOF) 3D sensing module or a structured light (structured light) 3D sensing module.
  • the structured light 3D sensing is an active depth sensing technology, and the basic components of the structured light 3D sensing module may include an infrared (Infrared) emitter, an IR camera module, and the like.
  • the working principle of the structured light 3D sensing module is to first emit a light spot of a specific pattern on the object to be photographed, and then receive the light coding of the light spot pattern on the surface of the object, and then compare the similarities and differences with the original projected light spot. And use the principle of trigonometry to calculate the three-dimensional coordinates of the object.
  • the three-dimensional coordinates include the distance between the electronic device 100 and the object to be photographed.
  • the TOF 3D sensing can be an active depth sensing technology, and the basic components of the TOF 3D sensing module can include an infrared (Infrared) transmitter, an IR camera module, and the like.
  • the working principle of the TOF 3D sensing module is to calculate the distance (ie depth) between the TOF 3D sensing module and the object to be photographed through the time of infrared reentry, so as to obtain a 3D depth-of-field map.
  • Structured light 3D sensing modules can also be used in face recognition, somatosensory game consoles, industrial machine vision detection and other fields.
  • TOF 3D sensing modules can also be applied to game consoles, augmented reality (AR)/virtual reality (VR) and other fields.
  • AR augmented reality
  • VR virtual reality
  • the camera module 193 may also be composed of two or more cameras.
  • the two or more cameras may include color cameras, and the color cameras may be used to collect color image data of the photographed object.
  • the two or more cameras may use stereo vision technology to collect depth data of the photographed object.
  • Stereoscopic vision technology is based on the principle of human eye parallax. Under natural light sources, two or more cameras shoot images of the same object from different angles, and then perform triangulation and other operations to obtain the electronic device 100 and the photographed object. distance information between objects, that is, depth information.
  • the electronic device 100 may include one or more camera modules 193 .
  • the electronic device 100 may include a front camera module 193 and a rear camera module 193 .
  • the front camera module 193 can usually be used to collect the color image data and depth data of the photographer facing the display screen 194, and the rear camera module can be used to collect the shooting objects (such as people, landscapes, etc.) that the photographer faces. etc.) color image data and depth data.
  • a digital signal processor can be used to process digital signals as well as other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG Moving Picture Experts Group
  • MPEG2 moving picture experts group
  • MPEG3 MPEG4
  • MPEG4 Moving Picture Experts Group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 .
  • the external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card. Or transfer music, video and other files from electronic devices to external memory cards.
  • Internal memory 121 may be used to store computer executable program code, which includes instructions.
  • the internal memory 121 may include a storage program area and a storage data area.
  • the storage program area can store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), and the like.
  • the storage data area may store data (such as audio data, phone book, etc.) created during the use of the electronic device 100 and the like.
  • the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like.
  • the processor 110 executes various functional methods or data processing of the electronic device 100 by executing the instructions stored in the internal memory 121 and/or the instructions stored in the memory provided in the processor.
  • the electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone connector 170D, an application processor, and the like. Such as music playback, recording, etc.
  • the audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
  • Speaker 170A also referred to as a "speaker" is used to convert audio electrical signals into sound signals.
  • the electronic device 100 may listen to music through the speaker 170A, or output an audio signal for a hands-free call.
  • the receiver 170B also referred to as "earpiece" is used to convert audio electrical signals into sound signals.
  • the voice can be answered by placing the receiver 170B close to the human ear.
  • the microphone 170C also called “microphone” or “microphone” is used to convert sound signals into electrical signals.
  • the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into 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, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
  • the earphone connector 170D is used to connect wired earphones.
  • the earphone connector 170D may be a USB connector 130, or a 3.5mm connector that conforms to the Open Mobile Terminal Platform (OMTP) standard, and conforms to the cellular telecommunications industry association of the USA (CTIA) Standard connector.
  • OMTP Open Mobile Terminal Platform
  • CTIA cellular telecommunications industry association of the USA
  • the keys 190 may include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key.
  • the electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
  • Motor 191 can generate vibrating cues.
  • the motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback.
  • touch operations acting on different applications can correspond to different vibration feedback effects.
  • the motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 .
  • Different application scenarios for example: time reminder, receiving information, alarm clock, games, etc.
  • the touch vibration feedback effect can also support customization.
  • the indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
  • the SIM card interface 195 may be a hardware module for connecting a SIM card.
  • the SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 .
  • the electronic device 100 may support one or more SIM card interfaces.
  • the SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. Multiple cards can be of the same type or different.
  • the SIM card interface 195 can also be compatible with different types of SIM cards.
  • the SIM card interface 195 is also compatible with external memory cards.
  • the electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication.
  • the electronic device 100 employs an eSIM, ie: an embedded SIM card.
  • the eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
  • the processor 110 may execute the instructions stored in the internal memory 121 to perform fine-grained control over resource usage according to the process type in the foreground application.
  • the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead and ensure the use of resources in the foreground process under the condition of ensuring services. experience.
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture.
  • the embodiments of the present application take an Android system with a layered architecture as an example to exemplarily describe the software structure of the electronic device 100 .
  • FIG. 2 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces.
  • the Android system is divided into five layers, from top to bottom, the application layer, the application framework layer, the Android runtime (ART) and native C/C++ libraries, the hardware abstraction layer and the kernel Floor.
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, weather, browser, etc.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer can include window managers, content providers, view systems, resource managers, notification managers, activity managers, input managers, and so on.
  • the window manager provides window management services (window manager service, WMS), WMS can be used for window management, window animation management, surface management and as a transfer station for the input system.
  • WMS window manager service
  • Content providers are used to store and retrieve data and make these data accessible to applications. This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc. Content providers provide support for data access between applications.
  • the view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications.
  • a display interface can consist of one or more views.
  • the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
  • the resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
  • the notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc.
  • the notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
  • the activity manager can provide activity management services (activity manager service, AMS).
  • AMS activity management services
  • the activity manager is used to manage activities, and is responsible for the startup, switching, scheduling of various components in the system, and the management and scheduling of applications.
  • the input manager can provide an input manager service (IMS), and the IMS can be used to manage the input of the system, such as touch screen input, key input, sensor input, and the like.
  • IMS fetches events from input device nodes, and distributes events to appropriate windows through interaction with WMS.
  • the Android runtime includes the core library and the Android runtime.
  • the Android runtime is responsible for converting source code to bytecode, converting bytecode to machine code, and running the machine code.
  • the Android runtime supports ahead or time (AOT) compilation technology and just in time (JIT) compilation technology, in which AOT converts bytecode into machine code during application installation and stores it in On-memory; the JIT converts a portion of the bytecode to machine code in real-time while the application is running.
  • AOT ahead or time
  • JIT just in time
  • the core library is mainly used to provide the functions of basic Java class libraries, such as basic data structures, mathematics, IO, tools, databases, networks and other libraries.
  • the core library provides an API for users to develop Android applications.
  • a native C/C++ library can include multiple functional modules. For example: surface manager, media framework, libc, OpenGL ES, SQLite, Webkit, etc. Among them, the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
  • the media framework supports playback and recording of many common audio and video formats, as well as still image files.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • libc provides a library of standard C functions.
  • OpenGL ES provides the drawing and manipulation of 2D graphics and 3D graphics in applications.
  • SQLite provides a lightweight relational database for applications.
  • Webkit provides browser kernel support.
  • the modules in the application framework layer are written in the Java language, and the modules in the native C/C++ library are written in the C/C++ language, and the communication between the two can be realized through the Java native interface (JNI).
  • JNI Java native interface
  • the hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer, which can include a display module, a camera module, an audio module, and a Bluetooth module.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least display driver, camera driver, audio driver, sensor driver, Binder driver, etc.
  • the kernel layer also supports functions such as memory management, system process management, file system management, and power management.
  • the user performs an input operation on the electronic device 100 (such as an operation that triggers the electronic device to display an application), and the kernel layer can generate a corresponding input event (such as a folding screen unfolding event) according to the input operation, and report the event to the application framework layer. event.
  • the window properties of the application are set by the activity management server AMS of the application framework layer.
  • the window management server WMS of the application framework layer draws the window according to the settings of the AMS, and then sends the window data to the display driver of the kernel layer, and the display driver displays the corresponding application interface on the folding screen.
  • the properties of the window may include the position and size of the Activity window, and the visible properties of the Activity window (ie, the state of the Activity window).
  • the position of the Activity window is the position of the Activity window on the display screen, and the size of the Activity window may be information such as width and height in the application startup config.
  • the visible property of the Activity window can be true or false. When the visible property of the Activity window is true, it means that the Activity window is in an active state, and the Activity window is visible to the user, that is, the display driver will display the content of the Activity window. When the visible attribute of the Activity of the Activity window is false, it means that the Activity window is in the pause state, and the Activity window is invisible to the user, that is, the display driver will not display the content of the Activity window.
  • the application can call the start Activity interface to start the corresponding Activity.
  • the activity manager AMS may request the window manager WMS to draw a window corresponding to the Activity, and invoke the display driver to display the interface.
  • the resource manager in the application framework layer can perform fine-grained control over resource usage for the processes in the foreground application. Therefore, compared with allowing each process in the foreground application to normally use each resource, the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead and reduce the power consumption of the electronic device.
  • the method may include:
  • S301 Detect a first application program in a foreground running state.
  • the running state of the application in the operating system can be divided into a foreground running state and a background running state.
  • an application running in the foreground is also called a foreground application
  • an application running in the background is also called a background application.
  • the foreground running state can be that the application program runs directly on the display window or interface of the display screen, showing the current interface of the program running, or the user of the electronic device (that is, the user) interacts with the application through the interface displayed by the application program.
  • the foreground running state can also be that an application applies for a new Activity (startActivity) through the activity manager AMS, or the Activity in the Paused state re-enters the active state.
  • the display screen In the background running state, the display screen does not present the running interface of the application, but the application continues to provide services in the background.
  • the application can switch from the background running state to the foreground running state at any time, or from the foreground running state to the background running state; for applications without a visual display interface, its Can be in the background running state, but cannot switch to the foreground running state.
  • the electronic device 100 after the electronic device 100 detects the first operation instructing the user to open the first application, the electronic device 100 runs the first application in the foreground.
  • the first application program may be a system application program or a third-party application program, which is not limited in this embodiment of the present application.
  • the user may instruct the electronic device 100 to open the first application by clicking on the icon of the first application, a voice command, or a gesture in various manners.
  • the electronic device 100 detects the first operation of the user clicking the browser icon 401, and in response to the first operation, the electronic device 100 100 Starts the browser application in the foreground.
  • the interface of the browser is displayed on the screen, and the application browser is in the foreground running state at this time.
  • one or more applications may run simultaneously on the electronic device 100, including applications running in the foreground and applications running in the background, and there may be various implementations for determining whether a system application is running in the foreground.
  • the Android operating system will call methods such as onResume to make the Activity of the first application program in a running state.
  • Acticity is a component used to control the display interface, which can provide users with an interface for interacting with the system, and each application has one or more Acticities.
  • the Activity includes: running the Resumed state, pausing the Paused state and stopping the Stopped state; and then, if the Activity of the first application program is in the Resumed state, It means that the first application is in the foreground running state, and if the Activity of the first application is in the Paused state, it means that the first application is running in the background.
  • the Activity includes: a Resumed state and a Stopped state; further, if the Activity of the first application program is in the Resumed state, it means that the first The application is running in the background. In this way, it can be determined whether the application is in the foreground running state according to the state of the Activity of the system application.
  • the application of the currently focused layer can be acquired with a delay of 100ms as the currently visible first application. If the first application If the interface component of the program is in the running state, it means that the first application is in the foreground running state, and the first application is set to the foreground flag; otherwise, the first application is set to the background flag.
  • the currently visible first application can be obtained immediately. If the interface component of the first application is in the running state, it means that the first application is in the foreground running state, and the first application is in the foreground running state. The application sets the foreground flag, otherwise, the first application sets the background flag.
  • the Android operating system if the currently visible Activity of the first application is in the Resumed state, it means that the first application is in the foreground running state.
  • step S302 For the first application program determined in step S301, identify the non-critical process of the first application program.
  • the electronic device 100 may identify the non-critical process in the first application program according to the type of business performed by the process.
  • the electronic device 100 usually creates multiple business processes for it, so as to execute different services to realize corresponding functions.
  • the electronic device 100 may create one or more of the browser main process, the web browsing process, and the download service process; for another example, when the foreground application is a navigation application, The electronic device 100 may create one or more of a navigation application main process, a map navigation process, and a message push process.
  • each business process in the foreground application can apply for resources, and the resources may include software resources and/or hardware resources, so as to support the normal operation of various functional services of the foreground application.
  • the business types can be divided into foreground business and non-foreground business, where the foreground business can be the business that the user directly interacts with, and the non-foreground business can be the one that the user does not directly interact with.
  • Interactive business Exemplarily, taking the browser as the first application running in the foreground as an example, see (b) in FIG. 4 , when the user uses the browser to browse the webpage, the webpage browsing process belongs to the foreground business process.
  • the process is a non-foreground business process of the first application.
  • the Android operating system if a certain process does not run the UI component, it may be that the process does not run the Activity.
  • each application running in the foreground corresponds to a user interface (UI), and the UI thread is created when the application is started, and is mainly used to control the display, update and control interaction of the UI interface.
  • UI user interface
  • the electronic device 100 may learn and identify whether the process is a non-critical process according to the characteristics of the process.
  • the cloud server may learn and identify whether the process is a non-critical process according to the characteristics of the process, and the electronic device 100 may obtain the identification result of the process from the cloud server.
  • the electronic device 100 can obtain the types of various business processes.
  • the business process may include a perceptible process and an imperceptible process, and the like.
  • a perceptible process can be a running business process that the user can hear, see, or touch, such as a message receiving/sending process, an alarm clock process, an upload/download process, an audio playback process, or a navigation process. Not limited to this. Although the perceptible process has entered the background, it can still be perceived by the user that the business is running.
  • the imperceptible process may be a running business process that cannot be perceived by the user.
  • the electronic device 100 may learn and identify whether a process is a perceptible process or an imperceptible process according to the characteristics of the process.
  • the cloud server may learn and identify whether the process is a perceptible process or an imperceptible process according to the characteristics of the process, and the electronic device 100 may obtain the identification result of the process from the cloud server.
  • the electronic device 100 may determine that these processes are user-perceivable processes.
  • the electronic device 100 may collect heartbeats, network data packets by process, record notifications, vibrations, or collect other related information of the process.
  • the electronic device 100 identifies whether the process characteristics shown in Table 1 are met according to the relevant information; if so, the electronic device 100 determines that the process is a perceptible process; if not, the electronic device 100 determines that the process is an imperceptible process.
  • having network authority means that the process has the authority to use network resources and can use network resources normally.
  • the electronic device 100 can collect heartbeats, network data packets, record notifications, vibrations, or other related information of the process according to the process, and upload it to the cloud server.
  • the cloud server identifies whether the process characteristics shown in Table 1 are met according to the relevant information of the process; if so, the cloud server determines that the process is a perceptible process; if not, the cloud server determines that the process is an imperceptible process.
  • the cloud server returns the identification result of the process to the electronic device 100 .
  • whether the electronic device 100 or the cloud service determines whether the process is a perceptible process or an imperceptible process according to the process characteristics can be performed after the first application enters the foreground running state; Save the training result of process identification and save it in the list of perceptible and non-perceptible processes. Perceived and imperceptible processes can also be preset.
  • the non-critical process of the first application may be a non-foreground business process of the first application, or may be an imperceptible process of the first application.
  • the non-critical process of the first application may be an imperceptible process in the non-foreground business process of the first application.
  • the electronic device 100 retains the perceptible process in it, and performs resource management and control on the non-perceived process in it, which can not affect the foreground service and user experience on the basis of , reduce the power consumption of electronic equipment.
  • step S303 After determining the non-critical process of the first application, the electronic device 100 performs step S303 on the non-critical process determined in step S302.
  • a one-way process can be a process that is not called by any other process.
  • step S302 starting from the switching of the first application to the foreground running state, statistics on all processes on the electronic device 100 being invoked and/or invocation relationships are performed, and the invocation of the non-critical process determined in step S302 is obtained after a period of time after the statistics are started. As a result, a one-way process within it is identified.
  • the non-critical processes determined in step S302 may be created from the time of creation, and the calling and/or calling relationships of all processes on the electronic device 100 may be counted, and the imperceptible processes determined in step S303 may be obtained after starting statistics for a period of time The result of the call to identify the one-way process.
  • the calling relationship between all processes running on the electronic device 100 can be identified in the kernel Binder driver.
  • other methods may also be used to identify the logical relationship of calls between processes, which is not limited in this application.
  • FIG. 6 is a schematic diagram of the principle of inter-process communication of the Android operating system.
  • Each Android operating system process can only run in the virtual address space owned by its own process.
  • the virtual address space includes user space and kernel space independent of each other. For user space, different processes cannot share with each other, but the kernel space between different processes can be shared.
  • Each communication between the two different processes is implemented through the Binder driver located in the kernel space.
  • the Binder mechanism adopts the client-server (Client-Server) communication mode, the application process acts as the client, the designated program acts as the server, and the two communicate through the Binder driver.
  • the client needs to transfer a piece of memory data to the server.
  • the general method is that the client copies this piece of data from the client's process space to the kernel space, and then the kernel copies this piece of data from the kernel space to the kernel space.
  • the process space on the server side so the server side can access this piece of data, but this method performs two memory copy operations.
  • the Binder mechanism only needs to copy the data of the client process space to the kernel space once, and then the server side shares this data with the kernel. The whole process only needs to perform a memory copy operation, which improves the operation efficiency.
  • the client process and the server process can be any two processes, either an application or a service.
  • it can be a communication between an application and an application, or between an application and a service. Communication.
  • the processes running in the system can communicate through the Binder mechanism. Inter-process calls are done through Binder shared memory.
  • the calling relationship between all processes can be identified in the kernel Binder driver, and the logical relationship between the calls can be recorded. / or the specific case of the call.
  • FIG. 7 shows a schematic diagram of an inter-process calling relationship of an application.
  • the main process A of the first application program derives three service sub-processes A1 , A2 and A3 .
  • the child process A1 For the child process A1, it is called by the main process A and the child process A3, and calls the main process A at the same time, so the child process A1 has a two-way calling dependency.
  • the child process A2 For the child process A2, it calls the main process A and the child process A3, but is not called by any other process, so the child process A2 is a one-way process.
  • the child process A3 it is called by the child process A2, and calls the main process A and the child process A1 at the same time, so the child process A3 has a two-way calling dependency.
  • FIG. 8 shows a schematic diagram of the mutual calling relationship between the processes of two application programs.
  • the main process A of the first application program derives three service sub-processes A1 , A2 and A3
  • the main process B of the second application program derives three service sub-processes B1 , B2 and B3 .
  • the child process A1 it is called by the main process A, the child process A3, and the child process B3, and calls the main process A at the same time, so the child process A1 has a two-way calling dependency.
  • the child process A2 calls the main process A and the child process A3, but is not called by any process, so the child process A2 is a one-way process.
  • the child process A3 For the child process A3, it is called by the child process A2 and the child process B2, and calls the main process A and the child process A1 at the same time, so the child process A3 has a two-way calling dependency.
  • the child process B1 For the child process B1, it is called by the main process B, the child process B2, and the child process B3, and calls the main process B at the same time, so the child process B1 has a two-way calling dependency.
  • the child process B2 it calls the child process B1, the child process B3 and the child process A3, but is not called by any other process, so the child process B2 is a one-way process.
  • the child process B3 For the child process B3, it is called by the child process B2, and calls the child process A1 and the child process B1 at the same time, so the child process B3 has a two-way calling dependency.
  • S304 For the application in the foreground running state, perform resource management and control on the one-way process determined in S304.
  • the electronic device 100 can perform resource management and control on the one-way process A2 and the one-way process B2.
  • the manner in which the electronic device 100 performs resource management and control on the process may specifically include: suspending the Alarm heartbeat by process; disconnecting the TCP connection by process; restricting network permissions by process; caching or discarding broadcasts by process; pausing GNSS by process Use of resources such as /Wakelock/Job/broadcast, etc.
  • suspending the Alarm heartbeat by process refers to stopping the current process based on the Alarm's heartbeat packet.
  • the TCP connection exchanges information through the Socket link.
  • the TCP connection is disconnected by process, that is, the Socket link corresponding to the TCP connection of the current process is disconnected.
  • Restricting network permissions by process means restricting the current process from using network resources.
  • Pausing resources such as GNSS/Wakelock/Job/broadcast by process means that the current process is prohibited from using resources such as GNSS/Wakelock/Job/broadcast.
  • suspending the broadcast resources by process includes caching or discarding the broadcast content of the current non-critical process.
  • performing resource management on a process can restrict the process from using one or more resources.
  • the electronic device 100 may restrict the process to use the socket link and network resources, but allow the process to use the Alarm resource normally.
  • the manner in which the electronic device 100 performs resource management and control on the process may also be other manners, which are not limited in this application.
  • performing resource management and control on the one-way process determined in step S304 can reduce the system overhead and ensure the resource usage experience of the foreground business process under the condition that the foreground business process is not affected.
  • step S304 for the application in the foreground running state, among the non-critical processes determined in step S302, the process that has been called a few times, or the process that has not been called for a long time, or satisfies
  • the process of the preset calling scene is used for resource management and control, which can further reduce the system overhead, and at the same time ensure that the foreground business process is not affected as much as possible.
  • the method may further include:
  • step S305 Stop performing resource management and control on the one-way process determined in step S304.
  • the resource management and control of the process is stopped immediately.
  • step S304 when it is detected that the one-way process determined in step S304 receives a data packet from the network side, the resource management and control of the process is stopped.
  • the manner in which the electronic device 100 stops performing resource management and control on the one-way process may also be other manners, which are not limited in this application.
  • the process can use various resources normally, so as to ensure that the application currently in the foreground running state normally provides services.
  • the resource method provided by the present application can precisely manage and control the resource usage of its non-foreground business process from the perspective of the process.
  • the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead under the condition of ensuring services, thereby ensuring the foreground application.
  • an embodiment of the present application also provides an electronic device, including a detection unit, a determination unit, and a management and control unit, each of which can cooperate with each other to enable the electronic device to execute the steps in the foregoing embodiments to implement the foregoing resource management and control method.
  • Embodiments of the present application also provide an electronic device, including one or more processors; a memory; and one or more computer programs.
  • One or more computer programs are stored in the memory, the one or more computer programs including instructions.
  • the electronic device is caused to execute the relevant steps in the foregoing embodiments, so as to implement the foregoing resource management and control method.
  • the present application provides a computer program product containing instructions, when the computer program product runs on an electronic device (eg, the electronic device 100 described above), the electronic device executes the above-mentioned relevant steps, so as to realize the resource management and control method in the above-mentioned embodiment. .
  • the present application provides a computer-readable storage medium, where computer instructions are stored in the computer storage medium, and when the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned relevant steps, so as to realize the resource management and control method in the above-mentioned embodiment. .
  • the electronic devices, computer program products, or computer-readable storage media provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, for the beneficial effects that can be achieved, reference may be made to the corresponding methods provided above. The beneficial effects of the method are not repeated here.
  • the embodiments of the present application may be implemented in hardware, or in a manner of hardware and software.
  • the above-described functions can be stored in a computer-readable medium.
  • the medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage medium includes: flash memory, removable hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Multimedia (AREA)
  • Telephone Function (AREA)

Abstract

A resource management and control method, and a device, which relate to the technical field of electronics. Fine-grained management and control are performed on the resource use of a process according to a process type in a foreground application, such that unnecessary system overheads can be reduced while a service is ensured, and the resource use experience of a foreground service process is ensured. The specific solution is: determining a first application program to be in a foreground running state; determining a first process of the first application program, wherein the first process is a non-critical process; acquiring a first number of times of the first process being called by other processes; and when the first number of times is less than, or less than or equal to a first threshold value, performing resource management and control on the first process. The method is used for resource management and control.

Description

一种资源管控方法及设备A resource management and control method and device
本申请要求于2020年12月14日提交国家知识产权局、申请号为202011464555.3、申请名称为“一种资源管控方法及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application with an application number of 202011464555.3 and an application title of "A Resource Management and Control Method and Equipment", which was submitted to the State Intellectual Property Office on December 14, 2020, the entire contents of which are incorporated herein by reference. middle.
技术领域technical field
本申请实施例涉及电子技术领域,尤其涉及一种资源管控方法及设备。The embodiments of the present application relate to the field of electronic technologies, and in particular, to a resource management and control method and device.
背景技术Background technique
随着移动通信技术的发展,移动操作系统中都提供了对应用的进程进行资源限制的方法。传统的操作系统中,通常是对后台运行的应用的进程降低其优先级,来对其资源使用加以限制,以提供更多的资源给前台运行的应用的进程使用,提高前台应用的操作效率。然而,对前台应用的进程通常不会进行管控。With the development of the mobile communication technology, the mobile operating system provides a method for resource limitation on the process of the application. In a traditional operating system, the process of an application running in the background is usually reduced its priority to limit the use of its resources, so as to provide more resources for the process of the application running in the foreground, and improve the operation efficiency of the foreground application. However, the process of the foreground application is usually not controlled.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供一种资源管控方法及设备,能够根据前台应用程序中的进程类型对资源使用进行细粒度的管控,可以在保证业务的情况下,减少不必要的系统开销,降低电子设备的功耗,同时保证前台进程资源使用体验。The embodiments of the present application provide a resource management and control method and device, which can perform fine-grained management and control of resource usage according to process types in foreground applications, and can reduce unnecessary system overhead and reduce the cost of electronic devices while ensuring services. Power consumption, while ensuring the experience of foreground process resource usage.
为达到上述目的,本申请实施例采用如下技术方案:In order to achieve the above purpose, the embodiment of the present application adopts the following technical solutions:
第一方面,本申请实施例提供了一种资源管控方法,应用于电子设备,包括:确定处于前台运行状态的第一应用程序。确定第一应用程序的第一进程,其中,第一进程为非关键进程。获取第一进程被其他进程调用的第一次数。当第一次数小于或小于等于第一阈值时,对第一进程进行资源管控。In a first aspect, an embodiment of the present application provides a resource management and control method, which is applied to an electronic device and includes: determining a first application program in a foreground running state. A first process of the first application is determined, wherein the first process is a non-critical process. Get the first number of times the first process was called by other processes. When the first number of times is less than or less than or equal to the first threshold, perform resource management and control on the first process.
在本申请中,电子设备可以根据前台应用程序中的进程类型对进程的资源使用进行细粒度管控,从而在保证业务的同时减少不必要的系统开销,保证前台进程资源使用体验。In the present application, the electronic device can perform fine-grained control on the resource usage of the process according to the process type in the foreground application, thereby reducing unnecessary system overhead while ensuring services, and ensuring the experience of using resources of the foreground process.
一种可能的实现方式中,第一进程被其他进程调用的第一次数,可以是第一应用程序切换到前台运行状态开始统计第一时间内第一进程被其他进程调用的第一次数;或者第一进程从创建开始统计第一时间内被其他进程调用的第一次数。其中,第一时间大于或大于等于第一时间阈值。In a possible implementation manner, the first number of times the first process is called by other processes may be the first number of times the first process is called by other processes within the first time after the first application switches to the foreground running state and starts counting the first times. ; or the first process counts the first number of times it is called by other processes within the first time since its creation. Wherein, the first time is greater than or equal to the first time threshold.
一种可能的实现方式中,获取第一进程被其他进程调用的第一次数,包括:电子设备在内核Binder驱动中识别第一进程被其他进程调用的第一次数。In a possible implementation manner, acquiring the first number of times that the first process is called by other processes includes: the electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
也就是说,电子设备可以在内核Binder驱动中识别并记录第一进程被其他进程调用的次数,以便后续根据该被调用次数对进程进行管控。That is, the electronic device can identify and record the number of times the first process is called by other processes in the kernel Binder driver, so that the process can be managed and controlled subsequently according to the number of times of being called.
一种可能的实现方式中,第一进程为非关键进程,包括:第一进程为第一应用程序的非前台业务进程,或第一进程为第一应用程序的不可感知进程,或第一进程为第一应用程序的非前台业务进程中的不可感知进程。其中,非前台业务进程是没有运行UI组件,且不会被前台UI线程调用的进程,不可感知进程为不包括目标特征的进程。其中,目标特 征是预设的,或者是电子设备训练获得的特征。In a possible implementation manner, the first process is a non-critical process, including: the first process is a non-foreground business process of the first application, or the first process is an imperceptible process of the first application, or the first process It is an imperceptible process in the non-foreground business process of the first application. Among them, the non-foreground business process is a process that does not run UI components and will not be called by the foreground UI thread, and an imperceptible process is a process that does not include target features. Among them, the target features are preset, or the features obtained by electronic equipment training.
在本实现方式中,对非前台业务进程中的不可感知进程进行管控,可以在不影响用户使用体验的同时,减小第一应用程序的资源消耗和电子设备功耗。对非前台业务进程和不可感知进程进行资源管控,可以进一步减小资源消耗和功耗,同时,尽量使得第一应用程序的功能和服务能够正常运行,尽量不影响用户的使用体验。In this implementation manner, the management and control of the imperceptible process in the non-foreground service process can reduce the resource consumption of the first application and the power consumption of the electronic device without affecting the user experience. Resource management and control for non-foreground business processes and imperceptible processes can further reduce resource consumption and power consumption, and at the same time, try to make the functions and services of the first application run normally, and try not to affect the user experience.
一种可能的实现方式中,当不可感知进程为消息收发类进程时,目标特征包括有周期性的Alarm心跳、集成第三方推送服务SDK、有网络权限、有TCP长连接、周期性收发数据包、有通知栏、有声音、有振动中的一项或多项;或者,当不可感知进程为闹钟类进程时,目标特征包括设置有周期性的Alarm时钟定时器、有声音、有振动、每天至少启动一次且自动启动到前台中的一项或多项;或者,当不可感知进程为上传下载类进程时,目标特征包括有网络权限、有TCP长连接、有数据包收发、常驻通知栏、有输入输出操作中的一项或多项;或者,当不可感知进程为音频播放类进程时,目标特征包括有连续性的声音播放、有网络、常驻通知栏、有输入输出操作中的一项或多项;或者,当不可感知进程为导航类进程时,目标特征包括有GPS请求、有间歇性声音、有网络、常驻通知栏、集成地图SDK中的一项或多项;或者,当不可感知进程为录音类进程时,目标特征包括有音频输入、常驻通知栏、有输入输出操作中的一项或多项。In a possible implementation, when the imperceptible process is a message sending and receiving process, the target features include periodic Alarm heartbeats, integration of third-party push service SDKs, network permissions, long TCP connections, and periodic sending and receiving of data packets. , one or more of notification bar, sound, and vibration; or, when the imperceptible process is an alarm clock process, the target features include setting a periodic Alarm clock timer, sound, vibration, daily One or more items that are started at least once and automatically start to the foreground; or, when the imperceptible process is an upload and download process, the target features include network permissions, TCP long connections, data packet sending and receiving, and resident notification bar , one or more of input and output operations; or, when the imperceptible process is an audio playback process, the target features include continuous sound playback, network, resident notification bar, and input and output operations. One or more; or, when the imperceptible process is a navigation type process, the target characteristics include one or more of GPS request, intermittent sound, network, resident notification bar, integrated map SDK; or , when the imperceptible process is a recording process, the target feature includes one or more of audio input, resident notification bar, and input and output operations.
一种可能的实现方式中,确定处于前台运行状态的第一应用程序,包括:电子设备的显示屏所呈现的应用UI图层发生触摸焦点变化,获取当前焦点所在图层的应用作为可见的应用程序,若该应用程序的界面组件处于运行状态,确定该应用程序为处于前台运行状态的第一应用程序;或电子设备解锁时,获取当前可见的应用程序,若该应用程序的界面组件处于运行状态,确定该应用程序为处于前台运行状态的第一应用程序。In a possible implementation manner, determining the first application program in the foreground running state includes: the touch focus of the application UI layer presented by the display screen of the electronic device changes, and the application of the layer where the current focus is located is obtained as the visible application. program, if the interface component of the application is in the running state, determine that the application is the first application in the foreground running state; or when the electronic device is unlocked, obtain the currently visible application, if the interface component of the application is running state, it is determined that the application is the first application in the foreground running state.
在一种可能的实现方式中,对第一进程进行资源管控包括:限制第一进程使用资源,从而减少第一应用程序的资源消耗和电子设备的功耗。In a possible implementation manner, performing resource management and control on the first process includes: restricting the use of resources by the first process, thereby reducing resource consumption of the first application and power consumption of the electronic device.
在一种可能的实现方式中,该资源包括:位置定位资源,网络资源,蓝牙资源,传输控制协议TCP连接资源,音频资源,调制解调器资源,定时闹钟资源,唤醒锁资源,广播资源,延时处理资源,或服务资源中的一项或多项。In a possible implementation manner, the resources include: location positioning resources, network resources, Bluetooth resources, transmission control protocol TCP connection resources, audio resources, modem resources, timed alarm clock resources, wake-up lock resources, broadcast resources, and delay processing resource, or one or more of the service resources.
在一种可能的实现方式中,电子设备对第一进程进行资源管控之后,还包括:停止对第一进程进行资源管控,避免影响用户的使用体验。In a possible implementation manner, after the electronic device performs resource management and control on the first process, the method further includes: stopping resource management and control on the first process to avoid affecting the user experience.
在一种可能的实现方式中,停止对第一进程进行资源管控,包括:当第一应用程序为非即时消息类应用程序,当检测到第一进程接收广播,接收广播ANR,发生service ANR,发生input ANR以及发生Binder调用中的一项或多项时,停止对第一进程进行资源管控;或者,当第一应用程序为即时消息类应用程序,当检测到第一进程收到来自网络侧的数据包时,停止对第一进程进行资源管控。In a possible implementation manner, stopping the resource management and control of the first process includes: when the first application is a non-instant messaging application, when it is detected that the first process receives a broadcast, receives a broadcast ANR, and a service ANR occurs, When one or more of the input ANR and the Binder call occur, stop the resource management and control of the first process; or, when the first application is an instant messaging application, when it is detected that the first process receives a message from the network side When the data packet is received, stop the resource management and control of the first process.
第二方面,本申请实施例提供了一种电子设备,包括:屏幕,用于显示界面;一个或多个处理器;以及存储器,存储器中存储有代码。当代码被电子设备执行时,使得电子设备执行如下步骤:确定处于前台运行状态的第一应用程序。确定第一应用程序的第一进程,其中,第一进程为非关键进程。获取第一进程被其他进程调用的第一次数。当第一次数小于或小于等于第一阈值时,对第一进程进行资源管控。In a second aspect, embodiments of the present application provide an electronic device, including: a screen for displaying an interface; one or more processors; and a memory, where codes are stored in the memory. When the code is executed by the electronic device, the electronic device is caused to perform the following steps: determining the first application program in the foreground running state. A first process of the first application is determined, wherein the first process is a non-critical process. Get the first number of times the first process was called by other processes. When the first number of times is less than or less than or equal to the first threshold, perform resource management and control on the first process.
一种可能的实现方式中,第一进程被其他进程调用的第一次数,可以是第一应用程序切换到前台运行状态开始统计第一时间内第一进程被其他进程调用的第一次数;或者第一 进程从创建开始统计第一时间内被其他进程调用的第一次数。其中,第一时间大于或大于等于第一时间阈值。In a possible implementation manner, the first number of times the first process is called by other processes may be the first number of times the first process is called by other processes within the first time after the first application switches to the foreground running state and starts counting the first times. ; or the first process counts the first number of times it is called by other processes within the first time since its creation. Wherein, the first time is greater than or equal to the first time threshold.
一种可能的实现方式中,获取第一进程被其他进程调用的第一次数,包括:电子设备在内核Binder驱动中识别第一进程被其他进程调用的第一次数。In a possible implementation manner, acquiring the first number of times that the first process is called by other processes includes: the electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
一种可能的实现方式中,第一进程为非关键进程,包括:第一进程为第一应用程序的非前台业务进程,或第一进程为第一应用程序的不可感知进程,或第一进程为第一应用程序的非前台业务进程中的不可感知进程。其中,非前台业务进程是没有运行UI组件,且不会被前台UI线程调用的进程,不可感知进程为不包括目标特征的进程。其中,目标特征是预设的,或者是电子设备训练获得的特征。In a possible implementation manner, the first process is a non-critical process, including: the first process is a non-foreground business process of the first application, or the first process is an imperceptible process of the first application, or the first process It is an imperceptible process in the non-foreground business process of the first application. Among them, the non-foreground business process is a process that does not run UI components and will not be called by the foreground UI thread, and an imperceptible process is a process that does not include target features. Wherein, the target feature is preset, or the feature obtained by the training of the electronic device.
一种可能的实现方式中,当不可感知进程为消息收发类进程时,目标特征包括有周期性的Alarm心跳、集成第三方推送服务SDK、有网络权限、有TCP长连接、周期性收发数据包、有通知栏、有声音、有振动中的一项或多项;或者,当不可感知进程为闹钟类进程时,目标特征包括设置有周期性的Alarm时钟定时器、有声音、有振动、每天至少启动一次且自动启动到前台中的一项或多项;或者,当不可感知进程为上传下载类进程时,目标特征包括有网络权限、有TCP长连接、有数据包收发、常驻通知栏、有输入输出操作中的一项或多项;或者,当不可感知进程为音频播放类进程时,目标特征包括有连续性的声音播放、有网络、常驻通知栏、有输入输出操作中的一项或多项;或者,当不可感知进程为导航类进程时,目标特征包括有GPS请求、有间歇性声音、有网络、常驻通知栏、集成地图SDK中的一项或多项;或者,当不可感知进程为录音类进程时,目标特征包括有音频输入、常驻通知栏、有输入输出操作中的一项或多项。In a possible implementation, when the imperceptible process is a message sending and receiving process, the target features include periodic Alarm heartbeats, integration of third-party push service SDKs, network permissions, long TCP connections, and periodic sending and receiving of data packets. , one or more of notification bar, sound, and vibration; or, when the imperceptible process is an alarm clock process, the target features include setting a periodic Alarm clock timer, sound, vibration, daily One or more items that are started at least once and automatically start to the foreground; or, when the imperceptible process is an upload and download process, the target features include network permissions, TCP long connections, data packet sending and receiving, and resident notification bar , one or more of input and output operations; or, when the imperceptible process is an audio playback process, the target features include continuous sound playback, network, resident notification bar, and input and output operations. One or more; or, when the imperceptible process is a navigation type process, the target characteristics include one or more of GPS request, intermittent sound, network, resident notification bar, integrated map SDK; or , when the imperceptible process is a recording process, the target feature includes one or more of audio input, resident notification bar, and input and output operations.
一种可能的实现方式中,确定处于前台运行状态的第一应用程序,包括:电子设备的显示屏所呈现的应用UI图层发生触摸焦点变化,获取当前焦点所在图层的应用作为可见的应用程序,若该应用程序的界面组件处于运行状态,确定该应用程序为处于前台运行状态的第一应用程序;或电子设备解锁时,获取当前可见的应用程序,若该应用程序的界面组件处于运行状态,确定该应用程序为处于前台运行状态的第一应用程序。In a possible implementation manner, determining the first application program in the foreground running state includes: the application UI layer presented by the display screen of the electronic device changes the touch focus, and obtaining the application of the layer where the current focus is located as the visible application program, if the interface component of the application is in the running state, determine that the application is the first application in the foreground running state; or when the electronic device is unlocked, obtain the currently visible application, if the interface component of the application is running state, it is determined that the application is the first application in the foreground running state.
在一种可能的实现方式中,对第一进程进行资源管控包括:限制第一进程使用资源,从而减少第一应用程序的资源消耗和电子设备的功耗。In a possible implementation manner, performing resource management and control on the first process includes: restricting the use of resources by the first process, thereby reducing resource consumption of the first application and power consumption of the electronic device.
在一种可能的实现方式中,该资源包括:位置定位资源,网络资源,蓝牙资源,传输控制协议TCP连接资源,音频资源,调制解调器资源,定时闹钟资源,唤醒锁资源,广播资源,延时处理资源,或服务资源中的一项或多项。In a possible implementation manner, the resources include: location positioning resources, network resources, Bluetooth resources, transmission control protocol TCP connection resources, audio resources, modem resources, timed alarm clock resources, wake-up lock resources, broadcast resources, and delay processing resource, or one or more of the service resources.
在一种可能的实现方式中,电子设备对第一进程进行资源管控之后,还包括:停止对第一进程进行资源管控,避免影响用户的使用体验。In a possible implementation manner, after the electronic device performs resource management and control on the first process, the method further includes: stopping resource management and control on the first process to avoid affecting the user experience.
在一种可能的实现方式中,停止对第一进程进行资源管控,包括:当第一应用程序为非即时消息类应用程序,当检测到第一进程接收广播,接收广播ANR,发生service ANR,发生input ANR以及发生Binder调用中的一项或多项时,停止对第一进程进行资源管控;或者,当第一应用程序为即时消息类应用程序,当检测到第一进程收到来自网络侧的数据包时,停止对第一进程进行资源管控。In a possible implementation manner, stopping the resource management and control of the first process includes: when the first application is a non-instant messaging application, when it is detected that the first process receives a broadcast, receives a broadcast ANR, and a service ANR occurs, When one or more of the input ANR and the Binder call occur, stop the resource management and control of the first process; or, when the first application is an instant messaging application, when it is detected that the first process receives a message from the network side When the data packet is received, stop the resource management and control of the first process.
第三方面,本申请实施例提供了一种资源管控装置,该装置包含在电子设备中。该装置具有实现上述方面及可能的设计中任一方法中电子设备行为的功能。该功能可以通过硬件实现,也可以通过硬件执行相应的软件实现。硬件或软件包括至少一个与上述功能相对 应的模块或单元。例如,检测模块/单元,确定模块/单元,以及管控模块/单元等。In a third aspect, an embodiment of the present application provides a resource management and control apparatus, and the apparatus is included in an electronic device. The apparatus has the function of implementing the behavior of the electronic device in any of the above aspects and possible designs. This function can be implemented by hardware or by executing corresponding software by hardware. The hardware or software includes at least one module or unit corresponding to the above-mentioned functions. For example, detecting modules/units, determining modules/units, and managing and controlling modules/units, etc.
第四方面,本申请实施例提供了一种计算机存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行上述方面任一项可能的设计中的资源管控方法。In a fourth aspect, an embodiment of the present application provides a computer storage medium, including computer instructions, which, when the computer instructions are executed on an electronic device, enable the electronic device to execute the resource management and control method in any possible design of the foregoing aspects.
第五方面,本申请实施例提供了一种计算机程序产品,当计算机程序产品在计算机上运行时,使得计算机执行上述方面任一项可能的设计中的资源管控方法。In a fifth aspect, embodiments of the present application provide a computer program product, which, when the computer program product runs on a computer, enables the computer to execute the resource management and control method in any of the possible designs of the foregoing aspects.
上述其他方面对应的有益效果,可以参见关于方法方面关于有益效果的描述,此处不予赘述。For the beneficial effects corresponding to the above-mentioned other aspects, reference may be made to the description of the beneficial effects in the method aspect, which will not be repeated here.
附图说明Description of drawings
图1为本申请实施例提供的一种电子设备的硬件结构示意图;1 is a schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present application;
图2为本申请实施例提供的一种电子设备的软件结构示意图;2 is a schematic diagram of a software structure of an electronic device provided by an embodiment of the present application;
图3为本申请实施例提供的一种资源管控方法流程图;FIG. 3 is a flowchart of a resource management and control method provided by an embodiment of the present application;
图4为本申请实施例提供的一组界面示意图;FIG. 4 is a schematic diagram of a group of interfaces provided by an embodiment of the present application;
图5为本申请实施例提供的一种根据进程特征确定可感知进程和不可感知进程的示意图;FIG. 5 is a schematic diagram of determining a perceptible process and an imperceptible process according to process characteristics according to an embodiment of the present application;
图6是Android操作系统进程间通信的原理示意图;Fig. 6 is the principle schematic diagram of inter-process communication of Android operating system;
图7是一个应用程序的进程间调用关系示意图;Fig. 7 is a schematic diagram of an inter-process calling relationship of an application;
图8是两个应用程序的进程互相调用关系示意图。FIG. 8 is a schematic diagram of the mutual calling relationship between the processes of two application programs.
具体实施方式Detailed ways
下面将结合附图,对本申请中的技术方案进行描述。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。The technical solutions in the present application will be described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all of the embodiments.
其中,在本申请实施例的描述中,除非另有说明,“/”表示或的意思,例如,A/B可以表示A或B;本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,在本申请实施例的描述中,“多个”是指两个或多于两个。Wherein, in the description of the embodiments of the present application, unless otherwise stated, “/” means or means, for example, A/B can mean A or B; “and/or” in this document is only a description of the associated object The association relationship of , indicates that there can be three kinds of relationships, for example, A and/or B, can indicate that A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "plurality" refers to two or more than two.
以下,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本实施例的描述中,除非另有说明,“多个”的含义是两个或两个以上。Hereinafter, the terms "first" and "second" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implying the number of indicated technical features. Thus, a feature defined as "first", "second" may expressly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
首先,对本申请实施例涉及的部分用语进行解释说明。First, some terms involved in the embodiments of the present application are explained.
(1)电子设备:可以为安装各类应用程序,并且能够将已安装的应用程序中提供的对象进行显示的设备。示例性地,该电子设备可以包含能够实现数据处理功能的器件(比如处理器或图像处理器或其他处理器),以及能够显示用户界面的器件(比如显示屏)。该电子设备可以是移动的,也可以是固定的。例如,电子设备可以包括手机、可折叠电子设备、平板电脑、桌面型计算机、膝上型计算机、手持计算机、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、蜂窝电话、个人数字助理(personal digital assistant,PDA)、增强现实(augmented reality,AR)设备、虚拟现实(virtual reality,VR)设备、人工智能(artificial intelligence,AI)设备、可穿戴式设备、车载设备、智能家居设备、智慧城市设备中的至少一种。本申请实施例对电子设备的具体类型不作特殊限制。(1) Electronic device: a device that can install various application programs and can display objects provided in the installed application programs. Illustratively, the electronic device may include a device capable of implementing data processing functions (such as a processor or an image processor or other processors), and a device capable of displaying a user interface (such as a display screen). The electronic device can be mobile or fixed. For example, electronic devices may include cell phones, foldable electronic devices, tablet computers, desktop computers, laptop computers, handheld computers, notebook computers, ultra-mobile personal computers (UMPCs), netbooks, cell phones, Personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, in-vehicle device, intelligent At least one of home equipment and smart city equipment. The embodiments of the present application do not specifically limit the specific type of the electronic device.
(2)操作系统(operating system,OS):是运行在电子设备上的最基本的系统软件,例如
Figure PCTCN2021135662-appb-000001
系统、安卓
Figure PCTCN2021135662-appb-000002
系统、
Figure PCTCN2021135662-appb-000003
系统。以智能手机为例,操作系统可以是Android系统或IOS系统。本申请实施例主要以Android系统为例进行介绍。本领域技术人员可以理解,在其它操作系统中,也可以采用类似的算法实现。
(2) Operating system (OS): It is the most basic system software running on electronic devices, such as
Figure PCTCN2021135662-appb-000001
system, android
Figure PCTCN2021135662-appb-000002
system,
Figure PCTCN2021135662-appb-000003
system. Taking a smartphone as an example, the operating system may be an Android system or an IOS system. The embodiments of the present application mainly take the Android system as an example for introduction. Those skilled in the art can understand that in other operating systems, similar algorithms can also be used for implementation.
(3)应用程序(application,APP):可以简称为应用,是能够完成某项或多项特定功能的计算机程序。它可以具有可视的显示界面,能与用户进行交互,比如设置、电子地图、浏览器等;或者,也可以不具有可视的显示界面,不能与用户进行交互。示例性地,应用可以划分为第三方应用和系统应用,其中,第三方应用可以理解为用户安装的应用,比如
Figure PCTCN2021135662-appb-000004
连我
Figure PCTCN2021135662-appb-000005
等;系统应用可以理解为操作系统预置的应用,比如设置、拨号、信息等。
(3) Application (application, APP): It can be referred to as an application, which is a computer program that can perform one or more specific functions. It may have a visual display interface and can interact with users, such as settings, electronic maps, browsers, etc.; or, it may not have a visual display interface and cannot interact with users. Exemplarily, applications can be divided into third-party applications and system applications, where a third-party application can be understood as an application installed by a user, such as
Figure PCTCN2021135662-appb-000004
even me
Figure PCTCN2021135662-appb-000005
etc.; system applications can be understood as applications preset by the operating system, such as settings, dialing, and information.
(4)进程:进程(process)是计算机中的程序关于某数据集合上的一次运行活动,是系统进行资源分配和调度的基本单位。应用程序在运行过程中可以创建多个进程,每个进程可以根据自身的业务需求申请使用资源。(4) Process: A process is a running activity of a program in a computer on a certain data set, and is the basic unit of resource allocation and scheduling in the system. An application can create multiple processes during running, and each process can apply for resources according to its own business needs.
应用程序在运行过程中可以创建多个进程,每个进程可以根据自身的业务需求申请使用资源。An application can create multiple processes during running, and each process can apply for resources according to its own business needs.
例如,在一种资源划分方式中,应用程序的进程申请使用的资源可以包括硬件资源和软件资源。比如,该硬件资源可以包括位置定位资源,网络资源,蓝牙(bluetooth,BT)资源,传输控制协议TCP连接资源,音频资源或调制解调器Modem资源等。其中,位置定位资源可以包括全球卫星定位系统(global positioning system,GPS)资源,全球导航卫星系统(global navigation satellite system,GLONASS)资源,北斗卫星导航系统(beidou navigation satellite system,BDS)资源,准天顶卫星系统(quasi-zenith satellite system,QZSS)资源和/或星基增强系统(satellite based augmentation systems,SBAS)资源等。网络资源指可以用于上网的资源,例如运营商移动数据业务(2G/3G/4G/5G)资源或无线保真(wireless fidelity,Wi-Fi)资源等。TCP连接可以通过套接字Socket链路进行信息交互。音频资源用于实现音频的播放,例如包括扬声器资源或音频编/解码器资源等。For example, in a resource division method, the resources requested by the process of the application program may include hardware resources and software resources. For example, the hardware resources may include location positioning resources, network resources, Bluetooth (bluetooth, BT) resources, transmission control protocol TCP connection resources, audio resources or modem resources, and the like. The location positioning resources may include global positioning system (GPS) resources, global navigation satellite system (GLONASS) resources, Beidou navigation satellite system (BDS) resources, quasi-sky Quasi-zenith satellite system (QZSS) resources and/or satellite-based augmentation systems (satellite based augmentation systems, SBAS) resources, etc. Network resources refer to resources that can be used for Internet access, such as operator mobile data service (2G/3G/4G/5G) resources or wireless fidelity (wireless fidelity, Wi-Fi) resources. A TCP connection can exchange information through a socket link. Audio resources are used to implement audio playback, such as speaker resources or audio codec resources.
以Android操作系统为例,该软件资源可以包括定时闹钟(Alarm)资源,唤醒锁(Wakelock)资源,广播资源,延时处理(Job)资源或服务(Service)资源等。其中,Alarm资源可以用于根据设定的时间或周期进行系统级的提示。Wakelock资源可以用于阻止处理器休眠。广播资源可以用于在不同应用程序或不同组件之间进行信息传输。Job资源是一个可以在后台进行延时处理的库中的资源。Service资源是一种可以在后台执行长时间运行操作而没有用户界面的应用组件。Taking the Android operating system as an example, the software resources may include a timed alarm (Alarm) resource, a wakelock (Wakelock) resource, a broadcast resource, a delayed processing (Job) resource or a service (Service) resource, and the like. Among them, the Alarm resource can be used for system-level prompting according to the set time or period. The Wakelock resource can be used to prevent the processor from sleeping. Broadcast resources can be used for information transfer between different applications or different components. A Job resource is a resource in a library that can perform delayed processing in the background. A Service resource is an application component that can perform long-running operations in the background without a user interface.
现有技术允许前台应用程序中的每个进程都能正常使用资源,而实际上有些进程的资源并不需要使用,当前台应用衍生多个业务子进程时,会使得电子设备的资源消耗和功耗较大。The existing technology allows each process in the foreground application to use resources normally, but in fact, the resources of some processes do not need to be used. Large consumption.
本申请实施例提供一种资源管控方法,可以应用于任何安装有应用程序的电子设备。电子设备可以根据前台应用程序中的进程类型对进程的资源使用进行精准化管控。对于前台应用程序内的一些进程,对其资源使用进行管控,在保证业务的情况下,减少不必要的系统开销,保证前台其他进程的资源使用体验。The embodiment of the present application provides a resource management and control method, which can be applied to any electronic device installed with an application program. The electronic device can precisely control the resource usage of the process according to the process type in the foreground application. For some processes in the foreground application, control the use of their resources, reduce unnecessary system overhead and ensure the resource usage experience of other processes in the foreground while ensuring the business.
图1示意了一种电子设备100的结构示意图。FIG. 1 is a schematic structural diagram of an electronic device 100 .
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行 总线(universal serial bus,USB)接头130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接头170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) connector 130, a charge management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone connector 170D, sensor module 180, buttons 190, motor 191, indicator 192, camera 193, display screen 194, and Subscriber identification module (subscriber identification module, SIM) card interface 195 and so on. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, and ambient light. Sensor 180L, bone conduction sensor 180M, etc.
可以理解的是,本申请实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。It can be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100 . In other embodiments of the present application, the electronic device 100 may include more or less components than shown, or combine some components, or separate some components, or arrange different components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。The processor 110 may include one or more processing units, for example, 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), controller, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural-network processing unit (neural-network processing unit, NPU), etc. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
处理器110可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。The processor 110 may generate an operation control signal according to the instruction operation code and the timing signal, and complete the control of fetching and executing the instruction.
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器可以为高速缓冲存储器。该存储器可以保存处理器110用过或使用频率较高的指令或数据。如果处理器110需要使用该指令或数据,可从该存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 may be a cache memory. The memory may store instructions or data that are used by the processor 110 or are frequently used. If the processor 110 needs to use the instructions or data, it can be called directly from this memory. Repeated accesses are avoided and the latency of the processor 110 is reduced, thereby increasing the efficiency of the system.
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。处理器110可以通过以上至少一种接口连接触摸传感器、音频模块、无线通信模块、显示器、摄像头等模块。In some embodiments, the processor 110 may include one or more interfaces. The interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transceiver (universal asynchronous transmitter) receiver/transmitter, UART) interface, mobile industry processor interface (MIPI), general-purpose input/output (GPIO) interface, subscriber identity module (SIM) interface, and / or universal serial bus (universal serial bus, USB) interface, etc. The processor 110 may be connected to modules such as a touch sensor, an audio module, a wireless communication module, a display, a camera, and the like through at least one of the above interfaces.
可以理解的是,本申请实施例示意的各模块间的接口连接关系,只是示意性说明,并不构成对电子设备100的结构限定。在本申请另一些实施例中,电子设备100也可以采用上述实施例中不同的接口连接方式,或多种接口连接方式的组合。It can be understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is only a schematic illustration, and does not constitute a structural limitation of the electronic device 100 . In other embodiments of the present application, the electronic device 100 may also adopt different interface connection manners in the foregoing embodiments, or a combination of multiple interface connection manners.
USB接头130是一种符合USB标准规范的连接器,可以用于连接电子设备100和外围设备,具体可以是Mini USB接头,Micro USB接头,USB Type C接头等。USB接头130可以用于连接充电器,实现充电器为该电子设备100充电,也可以用于连接其他电子设备,实现电子设备100与其他电子设备之间传输数据。也可以用于连接耳机,通过耳机输出电子设备中存储的音频。该接头还可以用于连接其他电子设备,例如VR设备等。在一些实 施例中,USB的标准规范可以为USB1.x、USB2.0、USB3.x或USB4。The USB connector 130 is a connector that conforms to the USB standard specification, and can be used to connect the electronic device 100 and peripheral devices, specifically a Mini USB connector, a Micro USB connector, a USB Type C connector, and the like. The USB connector 130 can be used to connect to a charger, so that the charger can charge the electronic device 100, and can also be used to connect to other electronic devices, so as to transmit data between the electronic device 100 and other electronic devices. It can also be used to connect headphones to output audio stored in electronic devices through the headphones. This connector can also be used to connect other electronic devices, such as VR devices, etc. In some embodiments, the standard specification of USB may be USB1.x, USB2.0, USB3.x, or USB4.
充电管理模块140用于接收充电器的充电输入。其中,充电器可以是无线充电器,也可以是有线充电器。在一些有线充电的实施例中,充电管理模块140可以通过USB接头130接收有线充电器的充电输入。在一些无线充电的实施例中,充电管理模块140可以通过电子设备100的无线充电线圈接收无线充电输入。充电管理模块140为电池142充电的同时,还可以通过电源管理模块141为电子设备100供电。The charging management module 140 is used for receiving charging input from the charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from the wired charger through the USB connector 130 . In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100 . While the charging management module 140 charges the battery 142 , the electronic device 100 can also be powered by the power management module 141 .
电源管理模块141用于连接电池142,充电管理模块140与处理器110。电源管理模块141接收电池142和/或充电管理模块140的输入,为处理器110,内部存储器121,显示屏194,摄像头193等供电。电源管理模块141还可以用于监测电池容量,电池循环次数,电池健康状态(漏电,阻抗)等参数。在其他一些实施例中,电源管理模块141也可以设置于处理器110中。在另一些实施例中,电源管理模块141和充电管理模块140也可以设置于同一个器件中。The power management module 141 is used for connecting the battery 142 , the charging management module 140 and the processor 110 . The power management module 141 receives input from the battery 142 and/or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the like. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle times, battery health status (leakage, impedance). In some 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 charging management module 140 may also be provided in the same device.
电子设备100的无线通信功能可以通过天线1,天线2,移动通信模块150,无线通信模块160,调制解调处理器以及基带处理器等实现。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, the modulation and demodulation processor, the baseband processor, and the like.
天线1和天线2用于发射和接收电磁波信号。电子设备100中的每个天线可用于覆盖单个或多个通信频带。不同的天线还可以复用,以提高天线的利用率。例如:可以将天线1复用为无线局域网的分集天线。在另外一些实施例中,天线可以和调谐开关结合使用。Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 may be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, the antenna 1 can be multiplexed as a diversity antenna of the wireless local area network. In other embodiments, the antenna may be used in conjunction with a tuning switch.
移动通信模块150可以提供应用在电子设备100上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块150可以包括至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。移动通信模块150可以由天线1接收电磁波,并对接收的电磁波进行滤波,放大等处理,传送至调制解调处理器进行解调。移动通信模块150还可以对经调制解调处理器调制后的信号放大,经天线1转为电磁波辐射出去。在一些实施例中,移动通信模块150的至少部分功能模块可以被设置于处理器110中。在一些实施例中,移动通信模块150的至少部分功能模块可以与处理器110的至少部分模块被设置在同一个器件中。The mobile communication module 150 may provide wireless communication solutions including 2G/3G/4G/5G etc. applied on the electronic device 100 . The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA) and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and then turn it into an electromagnetic wave for radiation through the antenna 1 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the processor 110 . In some embodiments, at least part of the functional modules of the mobile communication module 150 may be provided in the same device as at least part of the modules of the processor 110 .
调制解调处理器可以包括调制器和解调器。其中,调制器用于将待发送的低频基带信号调制成中高频信号。解调器用于将接收的电磁波信号解调为低频基带信号。随后解调器将解调得到的低频基带信号传送至基带处理器处理。低频基带信号经基带处理器处理后,被传递给应用处理器。应用处理器通过音频设备(不限于扬声器170A,受话器170B等)输出声音信号,或通过显示屏194显示图像或视频。在一些实施例中,调制解调处理器可以是独立的器件。在另一些实施例中,调制解调处理器可以独立于处理器110,与移动通信模块150或其他功能模块设置在同一个器件中。The modem processor may include a modulator and a demodulator. Wherein, the modulator is used to modulate the low frequency baseband signal to be sent into a medium and high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low frequency baseband signal. Then the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low frequency baseband signal is processed by the baseband processor and passed to the application processor. The application processor outputs sound signals through audio devices (not limited to the speaker 170A, the receiver 170B, etc.), or displays images or videos through the display screen 194 . In some embodiments, the modem processor may be a stand-alone device. In other embodiments, the modem processor may be independent of the processor 110, and may be provided in the same device as the mobile communication module 150 or other functional modules.
无线通信模块160可以提供应用在电子设备100上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),蓝牙低功耗(bluetooth low energy,BLE),超宽带(ultra wide band,UWB),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC),红外技术(infrared,IR)等无线通信的解决方案。无线通信模块160可以是集成至少一个通信处理模块的一个或多个器件。无线通信模块160经由天线2接收电磁波,将电磁波信号调频以及滤波处理,将处理后的信号发送到处理器110。无线通信模块160还可以从处理器110接收待发送的信号,对其 进行调频,放大,经天线2转为电磁波辐射出去。The wireless communication module 160 can provide applications on the electronic device 100 including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), bluetooth low power power consumption (bluetooth low energy, BLE), ultra wide band (UWB), global navigation satellite system (global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC), infrared technology (infrared, IR) and other wireless communication solutions. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2 , frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110 . The wireless communication module 160 can also receive the signal to be sent from the processor 110, perform frequency modulation on it, amplify it, and convert it into an electromagnetic wave for radiation through the antenna 2.
在一些实施例中,电子设备100的天线1和移动通信模块150耦合,天线2和无线通信模块160耦合,使得电子设备100可以通过无线通信技术与网络和其他电子设备通信。该无线通信技术可以包括全球移动通讯系统(global system for mobile communications,GSM),通用分组无线服务(general packet radio service,GPRS),码分多址接入(code division multiple access,CDMA),宽带码分多址(wideband code division multiple access,WCDMA),时分码分多址(time-division code division multiple access,TD-SCDMA),长期演进(long term evolution,LTE),BT,GNSS,WLAN,NFC,FM,和/或IR技术等。该GNSS可以包括全球卫星定位系统(global positioning system,GPS),全球导航卫星系统(global navigation satellite system,GLONASS),北斗卫星导航系统(beidou navigation satellite system,BDS),准天顶卫星系统(quasi-zenith satellite system,QZSS)和/或星基增强系统(satellite based augmentation systems,SBAS)。In some embodiments, the antenna 1 of the electronic device 100 is coupled with the mobile communication module 150, and the antenna 2 is coupled with the wireless communication module 160, so that the electronic device 100 can communicate with the network and other electronic devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code Division Multiple Access (WCDMA), Time Division Code Division Multiple Access (TD-SCDMA), Long Term Evolution (LTE), BT, GNSS, WLAN, NFC, FM, and/or IR technology, etc. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (quasi- zenith satellite system, QZSS) and/or satellite based augmentation systems (SBAS).
电子设备100可以通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算以及图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。The electronic device 100 may implement a display function 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 screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or alter display information.
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或多个显示屏194。Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (active-matrix organic light). emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light-emitting diode (quantum dot light emitting diodes, QLED) and so on. In some embodiments, electronic device 100 may include one or more display screens 194 .
电子设备100可以通过摄像模组193,ISP,视频编解码器,GPU,显示屏194以及应用处理器AP、神经网络处理器NPU等实现摄像功能。The electronic device 100 may implement a camera function through a camera module 193, an ISP, a video codec, a GPU, a display screen 194, an application processor AP, a neural network processor NPU, and the like.
摄像模组193可用于采集拍摄对象的彩色图像数据以及深度数据。ISP可用于处理摄像模组193采集的彩色图像数据。例如,拍照时,打开快门,光线通过镜头传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将该电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像模组193中。The camera module 193 can be used to collect color image data and depth data of the photographed object. The ISP can be used to process the color image data collected by the camera module 193 . For example, when taking a picture, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on image noise, brightness, and skin tone. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, the ISP may be provided in the camera module 193 .
在一些实施例中,摄像模组193可以由彩色摄像模组和3D感测模组组成。In some embodiments, the camera module 193 may be composed of a color camera module and a 3D sensing module.
在一些实施例中,彩色摄像模组的摄像头的感光元件可以是电荷耦合器件(charge coupled device,CCD)或互补金属氧化物半导体(complementary metal-oxide-semiconductor,CMOS)光电晶体管。感光元件把光信号转换成电信号,之后将电信号传递给ISP转换成数字图像信号。ISP将数字图像信号输出到DSP加工处理。DSP将数字图像信号转换成标准的RGB,YUV等格式的图像信号。In some embodiments, the photosensitive element of the camera of the color camera module may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. DSP converts digital image signals into standard RGB, YUV and other formats of image signals.
在一些实施例中,3D感测模组可以是(time of flight,TOF)3D感测模块或结构光(structured light)3D感测模块。其中,结构光3D感测是一种主动式深度感测技术,结构光3D感测模组的基本零组件可包括红外线(Infrared)发射器、IR相机模块等。结构光3D感测模组的工作原理是先对被拍摄物体发射特定图案的光斑(pattern),再接收该物体表面上的光斑图案编码(light coding),进而比对与原始投射光斑的异同,并利用三角原理计算出物体的三维坐标。该三维坐标中就包括电子设备100距离被拍摄物体的距离。其中,TOF 3D感测可以是主动式深度感测技术,TOF 3D感测模组的基本组件可包括红外线(Infrared)发射器、IR相机模等。TOF 3D感测模组的工作原理是通过红外线折返的时间去计算TOF3D感测模组跟被拍摄物体之间的距离(即深度),以得到3D景深图。In some embodiments, the 3D sensing module may be a time of flight (TOF) 3D sensing module or a structured light (structured light) 3D sensing module. The structured light 3D sensing is an active depth sensing technology, and the basic components of the structured light 3D sensing module may include an infrared (Infrared) emitter, an IR camera module, and the like. The working principle of the structured light 3D sensing module is to first emit a light spot of a specific pattern on the object to be photographed, and then receive the light coding of the light spot pattern on the surface of the object, and then compare the similarities and differences with the original projected light spot. And use the principle of trigonometry to calculate the three-dimensional coordinates of the object. The three-dimensional coordinates include the distance between the electronic device 100 and the object to be photographed. Among them, the TOF 3D sensing can be an active depth sensing technology, and the basic components of the TOF 3D sensing module can include an infrared (Infrared) transmitter, an IR camera module, and the like. The working principle of the TOF 3D sensing module is to calculate the distance (ie depth) between the TOF 3D sensing module and the object to be photographed through the time of infrared reentry, so as to obtain a 3D depth-of-field map.
结构光3D感测模组还可应用于人脸识别、体感游戏机、工业用机器视觉检测等领域。TOF 3D感测模组还可应用于游戏机、增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR)等领域。Structured light 3D sensing modules can also be used in face recognition, somatosensory game consoles, industrial machine vision detection and other fields. TOF 3D sensing modules can also be applied to game consoles, augmented reality (AR)/virtual reality (VR) and other fields.
在另一些实施例中,摄像模组193还可以由两个或更多个摄像头构成。这两个或更多个摄像头可包括彩色摄像头,彩色摄像头可用于采集被拍摄物体的彩色图像数据。这两个或更多个摄像头可采用立体视觉(stereo vision)技术来采集被拍摄物体的深度数据。立体视觉技术是基于人眼视差的原理,在自然光源下,通过两个或两个以上的摄像头从不同的角度对同一物体拍摄影像,再进行三角测量法等运算来得到电子设备100与被拍摄物之间的距离信息,即深度信息。In other embodiments, the camera module 193 may also be composed of two or more cameras. The two or more cameras may include color cameras, and the color cameras may be used to collect color image data of the photographed object. The two or more cameras may use stereo vision technology to collect depth data of the photographed object. Stereoscopic vision technology is based on the principle of human eye parallax. Under natural light sources, two or more cameras shoot images of the same object from different angles, and then perform triangulation and other operations to obtain the electronic device 100 and the photographed object. distance information between objects, that is, depth information.
在一些实施例中,电子设备100可以包括1个或多个摄像模组193。具体的,电子设备100可以包括1个前置摄像模组193以及1个后置摄像模组193。其中,前置摄像模组193通常可用于采集面对显示屏194的拍摄者自己的彩色图像数据以及深度数据,后置摄像模组可用于采集拍摄者所面对的拍摄对象(如人物、风景等)的彩色图像数据以及深度数据。In some embodiments, the electronic device 100 may include one or more camera modules 193 . Specifically, the electronic device 100 may include a front camera module 193 and a rear camera module 193 . Among them, the front camera module 193 can usually be used to collect the color image data and depth data of the photographer facing the display screen 194, and the rear camera module can be used to collect the shooting objects (such as people, landscapes, etc.) that the photographer faces. etc.) color image data and depth data.
数字信号处理器可以用于处理数字信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。A digital signal processor can be used to process digital signals as well as other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy and so on.
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。Video codecs are used to compress or decompress digital video. The electronic device 100 may support one or more video codecs. In this way, the electronic device 100 can play or record videos of various encoding formats, such as: Moving Picture Experts Group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transfer mode between neurons in the human brain, it can quickly process the input information and can continuously learn by itself. Applications such as intelligent cognition of the electronic device 100 can be implemented through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
外部存储器接口120可以用于连接外部存储卡,例如Micro SD卡,实现扩展电子设备100的存储能力。外部存储卡通过外部存储器接口120与处理器110通信,实现数据存储功能。例如将音乐,视频等文件保存在外部存储卡中。或将音乐,视频等文件从电子设备传输至外部存储卡中。The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 . The external memory card communicates with the processor 110 through the external memory interface 120 to realize the data storage function. For example to save files like music, video etc in external memory card. Or transfer music, video and other files from electronic devices to external memory cards.
内部存储器121可以用于存储计算机可执行程序代码,该可执行程序代码包括指令。内部存储器121可以包括存储程序区和存储数据区。其中,存储程序区可存储操作系统,至少一个功能所需的应用程序(比如声音播放功能,图像播放功能等)等。存储数据区可存储电子设备100使用过程中所创建的数据(比如音频数据,电话本等)等。此外,内部存储器121可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件,闪存器件,通用闪存存储器(universal flash storage,UFS)等。处理器110通过运行存储在内部存储器121的指令,和/或存储在设置于处理器中的存储器的指令,执行电子设备100的各种功能方法或数据处理。Internal memory 121 may be used to store computer executable program code, which includes instructions. The internal memory 121 may include a storage program area and a storage data area. The storage program area can store an operating system, an application program required for at least one function (such as a sound playback function, an image playback function, etc.), and the like. The storage data area may store data (such as audio data, phone book, etc.) created during the use of the electronic device 100 and the like. In addition, the internal memory 121 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, universal flash storage (UFS), and the like. The processor 110 executes various functional methods or data processing of the electronic device 100 by executing the instructions stored in the internal memory 121 and/or the instructions stored in the memory provided in the processor.
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接头170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。The electronic device 100 may implement audio functions through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone connector 170D, an application processor, and the like. Such as music playback, recording, etc.
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。The audio module 170 is used for converting digital audio information into analog audio signal output, and also for converting analog audio input into digital audio signal. Audio module 170 may also be used to encode and decode audio signals. In some embodiments, the audio module 170 may be provided in the processor 110 , or some functional modules of the audio module 170 may be provided in the processor 110 .
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或输出免提通话的音频信号。Speaker 170A, also referred to as a "speaker", is used to convert audio electrical signals into sound signals. The electronic device 100 may listen to music through the speaker 170A, or output an audio signal for a hands-free call.
受话器170B,也称“听筒”,用于将音频电信号转换成声音信号。当电子设备100接听电话或语音信息时,可以通过将受话器170B靠近人耳接听语音。The receiver 170B, also referred to as "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 answers a call or a voice message, the voice can be answered by placing the receiver 170B close to the human ear.
麦克风170C,也称“话筒”,“传声器”,用于将声音信号转换为电信号。当拨打电话或发送语音信息时,用户可以通过人嘴靠近麦克风170C发声,将声音信号输入到麦克风170C。电子设备100可以设置至少一个麦克风170C。在另一些实施例中,电子设备100可以设置两个麦克风170C,除了采集声音信号,还可以实现降噪功能。在另一些实施例中,电子设备100还可以设置三个,四个或更多麦克风170C,实现采集声音信号,降噪,还可以识别声音来源,实现定向录音功能等。The microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can make a sound by approaching the microphone 170C through a human mouth, and input the sound signal into 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, which can implement a noise reduction function in addition to collecting sound signals. In other embodiments, the electronic device 100 may further be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify sound sources, and implement directional recording functions.
耳机接头170D用于连接有线耳机。耳机接头170D可以是USB接头130,也可以是3.5mm的符合开放移动电子设备平台(open mobile terminal platform,OMTP)标准的接头,符合美国蜂窝电信工业协会(cellular telecommunications industry association of the USA,CTIA)标准的接头。The earphone connector 170D is used to connect wired earphones. The earphone connector 170D may be a USB connector 130, or a 3.5mm connector that conforms to the Open Mobile Terminal Platform (OMTP) standard, and conforms to the cellular telecommunications industry association of the USA (CTIA) Standard connector.
按键190可以包括开机键,音量键等。按键190可以是机械按键。也可以是触摸式按键。电子设备100可以接收按键输入,产生与电子设备100的用户设置以及功能控制有关的键信号输入。The keys 190 may include a power-on key, a volume key, and the like. Keys 190 may be mechanical keys. It can also be a touch key. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100 .
马达191可以产生振动提示。马达191可以用于来电振动提示,也可以用于触摸振动反馈。例如,作用于不同应用(例如拍照,音频播放等)的触摸操作,可以对应不同的振动反馈效果。作用于显示屏194不同区域的触摸操作,马达191也可对应不同的振动反馈效果。不同的应用场景(例如:时间提醒,接收信息,闹钟,游戏等)也可以对应不同的振动反馈效果。触摸振动反馈效果还可以支持自定义。Motor 191 can generate vibrating cues. The motor 191 can be used for vibrating alerts for incoming calls, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. The motor 191 can also correspond to different vibration feedback effects for touch operations on different areas of the display screen 194 . Different application scenarios (for example: time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
指示器192可以是指示灯,可以用于指示充电状态,电量变化,也可以用于指示消息,未接来电,通知等。The indicator 192 can be an indicator light, which can be used to indicate the charging state, the change of the power, and can also be used to indicate a message, a missed call, a notification, and the like.
SIM卡接口195可以是硬件模块,用于连接SIM卡。SIM卡可以通过插入SIM卡接口195,或从SIM卡接口195拔出,实现和电子设备100的接触和分离。电子设备100可以支持1个或多个SIM卡接口。SIM卡接口195可以支持Nano SIM卡,Micro SIM卡,SIM卡等。同一个SIM卡接口195可以同时插入多张卡。多张卡的类型可以相同,也可以不同。SIM卡接口195也可以兼容不同类型的SIM卡。SIM卡接口195也可以兼容外部存储卡。电子设备100通过SIM卡和网络交互,实现通话以及数据通信等功能。在一些实施例中,电子设备100采用eSIM,即:嵌入式SIM卡。eSIM卡可以嵌在电子设备100中,不能和电子设备100分离。The SIM card interface 195 may be a hardware module for connecting a SIM card. The SIM card can be contacted and separated from the electronic device 100 by inserting into the SIM card interface 195 or pulling out from the SIM card interface 195 . The electronic device 100 may support one or more SIM card interfaces. The SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card and so on. Multiple cards can be inserted into the same SIM card interface 195 at the same time. Multiple cards can be of the same type or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 is also compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as call and data communication. In some embodiments, the electronic device 100 employs an eSIM, ie: an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100 .
在本申请的实施例中,处理器110可以运行存储在内部存储器121的指令,根据前台应用程序中的进程类型对资源使用进行细粒度的管控。与现有技术中允许前台应用程序内的各进程正常使用各项资源相比,本申请实施例提供的资源管控方法可以在保证业务的情况下,减少不必要的系统开销,保证前台进程资源使用体验。In the embodiment of the present application, the processor 110 may execute the instructions stored in the internal memory 121 to perform fine-grained control over resource usage according to the process type in the foreground application. Compared with the prior art that allows each process in the foreground application to use various resources normally, the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead and ensure the use of resources in the foreground process under the condition of ensuring services. experience.
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本申请实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. The embodiments of the present application take an Android system with a layered architecture as an example to exemplarily describe the software structure of the electronic device 100 .
图2是本发明实施例的电子设备100的软件结构框图。FIG. 2 is a block diagram of a software structure of an electronic device 100 according to an embodiment of the present invention.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为五层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime,ART)和原生C/C++库,硬件抽象层以及内核层。The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, the application layer, the application framework layer, the Android runtime (ART) and native C/C++ libraries, the hardware abstraction layer and the kernel Floor.
应用程序层可以包括一系列应用程序包。The application layer can include a series of application packages.
如图2所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,天气,浏览器等应用程序。As shown in Figure 2, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, weather, browser, etc.
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.
如图2所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,资源管理器,通知管理器,活动管理器,输入管理器等。As shown in Figure 2, the application framework layer can include window managers, content providers, view systems, resource managers, notification managers, activity managers, input managers, and so on.
窗口管理器提供窗口管理服务(window manager service,WMS),WMS可以用于窗口管理、窗口动画管理、surface管理以及作为输入系统的中转站。The window manager provides window management services (window manager service, WMS), WMS can be used for window management, window animation management, surface management and as a transfer station for the input system.
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。该数据可以包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。内容提供器为应用程序间的数据访问提供支持。Content providers are used to store and retrieve data and make these data accessible to applications. This data can include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc. Content providers provide support for data access between applications.
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, and so on. View systems can be used to build applications. A display interface can consist of one or more views. For example, the display interface including the short message notification icon may include a view for displaying text and a view for displaying pictures.
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。The resource manager provides various resources for the application, such as localization strings, icons, pictures, layout files, video files and so on.
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。The notification manager enables applications to display notification information in the status bar, which can be used to convey notification-type messages, and can disappear automatically after a brief pause without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also display notifications in the status bar at the top of the system in the form of graphs or scroll bar text, such as notifications of applications running in the background, and notifications on the screen in the form of dialog windows. For example, text information is prompted in the status bar, a prompt sound is issued, the electronic device vibrates, and the indicator light flashes.
活动管理器可以提供活动管理服务(activity manager service,AMS),活动管理器用于负责管理Activity,负责系统中各组件的启动、切换、调度及应用程序的管理和调度等工作。The activity manager can provide activity management services (activity manager service, AMS). The activity manager is used to manage activities, and is responsible for the startup, switching, scheduling of various components in the system, and the management and scheduling of applications.
输入管理器可以提供输入管理服务(input manager service,IMS),IMS可以用于管理系统的输入,例如触摸屏输入、按键输入、传感器输入等。IMS从输入设备节点取出事件,通过和WMS的交互,将事件分配至合适的窗口。The input manager can provide an input manager service (IMS), and the IMS can be used to manage the input of the system, such as touch screen input, key input, sensor input, and the like. IMS fetches events from input device nodes, and distributes events to appropriate windows through interaction with WMS.
安卓运行时包括核心库和安卓运行时。安卓运行时负责将源代码转换为字节码,将字节码转换为机器码,以及运行机器码。在编译技术上,安卓运行时支持提前(ahead or time,AOT)编译技术和及时(just in time,JIT)编译技术,其中AOT在应用程序安装期间,将字节码转换成机器码并存储在存储器上;JIT在应用程序运行时实时将一部分字节码转换 成机码。The Android runtime includes the core library and the Android runtime. The Android runtime is responsible for converting source code to bytecode, converting bytecode to machine code, and running the machine code. In terms of compilation technology, the Android runtime supports ahead or time (AOT) compilation technology and just in time (JIT) compilation technology, in which AOT converts bytecode into machine code during application installation and stores it in On-memory; the JIT converts a portion of the bytecode to machine code in real-time while the application is running.
核心库主要用于提供基本的Java类库的功能,例如基础数据结构、数学、IO、工具、数据库、网络等库。核心库为用户进行安卓应用开发提供了API。The core library is mainly used to provide the functions of basic Java class libraries, such as basic data structures, mathematics, IO, tools, databases, networks and other libraries. The core library provides an API for users to develop Android applications.
原生C/C++库可以包括多个功能模块。例如:表面管理器(surface manager),媒体框架(media framework),libc,OpenGL ES、SQLite、Webkit等。其中,表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。媒体框架支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。libc提供标准C函数库。OpenGL ES提供应用程序中2D图形和3D图形的绘制和操作。SQLite为应用程序提供轻量级关系型数据库。Webkit提供游览器内核的支持。A native C/C++ library can include multiple functional modules. For example: surface manager, media framework, libc, OpenGL ES, SQLite, Webkit, etc. Among them, the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications. The media framework supports playback and recording of many common audio and video formats, as well as still image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. libc provides a library of standard C functions. OpenGL ES provides the drawing and manipulation of 2D graphics and 3D graphics in applications. SQLite provides a lightweight relational database for applications. Webkit provides browser kernel support.
应用程序框架层中的模块使用Java语言编写,原生C/C++库中的模块使用C/C++语言编写,两者之间的通信可以通过Java本地接口(Java native interface,JNI)实现。The modules in the application framework layer are written in the Java language, and the modules in the native C/C++ library are written in the C/C++ language, and the communication between the two can be realized through the Java native interface (JNI).
硬件抽象层运行于用户空间(user space),对内核层驱动进行封装,向上层提供调用接口,可以包含显示模块、摄像头模块、音频模块、蓝牙模块。The hardware abstraction layer runs in user space, encapsulates the kernel layer driver, and provides a calling interface to the upper layer, which can include a display module, a camera module, an audio module, and a Bluetooth module.
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动,Binder驱动等。内核层在提供硬件驱动外,还支持内存管理、系统进程管理、文件系统管理、电源管理等功能。The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, sensor driver, Binder driver, etc. In addition to providing hardware drivers, the kernel layer also supports functions such as memory management, system process management, file system management, and power management.
其中,用户对电子设备100进行输入操作(如触发电子设备显示某个应用的操作),内核层可以根据输入操作产生相应的输入事件(如折叠屏展开事件),并向应用程序框架层上报该事件。由应用程序框架层的活动管理服务器AMS设置应用的窗口属性。应用程序框架层的窗口管理服务器WMS根据AMS的设置绘制窗口,然后将窗口数据发送给内核层的显示驱动,由显示驱动在折叠屏显示对应的应用界面。The user performs an input operation on the electronic device 100 (such as an operation that triggers the electronic device to display an application), and the kernel layer can generate a corresponding input event (such as a folding screen unfolding event) according to the input operation, and report the event to the application framework layer. event. The window properties of the application are set by the activity management server AMS of the application framework layer. The window management server WMS of the application framework layer draws the window according to the settings of the AMS, and then sends the window data to the display driver of the kernel layer, and the display driver displays the corresponding application interface on the folding screen.
其中,窗口的属性可以包括Activity窗口的位置和大小,以及Activity窗口的可见属性(即Activity窗口的状态)。Activity窗口的位置是该Activity窗口在显示屏的位置、Activity窗口的大小可以是应用启动config中的宽高等信息。Activity窗口的可见属性可以为true或者false。当Activity窗口的可见属性是true时,表示该Activity窗口处于活动状态,该Activity窗口对用户可见,即显示驱动会显示该Activity窗口的内容。当Activity窗口的Activity的可见属性是false时,表示该Activity窗口处于pause状态,该Activity窗口对用户不可见,即显示驱动会不显示该Activity窗口的内容。The properties of the window may include the position and size of the Activity window, and the visible properties of the Activity window (ie, the state of the Activity window). The position of the Activity window is the position of the Activity window on the display screen, and the size of the Activity window may be information such as width and height in the application startup config. The visible property of the Activity window can be true or false. When the visible property of the Activity window is true, it means that the Activity window is in an active state, and the Activity window is visible to the user, that is, the display driver will display the content of the Activity window. When the visible attribute of the Activity of the Activity window is false, it means that the Activity window is in the pause state, and the Activity window is invisible to the user, that is, the display driver will not display the content of the Activity window.
其中,应用可调用启动Activity接口以启动对应的Activity。活动管理器AMS响应于应用的调用,可请求窗口管理器WMS绘制Activity对应的窗口,并调用显示驱动实现界面的显示。Wherein, the application can call the start Activity interface to start the corresponding Activity. In response to the invocation of the application, the activity manager AMS may request the window manager WMS to draw a window corresponding to the Activity, and invoke the display driver to display the interface.
在本申请的实施例中,应用程序框架层中的资源管理器可以针对前台应用程序内的进程,对资源使用进行细粒度的管控。因而,与允许前台应用程序内的各进程正常使用各项资源相比,本申请实施例提供的资源管控方法可以减少不必要的系统开销,降低电子设备的功耗。In the embodiments of the present application, the resource manager in the application framework layer can perform fine-grained control over resource usage for the processes in the foreground application. Therefore, compared with allowing each process in the foreground application to normally use each resource, the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead and reduce the power consumption of the electronic device.
以下将以具有图1和图2所示结构的电子设备100为例,对本申请实施例提供的资源管控方法进行阐述。参见图3,该方法可以包括:The resource management and control method provided by the embodiment of the present application will be described below by taking the electronic device 100 having the structure shown in FIG. 1 and FIG. 2 as an example. Referring to Figure 3, the method may include:
S301:检测处于前台运行状态的第一应用程序。S301: Detect a first application program in a foreground running state.
示例性地,应用程序在操作系统中的运行状态可以分为前台运行状态和后台运行状态。 其中,处于前台运行状态的应用程序又称为前台应用,处于后台运行状态的应用程序又称为后台应用。前台运行状态,可以是应用程序直接在显示屏的显示窗口或界面上运行,呈现出程序运行的当前界面,也可以是电子设备的使用者(即用户)通过应用程序显示的界面与应用进行交互。前台运行状态还可以是一个应用程序通过活动管理器AMS申请一个新的Activity(startActivity),或者是处于Paused状态的Activity重新进入到活动状态。后台运行状态,可以是显示屏不呈现应用的运行界面,但该应用在后台继续提供服务。对于具有可视的显示界面的应用来说,其可以随时从后台运行状态切换成前台运行状态,或者从前台运行状态切换为后台运行状态;对于不具有可视的显示界面的应用来说,其可以处于后台运行状态,而无法切换到前台运行状态。Exemplarily, the running state of the application in the operating system can be divided into a foreground running state and a background running state. Among them, an application running in the foreground is also called a foreground application, and an application running in the background is also called a background application. The foreground running state can be that the application program runs directly on the display window or interface of the display screen, showing the current interface of the program running, or the user of the electronic device (that is, the user) interacts with the application through the interface displayed by the application program. . The foreground running state can also be that an application applies for a new Activity (startActivity) through the activity manager AMS, or the Activity in the Paused state re-enters the active state. In the background running state, the display screen does not present the running interface of the application, but the application continues to provide services in the background. For an application with a visual display interface, it can switch from the background running state to the foreground running state at any time, or from the foreground running state to the background running state; for applications without a visual display interface, its Can be in the background running state, but cannot switch to the foreground running state.
示例性地,电子设备100检测到用户指示打开第一应用程序的第一操作后,在前台运行第一应用程序。Exemplarily, after the electronic device 100 detects the first operation instructing the user to open the first application, the electronic device 100 runs the first application in the foreground.
其中,该第一应用程序可以是系统应用程序,也可以是第三方应用程序,本申请实施例对此不做限定。用户可以通过点击第一应用程序的图标、语音指令或隔空手势等多种方式的操作,指示电子设备100打开第一应用程序。The first application program may be a system application program or a third-party application program, which is not limited in this embodiment of the present application. The user may instruct the electronic device 100 to open the first application by clicking on the icon of the first application, a voice command, or a gesture in various manners.
示例性地,如图4中(a)所示,以第一应用程序为浏览器为例,电子设备100检测到用户点击浏览器图标401的第一操作,响应于该第一操作,电子设备100在前台启动浏览器应用。如图4中(b)所示,电子设备100启动浏览器应用后,在屏幕上显示浏览器的界面,此时应用程序浏览器处于前台运行状态。Exemplarily, as shown in (a) of FIG. 4 , taking the first application as a browser as an example, the electronic device 100 detects the first operation of the user clicking the browser icon 401, and in response to the first operation, the electronic device 100 100 Starts the browser application in the foreground. As shown in (b) of FIG. 4 , after the electronic device 100 starts the browser application, the interface of the browser is displayed on the screen, and the application browser is in the foreground running state at this time.
示例性地,电子设备100上可同时运行一个或多个应用,包括处于前台运行状态的应用和处于后台运行状态的应用,判断系统应用是否处于前台运行状态的实现方式可以有多种。在一种可能的实现方式中,当第一应用程序被打开后,Android操作系统会调用onResume等方法来使第一应用程序的Activity处于运行状态。其中,Acticity是用于控制显示界面的组件,可以为用户提供与系统交互的界面,每一个应用都有一个或者多个Acticity。若第一应用程序具有可视的显示界面,则第一应用程序的Acticity启动后,Activity包括:运行Resumed状态、暂停Paused状态以及停止Stopped状态;进而,如果第一应用程序的Activity处于Resumed状态,则表示第一应用程序处于前台运行状态,而如果第一应用程序的Activity处于Paused状态,则表示第一应用程序处于后台运行状态。若第一应用程序不具有可视的显示界面,则在第一应用程序的Activity启动后,Activity包括:Resumed状态、Stopped状态;进而,如果第一应用程序的Activity处于Resumed状态,则表示第一应用程序处于后台运行状态。如此,可以根据系统应用程序的Activity所处的状态,来判断应用是否处于前台运行状态。Exemplarily, one or more applications may run simultaneously on the electronic device 100, including applications running in the foreground and applications running in the background, and there may be various implementations for determining whether a system application is running in the foreground. In a possible implementation manner, after the first application program is opened, the Android operating system will call methods such as onResume to make the Activity of the first application program in a running state. Among them, Acticity is a component used to control the display interface, which can provide users with an interface for interacting with the system, and each application has one or more Acticities. If the first application program has a visible display interface, after the Activity of the first application program is started, the Activity includes: running the Resumed state, pausing the Paused state and stopping the Stopped state; and then, if the Activity of the first application program is in the Resumed state, It means that the first application is in the foreground running state, and if the Activity of the first application is in the Paused state, it means that the first application is running in the background. If the first application program does not have a visible display interface, after the Activity of the first application program is started, the Activity includes: a Resumed state and a Stopped state; further, if the Activity of the first application program is in the Resumed state, it means that the first The application is running in the background. In this way, it can be determined whether the application is in the foreground running state according to the state of the Activity of the system application.
一些实施例中,当电子设备100显示屏所呈现的应用UI图层发生触摸焦点变化时,可以延时100ms获取获取当前焦点所在图层的应用作为当前可见的第一应用程序,如果第一应用程序的界面组件处于运行状态,则表示第一应用程序处于前台运行状态,将第一应用程序置前台标志位,否则,将第一应用程序置后台标志位。In some embodiments, when the touch focus of the application UI layer displayed on the display screen of the electronic device 100 changes, the application of the currently focused layer can be acquired with a delay of 100ms as the currently visible first application. If the first application If the interface component of the program is in the running state, it means that the first application is in the foreground running state, and the first application is set to the foreground flag; otherwise, the first application is set to the background flag.
另一些实施例中,当电子设备100解锁时,可以立即获取当前可见的第一应用程序,如果第一应用程序的界面组件处于运行状态,则表示第一应用程序处于前台运行状态,将第一应用程序置前台标志位,否则,将第一应用程序置后台标志位。In other embodiments, when the electronic device 100 is unlocked, the currently visible first application can be obtained immediately. If the interface component of the first application is in the running state, it means that the first application is in the foreground running state, and the first application is in the foreground running state. The application sets the foreground flag, otherwise, the first application sets the background flag.
示例性地,在Android操作系统中,如果当前可见的第一应用程序的Activity处于Resumed状态,则表示第一应用程序处于前台运行状态。Exemplarily, in the Android operating system, if the currently visible Activity of the first application is in the Resumed state, it means that the first application is in the foreground running state.
S302:对于步骤S301确定的第一应用程序,识别第一应用程序的非关键进程。S302: For the first application program determined in step S301, identify the non-critical process of the first application program.
一些实施例中,电子设备100可以根据进程执行的业务类型,识别第一应用程序中的非关键进程。In some embodiments, the electronic device 100 may identify the non-critical process in the first application program according to the type of business performed by the process.
对于电子设备100中的某一个或多个应用,电子设备100通常会为其创建多个业务进程,用于执行不同的业务,以实现对应功能。例如,当前台应用程序为浏览器时,电子设备100可以创建浏览器主进程、浏览网页进程,以及下载服务进程等进程中的一个或多个;再例如,当前台应用程序为导航应用时,电子设备100可以创建导航应用主进程、地图导航进程,以及消息推送进程等进程中的一个或多个。For one or more applications in the electronic device 100, the electronic device 100 usually creates multiple business processes for it, so as to execute different services to realize corresponding functions. For example, when the foreground application is a browser, the electronic device 100 may create one or more of the browser main process, the web browsing process, and the download service process; for another example, when the foreground application is a navigation application, The electronic device 100 may create one or more of a navigation application main process, a map navigation process, and a message push process.
其中,前台应用程序中的各个业务进程可以申请资源,该资源可以包括软件资源和/或硬件资源,以支持前台应用程序的各项功能服务能够正常进行。Wherein, each business process in the foreground application can apply for resources, and the resources may include software resources and/or hardware resources, so as to support the normal operation of various functional services of the foreground application.
示例性地,对于处于前台运行状态的应用程序,其业务类型可以分为前台业务和非前台业务,其中,前台业务可以是用户直接与其进行交互的业务,非前台业务可以是用户不直接与其发生交互的业务。示例性地,以处于前台运行状态的第一应用程序为浏览器为例,参见图4中(b),当用户使用浏览器浏览网页时,浏览网页进程属于前台业务进程。Exemplarily, for an application running in the foreground, its business types can be divided into foreground business and non-foreground business, where the foreground business can be the business that the user directly interacts with, and the non-foreground business can be the one that the user does not directly interact with. Interactive business. Exemplarily, taking the browser as the first application running in the foreground as an example, see (b) in FIG. 4 , when the user uses the browser to browse the webpage, the webpage browsing process belongs to the foreground business process.
一些实施例中,对于步骤S301确定的第一应用程序,在第一应用程序处于前台运行状态的生命周期中,当第一应用程序的某一进程没有运行UI组件以及不会被前台UI线程调用时,该进程为第一应用程序的非前台业务进程。具体地,在Android操作系统中,某一进程没有运行UI组件,可以是该进程没有运行Activity。其中,每个处于前台运行状态的应用程序对应一个用户界面(user interface,UI),UI线程是应用程序被启动时创建的,主要是用于负责控制UI界面的显示、更新和控件交互。In some embodiments, for the first application determined in step S301, in the life cycle of the first application in the foreground running state, when a certain process of the first application does not run the UI component and will not be called by the foreground UI thread , the process is a non-foreground business process of the first application. Specifically, in the Android operating system, if a certain process does not run the UI component, it may be that the process does not run the Activity. Among them, each application running in the foreground corresponds to a user interface (UI), and the UI thread is created when the application is started, and is mainly used to control the display, update and control interaction of the UI interface.
另一些实施例中,电子设备100可以根据进程的特征,学习和识别进程是否为非关键进程。或者,云端服务器可以根据进程的特征,学习和识别进程是否为非关键进程,电子设备100可以从云端服务器获取进程的识别结果。In other embodiments, the electronic device 100 may learn and identify whether the process is a non-critical process according to the characteristics of the process. Alternatively, the cloud server may learn and identify whether the process is a non-critical process according to the characteristics of the process, and the electronic device 100 may obtain the identification result of the process from the cloud server.
对于处于前台运行状态的应用程序,电子设备100可以获取其各种业务进程的类型。可选地,业务进程可以包括可感知进程及不可感知进程等。可感知进程可以是用户能听到、看到、触摸到的正在运行的业务进程,例如消息收/发类进程、闹钟类进程、上传/下载类进程、音频播放类进程或导航类进程,但不限于此。虽然可感知进程已经进入到后台运行,但依然可以被用户感知到该业务正在运行。不可感知进程可以是不能被用户感知到正在运行的业务进程。For an application running in the foreground state, the electronic device 100 can obtain the types of various business processes. Optionally, the business process may include a perceptible process and an imperceptible process, and the like. A perceptible process can be a running business process that the user can hear, see, or touch, such as a message receiving/sending process, an alarm clock process, an upload/download process, an audio playback process, or a navigation process. Not limited to this. Although the perceptible process has entered the background, it can still be perceived by the user that the business is running. The imperceptible process may be a running business process that cannot be perceived by the user.
在一些实施例中,电子设备100可以根据进程的特征,学习和识别进程是否为可感知进程或不可感知进程。或者,云端服务器可以根据进程的特征,学习和识别进程是否为可感知进程或不可感知进程,电子设备100可以从云端服务器获取进程的识别结果。In some embodiments, the electronic device 100 may learn and identify whether a process is a perceptible process or an imperceptible process according to the characteristics of the process. Alternatively, the cloud server may learn and identify whether the process is a perceptible process or an imperceptible process according to the characteristics of the process, and the electronic device 100 may obtain the identification result of the process from the cloud server.
若进程满足表1所示的通常与用户的感知相关联的目标特征,则电子设备100可以确定这些进程为用户可感知的进程。If the processes satisfy the target characteristics generally associated with the user's perception shown in Table 1, the electronic device 100 may determine that these processes are user-perceivable processes.
示例性地,参见图5,电子设备100可以按进程采集心跳、网络数据包,记录通知、振动,或收集进程的其他相关信息。电子设备100根据该相关信息识别是否满足表1所示的进程特征;若满足,则电子设备100确定该进程为可感知进程;若不满足,则电子设备100确定该进程为不可感知进程。其中,有网络权限是指,该进程有使用网络资源的权限,可以正常使用网络资源。For example, referring to FIG. 5 , the electronic device 100 may collect heartbeats, network data packets by process, record notifications, vibrations, or collect other related information of the process. The electronic device 100 identifies whether the process characteristics shown in Table 1 are met according to the relevant information; if so, the electronic device 100 determines that the process is a perceptible process; if not, the electronic device 100 determines that the process is an imperceptible process. Among them, having network authority means that the process has the authority to use network resources and can use network resources normally.
或者,电子设备100可以按进程采集心跳、网络数据包,记录通知、振动,或收集进 程的其他相关信息,并上传给云端服务器。云端服务器根据进程的相关信息识别是否满足表1所示的进程特征;若满足,则云端服务器确定该进程为可感知进程;若不满足,则云端服务器确定该进程为不可感知进程。云端服务器将进程的识别结果返回给电子设备100。Alternatively, the electronic device 100 can collect heartbeats, network data packets, record notifications, vibrations, or other related information of the process according to the process, and upload it to the cloud server. The cloud server identifies whether the process characteristics shown in Table 1 are met according to the relevant information of the process; if so, the cloud server determines that the process is a perceptible process; if not, the cloud server determines that the process is an imperceptible process. The cloud server returns the identification result of the process to the electronic device 100 .
需要说明的是,电子设备100或云端服务根据进程特征确定进程是否为可感知进程或不可感知进程,可以在第一应用程序每次进入前台运行状态后进行;也可以预先进行学习和训练,并保存进程识别的训练结果,并保存在可感知进程和不可感知进程名单中。可感知进程和不可感知进程也可以是预设的。It should be noted that whether the electronic device 100 or the cloud service determines whether the process is a perceptible process or an imperceptible process according to the process characteristics can be performed after the first application enters the foreground running state; Save the training result of process identification and save it in the list of perceptible and non-perceptible processes. Perceived and imperceptible processes can also be preset.
表1Table 1
Figure PCTCN2021135662-appb-000006
Figure PCTCN2021135662-appb-000006
一些实施例中,第一应用程序的非关键进程可以是第一应用程序的非前台业务进程,也可以是第一应用程序的不可感知进程。In some embodiments, the non-critical process of the first application may be a non-foreground business process of the first application, or may be an imperceptible process of the first application.
另一些实施例中,第一应用程序的非关键进程可以是第一应用程序的非前台业务进程中的不可感知进程。对于用户不可感知进程,用户不能直接感知到该业务。因此,在实际应用中,对于第一应用程序的非前台业务进程,电子设备100保留其中的可感知进程,对其中的不可感知进程进行资源管控,能够在不影响前台业务以及用户体验的基础上,降低电子设备的功耗。In other embodiments, the non-critical process of the first application may be an imperceptible process in the non-foreground business process of the first application. For the user-insensitive process, the user cannot directly perceive the service. Therefore, in practical applications, for the non-foreground service process of the first application, the electronic device 100 retains the perceptible process in it, and performs resource management and control on the non-perceived process in it, which can not affect the foreground service and user experience on the basis of , reduce the power consumption of electronic equipment.
电子设备100在确定第一应用程序的非关键进程后,对步骤S302确定的非关键进程执行步骤S303。After determining the non-critical process of the first application, the electronic device 100 performs step S303 on the non-critical process determined in step S302.
S303:确定步骤S302确定的非关键进程中的单向进程。S303: Determine the one-way process among the non-critical processes determined in step S302.
其中,单向进程可以是不被其他任何进程调用的进程。Among them, a one-way process can be a process that is not called by any other process.
一些实施例中,从第一应用程序切换到前台运行状态开始,统计电子设备100上所有进程被调用和/或调用的关系,并获取步骤S302确定的非关键进程在开始统计一段时间后的调用结果,识别其中的单向进程。In some embodiments, starting from the switching of the first application to the foreground running state, statistics on all processes on the electronic device 100 being invoked and/or invocation relationships are performed, and the invocation of the non-critical process determined in step S302 is obtained after a period of time after the statistics are started. As a result, a one-way process within it is identified.
另一些实施例中,可以在步骤S302确定的非关键进程从创建开始,统计电子设备100上所有进程被调用和/或调用的关系,并获取步骤S303确定的不可感知进程在开始统计一段时间后的调用结果,识别其中的单向进程。In other embodiments, the non-critical processes determined in step S302 may be created from the time of creation, and the calling and/or calling relationships of all processes on the electronic device 100 may be counted, and the imperceptible processes determined in step S303 may be obtained after starting statistics for a period of time The result of the call to identify the one-way process.
示例性地,以Android操作系统为例,可以在内核Binder驱动中识别电子设备100上运行的所有进程间的调用关系。另一些实施例中,识别进程间调用的逻辑关系也可以采用其他方式,本申请对此不做限定。Exemplarily, taking the Android operating system as an example, the calling relationship between all processes running on the electronic device 100 can be identified in the kernel Binder driver. In other embodiments, other methods may also be used to identify the logical relationship of calls between processes, which is not limited in this application.
图6是Android操作系统进程间通信的原理示意图。每个Android操作系统的进程,只能运行在自己进程所拥有的虚拟地址空间。虚拟地址空间包括彼此独立的用户空间和内核空间。对于用户空间,不同进程之间彼此是不能共享的,而不同进程之间的内核空间却是可共享的。不同的两个进程的每一次通信都要通过位于内核空间的Binder驱动程序来实现。FIG. 6 is a schematic diagram of the principle of inter-process communication of the Android operating system. Each Android operating system process can only run in the virtual address space owned by its own process. The virtual address space includes user space and kernel space independent of each other. For user space, different processes cannot share with each other, but the kernel space between different processes can be shared. Each communication between the two different processes is implemented through the Binder driver located in the kernel space.
Binder机制采用客户端-服务器(Client-Server)通信模式,应用程序进程作为客户端,指定程序作为服务器端,两者之间通过Binder驱动程序进行通信。相关技术中,客户端要将一块内存数据传递给服务器端,一般的方法是,客户端将这块数据从客户端的进程空间拷贝到内核空间中,然后内核再将这块数据从内核空间拷贝到服务器端的进程空间,如此,服务器端就可以访问这块数据了,但是该方法执行了两次内存拷贝操作。而Binder机制只需要把客户端进程空间的数据拷贝一次到内核空间,然后服务器端与内核共享这块数据即可,整个过程只需要执行一次内存拷贝操作,提高了操作效率。The Binder mechanism adopts the client-server (Client-Server) communication mode, the application process acts as the client, the designated program acts as the server, and the two communicate through the Binder driver. In the related art, the client needs to transfer a piece of memory data to the server. The general method is that the client copies this piece of data from the client's process space to the kernel space, and then the kernel copies this piece of data from the kernel space to the kernel space. The process space on the server side, so the server side can access this piece of data, but this method performs two memory copy operations. The Binder mechanism only needs to copy the data of the client process space to the kernel space once, and then the server side shares this data with the kernel. The whole process only needs to perform a memory copy operation, which improves the operation efficiency.
基于上述Binder机制的原理,客户端进程和服务端进程可以是任意两个进程,可以是应用,也可以是服务,例如,可以是应用与应用之间的通信,也可以是应用与服务之间的通信。Based on the principle of the above-mentioned Binder mechanism, the client process and the server process can be any two processes, either an application or a service. For example, it can be a communication between an application and an application, or between an application and a service. Communication.
在本申请提供的实施例中,系统中运行的进程可以通过Binder机制进行通信。进程间调用通过Binder共享内存的方式完成。In the embodiments provided in this application, the processes running in the system can communicate through the Binder mechanism. Inter-process calls are done through Binder shared memory.
一些实施例中,在内核Binder驱动中可以识别所有进程间的调用关系,并记录进程间调用的逻辑关系,可以是统计所有进程被调用和/或调用的次数,也可以是所有进程被调用和/或调用的具体情况。In some embodiments, the calling relationship between all processes can be identified in the kernel Binder driver, and the logical relationship between the calls can be recorded. / or the specific case of the call.
图7示出一个应用程序的进程间调用关系示意图。如图7所示,第一应用程序的主进程A衍生出A1、A2及A3三个业务子进程。对于子进程A1,其被主进程A以及子进程A3调用,同时调用主进程A,因此子进程A1存在双向调用依赖。对于子进程A2,其调用主进程A以及子进程A3,而不被其他任何进程调用,因此子进程A2为单向进程。对于子进程A3,其被子进程A2调用,同时调用主进程A以及子进程A1,因此子进程A3存在双向调用依赖。FIG. 7 shows a schematic diagram of an inter-process calling relationship of an application. As shown in FIG. 7 , the main process A of the first application program derives three service sub-processes A1 , A2 and A3 . For the child process A1, it is called by the main process A and the child process A3, and calls the main process A at the same time, so the child process A1 has a two-way calling dependency. For the child process A2, it calls the main process A and the child process A3, but is not called by any other process, so the child process A2 is a one-way process. For the child process A3, it is called by the child process A2, and calls the main process A and the child process A1 at the same time, so the child process A3 has a two-way calling dependency.
图8示出了两个应用程序的进程互相调用关系示意图。如图8所示,第一应用程序的主进程A衍生出A1、A2及A3三个业务子进程,第二应用程序的主进程B衍生出B1、B2及B3三个业务子进程。对于子进程A1,其被主进程A、子进程A3以及子进程B3调用,同时调用主进程A,因此子进程A1存在双向调用依赖。对于子进程A2,其调用主进程A以及子进程A3调用,而不被任何进程调用,因此子进程A2为单向进程。对于子进程A3,其被子进程A2以及子进程B2调用,同时调用主进程A以及子进程A1,因此子进程A3存在双向调用依赖。对于子进程B1,其被主进程B、子进程B2以及子进程B3调用,同时调用主进程B,因此子进程B1存在双向调用依赖。对于子进程B2,其调用子进程B1、子进程B3以及子进程A3,而不被其他任何进程调用,因此子进程B2为单向进程。对于子进程B3,其被子进程B2调用,同时调用子进程A1以及子进程B1,因此子进程B3存在双向调用依赖。FIG. 8 shows a schematic diagram of the mutual calling relationship between the processes of two application programs. As shown in FIG. 8 , the main process A of the first application program derives three service sub-processes A1 , A2 and A3 , and the main process B of the second application program derives three service sub-processes B1 , B2 and B3 . For the child process A1, it is called by the main process A, the child process A3, and the child process B3, and calls the main process A at the same time, so the child process A1 has a two-way calling dependency. For the child process A2, it calls the main process A and the child process A3, but is not called by any process, so the child process A2 is a one-way process. For the child process A3, it is called by the child process A2 and the child process B2, and calls the main process A and the child process A1 at the same time, so the child process A3 has a two-way calling dependency. For the child process B1, it is called by the main process B, the child process B2, and the child process B3, and calls the main process B at the same time, so the child process B1 has a two-way calling dependency. For the child process B2, it calls the child process B1, the child process B3 and the child process A3, but is not called by any other process, so the child process B2 is a one-way process. For the child process B3, it is called by the child process B2, and calls the child process A1 and the child process B1 at the same time, so the child process B3 has a two-way calling dependency.
S304:针对处于前台运行状态的应用,对S304确定的单向进程进行资源管控。S304: For the application in the foreground running state, perform resource management and control on the one-way process determined in S304.
示例性地,如图7及图8所示,当子进程A2和子进程B2为非关键进程时,电子设备100可以对单向进程A2和单向进程B2进行资源管控。Exemplarily, as shown in FIG. 7 and FIG. 8 , when the sub-process A2 and the sub-process B2 are non-critical processes, the electronic device 100 can perform resource management and control on the one-way process A2 and the one-way process B2.
示例性地,电子设备100对进程进行资源管控的方式具体可以包括:按进程暂停Alarm心跳;按进程断开TCP连接;按进程限制网络权限;按进程对广播进行缓存或丢弃;按进程暂停GNSS/Wakelock/Job/广播等资源的使用等。Exemplarily, the manner in which the electronic device 100 performs resource management and control on the process may specifically include: suspending the Alarm heartbeat by process; disconnecting the TCP connection by process; restricting network permissions by process; caching or discarding broadcasts by process; pausing GNSS by process Use of resources such as /Wakelock/Job/broadcast, etc.
其中,按进程暂停Alarm心跳是指,停止当前进程基于Alarm的心跳包。TCP连接是通过Socket链路进行信息交互的,按进程断开TCP连接也就是说,断开当前进程的TCP连接对应的Socket链路。按进程限制网络权限是指,限制当前进程使用网络资源。按进程暂停GNSS/Wakelock/Job/广播等资源是指,禁止当前进程使用GNSS/Wakelock/Job/广播等资源。其中,按进程暂停广播资源包括,缓存或丢弃当前非关键进程的广播内容。Among them, suspending the Alarm heartbeat by process refers to stopping the current process based on the Alarm's heartbeat packet. The TCP connection exchanges information through the Socket link. The TCP connection is disconnected by process, that is, the Socket link corresponding to the TCP connection of the current process is disconnected. Restricting network permissions by process means restricting the current process from using network resources. Pausing resources such as GNSS/Wakelock/Job/broadcast by process means that the current process is prohibited from using resources such as GNSS/Wakelock/Job/broadcast. Wherein, suspending the broadcast resources by process includes caching or discarding the broadcast content of the current non-critical process.
在另一种可能的实现方式中,对进程进行资源管控可以限制进程使用一种或多种资源。例如,电子设备100可以限制进程使用Socket链路和网络资源,但允许进程正常使用Alarm资源。In another possible implementation, performing resource management on a process can restrict the process from using one or more resources. For example, the electronic device 100 may restrict the process to use the socket link and network resources, but allow the process to use the Alarm resource normally.
在另一种可能的实现方式中,电子设备100对进程进行资源管控的方式还可以是其他方式,本申请对此不做限定。In another possible implementation manner, the manner in which the electronic device 100 performs resource management and control on the process may also be other manners, which are not limited in this application.
针对处于前台运行状态的应用,对步骤S304确定的单向进程进行资源管控,可以在保证前台业务进程不受影响的情况下,减少系统开销,保证前台业务进程的资源使用体验。For the application in the foreground running state, performing resource management and control on the one-way process determined in step S304 can reduce the system overhead and ensure the resource usage experience of the foreground business process under the condition that the foreground business process is not affected.
另一种可能的实现方式中,步骤S304中,针对处于前台运行状态的应用,可以对步骤S302中确定的非关键进程中被调用次数少的进程,或者长时间未被调用的进程,或者满足预设调用场景的进程进行资源管控,可以进一步减少系统开销,同时尽可能保证前台业务进程不受影响。In another possible implementation manner, in step S304, for the application in the foreground running state, among the non-critical processes determined in step S302, the process that has been called a few times, or the process that has not been called for a long time, or satisfies The process of the preset calling scene is used for resource management and control, which can further reduce the system overhead, and at the same time ensure that the foreground business process is not affected as much as possible.
在步骤S304之后,该方法还可以包括:After step S304, the method may further include:
S305:停止对步骤S304确定的单向进程进行资源管控。S305: Stop performing resource management and control on the one-way process determined in step S304.
一些实施例中,对于非即时消息类应用程序,当检测到步骤S304确定的单向进程接收广播或者广播ANR、发生service ANR、input ANR、Binder调用时立即停止对该进程进行资源管控。In some embodiments, for a non-instant messaging application, when it is detected that the one-way process determined in step S304 receives a broadcast or broadcast ANR, and a service ANR, input ANR, or Binder call occurs, the resource management and control of the process is stopped immediately.
一些实施例中,对于即时消息类应用程序,当检测到步骤S304确定的单向进程收到来自网络侧的数据包时,停止对该进程进行资源管控。In some embodiments, for an instant messaging application, when it is detected that the one-way process determined in step S304 receives a data packet from the network side, the resource management and control of the process is stopped.
在另一种可能的实现方式中,电子设备100停止对单向进程进行资源管控的方式还可以是其他方式,本申请对此不做限定。In another possible implementation manner, the manner in which the electronic device 100 stops performing resource management and control on the one-way process may also be other manners, which are not limited in this application.
示例性地,停止对该进程进行资源管控后,该进程可以正常使用各种资源,以保证当前处于前台运行状态的应用程序正常提供服务。Exemplarily, after the resource management and control of the process is stopped, the process can use various resources normally, so as to ensure that the application currently in the foreground running state normally provides services.
终上所述,对于处于前台运行状态的应用程序,本申请提供的资源方法可以从进程的角度对其非前台业务进程的资源使用进行精准化管控。与现有技术中前台应用程序的各进程均能正常使用各项资源相比,本申请实施例提供的资源管控方法可以在保证业务的情况下,减少不必要的系统开销,从而保证前台应用程序的前台业务进程的资源使用体验。As mentioned above, for an application running in the foreground, the resource method provided by the present application can precisely manage and control the resource usage of its non-foreground business process from the perspective of the process. Compared with the prior art that each process of the foreground application can normally use various resources, the resource management and control method provided by the embodiment of the present application can reduce unnecessary system overhead under the condition of ensuring services, thereby ensuring the foreground application. The resource usage experience of the foreground business process.
另外,本申请实施例还提供了一种电子设备,包括检测单元,确定单元和管控单元,各单元可以相互配合以使得电子设备执行上述实施例中的各个步骤,实现上述资源管控方法。In addition, an embodiment of the present application also provides an electronic device, including a detection unit, a determination unit, and a management and control unit, each of which can cooperate with each other to enable the electronic device to execute the steps in the foregoing embodiments to implement the foregoing resource management and control method.
本申请实施例还提供了一种电子设备,包括一个或多个处理器;存储器;以及一个或多个计算机程序。一个或多个计算机程序被存储在存储器中,一个或多个计算机程序包括指令。当指令被一个或多个处理器执行时,使得电子设备执行上述实施例中的相关各个步骤,以实现上述资源管控方法。Embodiments of the present application also provide an electronic device, including one or more processors; a memory; and one or more computer programs. One or more computer programs are stored in the memory, the one or more computer programs including instructions. When the instruction is executed by one or more processors, the electronic device is caused to execute the relevant steps in the foregoing embodiments, so as to implement the foregoing resource management and control method.
本申请提供一种包含指令的计算机程序产品,当所述计算机程序产品在电子设备(例如上述电子设备100)上运行时,使得电子设备执行上述相关步骤,以实现上述实施例中的资源管控方法。The present application provides a computer program product containing instructions, when the computer program product runs on an electronic device (eg, the electronic device 100 described above), the electronic device executes the above-mentioned relevant steps, so as to realize the resource management and control method in the above-mentioned embodiment. .
本申请提供一种计算机可读存储介质,该计算机存储介质中存储有计算机指令,当该计算机指令在电子设备上运行时,使得电子设备执行上述相关步骤,以实现上述实施例中的资源管控方法。The present application provides a computer-readable storage medium, where computer instructions are stored in the computer storage medium, and when the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned relevant steps, so as to realize the resource management and control method in the above-mentioned embodiment. .
其中,本申请实施例提供的电子设备、计算机程序产品或计算机可读存储介质均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。The electronic devices, computer program products, or computer-readable storage media provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, for the beneficial effects that can be achieved, reference may be made to the corresponding methods provided above. The beneficial effects of the method are not repeated here.
所属领域的技术人员可以清楚地了解到本申请实施例可以用硬件实现,或硬件与软件的方式实现。当使用硬件与软件实现,可以将上述功能存储在计算机可读介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:快闪存储器、移动硬盘、只读存储器、随机存取存储器、磁碟或者光盘等各种可以存储程序代码的介质。Those skilled in the art can clearly understand that the embodiments of the present application may be implemented in hardware, or in a manner of hardware and software. When implemented using hardware and software, the above-described functions can be stored in a computer-readable medium. Based on this understanding, the technical solutions of the embodiments of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a storage The medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: flash memory, removable hard disk, read-only memory, random access memory, magnetic disk or optical disk and other media that can store program codes.
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的范围。As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand: The technical solutions described in the embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims (20)

  1. 一种资源管控方法,应用于电子设备,其特征在于,包括:A resource management and control method, applied to electronic equipment, is characterized in that, comprising:
    确定处于前台运行状态的第一应用程序;Determine the first application program in the foreground running state;
    确定所述第一应用程序的第一进程,其中,所述第一进程为非关键进程;determining a first process of the first application, wherein the first process is a non-critical process;
    获取所述第一进程被其他进程调用的第一次数;Obtain the first number of times that the first process is called by other processes;
    当所述第一次数小于或小于等于第一阈值时,对所述第一进程进行资源管控。When the first number of times is less than or equal to a first threshold, perform resource management and control on the first process.
  2. 根据权利要求1所述的方法,其特征在于,所述第一进程被其他进程调用的第一次数,包括:The method according to claim 1, wherein the first number of times the first process is called by other processes includes:
    所述第一应用程序切换到前台运行状态开始统计第一时间内所述第一进程被其他进程调用的所述第一次数,或,所述第一进程从创建开始统计所述第一时间内被其他进程调用的所述第一次数;The first application switches to the foreground running state and starts to count the first number of times the first process is called by other processes within a first time, or, the first process starts to count the first time from creation the first number of times it is called by other processes;
    其中,所述第一时间大于或大于等于第一时间阈值。Wherein, the first time is greater than or equal to a first time threshold.
  3. 根据权利要求1所述的方法,其特征在于,所述获取所述第一进程被其他进程调用的第一次数,包括:The method according to claim 1, wherein the acquiring the first number of times the first process is called by other processes comprises:
    所述电子设备在内核Binder驱动中识别所述第一进程被其他进程调用的所述第一次数。The electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
  4. 根据权利要求1所述的方法,其特征在于,所述第一进程为非关键进程,包括:The method according to claim 1, wherein the first process is a non-critical process, comprising:
    所述第一进程为所述第一应用程序的非前台业务进程,或The first process is a non-foreground business process of the first application, or
    所述第一进程为所述第一应用程序的不可感知进程,或the first process is a non-aware process of the first application, or
    所述第一进程为所述非前台业务进程中的不可感知进程;The first process is an imperceptible process in the non-foreground service process;
    其中,所述非前台业务进程为没有运行UI组件且不会被前台UI线程调用的进程,所述不可感知进程为不包括目标特征的进程;Wherein, the non-foreground business process is a process that does not run UI components and will not be called by the foreground UI thread, and the non-perceptible process is a process that does not include target features;
    其中,所述目标特征是预设的,或者是所述电子设备训练获得的特征。Wherein, the target feature is preset, or a feature obtained by training the electronic device.
  5. 根据权利要求4所述的方法,其特征在于,包括:The method of claim 4, comprising:
    当所述不可感知进程为消息收发类进程时,所述目标特征包括有周期性的Alarm心跳、集成第三方推送服务SDK、有网络权限、有TCP长连接、周期性收发数据包、有通知栏、有声音、有振动中的一项或多项;或When the imperceptible process is a message sending and receiving process, the target features include periodic Alarm heartbeat, integrated third-party push service SDK, network authority, TCP long connection, periodic data packet sending and receiving, and notification bar , one or more of sound, vibration; or
    当所述不可感知进程为闹钟类进程时,所述目标特征包括设置有周期性的Alarm时钟定时器、有声音、有振动、每天至少启动一次且自动启动到前台中的一项或多项;或When the non-perceptible process is an alarm clock class process, the target feature includes one or more of being set with a periodic Alarm clock timer, having a sound, having a vibration, starting at least once a day, and automatically starting to the foreground; or
    当所述不可感知进程为上传下载类进程时,所述目标特征包括有网络权限、有TCP长连接、有数据包收发、常驻通知栏、有输入输出操作中的一项或多项;或When the imperceptible process is an upload and download process, the target feature includes one or more of network permissions, long TCP connections, data packet sending and receiving, resident notification bar, and input and output operations; or
    当所述不可感知进程为音频播放类进程时,所述目标特征包括有连续性的声音播放、有网络、常驻通知栏、有输入输出操作中的一项或多项;或When the imperceptible process is an audio playback process, the target feature includes one or more of continuous sound playback, presence of a network, resident notification bar, and input and output operations; or
    当所述不可感知进程为导航类进程时,所述目标特征包括有GPS请求、有间歇性声音、有网络、常驻通知栏、集成地图SDK中的一项或多项;或When the imperceptible process is a navigation type process, the target feature includes one or more of GPS request, intermittent sound, network, resident notification bar, and integrated map SDK; or
    当所述不可感知进程为录音类进程时,所述目标特征包括有音频输入、常驻通知栏、有输入输出操作中的一项或多项。When the imperceptible process is a recording type process, the target feature includes one or more of audio input, resident notification bar, and input and output operations.
  6. 根据权利要求1所述的方法,其特征在于,所述确定处于前台运行状态的第一应用程序,包括:The method according to claim 1, wherein the determining the first application running in the foreground comprises:
    所述电子设备的显示屏发生触摸焦点变化或所述电子设备解锁时,获取当前可见的应用程序,若所述应用程序的界面组件处于运行状态,确定所述应用程序为处于前台运行状 态的所述第一应用程序。When the touch focus of the display screen of the electronic device changes or the electronic device is unlocked, the currently visible application program is obtained, and if the interface component of the application program is in the running state, it is determined that the application is in the foreground running state. the first application.
  7. 根据权利要求1所述的方法,其特征在于,所述对所述第一进程进行资源管控,包括,限制所述第一进程使用资源。The method according to claim 1, wherein the performing resource management and control on the first process comprises restricting the use of resources by the first process.
  8. 根据权利要求7所述的方法,其特征在于,所述资源包括:位置定位资源,网络资源,蓝牙资源,传输控制协议TCP连接资源,音频资源,调制解调器资源,定时闹钟资源,唤醒锁资源,广播资源,延时处理资源,或服务资源中的一项或多项。The method according to claim 7, wherein the resources include: location positioning resources, network resources, Bluetooth resources, transmission control protocol TCP connection resources, audio resources, modem resources, timed alarm clock resources, wake-up lock resources, broadcast resources One or more of a resource, a delayed processing resource, or a service resource.
  9. 根据权利要求1所述的方法,其特征在于,所述对所述第一进程进行资源管控之后,还包括:The method according to claim 1, wherein after performing resource management and control on the first process, the method further comprises:
    停止对所述第一进程进行资源管控。Stop performing resource management and control on the first process.
  10. 根据权利要求9所述的方法,其特征在于,所述停止对所述第一进程进行资源管控,包括:The method according to claim 9, wherein the stopping the resource management and control of the first process comprises:
    当所述第一应用程序为非即时消息类应用程序,当检测到所述第一进程接收广播,接收广播ANR,发生service ANR,发生input ANR以及发生Binder调用中的一项或多项时,停止对所述第一进程进行资源管控;或When the first application is a non-instant messaging application, when it is detected that the first process receives broadcast, receives broadcast ANR, generates service ANR, generates input ANR, and generates one or more of Binder calls, stop resource management of the first process; or
    当所述第一应用程序为即时消息类应用程序,当检测到所述第一进程收到来自网络侧的数据包时,停止对所述第一进程进行资源管控。When the first application is an instant messaging application, when it is detected that the first process receives a data packet from the network side, the resource management and control of the first process is stopped.
  11. 一种电子设备,其特征在于,包括:An electronic device, comprising:
    屏幕,用于显示界面;screen, used to display the interface;
    一个或多个处理器;one or more processors;
    以及存储器,所述存储器中存储有代码;and a memory in which code is stored;
    当所述代码被所述电子设备执行时,使得所述电子设备执行如下步骤:When the code is executed by the electronic device, the electronic device is caused to perform the following steps:
    确定处于前台运行状态的第一应用程序;Determine the first application program in the foreground running state;
    确定所述第一应用程序的第一进程,其中,所述第一进程为非关键进程;determining a first process of the first application, wherein the first process is a non-critical process;
    获取所述第一进程被其他进程调用的第一次数;Obtain the first number of times that the first process is called by other processes;
    当所述第一次数小于或小于等于第一阈值时,对所述第一进程进行资源管控。When the first number of times is less than or equal to a first threshold, perform resource management and control on the first process.
  12. 根据权利要求11所述的电子设备,其特征在于,所述第一进程被其他进程调用的第一次数,包括:The electronic device according to claim 11, wherein the first number of times the first process is called by other processes includes:
    所述第一应用程序切换到前台运行状态开始统计第一时间内所述第一进程被其他进程调用的所述第一次数,或,所述第一进程从创建开始统计所述第一时间内被其他进程调用的所述第一次数;The first application switches to the foreground running state and starts to count the first number of times the first process is called by other processes within a first time, or, the first process starts to count the first time from creation the first number of times it is called by other processes;
    其中,所述第一时间大于或大于等于第一时间阈值。Wherein, the first time is greater than or equal to a first time threshold.
  13. 根据权利要求11所述的电子设备,其特征在于,所述获取所述第一进程被其他进程调用的第一次数,包括:The electronic device according to claim 11, wherein the acquiring the first number of times the first process is called by other processes comprises:
    所述电子设备在内核Binder驱动中识别所述第一进程被其他进程调用的所述第一次数。The electronic device identifies the first number of times that the first process is called by other processes in the kernel Binder driver.
  14. 根据权利要求13所述的电子设备,其特征在于,所述第一进程为非关键进程,包括:The electronic device according to claim 13, wherein the first process is a non-critical process, comprising:
    所述第一进程为所述第一应用程序的非前台业务进程,或The first process is a non-foreground business process of the first application, or
    所述第一进程为所述第一应用程序的不可感知进程,或the first process is a non-aware process of the first application, or
    所述第一进程为所述非前台业务进程中的不可感知进程;The first process is an imperceptible process in the non-foreground service process;
    其中,所述非前台业务进程为没有运行UI组件且不会被前台UI线程调用的进程,所 述不可感知进程为不包括目标特征的进程;Wherein, described non-foreground business process is the process that does not run UI component and will not be called by foreground UI thread, and described imperceptible process is the process that does not include target feature;
    其中,所述目标特征是预设的,或者是所述电子设备训练获得的特征。Wherein, the target feature is preset, or a feature obtained by training the electronic device.
  15. 根据权利要求11所述的电子设备,其特征在于,所述确定处于前台运行状态的第一应用程序,包括:The electronic device according to claim 11, wherein the determining of the first application program in the foreground running state comprises:
    所述电子设备的显示屏发生触摸焦点变化或所述电子设备解锁时,获取当前可见的应用程序,若所述应用程序的界面组件处于运行状态,确定所述应用程序为处于前台运行状态的所述第一应用程序。When the touch focus of the display screen of the electronic device changes or the electronic device is unlocked, the currently visible application program is obtained, and if the interface component of the application program is in the running state, it is determined that the application is in the foreground running state. the first application.
  16. 根据权利要求11所述的电子设备,其特征在于,所述对所述第一进程进行资源管控,包括,限制所述第一进程使用资源。The electronic device according to claim 11, wherein the performing resource management and control on the first process comprises restricting the use of resources by the first process.
  17. 根据权利要求11所述的电子设备,其特征在于,所述对所述第一进程进行资源管控之后,还包括:The electronic device according to claim 11, wherein after performing resource management and control on the first process, the method further comprises:
    停止对所述第一进程进行资源管控。Stop performing resource management and control on the first process.
  18. 根据权利要求17所述的电子设备,其特征在于,所述停止对所述第一进程进行资源管控,包括:The electronic device according to claim 17, wherein the stopping the resource management and control of the first process comprises:
    当所述第一应用程序为非即时消息类应用程序,当检测到所述第一进程接收广播,接收广播ANR,发生service ANR,发生input ANR以及发生Binder调用中的一项或多项时,停止对所述第一进程进行资源管控;或When the first application is a non-instant messaging application, when it is detected that the first process receives broadcast, receives broadcast ANR, generates service ANR, generates input ANR, and generates one or more of Binder calls, stop resource management of the first process; or
    当所述第一应用程序为即时消息类应用程序,当检测到所述第一进程收到来自网络侧的数据包时,停止对所述第一进程进行资源管控。When the first application is an instant messaging application, when it is detected that the first process receives a data packet from the network side, the resource management and control of the first process is stopped.
  19. 一种计算机存储介质,其特征在于,包括计算机指令,当所述计算机指令在电子设备上运行时,使得所述电子设备执行如权利要求1-10中任一项所述的资源管控方法。A computer storage medium is characterized by comprising computer instructions, when the computer instructions are executed on an electronic device, the electronic device is made to execute the resource management and control method according to any one of claims 1-10.
  20. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1-10中任一项所述的资源管控方法。A computer program product, characterized in that, when the computer program product runs on a computer, the computer is caused to execute the resource management and control method according to any one of claims 1-10.
PCT/CN2021/135662 2020-12-14 2021-12-06 Resource management and control method, and device WO2022127632A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011464555.3 2020-12-14
CN202011464555.3A CN114625525A (en) 2020-12-14 2020-12-14 Resource control method and equipment

Publications (1)

Publication Number Publication Date
WO2022127632A1 true WO2022127632A1 (en) 2022-06-23

Family

ID=81896680

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/135662 WO2022127632A1 (en) 2020-12-14 2021-12-06 Resource management and control method, and device

Country Status (2)

Country Link
CN (1) CN114625525A (en)
WO (1) WO2022127632A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349006A (en) * 2023-09-14 2024-01-05 荣耀终端有限公司 CPU resource management method and related device

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116055546A (en) * 2022-07-21 2023-05-02 荣耀终端有限公司 Process management method, electronic device, storage medium, and program product
CN116700815B (en) * 2022-10-21 2024-04-26 荣耀终端有限公司 Hardware resource control method, electronic device and readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102736953A (en) * 2011-04-08 2012-10-17 腾讯科技(深圳)有限公司 System resource allocation method and equipment
US20130031424A1 (en) * 2011-07-27 2013-01-31 Oracle International Corporation Proactive and adaptive cloud monitoring
CN109862184A (en) * 2019-01-28 2019-06-07 努比亚技术有限公司 Terminal and its resource management-control method, computer readable storage medium
CN109992397A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Process handling method and device, electronic equipment, computer readable storage medium
CN110032429A (en) * 2018-01-10 2019-07-19 广东欧珀移动通信有限公司 Information processing method, device, mobile terminal and computer readable storage medium
CN110806926A (en) * 2019-09-05 2020-02-18 华为技术有限公司 Resource control method and equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102736953A (en) * 2011-04-08 2012-10-17 腾讯科技(深圳)有限公司 System resource allocation method and equipment
US20130031424A1 (en) * 2011-07-27 2013-01-31 Oracle International Corporation Proactive and adaptive cloud monitoring
CN109992397A (en) * 2017-12-29 2019-07-09 广东欧珀移动通信有限公司 Process handling method and device, electronic equipment, computer readable storage medium
CN110032429A (en) * 2018-01-10 2019-07-19 广东欧珀移动通信有限公司 Information processing method, device, mobile terminal and computer readable storage medium
CN109862184A (en) * 2019-01-28 2019-06-07 努比亚技术有限公司 Terminal and its resource management-control method, computer readable storage medium
CN110806926A (en) * 2019-09-05 2020-02-18 华为技术有限公司 Resource control method and equipment

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117349006A (en) * 2023-09-14 2024-01-05 荣耀终端有限公司 CPU resource management method and related device

Also Published As

Publication number Publication date
CN114625525A (en) 2022-06-14

Similar Documents

Publication Publication Date Title
WO2020259452A1 (en) Full-screen display method for mobile terminal, and apparatus
WO2021013158A1 (en) Display method and related apparatus
WO2020108356A1 (en) Application display method and electronic device
WO2021000807A1 (en) Processing method and apparatus for waiting scenario in application
WO2021135730A1 (en) Display interface adaptation method, display interface adaptation design method and electronic device
WO2020000448A1 (en) Flexible screen display method and terminal
WO2021213164A1 (en) Application interface interaction method, electronic device, and computer readable storage medium
WO2021036770A1 (en) Split-screen processing method and terminal device
WO2022127632A1 (en) Resource management and control method, and device
WO2020093988A1 (en) Image processing method and electronic device
EP4084486A1 (en) Cross-device content projection method, and electronic device
WO2021258809A1 (en) Data synchronization method, electronic device, and computer readable storage medium
WO2022199509A1 (en) Method for application performing drawing operation, and electronic device
CN116360725B (en) Display interaction system, display method and device
WO2021052415A1 (en) Resource scheduling method and electronic device
WO2023005282A9 (en) Message pushing method and apparatus
WO2022095744A1 (en) Vr display control method, electronic device, and computer readable storage medium
WO2022042637A1 (en) Bluetooth-based data transmission method and related apparatus
WO2021073337A1 (en) Method and apparatus for installing plug-in, and storage medium
WO2022143180A1 (en) Collaborative display method, terminal device, and computer readable storage medium
CN115016697A (en) Screen projection method, computer device, readable storage medium, and program product
WO2022135195A1 (en) Method and apparatus for displaying virtual reality interface, device, and readable storage medium
WO2022152174A1 (en) Screen projection method and electronic device
WO2024083031A1 (en) Display method, electronic device, and system
WO2022206709A1 (en) Component loading method for application and related apparatus

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21905561

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21905561

Country of ref document: EP

Kind code of ref document: A1