WO2024037353A1 - Application processing method and electronic device - Google Patents

Application processing method and electronic device Download PDF

Info

Publication number
WO2024037353A1
WO2024037353A1 PCT/CN2023/111084 CN2023111084W WO2024037353A1 WO 2024037353 A1 WO2024037353 A1 WO 2024037353A1 CN 2023111084 W CN2023111084 W CN 2023111084W WO 2024037353 A1 WO2024037353 A1 WO 2024037353A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
terminal
audio
background
running
Prior art date
Application number
PCT/CN2023/111084
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 WO2024037353A1 publication Critical patent/WO2024037353A1/en

Links

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
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • 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]

Definitions

  • the embodiments of the present application relate to the field of terminal technology, and in particular, to an application processing method and electronic device.
  • the terminal can freeze applications that have a running time longer than the preset time to reduce the usage of terminal resources.
  • applications that are perceptible to the user when running in the background such as applications that play audio, applications that perform positioning and navigation, etc.
  • the terminal will not freeze these applications, and these applications will still occupy terminal resources.
  • Embodiments of the present application provide an application processing method and an electronic device, which can freeze applications that are perceptible to users when running in the background.
  • embodiments of the present application provide an application processing method.
  • the execution subject that executes the method may be a terminal or a chip in the terminal.
  • the following description takes the terminal as an example.
  • the terminal detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration.
  • the capacity of the buffer of AudioFlinger can be increased.
  • the buffer of AudioFlinger in the prior art can cache 1k audio stream.
  • the AudioFlinger buffer can buffer 1M audio streams.
  • the terminal responds that the duration of the audio stream buffered in the buffer is greater than or equal to the first preset duration, indicating that enough audio streams have been buffered in the buffer to maintain playback for a period of time, so the terminal can freeze and run in the background.
  • the application that is playing audio to reduce the application's occupation of terminal resources.
  • the application can continue to play the audio based on the audio cached in the buffer. In this way, after the application is frozen, the user can still hear the audio played by the background application, and the user does not perceive that the background application has been frozen. .
  • the terminal can perform freezing management to reduce the application's occupation of terminal resources.
  • the user can continue to listen to the music played by the application. Affect user experience.
  • the terminal before the terminal detects whether the duration of the audio stream cached in the buffer of AudioFlinger is greater than or equal to the first preset duration, the terminal can also respond to the target event to detect whether the application running in the background is playing audio.
  • the target event is an event triggered by any of the following: application startup, interface switching, and terminal frame dropping.
  • the terminal may determine that the application is playing audio in response to the audio stream of the application being cached in the buffer.
  • the terminal determines that the application does not play audio in response to the audio stream of the application being cached in the buffer.
  • the target event is an event with relatively high terminal load requirements, such as application startup and interface switching, or the target event is an event that indicates that the terminal is already under high load, such as terminal frame drop.
  • the target event can be understood as: an event that will cause a high load on the terminal, or an event that can characterize a high load on the terminal.
  • the purpose of executing the application processing method provided by this application is to: reduce the load of the terminal, ensure the smooth operation of the terminal, and avoid problems such as application lags and crashes that affect the user experience. .
  • the terminal may also perform a countdown, and the countdown time is a second preset time length, and the second preset time length is less than the first preset time length.
  • the purpose of the terminal's countdown is to unfreeze the application before the audio stream cached in the cache is played, so that the application continues to cache the audio stream in the cache, so as to avoid the audio stream in the cache being played out and the user's perception of audio interruption.
  • the terminal unfreezes the application.
  • the duration of the countdown is a second preset duration, and the second preset duration is smaller than During the first preset duration, it is ensured that before the audio stream in the buffer is played, the application continues to buffer the audio stream in the buffer, thereby ensuring audio continuity.
  • the terminal detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration. If the duration of the audio stream buffered in the buffer is less than the first preset duration, The duration indicates that the audio stream cached in the cache will be played quickly. In order not to affect the user experience, the terminal does not need to freeze the application.
  • the terminal can detect whether the application is performing network positioning.
  • the purpose of the terminal detecting whether the application is performing network positioning is to more comprehensively freeze and manage the applications running in the background. It should be understood that network positioning can be understood as base station positioning. The positioning accuracy of network positioning is low, that is, the terminal can accept lower positioning accuracy. Therefore, freezing the application for a period of time will not affect the user experience.
  • the terminal freezes the application in response to the application performing network positioning.
  • the terminal may perform a countdown, and the countdown duration is the third preset duration. Freezing applications on the terminal can reduce the application's occupation of terminal resources and reduce terminal load.
  • the purpose of terminal countdown is to prevent applications from freezing for a long time, causing users to perceive that the application is not positioned, and to avoid affecting the user experience.
  • the terminal can unfreeze the application, and the application can continue to perform network positioning.
  • the terminal when the terminal detects whether the application is performing network positioning, if the application is not performing network positioning, the terminal may detect whether the terminal is absolutely stationary.
  • the purpose of the terminal detecting whether the terminal is absolutely stationary is to more comprehensively freeze and manage applications running in the background. It should be understood that absolute stillness can be understood as: the position and attitude of the terminal have not changed.
  • the terminal can freeze the application to reduce the application's occupation of terminal resources.
  • the terminal can unfreeze the application when detecting a change in the terminal's position or attitude.
  • the terminal includes: a freezing module and a process management module.
  • the freezing module in response to the duration of the audio stream cached in the buffer being greater than or equal to the first preset duration, the freezing module writes the identifier of the process corresponding to the audio stream into the node, and the process is the application process.
  • the process management module freezes the process in response to the identification of the process written in the node.
  • the freezing module writes the process of the application to be unfrozen into the node, and the process management module can unfreeze the process in response to writing the identifier of the process in the node.
  • the terminal further includes: Location, the Location is used to obtain the location of the terminal and feed it back to the freezing module.
  • the freezing module responds to the location of the terminal from Location and does not send the location of the terminal to the application. In this way, the application cannot receive the terminal's location, so operations such as location updates will not be performed.
  • the freezing module responds to the location of the terminal from Location and sends the location of the terminal to the application. In this way, the application can receive the location of the terminal and continue to perform operations such as location update and playback location.
  • embodiments of the present application provide an electronic device, which may include a processor and a memory.
  • the memory is used to store computer-executable program code, and the program code includes instructions; when the processor executes the instructions, the instructions cause the electronic device to perform the method in the first aspect.
  • embodiments of the present application provide a computer program product containing instructions that, when run on a computer, cause the computer to execute the method in the first aspect.
  • embodiments of the present application provide a computer-readable storage medium that stores instructions that, when run on a computer, cause the computer to execute the method in the first aspect.
  • Figure 1 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
  • Figure 2 is a schematic flow chart of an embodiment of the application processing method provided by the embodiment of the present application.
  • FIG. 3 is a schematic flowchart of another embodiment of the application processing method provided by the embodiment of the present application.
  • Figure 4 is a schematic flow chart of an application playing audio provided by an embodiment of the present application.
  • Figure 5 is a schematic flow chart of network positioning using an application provided by an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of another embodiment of the application processing method provided by the embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the application runs in the foreground: the terminal runs the application in the foreground, and the application process is the foreground process.
  • the terminal displays the application interface and the user can see the application interface.
  • running the call application in the foreground can be understood as: the terminal displays the call interface.
  • Application running in the foreground can also be called: application running in the foreground.
  • the application runs in the background:
  • the terminal runs the application in the background, and the application process is a background process.
  • the terminal can display the interface of other applications without displaying the interface of the application running in the background, that is, the user cannot see the interface of the application running in the background.
  • the terminal can display a logo indicating that the application is running in the background on the interface of other applications.
  • the terminal can display a card indicating "on a call" on the interface, and information such as the call duration can be displayed on the card.
  • the card can be regarded as a symbol indicating that the calling application is running in the background.
  • Application running in the background can also be called: application running in the background.
  • Freezing The embodiment of this application refers to freezing the application process. Among them, freezing an application can also be understood as freezing an application's process.
  • Unfreeze Unfreeze the frozen application process.
  • User-perceivable applications running in the background including but not limited to applications that play audio and applications that perform positioning. For example, when an application that plays audio is running in the background, it will continue to play audio, and the user can hear the audio. Therefore, when the application that plays audio is running in the background, it is perceivable to the user. In another example, when the positioning application is running in the background, it will continue to locate the position of the terminal and play audio to notify the terminal's position. The user can perceive the position of the terminal. Therefore, when the positioning application is running in the background, it will continue to locate the position of the terminal. The user is aware.
  • the terminal in the embodiment of this application may be called user equipment (UE).
  • the terminal can be a mobile phone, a tablet (portable android device, PAD), a personal digital assistant (PDA), a handheld device with wireless communication capabilities, a computing device, a vehicle-mounted device or a wearable device, a virtual reality (virtual reality) reality (VR) terminal equipment, augmented reality (AR) terminal equipment, wireless terminals in industrial control (industrial control), terminals in smart home (smart home), etc.
  • the form of the terminal does not matter. Make specific limitations.
  • Terminal resources may include but are not limited to: processor resources, memory resources, and input/output (I/O) resources in the terminal.
  • I/O input/output
  • the applications running in the foreground are applications required by the user.
  • the terminal usually does not freeze the applications running in the foreground. Instead, it freezes the applications running in the background to reduce the occupation of terminal resources and reduce the load on the terminal.
  • the applications running in the background frozen by the terminal do not include applications that are perceptible to the user.
  • Examples of user-perceivable applications include, but are not limited to: applications for playing audio and applications for positioning.
  • an application that is user-aware when running in the background may be referred to as a target application.
  • the target application when the target application is running in the background, if the terminal freezes the target application, the user can perceive that the terminal does not play audio, does not perform positioning (navigation), etc., resulting in a low user experience. Therefore, when the target application is currently running in the background, the terminal cannot The target application will be frozen.
  • the main process of the target application can be bound to a service process, and the service process completes tasks such as audio playback and positioning.
  • the terminal when the target application is running in the background, the terminal can increase the priority of the target application, and the terminal will freeze the low-priority application running in the background. Since the target application has a high priority, the terminal will not Freeze the target application.
  • the processing rules when the application is running in the background can be preset, and the processing rules when the target application is running in the background can be: do not freeze. In this embodiment, when the target application is running in the background, the terminal does not freeze the target application according to the processing rules when the target application is running in the background.
  • Target applications running in the background will also occupy terminal resources, causing high load on the terminal.
  • embodiments of the present application provide an application processing method that can freeze and unfreeze applications that are perceivable to users when running in the background, so as to reduce terminal resources occupied by applications perceivable to users when running in the background and reduce terminal load. .
  • FIG. 1 is a schematic structural diagram of a terminal provided by an embodiment of the present application.
  • the terminal software system can adopt a layered architecture.
  • the layered architecture divides the terminal software system into several layers. Each layer has a clear role and division of labor, and the layers communicate through software interfaces.
  • the software system can be divided into five layers, namely application layer, application framework layer, Android runtime and system library, and hardware abstract layer. , HAL) and the kernel layer (kernel).
  • HAL application layer
  • kernel layer kernel layer
  • the embodiments of the present application do not limit the layering of the software structure of the terminal.
  • Figure 1 shows the application layer, application framework layer, hardware abstraction layer, and kernel layer involved in the embodiment of the present application.
  • the modules included in each layer shown in Figure 1 are modules involved in the embodiments of the present application.
  • the modules included in the following layers do not limit the structure of the terminal, nor does the level of module deployment. Limitations on the structure of the terminal. In some examples, the modules shown in Figure 1 can be deployed individually, or several modules can be deployed together, the division of modules in Figure 1 being one example.
  • the application layer can include a series of application packages.
  • the application layer runs applications by calling the application programming interface (API) provided by the application framework layer.
  • API application programming interface
  • the application package may include: target application, AudioTrack.
  • the target application is a user-aware application running in the background.
  • target applications include but are not limited to: applications that play audio and applications that perform positioning.
  • applications that play audio may include, but are not limited to: audio applications, social applications, navigation applications, and video applications.
  • Applications for positioning may include, but are not limited to: audio applications, social applications, and navigation applications.
  • Figure 1 takes the target application including audio application and navigation application as an example for illustration.
  • an audio application can create an AudioTrack instance when playing audio. AudioTrack, used to be called by audio applications to decode audio data.
  • audio applications can call AudioTrack to decode audio data and obtain audio streams in pulse code modulation (PCM) format.
  • PCM pulse code modulation
  • the application framework layer provides APIs and programming frameworks for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer can include: AudioFlinger, Location, freezing module, event transmission module, and front and back management modules.
  • AudioFlinger can be regarded as a module that provides audio processing services
  • Location can be regarded as a module that provides positioning services.
  • AudioFlinger the executor of the audio strategy, is responsible for the transmission of audio streams.
  • a buffer can be set up in AudioFlinger, and the buffer is used to cache the audio stream.
  • Location used to provide the location of the terminal to the target application.
  • a freezing module is used to detect whether the target application meets the freezing conditions, to freeze the target application when the target application meets the freezing conditions, and to detect whether the target application meets the unfreezing conditions to unfreeze the target application when the target application meets the unfreezing conditions.
  • the event transmission module is used to send events to the freezing module to trigger the freezing module to detect whether the target application meets the freezing conditions.
  • the front and back management module is used to detect whether the target application is running in the foreground or the background.
  • the information that the target application is running in the background can be synchronized to the freezing module.
  • the hardware abstraction layer can include multiple library modules.
  • the library modules can be, for example, camera library modules, motor library modules, and speaker library modules.
  • the application framework layer can achieve the purpose of the application framework layer accessing the device hardware by calling the corresponding library module in the hardware abstraction layer.
  • Device hardware may include motors, cameras, speakers, etc. in electronic devices.
  • the hardware abstraction layer may include AudioHAL.
  • AudioFlinger can access the audio hardware to play audio by calling AudioHAL. Audio hardware such as speakers, etc.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer is used to drive the hardware and make the hardware work.
  • the kernel layer at least includes a display driver, a camera driver, an audio driver, etc., which are not limited in the embodiments of this application. As shown in Figure 1, the kernel layer includes: process management module and audio driver.
  • the process management module is used to manage the process of the target application.
  • the process management module can freeze or unfreeze the process of the target application.
  • Audio driver used to drive audio hardware.
  • FIG. 2 is a schematic flowchart of an embodiment of the application processing method provided by the embodiment of the present application.
  • the application processing method provided by the embodiment of the present application may include:
  • Applications can run in the foreground or background, and the terminal can determine whether the application is running in the foreground or background. For example, when the application is running in the foreground, the identification of the application's process is marked as running in the foreground, and when the application is running in the background, the identification of the application's process is marked as running in the background. The terminal can determine whether the application is running in the foreground or background based on the process identifier.
  • the identifier of the application's process may be the application's process number.
  • the process number of the audio application is marked as running in the background.
  • the process number of the navigation application is marked as running in the background.
  • process 1 and process 2 are marked as running in the background, and the terminal can be marked as running in the background according to process 1.
  • Process 2 is marked as running in the background, and it is determined that audio applications and navigation applications are running in the background.
  • the terminal can detect in real time whether an application running in the background is playing audio.
  • the terminal may respond to the target event and detect whether an application running in the background is playing audio to reduce the terminal load.
  • the target event may include but is not limited to: starting an application, switching interfaces, or sliding to drop frames, etc.
  • the terminal in response to detecting that the terminal starts an application, switches interfaces, or slides to drop frames, the terminal can detect whether the application running in the background is playing audio.
  • the terminal responds to the target event and detects whether the application running in the background is playing audio is because: starting an application or switching interfaces requires relatively high terminal load.
  • the occurrence of the target event will increase the terminal load, which is characterized by sliding frames.
  • the terminal load is already high.
  • the terminal can detect whether the application running in the background is playing audio when detecting the target event, which can trigger the terminal to freeze the application running in the background.
  • Applications that play audio can reduce the occupation of the terminal load by playing audio running in the background and reduce the terminal load.
  • the terminal starting an application can be understood as: the terminal creates an application process and starts the application process to start the application. For example, when the application is not started, the user clicks the application icon on the desktop of the terminal to trigger the terminal to start the application.
  • Switching the interface can be understood as: the interface of the terminal changes.
  • Terminal frame drop can be understood as: when the terminal draws picture frames, the number of picture frames drawn is less than the number of picture frames corresponding to the refresh rate of the terminal, which in turn causes the number of picture frames displayed by the terminal to decrease, and even causes the terminal interface to freeze. Dayton's question. For example, taking the refresh rate of the terminal as 60Hz as an example, the terminal can display 60 frames per second, that is, one frame is displayed every 16.6ms. However, when the terminal draws frames, the number of frames drawn is less than 60. frames, only 30 frames are drawn, resulting in fewer frames displayed on the terminal, that is, the terminal drops frames. Sliding frame drop is one of the terminal frame drops. Sliding frame drop can be understood as: interface frame drop that occurs when the user performs a sliding operation on the terminal interface. Terminal frame drops may also include click frame drops, frame drops when any interface changes, etc. In some examples, the target event may include terminal frame drops.
  • the application can call AudioTrack to decode the audio data and obtain the audio stream.
  • the audio data may be locally stored audio data, or audio data downloaded from the server by the application, which is not limited in the embodiment of the present application.
  • the application can transmit the decoded audio stream to AudioFlinger, and AudioFlinger can cache the received audio stream in AudioFlinger's buffer for playback.
  • AudioFlinger can cache the audio stream, read the audio stream in the buffer, call the Audio HAL of the hardware abstraction layer, and control the audio hardware to play audio.
  • the terminal can detect whether there is an audio stream cached in the buffer to detect whether the application running in the background is playing audio. Among them, when there is an audio stream cached in the buffer, the terminal can determine that there is an application in the terminal that is playing the audio, but it cannot determine whether the application running in the foreground is playing the audio or the application running in the background is playing the audio.
  • the application when it transmits the decoded audio stream to AudioFlinger, it can also send the identifier of the process corresponding to the audio stream to AudioFlinger.
  • the terminal can determine that it is running in the foreground based on the identifier of the process corresponding to the audio stream cached in the buffer.
  • the application plays audio, or the application running in the background plays audio. In other words, the terminal can determine whether the application running in the background is playing audio.
  • the identifier of the process corresponding to the audio stream cached in the buffer is the process identifier of the application running in the foreground
  • the terminal can determine that the application running in the foreground is playing audio.
  • the identifier of the process corresponding to the audio stream cached in the buffer is the process identifier of the application running in the foreground
  • the terminal can determine that the application running in the background is playing audio.
  • the terminal can determine that process 1 is marked as running in the background, so that the terminal can determine that the application running in the background is playing audio.
  • S202 Detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration. If yes, execute S203, if not, execute S206.
  • the size of the buffer of AudioFlinger is increased.
  • the size of the buffer can be understood as the amount of data that the buffer can accommodate for the audio stream.
  • the buffer size of AudioFlinger is 20K.
  • the buffer size of AudioFlinger can be expanded to 1M, that is, the buffer size is increased to 1M, so that AudioFlinger can cache more audio streams.
  • the terminal can detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration.
  • the first preset time period may be 10 seconds.
  • the application when the application sends the decoded audio stream to AudioFlinger, it can also carry the timestamp of the audio stream.
  • the terminal can determine the duration of the audio stream buffered in AudioFlinger's buffer based on the timestamp of the audio stream buffered in AudioFlinger's buffer to detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration. For example, the terminal can subtract the earliest timestamp from the latest timestamp of the audio stream buffered in the buffer to obtain the duration of the audio stream buffered in the buffer.
  • the terminal when the duration of the audio stream cached in the buffer is greater than or equal to the first preset duration, it means that enough audio streams have been cached in the buffer, and freezing applications running in the background for a short time will not affect audio playback, and the terminal can play The audio stream has been cached in the buffer. Therefore, when the duration of the audio stream cached in the buffer is greater than or equal to the first preset duration, the terminal can freeze the application running in the background that is playing audio. When the duration of the audio stream cached in the buffer is less than the first preset duration, it means that there are fewer audio streams cached in the buffer. If the application running in the background is frozen, the audio stream cached in the buffer will be played out soon, and the user will perceive Audio playback is interrupted. In order not to affect the user experience, when the duration of the audio stream cached in the buffer is less than the first preset duration, the terminal may not freeze the application running in the background that is playing audio.
  • Terminal freezing application can be understood as: terminal freezing application process. For example, taking the application as an audio application, when the audio application is running in the background and playing audio, if the terminal detects that the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration, the terminal You can freeze the process of audio applications 1. After process 1 of the audio application is frozen, the audio application will not call AudioTrack to decode audio data, nor will it transmit the decoded audio stream to AudioFlinger.
  • AudioFlinger's buffer because the size of AudioFlinger's buffer is increased, after the application that plays audio is frozen, the audio stream is still cached in AudioFlinger's buffer, so AudioFlinger can continue to read the audio in the buffer. Stream, call the Audio HAL of the hardware abstraction layer, and control the audio hardware to play audio.
  • the terminal can still play audio, that is, the user perceives that the audio has not stopped playing. It should be understood that after the application that plays audio is frozen, the application that plays audio will not occupy terminal resources, so the terminal load can be reduced.
  • the terminal can count down after freezing the application so that the application can be unfrozen before the audio stream buffered in the AudioFlinger buffer is played. In this way, the application can continue to call AudioTrack to decode the audio data and continue Transmit the decoded audio stream to AudioFlinger to ensure that the application continues to play audio in the background, so that the user can perceive uninterrupted audio playback and improve the user experience.
  • the starting point for the terminal to countdown may be the moment when the terminal completes freezing the application.
  • the terminal countdown time is the second preset time, and the second preset time is shorter than the first preset time.
  • the first preset duration is 10s
  • the second preset duration can be 9s, that is, the terminal can unfreeze the application when there is 1s left of the audio stream buffered in the buffer.
  • Unfreezing an application on the terminal can be understood as: the process of unfreezing the application. After the application is unfrozen, the application can continue to call AudioTrack to decode audio data and continue to transmit the decoded audio stream to AudioFlinger. AudioFlinger can also continue to cache the audio stream in the buffer and call the Audio HAL of the hardware abstraction layer to control the audio hardware to play audio.
  • the terminal detects that the application running in the background switches to the foreground, and the terminal can also unfreeze the application.
  • the terminal detects the identification of the application running in the background displayed on the user's operation terminal interface, and the terminal can also unfreeze the application.
  • the terminal detects that the user operates the volume button on the terminal to control the volume of the audio played by the application, or the terminal detects that the user operates the button on the headset connected to the terminal to control the audio played by the application ( Such as pause, next song, etc.), the terminal can also unfreeze the application.
  • the app can also be positioned in the background. If the application performs positioning in the background, it can provide route navigation for the user, so that the user can also perceive that the application is positioning. In one embodiment, when the application running in the background does not play audio, or the duration of the audio stream buffered in AudioFlinger's buffer is less than the first preset duration, the terminal can continue to detect whether the application running in the background is performing network positioning, so that The terminal can more comprehensively determine the tasks performed by applications running in the background, determine whether to freeze applications running in the background, and ensure more accurate management of applications running in the background.
  • GPS global positioning system
  • base station positioning can be understood as: base station positioning.
  • the application can initiate a registration request to the Location.
  • the registration request is used to instruct the Location to feed back the location of the terminal to the application when it detects a change in the location of the terminal.
  • the registration request may also include the application's positioning requirements, such as base station positioning.
  • Location responds to the registration request and can use base station positioning to obtain the location of the terminal.
  • Location can call back the application interface and feedback the location of the terminal to the application.
  • the terminal can detect whether the application running in the background initiates a registration request for network positioning to Location to detect whether the application running in the background is performing network positioning. Among them, if the application running in the background has initiated a registration request for network positioning to Location, the terminal can determine that the application running in the background is performing network positioning. If the application running in the background has not initiated a registration request for network positioning to Location, the terminal can determine that the application running in the background has not initiated a registration request for network positioning to Location. The app is not network targeted.
  • the positioning accuracy of network positioning is low.
  • an application running in the background performs network positioning, it means that the application running in the background can receive lower positioning accuracy. Therefore, when the terminal detects that the application running in the background performs network positioning, the terminal can freeze. Applications running in the background have a low impact on positioning accuracy.
  • Location can call back the interface of the application when the location of the terminal changes and feedback the location of the terminal to the application.
  • the application is in a frozen state, the application Unable to receive the location of the terminal from Location.
  • the third preset time period and the second preset time period may be equal to or different from each other.
  • the third preset time length may be different from the second preset time length, for example, the third preset time length may be 1.5 seconds. It should be understood that the starting point for the terminal to countdown may be the moment when the terminal completes freezing the application.
  • the application can continue to receive the location of the terminal from Location, so as to update the location of the terminal in real time.
  • the application when the third preset duration can be 1.5s, the application is frozen within the 1.5s duration, and the application does not occupy terminal resources, which can reduce terminal load.
  • the application performs network positioning, that is, the application can accept lower-precision positioning, so the application does not update the terminal's location within 1.5 seconds, which will not affect the user experience.
  • the absolute rest of the terminal can be understood as: the position and posture of the terminal have not changed.
  • the terminal may detect whether the terminal's location changes based on the terminal's location from Location.
  • the terminal may include an acceleration sensor, a gyroscope, etc., and the terminal may detect the posture of the terminal based on the data collected by the acceleration sensor, gyroscope, etc., and further detect whether the posture of the terminal changes. Embodiments of the present application The process of the terminal obtaining the posture of the terminal will not be described in detail.
  • the terminal when neither the position nor the posture of the terminal changes, the terminal can determine that the terminal is absolutely stationary. When the terminal is absolutely stationary, the terminal does not need to update the location of the terminal. In this way, the terminal can freeze applications running in the background to reduce the resource usage of the terminal.
  • the terminal determines that the terminal is not absolutely stationary, and the terminal can continue to use network positioning, that is, the terminal does not respond and does not freeze applications running in the background.
  • the terminal can determine whether to freeze applications running in the background based on user-perceivable tasks performed in the background of the terminal and corresponding freezing conditions, so as to reduce the occupation of terminal resources by applications running in the background.
  • tasks that users can perceive include: playing audio, positioning, etc.
  • the above S201-S211 can be performed for user-perceivable applications running in the background.
  • the application processing method provided by the embodiment of the present application is described below with reference to FIG. 3 .
  • the terminal when the application is running in the foreground, the terminal does not freeze the application.
  • the terminal can freeze the application when the application that the user is not aware of runs for a preset period of time.
  • the terminal can freeze the application on demand. Freezing on demand can It is understood that the terminal can freeze the application as described in S201-S211 above.
  • the terminal can adaptively adjust the steps performed by the terminal for different types of user-perceivable applications running in the background, and can also achieve the purpose of reducing the amount of terminal resources occupied by applications running in the background.
  • a whitelist may be stored in the terminal.
  • the whitelist includes identification of different types of user-perceivable applications and processing steps when the application is running in the background.
  • the identification of an application may include but is not limited to: the name of the application, a picture, and other information used to distinguish the application.
  • the applications stored in the whitelist may include: first type applications, second type applications, and third type applications.
  • the first type of application only plays audio when running in the background
  • the second type of application only performs positioning when running in the background
  • the third type of application can both play audio and perform positioning when running in the background.
  • the first type of applications includes audiobook applications, audio applications, and social networking applications
  • the second type of applications includes city parking applications.
  • the third type of application is a navigation application. When the navigation application is running in the background, it can position and play navigation audio.
  • the terminal when the first type of application is running in the background, the terminal may perform S201-S205.
  • the terminal when the first type of application does not play audio in the background, even if the terminal freezes the application, the user will not notice it. Therefore, when the first type of application does not play audio in the background, the terminal can freeze the first type of application.
  • the terminal when the first type of application plays audio in the background, if the terminal detects that the duration of the audio stream buffered in AudioFlinger's buffer is less than the first preset duration, it means that there are fewer audio streams buffered in the buffer, and the terminal does not need to freeze the first audio stream.
  • a type of application so that AudioFlinger can continue to cache audio streams in the buffer to ensure continuous uninterrupted audio playback and improve user experience.
  • the terminal can execute S206-S211.
  • the terminal can execute S201-S211.
  • the terminal can perform different processing operations to detect whether the application meets the freezing conditions.
  • the terminal can freeze the application to reduce the impact of the application. Occupy terminal resources and reduce terminal load.
  • the terminal can adaptively reduce processing operations and improve processing efficiency.
  • the terminal can detect whether the application meets the freezing conditions, and then freeze the application when the application running in the background and perceivable by the user meets the freezing conditions. It can reduce the usage of terminal resources by applications running in the background and visible to users.
  • the terminal can also perform a countdown to unfreeze the application when the countdown ends, so that the audio playback is not interrupted, and the terminal can continue to update the terminal location without affecting the user experience.
  • the application can download audio data from the server, and the application calls AudioTrack to decode the audio data and obtain the audio stream.
  • Applications can stream audio to AudioFlinger.
  • AudioFlinger caches the received audio stream in AudioFlinger's buffer, and calls the Audio HAL of the hardware abstraction layer to control the audio hardware to play audio.
  • the application can initiate a registration request to Location during positioning.
  • Location can call back the application's interface when the terminal's location changes and feedback the terminal's location to the application.
  • the freezing module can connect applications and locations. Among them, when the location of the terminal changes, Location calls back the application interface and feeds back the location of the terminal to the freezing module.
  • the freezing module may not feedback the location of the terminal to the application, that is, the application cannot receive the location of the terminal from Location.
  • the freezing module can feed back the location of the terminal from Location to the application, and the application can receive the location of the terminal.
  • the application processing method provided by the embodiment of the present application may include:
  • S601 The freezing module detects whether the application running in the background is playing audio. If yes, execute S602; if not, execute S608.
  • the freezing module can detect in real time whether an application running in the background is playing audio.
  • the freezing module may detect whether an application running in the background is playing audio in response to a target event from the event transmission module.
  • a target event please refer to the relevant description in S201.
  • the event transmission module can send a target event to the freezing module.
  • the freeze module responds to the target event and can detect whether an application running in the background is playing audio event transport module.
  • the freezing module detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration. If yes, execute S603; if not, execute S608.
  • S602 may refer to the relevant description in S202.
  • the freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
  • the freezing module can write the identity of the process of the application running in the background to a node in the kernel layer. For example, the freezing module can write the process ID of the application running in the background to the node of the kernel layer.
  • the freezing module can also write a freezing identifier in the node to instruct the process management module to freeze the written process.
  • S604 The process management module freezes the process in response to the identification of the process written in the node.
  • the process management module can monitor the node, and can detect the status of the process in response to the identification of the process written in the node.
  • the status of the process includes frozen status and unfrozen status. If the process management module detects that the process is in a thawed state, the process management module freezes the process in response to the identification of the process.
  • the process management module may freeze the process in response to the frozen identification written in the node and the identification of the process.
  • S605 The freezing module counts down, and the countdown time is the second preset time length.
  • S605 may refer to the relevant description in S204. There is no order distinction between S605 and S604, and both can be executed at the same time.
  • the freezing module can also write a defrosting identifier in the node to instruct the written process to be defrosted.
  • the process management module responds to the identification of the process written in the node and unfreezes the process.
  • the process management module can detect the status of the process in response to the identification of the process written in the node. If the process management module detects that the process is in a frozen state, the process management module responds to the identification of the process and unfreezes the process. .
  • the process management module can unfreeze the process in response to the unfrozen identifier written in the node and the process identifier.
  • the freezing module detects whether the application running in the background is performing network positioning. If yes, execute S609; if not, execute S616.
  • S608 may refer to the relevant description in S206.
  • the freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
  • S610 The process management module freezes the process in response to the identification of the process written in the node.
  • the freezing module responds to receiving the location of the terminal from Location and does not feedback the location of the terminal to the application.
  • the freezing module may not feed back the location of the terminal to the application when receiving the location of the terminal from Location.
  • the freezing module counts down, and the countdown time is the third preset time length.
  • S612 may refer to the relevant description in S208. There is no order distinction between S610 and S609, and both can be executed at the same time.
  • the freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
  • the process management module responds to the identification of the process written in the node and unfreezes the process.
  • S613-S614 may refer to the relevant descriptions in S606-S607.
  • the freezing module responds to receiving the location of the terminal from Location and feeds back the location of the terminal to the application.
  • the freezing module can feedback the location of the terminal to the application when receiving the location of the terminal from Location.
  • the application can update the location of the terminal based on the location of the terminal from the freezing module. .
  • S616 The freezing module detects whether the terminal is absolutely still. If yes, execute S609; if not, execute S617.
  • S616 may refer to the relevant description in S210.
  • the freezing module determines that the terminal is not absolutely stationary and can continue to perform network positioning.
  • the freezing module does not freeze applications running in the background.
  • some of the steps shown in Figure 6 are optional steps, and the steps can be combined with each other.
  • the modules shown in Figure 6 can also be combined, and the combined modules are used for the steps performed by the modules.
  • the application processing method provided by the embodiments of this application is introduced from the perspective of internal module interaction of the terminal.
  • freezing and thawing of applications running in the background and perceivable by the user can be realized.
  • freezing At the same time, it can reduce the application's occupation of terminal resources.
  • it can also unfreeze the application in time without affecting the user experience.
  • the embodiment of the present application further provides an electronic device, and the electronic device may be the terminal described in the above embodiment.
  • the electronic device may include: a processor 701 (such as a CPU) and a memory 702 .
  • the memory 702 may include high-speed random-access memory (RAM), and may also include non-volatile memory (non-volatile memory, NVM), such as at least one disk memory.
  • RAM random-access memory
  • NVM non-volatile memory
  • Various instructions may be stored in the memory 702 , to complete various processing functions and implement the method steps of the present application.
  • the electronic device involved in this application may also include: a power supply 703, a communication bus 704, and a communication port 705.
  • the above-mentioned communication port 705 is used to realize connection and communication between the electronic device and other peripheral devices.
  • the memory 702 is used to store computer executable program code, and the program code includes instructions; when the processor 701 executes the instructions, the instructions cause the processor 701 of the electronic device to perform the actions in the above method embodiment, which implements The principles and technical effects are similar and will not be repeated here.
  • modules or components described in the above embodiments may be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASICs), or , one or more microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays (field programmable gate array, FPGA), etc.
  • ASICs application specific integrated circuits
  • DSP digital signal processor
  • FPGA field programmable gate array
  • the processing element can be a general processor, such as a central processing unit (CPU) or other processors that can call the program code such as a control device.
  • these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • SOC system-on-a-chip
  • a computer program product includes one or more computer instructions.
  • Computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g., computer instructions may be transmitted from a website, computer, server or data center via a wired link (e.g.
  • Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless means to transmit to another website site, computer, server or data center.
  • Computer-readable storage media can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or other integrated media that contains one or more available media. Available media may be magnetic media (eg, floppy disk, hard disk, tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), etc.
  • the term "plurality” as used herein means two or more.
  • the term “and/or” in this article is just an association relationship that describes related objects, indicating that three relationships can exist. For example, A and/or B can mean: A exists alone, A and B exist simultaneously, and they exist alone. B these three situations.
  • the character "/" in this article generally indicates that the related objects before and after are an “or” relationship; in the formula, the character "/” indicates that the related objects before and after are a “division” relationship.
  • words such as “first” and “second” are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating. Or suggestive order.
  • the size of the sequence numbers of the above-mentioned processes does not mean the order of execution.
  • the execution order of each process should be determined by its functions and internal logic, and should not be used in the implementation of the present application.
  • the implementation of the examples does not constitute any limitations.

Landscapes

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

Abstract

Provided in the embodiments of the present application are an application processing method and an electronic device. The method comprises: when an application, which is run in the background, is playing audio, detecting whether the duration of an audio stream, which is cached in a buffer of an AudioFlinger, is greater than or equal to a first preset duration; and in response to the duration of the audio stream, which is cached in the buffer, being greater than or equal to the first preset duration, freezing the application, and when the application is frozen, the application continuing to play the audio. In the embodiments of the present application, for an application which can be perceived by a user when run in the background, freezing management can be performed without affecting the user experience, for example, the user can continue to listen to music.

Description

应用处理方法和电子设备Application processing methods and electronic devices
本申请要求于2022年08月15日提交中国专利局、申请号为202210972739.3、申请名称为“应用处理方法和电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application filed with the China Patent Office on August 15, 2022, with application number 202210972739.3 and application name "Application Processing Method and Electronic Device", the entire content of which is incorporated into this application by reference.
技术领域Technical field
本申请实施例涉及终端技术领域,尤其涉及一种应用处理方法和电子设备。The embodiments of the present application relate to the field of terminal technology, and in particular, to an application processing method and electronic device.
背景技术Background technique
终端上安装的应用越来越多,应用丰富的功能可以便利用户的生活。应用在后台运行时,也会占用终端资源,导致终端资源紧张。More and more applications are installed on terminals, and the rich functions of applications can facilitate users' lives. When the application is running in the background, it will also occupy terminal resources, causing terminal resource shortage.
目前,当一些应用运行在后台时,终端可以冻结运行时长大于预设时长的应用,以减少终端资源的占用。但对于运行在后台时用户可感知的应用,如播放音频的应用,进行定位导航的应用等,这类应用虽然被用户切换到后台运行了,但仍在执行用户可感知到的功能,如播放音频、进行定位导航等。因此为了保障用户体验,终端不会冻结这些应用,这些应用仍会占用终端资源。Currently, when some applications are running in the background, the terminal can freeze applications that have a running time longer than the preset time to reduce the usage of terminal resources. However, for applications that are perceptible to the user when running in the background, such as applications that play audio, applications that perform positioning and navigation, etc., although such applications are switched to the background by the user, they are still performing functions that are perceptible to the user, such as playing audio, positioning and navigation, etc. Therefore, in order to ensure user experience, the terminal will not freeze these applications, and these applications will still occupy terminal resources.
因此,亟需一种对运行在后台时用户可感知的应用的处理方法。Therefore, there is an urgent need for a method of processing applications that are user-aware when running in the background.
发明内容Contents of the invention
本申请实施例提供一种应用处理方法和电子设备,可以对运行在后台时用户可感知的应用进行冻结。Embodiments of the present application provide an application processing method and an electronic device, which can freeze applications that are perceptible to users when running in the background.
第一方面,本申请实施例提供一种应用处理方法,执行该方法的执行主体可以为终端或终端中的芯片,下述以终端为例进行说明。该方法中,当运行在后台的应用正在播放音频时,终端检测AudioFlinger的缓存器中缓存的音频流的时长是否大于或等于第一预设时长。本申请实施例中,相较于现有技术中的AudioFlinger的缓存器,可以增大AudioFlinger的缓存器的容量,如现有技术中AudioFlinger的缓存器可以缓存1k的音频流,本申请实施例中的AudioFlinger的缓存器可以缓存1M的音频流。In the first aspect, embodiments of the present application provide an application processing method. The execution subject that executes the method may be a terminal or a chip in the terminal. The following description takes the terminal as an example. In this method, when the application running in the background is playing audio, the terminal detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration. In the embodiment of this application, compared with the buffer of AudioFlinger in the prior art, the capacity of the buffer of AudioFlinger can be increased. For example, the buffer of AudioFlinger in the prior art can cache 1k audio stream. In the embodiment of this application The AudioFlinger buffer can buffer 1M audio streams.
终端响应于所述缓存器中缓存的音频流的时长大于或等于所述第一预设时长,表征缓存器中已经缓存了足够的音频流,能够维持一段时间播放,因此终端可以冻结运行在后台正在播放音频的应用,以减少该应用对终端资源的占用。其中,当所述应用被冻结时,所述应用可以根据缓存器中缓存的音频,继续播放音频,这样在冻结应用后,用户仍可以听到后台应用播放音频,用户不感知后台应用已经被冻结。The terminal responds that the duration of the audio stream buffered in the buffer is greater than or equal to the first preset duration, indicating that enough audio streams have been buffered in the buffer to maintain playback for a period of time, so the terminal can freeze and run in the background. The application that is playing audio to reduce the application's occupation of terminal resources. When the application is frozen, the application can continue to play the audio based on the audio cached in the buffer. In this way, after the application is frozen, the user can still hear the audio played by the background application, and the user does not perceive that the background application has been frozen. .
本申请实施例中,对于后台运行时用户可感知的应用,终端可以进行冻结管理,以减少应用对终端资源的占用,另外,在应用被冻结后,用户可以继续听到应用播放的音乐,不影响用户体验。In the embodiment of this application, for applications that are perceptible to users when running in the background, the terminal can perform freezing management to reduce the application's occupation of terminal resources. In addition, after the application is frozen, the user can continue to listen to the music played by the application. Affect user experience.
在一种可能的实现方式中,终端检测AudioFlinger的缓存器中缓存的音频流的时长是否大于或等于第一预设时长之前,还可以响应于目标事件,检测运行在后台的应用是否正在播放音频,所述目标事件为如下任一项触发的事件:应用启动、界面切换,以及终端掉帧。其中,终端可以响应于所述缓存器中缓存有所述应用的音频流,确定所述应用正在播放音频。终端响应于所述缓存器中缓存没有所述应用的音频流,确定所述应用未播放音频。In one possible implementation, before the terminal detects whether the duration of the audio stream cached in the buffer of AudioFlinger is greater than or equal to the first preset duration, the terminal can also respond to the target event to detect whether the application running in the background is playing audio. , the target event is an event triggered by any of the following: application startup, interface switching, and terminal frame dropping. Wherein, the terminal may determine that the application is playing audio in response to the audio stream of the application being cached in the buffer. The terminal determines that the application does not play audio in response to the audio stream of the application being cached in the buffer.
目标事件为终端负载要求比较高的事件,如应用启动、界面切换,或者目标事件为表征终端已经高负载的事件,如终端掉帧。在一种示例中,目标事件可以理解为:会导致终端高负载的事件,或者可以表征终端高负载的事件。本申请实施例中,在终端检测到目标事件的情况下,执行本申请提供的应用处理方法的目的在于:降低终端的负载,保证终端顺利运行,避免应用卡顿、闪退等问题影响用户体验。The target event is an event with relatively high terminal load requirements, such as application startup and interface switching, or the target event is an event that indicates that the terminal is already under high load, such as terminal frame drop. In one example, the target event can be understood as: an event that will cause a high load on the terminal, or an event that can characterize a high load on the terminal. In the embodiment of this application, when the terminal detects the target event, the purpose of executing the application processing method provided by this application is to: reduce the load of the terminal, ensure the smooth operation of the terminal, and avoid problems such as application lags and crashes that affect the user experience. .
在一种可能的实现方式中,终端在冻结所述应用之后,还可以进行倒计时,所述倒计时的时长为第二预设时长,所述第二预设时长小于所述第一预设时长。终端进行倒计时的目的在于:在缓存器中缓存的音频流播放完之前,解冻应用,使得应用继续在缓存器中缓存音频流,避免缓存器中的音频流播放完,用户感知音频中断播放。In a possible implementation, after freezing the application, the terminal may also perform a countdown, and the countdown time is a second preset time length, and the second preset time length is less than the first preset time length. The purpose of the terminal's countdown is to unfreeze the application before the audio stream cached in the cache is played, so that the application continues to cache the audio stream in the cache, so as to avoid the audio stream in the cache being played out and the user's perception of audio interruption.
终端在倒计时结束时,解冻所述应用。其中,倒计时的时长为第二预设时长,所述第二预设时长小 于所述第一预设时长,可以保证缓存器中的音频流播放完之前,应用在缓存器中继续缓存音频流,可以保证音频的连续性。When the countdown ends, the terminal unfreezes the application. Wherein, the duration of the countdown is a second preset duration, and the second preset duration is smaller than During the first preset duration, it is ensured that before the audio stream in the buffer is played, the application continues to buffer the audio stream in the buffer, thereby ensuring audio continuity.
在一种可能的实现方式中,终端检测AudioFlinger的缓存器中缓存的音频流的时长是否大于或等于第一预设时长时,若缓存器中缓存的音频流的时长小于所述第一预设时长,表征缓存器中缓存的音频流很快就能播放完,为了不影响用户体验,终端可以不冻结应用。In a possible implementation, the terminal detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration. If the duration of the audio stream buffered in the buffer is less than the first preset duration, The duration indicates that the audio stream cached in the cache will be played quickly. In order not to affect the user experience, the terminal does not need to freeze the application.
另,终端可以检测所述应用是否在进行网络定位。终端检测应用是否在进行网络定位的目的是为了更全面地对后台运行的应用进行冻结管理。应理解,网络定位可以理解为基站定位,网络定位的定位精度低,即终端可以接受较低的定位精度,因此将应用冻结一段时间,也不会影响用户体验。In addition, the terminal can detect whether the application is performing network positioning. The purpose of the terminal detecting whether the application is performing network positioning is to more comprehensively freeze and manage the applications running in the background. It should be understood that network positioning can be understood as base station positioning. The positioning accuracy of network positioning is low, that is, the terminal can accept lower positioning accuracy. Therefore, freezing the application for a period of time will not affect the user experience.
在该种实现方式中,终端响应于所述应用在进行网络定位,冻结所述应用。终端在冻结应用后,可以进行倒计时,所述倒计时的时长为第三预设时长。终端冻结应用可以减少应用对终端资源的占用,降低终端负载,终端进行倒计时的目的在于:避免应用长时间冻结,导致用户感知应用不定位,避免影响用户体验。在倒计时结束时,终端可以解冻所述应用,应用可以继续进行网络定位。In this implementation manner, the terminal freezes the application in response to the application performing network positioning. After freezing the application, the terminal may perform a countdown, and the countdown duration is the third preset duration. Freezing applications on the terminal can reduce the application's occupation of terminal resources and reduce terminal load. The purpose of terminal countdown is to prevent applications from freezing for a long time, causing users to perceive that the application is not positioned, and to avoid affecting the user experience. At the end of the countdown, the terminal can unfreeze the application, and the application can continue to perform network positioning.
在一种可能的实现方式中,终端检测所述应用是否在进行网络定位时,若所述应用未进行网络定位,终端可以检测所述终端是否绝对静置。终端检测终端是否绝对静置的目的是为了更全面地对后台运行的应用进行冻结管理。应理解,绝对静置可以理解为:终端的位置和姿态均未发生变化。In a possible implementation, when the terminal detects whether the application is performing network positioning, if the application is not performing network positioning, the terminal may detect whether the terminal is absolutely stationary. The purpose of the terminal detecting whether the terminal is absolutely stationary is to more comprehensively freeze and manage applications running in the background. It should be understood that absolute stillness can be understood as: the position and attitude of the terminal have not changed.
在终端绝对静置的情况下,终端可以冻结所述应用,以减少应用对终端资源的占用。在该实现方式中,终端可以在检测到终端的位置或姿态变化时,解冻应用。When the terminal is absolutely stationary, the terminal can freeze the application to reduce the application's occupation of terminal resources. In this implementation, the terminal can unfreeze the application when detecting a change in the terminal's position or attitude.
下面结合终端中包括的内部模块,从内部模块的角度,讲述本申请实施例提供的应用处理方法,在一种示例中,所述终端包括:冻结模块和进程管理模块。The following describes the application processing method provided by the embodiment of the present application from the perspective of the internal modules included in the terminal. In one example, the terminal includes: a freezing module and a process management module.
其中,所述冻结模块响应于所述缓存器中缓存的音频流的时长大于或等于所述第一预设时长,将所述音频流对应的进程的标识写入节点,所述进程为所述应用的进程。所述进程管理模块响应于所述节点中写入所述进程的标识,冻结所述进程。Wherein, in response to the duration of the audio stream cached in the buffer being greater than or equal to the first preset duration, the freezing module writes the identifier of the process corresponding to the audio stream into the node, and the process is the application process. The process management module freezes the process in response to the identification of the process written in the node.
相应的,当应用需要解冻时,所述冻结模块将待解冻的应用的进程写入节点,所述进程管理模块响应于所述节点中写入所述进程的标识,可以解冻所述进程。Correspondingly, when an application needs to be unfrozen, the freezing module writes the process of the application to be unfrozen into the node, and the process management module can unfreeze the process in response to writing the identifier of the process in the node.
在一种可能的实现方式中,所述终端还包括:Location,所述Location用于获取所述终端的位置,且反馈至所述冻结模块。In a possible implementation, the terminal further includes: Location, the Location is used to obtain the location of the terminal and feed it back to the freezing module.
其中,当所述应用在进行网络定位,且所述应用被冻结后,所述冻结模块响应于来自Location的所述终端的位置,不向所述应用发送所述终端的位置。这样应用无法接收到终端的位置,因此不会进行位置更新等操作。Wherein, when the application is performing network positioning and the application is frozen, the freezing module responds to the location of the terminal from Location and does not send the location of the terminal to the application. In this way, the application cannot receive the terminal's location, so operations such as location updates will not be performed.
当所述应用在进行网络定位,且所述应用被解冻后,所述冻结模块响应于来自Location的所述终端的位置,向所述应用发送所述终端的位置。这样应用可以接收到终端的位置,可以子继续进行位置更新、播放位置等操作。When the application is performing network positioning and the application is unfrozen, the freezing module responds to the location of the terminal from Location and sends the location of the terminal to the application. In this way, the application can receive the location of the terminal and continue to perform operations such as location update and playback location.
第二方面,本申请实施例提供一种电子设备,该电子设备可以包括:处理器、存储器。存储器用于存储计算机可执行程序代码,程序代码包括指令;当处理器执行指令时,指令使所述电子设备执行如第一方面中的方法。In a second aspect, embodiments of the present application provide an electronic device, which may include a processor and a memory. The memory is used to store computer-executable program code, and the program code includes instructions; when the processor executes the instructions, the instructions cause the electronic device to perform the method in the first aspect.
第三方面,本申请实施例提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面中的方法。In a third aspect, embodiments of the present application provide a computer program product containing instructions that, when run on a computer, cause the computer to execute the method in the first aspect.
第四方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面中的方法。In a fourth aspect, embodiments of the present application provide a computer-readable storage medium that stores instructions that, when run on a computer, cause the computer to execute the method in the first aspect.
上述第二方面至第四方面的各可能的实现方式,其有益效果可以参见上述第一方面所带来的有益效果,在此不加赘述。The beneficial effects of each possible implementation manner of the above-mentioned second aspect to the fourth aspect can be referred to the beneficial effects brought by the above-mentioned first aspect, and will not be described again here.
附图说明Description of drawings
图1为本申请实施例提供的终端的一种结构示意图;Figure 1 is a schematic structural diagram of a terminal provided by an embodiment of the present application;
图2为本申请实施例提供的应用处理方法的一种实施例的流程示意图;Figure 2 is a schematic flow chart of an embodiment of the application processing method provided by the embodiment of the present application;
图3为本申请实施例提供的应用处理方法的另一种实施例的流程示意图;Figure 3 is a schematic flowchart of another embodiment of the application processing method provided by the embodiment of the present application;
图4为本申请实施例提供的应用播放音频的一种流程示意图; Figure 4 is a schematic flow chart of an application playing audio provided by an embodiment of the present application;
图5为本申请实施例提供的应用进行网络定位的一种流程示意图;Figure 5 is a schematic flow chart of network positioning using an application provided by an embodiment of the present application;
图6为本申请实施例提供的应用处理方法的另一种实施例的流程示意图;Figure 6 is a schematic flowchart of another embodiment of the application processing method provided by the embodiment of the present application;
图7为本申请实施例提供的电子设备的一种结构示意图。FIG. 7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
具体实施方式Detailed ways
本申请实施例涉及的专业术语释义:Definitions of professional terms involved in the embodiments of this application:
应用运行在前台:终端在前台运行应用,应用进程为前台进程。当应用运行在前台时,终端显示应用的界面,用户可见应用的界面。示例性的,如应用为通话应用,通话应用运行在前台可以理解为:终端显示通话界面。应用运行在前台也可以称为:应用在前台运行。The application runs in the foreground: the terminal runs the application in the foreground, and the application process is the foreground process. When the application is running in the foreground, the terminal displays the application interface and the user can see the application interface. For example, if the application is a call application, running the call application in the foreground can be understood as: the terminal displays the call interface. Application running in the foreground can also be called: application running in the foreground.
应用运行在后台:终端在后台运行应用,应用进程为后台进程。当应用运行在后台时,终端可以显示其他应用的界面,不显示运行在后台的应用的界面,即用户不可见运行在后台的应用的界面。或者,终端可以在其他应用的界面上,显示表征应用运行在后台的标识。示例性的,通话应用运行在后台时,终端在界面上可以显示表征“正在通话”的卡片,卡片上可以显示通话时长等信息,卡片可以看做表征通话应用运行在后台的标识。应用运行在后台也可以称为:应用在后台运行。The application runs in the background: The terminal runs the application in the background, and the application process is a background process. When an application is running in the background, the terminal can display the interface of other applications without displaying the interface of the application running in the background, that is, the user cannot see the interface of the application running in the background. Alternatively, the terminal can display a logo indicating that the application is running in the background on the interface of other applications. For example, when the calling application is running in the background, the terminal can display a card indicating "on a call" on the interface, and information such as the call duration can be displayed on the card. The card can be regarded as a symbol indicating that the calling application is running in the background. Application running in the background can also be called: application running in the background.
进程:看作正在运行的程序的实例,每个应用运行于独立的进程。Process: Considered as an instance of a running program, each application runs in an independent process.
冻结:本申请实施例指的是冻结应用的进程。其中,冻结应用也可以理解为冻结应用的进程。Freezing: The embodiment of this application refers to freezing the application process. Among them, freezing an application can also be understood as freezing an application's process.
解冻:解冻已被冻结的应用的进程。Unfreeze: Unfreeze the frozen application process.
运行在后台时用户可感知的应用:包括但不限于播放音频的应用,进行定位的应用。示例性的,播放音频的应用运行在后台时,还会继续播放音频,用户可以听到音频,因此播放音频的应用运行在后台时对用户是可感知的。又一示例性地,进行定位的应用运行在后台时,还会继续定位终端的位置,且播放音频以通知终端的位置,用户可以感知到终端的位置,因此进行定位的应用运行在后台时对用户是可感知的。User-perceivable applications running in the background: including but not limited to applications that play audio and applications that perform positioning. For example, when an application that plays audio is running in the background, it will continue to play audio, and the user can hear the audio. Therefore, when the application that plays audio is running in the background, it is perceivable to the user. In another example, when the positioning application is running in the background, it will continue to locate the position of the terminal and play audio to notify the terminal's position. The user can perceive the position of the terminal. Therefore, when the positioning application is running in the background, it will continue to locate the position of the terminal. The user is aware.
本申请实施例中的终端(terminal)可以称为用户设备(user equipment,UE)。例如,终端可以为手机、平板电脑(portable android device,PAD)、个人数字处理(personal digital assistant,PDA)、具有无线通信功能的手持设备、计算设备、车载设备或可穿戴设备,虚拟现实(virtual reality,VR)终端设备、增强现实(augmented reality,AR)终端设备、工业控制(industrial control)中的无线终端、智慧家庭(smart home)中的终端等,本申请实施例中对终端的形态不做具体限定。The terminal in the embodiment of this application may be called user equipment (UE). For example, the terminal can be a mobile phone, a tablet (portable android device, PAD), a personal digital assistant (PDA), a handheld device with wireless communication capabilities, a computing device, a vehicle-mounted device or a wearable device, a virtual reality (virtual reality) reality (VR) terminal equipment, augmented reality (AR) terminal equipment, wireless terminals in industrial control (industrial control), terminals in smart home (smart home), etc. In the embodiments of this application, the form of the terminal does not matter. Make specific limitations.
应用运行在前台或后台时均会占用终端资源,终端资源可以包括但不限于:终端中处理器的资源、内存资源,以及输入/输出(input/output,I/O)资源。当终端中运行的应用的数量较多时,导致终端高负载,会导致应用响应慢,甚至无响应、闪退等问题。运行在前台的应用为用户需求的应用,终端通常不会冻结前台运行的应用,而是通过冻结后台运行的应用,减少终端资源的占用,降低终端的负载。Applications will occupy terminal resources when running in the foreground or background. Terminal resources may include but are not limited to: processor resources, memory resources, and input/output (I/O) resources in the terminal. When there are a large number of applications running on the terminal, the terminal will be under high load, which will lead to slow application response, even no response, crashes and other problems. The applications running in the foreground are applications required by the user. The terminal usually does not freeze the applications running in the foreground. Instead, it freezes the applications running in the background to reduce the occupation of terminal resources and reduce the load on the terminal.
应注意,为了提高用户体验,现有技术方案中,终端冻结的后台运行的应用不包括用户可感知的应用。示例性的,用户可感知的应用包括但不限于:播放音频的应用,进行定位的应用。在一些示例中,可以将运行在后台时用户可感知的应用称为目标应用。其中,当目标应用运行在后台时,若终端冻结目标应用,则用户可以感知到终端不播放音频,不进行定位(导航)等,导致用户体验低,因此目前目标应用运行在后台时,终端不会冻结目标应用。It should be noted that in order to improve user experience, in the existing technical solution, the applications running in the background frozen by the terminal do not include applications that are perceptible to the user. Examples of user-perceivable applications include, but are not limited to: applications for playing audio and applications for positioning. In some examples, an application that is user-aware when running in the background may be referred to as a target application. Among them, when the target application is running in the background, if the terminal freezes the target application, the user can perceive that the terminal does not play audio, does not perform positioning (navigation), etc., resulting in a low user experience. Therefore, when the target application is currently running in the background, the terminal cannot The target application will be frozen.
在一种实施例中,当目标应用运行在后台时,目标应用的主进程可以绑定一个服务进程,由服务进程完成音频播放、定位等任务。In one embodiment, when the target application is running in the background, the main process of the target application can be bound to a service process, and the service process completes tasks such as audio playback and positioning.
其中,在一种实施例中,当目标应用运行在后台时,终端可以提高目标应用的优先级,终端会冻结运行在后台的低优先级的应用,由于目标应用的优先级高,终端不会冻结目标应用。在一种实施例中,可以预先设置应用运行在后台时的处理规则,目标应用运行在后台时的处理规则可以为:不冻结。在该种实施例中,当目标应用运行在后台时,终端根据目标应用运行在后台时的处理规则,不冻结目标应用。In one embodiment, when the target application is running in the background, the terminal can increase the priority of the target application, and the terminal will freeze the low-priority application running in the background. Since the target application has a high priority, the terminal will not Freeze the target application. In one embodiment, the processing rules when the application is running in the background can be preset, and the processing rules when the target application is running in the background can be: do not freeze. In this embodiment, when the target application is running in the background, the terminal does not freeze the target application according to the processing rules when the target application is running in the background.
为了提高用户体验,如上两种实现方式采用不同的方式,不冻结运行在后台的目标应用。运行在后台的目标应用也会占用终端资源,导致终端高负载。In order to improve user experience, the above two implementation methods adopt different methods and do not freeze the target application running in the background. Target applications running in the background will also occupy terminal resources, causing high load on the terminal.
有鉴于此,本申请实施例提供一种应用处理方法,可以对运行在后台时用户可感知的应用进行冻结和解冻,以减少运行在后台时用户可感知的应用占用的终端资源,降低终端负载。 In view of this, embodiments of the present application provide an application processing method that can freeze and unfreeze applications that are perceivable to users when running in the background, so as to reduce terminal resources occupied by applications perceivable to users when running in the background and reduce terminal load. .
在介绍本申请实施例提供的应用处理方法之前,先介绍本申请实施例提供的终端的结构:Before introducing the application processing method provided by the embodiment of the present application, the structure of the terminal provided by the embodiment of the present application is first introduced:
图1为本申请实施例提供的终端的一种结构示意图。参照图1,终端的软件系统可以采用分层架构,分层架构将终端的软件系统分成若干个层,每一层都有清晰的角色和分工,层与层之间通过软件接口通信。在一些示例中,可以将软件系统分为五层,分别为应用程序层(applications)、应用程序框架层(application framework)、安卓运行时(Android runtime)和系统库、硬件抽象层(hardware abstract layer,HAL)以及内核层(kernel)。本申请实施例对终端的软件结构的分层不做限制。Figure 1 is a schematic structural diagram of a terminal provided by an embodiment of the present application. Referring to Figure 1, the terminal software system can adopt a layered architecture. The layered architecture divides the terminal software system into several layers. Each layer has a clear role and division of labor, and the layers communicate through software interfaces. In some examples, the software system can be divided into five layers, namely application layer, application framework layer, Android runtime and system library, and hardware abstract layer. , HAL) and the kernel layer (kernel). The embodiments of the present application do not limit the layering of the software structure of the terminal.
应理解,图1中示出了本申请实施例涉及到的应用层、应用程序框架层、硬件抽象层,以及内核层。图1中所示的各分层中包括的模块为本申请实施例中涉及到的模块,如下各分层中包括的模块并不构成对终端的结构的限定,模块部署的层级也并不构成对终端的结构的限定。在一些示例中,图1中所示的模块可以单独部署,或者几个模块可以部署在一起,图1中对模块的划分为一种示例。It should be understood that Figure 1 shows the application layer, application framework layer, hardware abstraction layer, and kernel layer involved in the embodiment of the present application. The modules included in each layer shown in Figure 1 are modules involved in the embodiments of the present application. The modules included in the following layers do not limit the structure of the terminal, nor does the level of module deployment. Limitations on the structure of the terminal. In some examples, the modules shown in Figure 1 can be deployed individually, or several modules can be deployed together, the division of modules in Figure 1 being one example.
应用程序层可以包括一系列应用程序包,应用程序层通过调用应用程序框架层所提供的应用程序接口(application programming interface,API)运行应用程序。如图1所示,应用程序包可以包括:目标应用、AudioTrack。The application layer can include a series of application packages. The application layer runs applications by calling the application programming interface (API) provided by the application framework layer. As shown in Figure 1, the application package may include: target application, AudioTrack.
目标应用为运行在后台时用户可感知的应用。示例性的,目标应用包括但不限于:播放音频的应用,进行定位的应用。示例性的,播放音频的应用可以包括但不限于:音频类应用、社交类应用,导航类应用,以及视频类应用。进行定位的应用可以包括但不限于:音频类应用、社交类应用,以及导航类应用。图1中以目标应用包括音频类应用和导航类应用为例进行说明。The target application is a user-aware application running in the background. Examples of target applications include but are not limited to: applications that play audio and applications that perform positioning. Examples of applications that play audio may include, but are not limited to: audio applications, social applications, navigation applications, and video applications. Applications for positioning may include, but are not limited to: audio applications, social applications, and navigation applications. Figure 1 takes the target application including audio application and navigation application as an example for illustration.
以音频类应用为例,音频类应用在播放音频时,可以创建AudioTrack实例。AudioTrack,用于被音频类应用调用以解码音频数据。在一些示例中,如音频类应用可以调用AudioTrack解码音频数据,得到脉冲编码调制(pulse code modulation,PCM)格式的音频流。Taking an audio application as an example, an audio application can create an AudioTrack instance when playing audio. AudioTrack, used to be called by audio applications to decode audio data. In some examples, audio applications can call AudioTrack to decode audio data and obtain audio streams in pulse code modulation (PCM) format.
应用程序框架层为应用程序层的应用程序提供API和编程框架。应用程序框架层包括一些预先定义的函数。如图1所示,应用程序框架层可以包括:AudioFlinger、Location,冻结模块,事件传输模块,以及前后台管理模块。其中,AudioFlinger可以看做是提供音频处理服务的模块,Location可以看做是提供定位服务的模块。The application framework layer provides APIs and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions. As shown in Figure 1, the application framework layer can include: AudioFlinger, Location, freezing module, event transmission module, and front and back management modules. Among them, AudioFlinger can be regarded as a module that provides audio processing services, and Location can be regarded as a module that provides positioning services.
AudioFlinger,音频策略的执行者,负责音频流的传输。AudioFlinger中可以设置有缓冲器(buffer),缓冲器用于缓存音频流。AudioFlinger, the executor of the audio strategy, is responsible for the transmission of audio streams. A buffer can be set up in AudioFlinger, and the buffer is used to cache the audio stream.
Location,用于为目标应用提供终端的位置。Location, used to provide the location of the terminal to the target application.
冻结模块,用于检测目标应用是否满足冻结条件,以在目标应用满足冻结条件时冻结目标应用,以及检测目标应用是否满足解冻条件,以在目标应用满足解冻条件时解冻目标应用。A freezing module is used to detect whether the target application meets the freezing conditions, to freeze the target application when the target application meets the freezing conditions, and to detect whether the target application meets the unfreezing conditions to unfreeze the target application when the target application meets the unfreezing conditions.
事件传输模块,用于向冻结模块发送事件,以触发冻结模块检测目标应用是否满足冻结条件。The event transmission module is used to send events to the freezing module to trigger the freezing module to detect whether the target application meets the freezing conditions.
前后台管理模块,用于检测目标应用运行在前台或后台,当目标应用运行在后台时,可以向冻结模块同步目标应用为后台运行的信息。The front and back management module is used to detect whether the target application is running in the foreground or the background. When the target application is running in the background, the information that the target application is running in the background can be synchronized to the freezing module.
硬件抽象层可以包含多个库模块,库模块如可以为摄像头库模块、马达库模块,以及扬声器库模块等。应用程序框架层可以通过调用硬件抽象层中相应的库模块,实现应用程序框架层访问设备硬件的目的。设备硬件可以包括如电子设备中的马达、摄像头、扬声器等。The hardware abstraction layer can include multiple library modules. The library modules can be, for example, camera library modules, motor library modules, and speaker library modules. The application framework layer can achieve the purpose of the application framework layer accessing the device hardware by calling the corresponding library module in the hardware abstraction layer. Device hardware may include motors, cameras, speakers, etc. in electronic devices.
如图1所示,硬件抽象层可以包括AudioHAL。As shown in Figure 1, the hardware abstraction layer may include AudioHAL.
其中,AudioFlinger通过调用AudioHAL,可以访问音频硬件播放音频。音频硬件如扬声器等。Among them, AudioFlinger can access the audio hardware to play audio by calling AudioHAL. Audio hardware such as speakers, etc.
内核层是硬件和软件之间的层。内核层用于驱动硬件,使得硬件工作。内核层至少包含显示驱动,摄像头驱动,音频驱动等,本申请实施例对此不做限制。如图1所示,内核层包括:进程管理模块和音频驱动。The kernel layer is the layer between hardware and software. The kernel layer is used to drive the hardware and make the hardware work. The kernel layer at least includes a display driver, a camera driver, an audio driver, etc., which are not limited in the embodiments of this application. As shown in Figure 1, the kernel layer includes: process management module and audio driver.
进程管理模块,用于管理目标应用的进程,示例性的,如进程管理模块可以冻结或解冻目标应用的进程。The process management module is used to manage the process of the target application. For example, the process management module can freeze or unfreeze the process of the target application.
音频驱动,用于驱动音频硬件工作。Audio driver, used to drive audio hardware.
应理解,如上简述了终端各层级中的模块的功能,具体的功能可以参图6中的相关描述。It should be understood that the functions of the modules at each level of the terminal are briefly described above. For specific functions, please refer to the relevant descriptions in Figure 6 .
下面结合具体的实施例对本申请实施例提供的应用处理方法进行说明。下面这几个实施例可以相互结合,对于相同或相似的概念或过程在某些实施例不再赘述。 The application processing method provided by the embodiment of the present application will be described below with reference to specific embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes will not be described again in some embodiments.
图2为本申请实施例提供的应用处理方法的一种实施例的流程示意图。参照图2,本申请实施例提供的应用处理方法可以包括:FIG. 2 is a schematic flowchart of an embodiment of the application processing method provided by the embodiment of the present application. Referring to Figure 2, the application processing method provided by the embodiment of the present application may include:
S201,检测后台运行的应用是否正在播放音频。若是,执行S202,若否,执行S206。S201, detect whether the application running in the background is playing audio. If yes, execute S202; if not, execute S206.
应用可以运行在前后或后台,终端可以确定应用运行在前台或后台。示例性的,当应用运行在前台时,应用的进程的标识被标注为前台运行,当应用运行在后台时,应用的进程的标识被标注为后台运行。终端可以根据进程的标识的标注,确定应用运行在前台或后台。Applications can run in the foreground or background, and the terminal can determine whether the application is running in the foreground or background. For example, when the application is running in the foreground, the identification of the application's process is marked as running in the foreground, and when the application is running in the background, the identification of the application's process is marked as running in the background. The terminal can determine whether the application is running in the foreground or background based on the process identifier.
在一些示例中,应用的进程的标识可以为应用的进程号。示例性的,当音频类应用运行在后台时,音频类应用的进程号被标注为后台运行,当导航类应用运行在后台时,导航类应用的进程号被标注为后台运行。如音频类应用和导航类应用均运行在后台,且音频类应用的进程号为进程1,导航类应用的进程为进程2,则进程1、进程2被标注为后台运行,终端可以根据进程1、进程2被标注为后台运行,确定音频类应用和导航类应用均运行在后台。In some examples, the identifier of the application's process may be the application's process number. For example, when the audio application is running in the background, the process number of the audio application is marked as running in the background. When the navigation application is running in the background, the process number of the navigation application is marked as running in the background. For example, if both the audio application and the navigation application are running in the background, and the process number of the audio application is process 1, and the process number of the navigation application is process 2, then process 1 and process 2 are marked as running in the background, and the terminal can be marked as running in the background according to process 1. , Process 2 is marked as running in the background, and it is determined that audio applications and navigation applications are running in the background.
在一种实施例中,终端可以实时检测后台运行的应用是否正在播放音频。In one embodiment, the terminal can detect in real time whether an application running in the background is playing audio.
在一种实施例中,终端可以响应于目标事件,可以检测后台运行的应用是否正在播放音频,以减少终端负载。其中,目标事件可以包括但不限于:启动应用、切换界面,或滑动掉帧等。换句话说,终端响应于检测到终端启动应用、切换界面,或滑动掉帧,可以检测后台运行的应用是否正在播放音频。In one embodiment, the terminal may respond to the target event and detect whether an application running in the background is playing audio to reduce the terminal load. Among them, the target event may include but is not limited to: starting an application, switching interfaces, or sliding to drop frames, etc. In other words, in response to detecting that the terminal starts an application, switches interfaces, or slides to drop frames, the terminal can detect whether the application running in the background is playing audio.
应理解,终端之所以响应于目标事件,检测后台运行的应用是否正在播放音频,是因为:启动应用或切换界面,对于终端负载要求比较高,目标事件的发生会增加终端负载,滑动掉帧表征终端负载已经较高,为了保证用户体验,避免因终端负载高导致应用卡顿的问题,终端可以在检测到目标事件时,检测后台运行的应用是否正在播放音频,进而可以触发终端冻结后台运行的播放音频的应用,以降低后台运行的播放音频对终端负载的占用,降低终端负载。It should be understood that the reason why the terminal responds to the target event and detects whether the application running in the background is playing audio is because: starting an application or switching interfaces requires relatively high terminal load. The occurrence of the target event will increase the terminal load, which is characterized by sliding frames. The terminal load is already high. In order to ensure the user experience and avoid the problem of application lagging due to high terminal load, the terminal can detect whether the application running in the background is playing audio when detecting the target event, which can trigger the terminal to freeze the application running in the background. Applications that play audio can reduce the occupation of the terminal load by playing audio running in the background and reduce the terminal load.
其中,终端启动应用可以理解为:终端创建应用进程,启动应用进程,以启动应用。示例性的,如应用未启动时,用户在终端的桌面上点击应用的图标,以触发终端启动应用。Among them, the terminal starting an application can be understood as: the terminal creates an application process and starts the application process to start the application. For example, when the application is not started, the user clicks the application icon on the desktop of the terminal to trigger the terminal to start the application.
切换界面可以理解为:终端的界面发生变化。Switching the interface can be understood as: the interface of the terminal changes.
终端掉帧可以理解为:终端在绘制画面帧时,绘制的画面帧的数量少于终端的刷新率对应的画面帧的数量,进而造成终端显示的画面帧的数量变少,甚至造成终端界面卡顿的问题。示例性的,以终端的刷新率为60Hz为例,终端每秒钟可以显示60帧画面帧,即每隔16.6ms显示一帧画面帧,但终端绘制画面帧时,绘制的帧数少于60帧,只绘制了30帧,导致终端显示的画面帧的数量变少,即终端掉帧。滑动掉帧为终端掉帧中的一种情况,滑动掉帧可以理解为:用户在终端界面上执行滑动操作时出现的界面掉帧。终端掉帧还可以包括点击掉帧,以及任一界面变化时的掉帧等,在一些示例中,目标事件可以包括终端掉帧。Terminal frame drop can be understood as: when the terminal draws picture frames, the number of picture frames drawn is less than the number of picture frames corresponding to the refresh rate of the terminal, which in turn causes the number of picture frames displayed by the terminal to decrease, and even causes the terminal interface to freeze. Dayton's question. For example, taking the refresh rate of the terminal as 60Hz as an example, the terminal can display 60 frames per second, that is, one frame is displayed every 16.6ms. However, when the terminal draws frames, the number of frames drawn is less than 60. frames, only 30 frames are drawn, resulting in fewer frames displayed on the terminal, that is, the terminal drops frames. Sliding frame drop is one of the terminal frame drops. Sliding frame drop can be understood as: interface frame drop that occurs when the user performs a sliding operation on the terminal interface. Terminal frame drops may also include click frame drops, frame drops when any interface changes, etc. In some examples, the target event may include terminal frame drops.
应用在播放音频时,应用可以调用AudioTrack解码音频数据,得到音频流。音频数据可以为本地存储的音频数据,或应用从服务端下载的音频数据,本申请实施例对此不做限制。应用可以将解码得到的音频流传输至AudioFlinger,AudioFlinger可以将接收到的音频流缓存在AudioFlinger的buffer中,以进行播放。其中,AudioFlinger可以边缓存音频流,边在buffer中读取音频流,调用硬件抽象层的Audio HAL,控制音频硬件播放音频。When an application plays audio, the application can call AudioTrack to decode the audio data and obtain the audio stream. The audio data may be locally stored audio data, or audio data downloaded from the server by the application, which is not limited in the embodiment of the present application. The application can transmit the decoded audio stream to AudioFlinger, and AudioFlinger can cache the received audio stream in AudioFlinger's buffer for playback. Among them, AudioFlinger can cache the audio stream, read the audio stream in the buffer, call the Audio HAL of the hardware abstraction layer, and control the audio hardware to play audio.
终端可以检测buffer中是否缓存有音频流,以检测后台运行的应用是否在播放音频。其中,当buffer中缓存有音频流时,终端可以确定终端中存在应用正在播放音频,但并不能确定是前台运行的应用播放音频,还是后台运行的应用播放音频。The terminal can detect whether there is an audio stream cached in the buffer to detect whether the application running in the background is playing audio. Among them, when there is an audio stream cached in the buffer, the terminal can determine that there is an application in the terminal that is playing the audio, but it cannot determine whether the application running in the foreground is playing the audio or the application running in the background is playing the audio.
应注意的是,应用在将解码得到的音频流传输至AudioFlinger时,还可以向AudioFlinger发送音频流对应的进程的标识,终端可以根据buffer中缓存的音频流对应的进程的标识,确定是前台运行的应用播放音频,还是后台运行的应用播放音频,换句话说,终端可以确定后台运行的应用是否正在播放音频。其中,当buffer中缓存的音频流对应的进程的标识为前台运行的应用的进程的标识时,终端可以确定前台运行的应用正在播放音频,当buffer中缓存的音频流对应的进程的标识为后台运行的应用的进程的标识时,终端可以确定后台运行的应用正在播放音频。It should be noted that when the application transmits the decoded audio stream to AudioFlinger, it can also send the identifier of the process corresponding to the audio stream to AudioFlinger. The terminal can determine that it is running in the foreground based on the identifier of the process corresponding to the audio stream cached in the buffer. The application plays audio, or the application running in the background plays audio. In other words, the terminal can determine whether the application running in the background is playing audio. Among them, when the identifier of the process corresponding to the audio stream cached in the buffer is the process identifier of the application running in the foreground, the terminal can determine that the application running in the foreground is playing audio. When the identifier of the process corresponding to the audio stream cached in the buffer is the process identifier of the application running in the foreground, When identifying the process of a running application, the terminal can determine that the application running in the background is playing audio.
示例性的,如buffer中缓存的音频流对应的进程的标识为进程1时,终端可以确定进程1被标注为后台运行,从而终端可以确定后台运行的应用正在播放音频。For example, when the identifier of the process corresponding to the audio stream buffered in the buffer is process 1, the terminal can determine that process 1 is marked as running in the background, so that the terminal can determine that the application running in the background is playing audio.
S202,检测AudioFlinger的buffer中缓存的音频流的时长是否大于或等于第一预设时长。若是,执行 S203,若否,执行S206。S202: Detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration. If yes, execute S203, if not, execute S206.
本申请实施例中增大了AudioFlinger的buffer的大小,buffer的大小可以理解为buffer可以容纳音频流的数据量。示例性的,现有技术中AudioFlinger的buffer的大小为20K,本申请实施例中可以将AudioFlinger的buffer扩容至1M,即增大buffer的大小至1M,这样AudioFlinger可以缓存更多的音频流。In the embodiment of this application, the size of the buffer of AudioFlinger is increased. The size of the buffer can be understood as the amount of data that the buffer can accommodate for the audio stream. For example, in the prior art, the buffer size of AudioFlinger is 20K. In the embodiment of this application, the buffer size of AudioFlinger can be expanded to 1M, that is, the buffer size is increased to 1M, so that AudioFlinger can cache more audio streams.
终端可以检测AudioFlinger的buffer中缓存的音频流的时长是否大于或等于第一预设时长。示例性的,第一预设时长可以为10s。在一种示例中,应用在向AudioFlinger发送解码得到的音频流时,还可以携带音频流的时间戳。终端可以根据AudioFlinger的buffer中缓存的音频流的时间戳,确定AudioFlinger的buffer中缓存的音频流的时长,以检测AudioFlinger的buffer中缓存的音频流的时长是否大于或等于第一预设时长。示例性的,终端可以将buffer中缓存的音频流的最晚时间戳减去最早时间戳,得到buffer中缓存的音频流的时长。The terminal can detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration. For example, the first preset time period may be 10 seconds. In one example, when the application sends the decoded audio stream to AudioFlinger, it can also carry the timestamp of the audio stream. The terminal can determine the duration of the audio stream buffered in AudioFlinger's buffer based on the timestamp of the audio stream buffered in AudioFlinger's buffer to detect whether the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration. For example, the terminal can subtract the earliest timestamp from the latest timestamp of the audio stream buffered in the buffer to obtain the duration of the audio stream buffered in the buffer.
其中,当buffer中缓存的音频流的时长大于或等于第一预设时长时,表征buffer中已经缓存足够多的音频流,短时间冻结后台运行的应用也不会影响音频的播放,终端可以播放buffer中已经缓存的音频流,因此当buffer中缓存的音频流的时长大于或等于第一预设时长时,终端可以冻结后台运行的正在播放音频的应用。当buffer中缓存的音频流的时长小于第一预设时长时,表征buffer中缓存的音频流较少,若冻结后台运行的应用,buffer中缓存的音频流很快就会播放完,用户感知到音频播放中断,为了不影响用户的体验,当buffer中缓存的音频流的时长小于第一预设时长时,终端可以不冻结后台运行的正在播放音频的应用。Among them, when the duration of the audio stream cached in the buffer is greater than or equal to the first preset duration, it means that enough audio streams have been cached in the buffer, and freezing applications running in the background for a short time will not affect audio playback, and the terminal can play The audio stream has been cached in the buffer. Therefore, when the duration of the audio stream cached in the buffer is greater than or equal to the first preset duration, the terminal can freeze the application running in the background that is playing audio. When the duration of the audio stream cached in the buffer is less than the first preset duration, it means that there are fewer audio streams cached in the buffer. If the application running in the background is frozen, the audio stream cached in the buffer will be played out soon, and the user will perceive Audio playback is interrupted. In order not to affect the user experience, when the duration of the audio stream cached in the buffer is less than the first preset duration, the terminal may not freeze the application running in the background that is playing audio.
S203,冻结应用。S203, freeze the application.
应用指的是后台正在播放音频的应用。终端冻结应用可以理解为:终端冻结应用的进程。示例性的,以应用为音频类应用为例,当音频类应用运行在后台且在播放音频时,若终端检测到AudioFlinger的buffer中缓存的音频流的时长大于或等于第一预设时长,终端可以冻结音频类应用的进程1。音频类应用的进程1被冻结后,音频类应用不会调用AudioTrack解码音频数据,也不会向AudioFlinger传输解码后的音频流。Application refers to the application that is playing audio in the background. Terminal freezing application can be understood as: terminal freezing application process. For example, taking the application as an audio application, when the audio application is running in the background and playing audio, if the terminal detects that the duration of the audio stream buffered in AudioFlinger's buffer is greater than or equal to the first preset duration, the terminal You can freeze the process of audio applications 1. After process 1 of the audio application is frozen, the audio application will not call AudioTrack to decode audio data, nor will it transmit the decoded audio stream to AudioFlinger.
应注意的是,本申请实施例中因为增大了AudioFlinger的buffer的大小,因此在播放音频的应用被冻结后,AudioFlinger的buffer中还缓存有音频流,因此AudioFlinger可以继续读取buffer中的音频流,调用硬件抽象层的Audio HAL,控制音频硬件播放音频。换句话说,在播放音频的应用被冻结后,终端还可以播放音频,即用户感知音频未停止播放。应理解,在播放音频的应用被冻结后,播放音频的应用不会占用终端资源,因此可以降低终端负载。It should be noted that in the embodiment of this application, because the size of AudioFlinger's buffer is increased, after the application that plays audio is frozen, the audio stream is still cached in AudioFlinger's buffer, so AudioFlinger can continue to read the audio in the buffer. Stream, call the Audio HAL of the hardware abstraction layer, and control the audio hardware to play audio. In other words, after the application that plays audio is frozen, the terminal can still play audio, that is, the user perceives that the audio has not stopped playing. It should be understood that after the application that plays audio is frozen, the application that plays audio will not occupy terminal resources, so the terminal load can be reduced.
S204,进行倒计时,倒计时的时长为第二预设时长。S204, perform a countdown, and the countdown duration is the second preset duration.
为了保证用户感知应用在后台播放的音频不中断,终端可以在冻结应用后进行倒计时,以便在AudioFlinger的buffer中缓存的音频流播放完之前,解冻应用,如此应用可以继续调用AudioTrack解码音频数据,继续向AudioFlinger传输解码后的音频流,进而保证应用继续在后台播放音频,达到用户感知音频播放不中断的目的,提高用户体验。应理解,终端进行倒计时的起始点可以是终端完成冻结应用的时刻。In order to ensure that the user perceives that the audio played by the application in the background is not interrupted, the terminal can count down after freezing the application so that the application can be unfrozen before the audio stream buffered in the AudioFlinger buffer is played. In this way, the application can continue to call AudioTrack to decode the audio data and continue Transmit the decoded audio stream to AudioFlinger to ensure that the application continues to play audio in the background, so that the user can perceive uninterrupted audio playback and improve the user experience. It should be understood that the starting point for the terminal to countdown may be the moment when the terminal completes freezing the application.
其中,为了在AudioFlinger的buffer中缓存的音频流播放完之前,解冻应用,终端倒计时的时长为第二预设时长,第二预设时长小于第一预设时长。示例性的,第一预设时长为10s,第二预设时长可以为9s,即终端可以在buffer中缓存的音频流还剩1s时,解冻应用。Among them, in order to unfreeze the application before the audio stream buffered in the AudioFlinger buffer is played, the terminal countdown time is the second preset time, and the second preset time is shorter than the first preset time. For example, the first preset duration is 10s, and the second preset duration can be 9s, that is, the terminal can unfreeze the application when there is 1s left of the audio stream buffered in the buffer.
S205,倒计时结束时,解冻应用。S205, when the countdown ends, unfreeze the application.
终端解冻应用可以理解为:解冻应用的进程。应用解冻后,应用可以继续调用AudioTrack解码音频数据,继续向AudioFlinger传输解码后的音频流,AudioFlinger也可以继续在buffer中缓存音频流,且调用硬件抽象层的Audio HAL,控制音频硬件播放音频。Unfreezing an application on the terminal can be understood as: the process of unfreezing the application. After the application is unfrozen, the application can continue to call AudioTrack to decode audio data and continue to transmit the decoded audio stream to AudioFlinger. AudioFlinger can also continue to cache the audio stream in the buffer and call the Audio HAL of the hardware abstraction layer to control the audio hardware to play audio.
在一种实施例中,若在倒计时还未结束,终端就检测到后台运行的应用切换至前台运行,终端也可以解冻应用。或者,若在倒计时还未结束,终端就检测到用户操作终端界面上显示的表征后台运行的应用的标识,终端也可以解冻应用。或者,若在倒计时还未结束,终端检测到用户操作终端上的音量按键以控制应用播放的音频的音量,或者,终端检测到用户操作与终端连接的耳机上的按键以控制应用播放的音频(如暂停、下一首等),终端也可以解冻应用。In one embodiment, if the countdown has not ended yet, the terminal detects that the application running in the background switches to the foreground, and the terminal can also unfreeze the application. Alternatively, if the countdown has not ended yet, the terminal detects the identification of the application running in the background displayed on the user's operation terminal interface, and the terminal can also unfreeze the application. Or, if the countdown has not ended, the terminal detects that the user operates the volume button on the terminal to control the volume of the audio played by the application, or the terminal detects that the user operates the button on the headset connected to the terminal to control the audio played by the application ( Such as pause, next song, etc.), the terminal can also unfreeze the application.
S206,检测后台运行的应用是否在进行网络定位。若是,执行S207,若否,执行S210。 S206: Detect whether the application running in the background is performing network positioning. If yes, execute S207; if not, execute S210.
应用在后台运行时除了可以播放音频之外,应用还可以在后台进行定位。如应用在后台进行定位,可以为用户提供线路导航,这样用户也可以感知到应用在定位。在一种实施例中,当后台运行的应用未播放音频,或者AudioFlinger的buffer中缓存的音频流的时长小于第一预设时长时,终端可以继续检测后台运行的应用是否在进行网络定位,以便于终端可以更全面地确定后台运行的应用执行的任务,以确定是否冻结后台运行的应用,保证更为准确地对后台运行的应用进行管理。In addition to playing audio while the app is running in the background, the app can also be positioned in the background. If the application performs positioning in the background, it can provide route navigation for the user, so that the user can also perceive that the application is positioning. In one embodiment, when the application running in the background does not play audio, or the duration of the audio stream buffered in AudioFlinger's buffer is less than the first preset duration, the terminal can continue to detect whether the application running in the background is performing network positioning, so that The terminal can more comprehensively determine the tasks performed by applications running in the background, determine whether to freeze applications running in the background, and ensure more accurate management of applications running in the background.
目前常用的定位方法包括:全球定位系统(global positioning system,GPS)定位和基站定位。网络定位可以理解为:基站定位。其中,当应用需求定位时,可以向Location发起注册请求,注册请求用于指示Location在检测到终端的位置改变时,向应用反馈终端的位置。在一些示例中,注册请求中还可以包括应用的定位需求,定位需求如基站定位。其中,Location响应于注册请求,可以采用基站定位的方式获取终端的位置,当终端的位置改变时,Location可以回调应用的接口,向应用反馈终端的位置。Currently commonly used positioning methods include: global positioning system (GPS) positioning and base station positioning. Network positioning can be understood as: base station positioning. When the application needs positioning, it can initiate a registration request to the Location. The registration request is used to instruct the Location to feed back the location of the terminal to the application when it detects a change in the location of the terminal. In some examples, the registration request may also include the application's positioning requirements, such as base station positioning. Among them, Location responds to the registration request and can use base station positioning to obtain the location of the terminal. When the location of the terminal changes, Location can call back the application interface and feedback the location of the terminal to the application.
在该示例中,终端可以检测后台运行的应用是否向Location发起网络定位的注册请求,以检测后台运行的应用是否在进行网络定位。其中,若后台运行的应用已向Location发起网络定位的注册请求,终端可以确定后台运行的应用在进行网络定位,若后台运行的应用未向Location发起网络定位的注册请求,终端可以确定后台运行的应用未进行网络定位。In this example, the terminal can detect whether the application running in the background initiates a registration request for network positioning to Location to detect whether the application running in the background is performing network positioning. Among them, if the application running in the background has initiated a registration request for network positioning to Location, the terminal can determine that the application running in the background is performing network positioning. If the application running in the background has not initiated a registration request for network positioning to Location, the terminal can determine that the application running in the background has not initiated a registration request for network positioning to Location. The app is not network targeted.
其中,网络定位的定位精度低,当后台运行的应用在进行网络定位时,表征后台运行的应用可以接收较低的定位精度,因此终端检测到后台运行的应用在进行网络定位时,终端可以冻结后台运行的应用,对定位精度的影响低。Among them, the positioning accuracy of network positioning is low. When an application running in the background performs network positioning, it means that the application running in the background can receive lower positioning accuracy. Therefore, when the terminal detects that the application running in the background performs network positioning, the terminal can freeze. Applications running in the background have a low impact on positioning accuracy.
S207,冻结应用。S207, freeze the application.
S207中的冻结应用可以参照S203中的相关描述。本申请实施例中,运行在后台且在进行网络定位的应用被冻结后,Location可以在终端的位置改变时,回调应用的接口,向应用反馈终端的位置,但由于应用处于被冻结状态,应用无法接收来自Location的终端的位置。For the frozen application in S207, please refer to the relevant description in S203. In the embodiment of this application, after the application running in the background and performing network positioning is frozen, Location can call back the interface of the application when the location of the terminal changes and feedback the location of the terminal to the application. However, because the application is in a frozen state, the application Unable to receive the location of the terminal from Location.
S208,进行倒计时,倒计时的时长为第三预设时长。S208, perform a countdown, and the countdown duration is the third preset duration.
第三预设时长与第二预设时长可以相等或不等。示例性的,第三预设时长与第二预设时长可以不等,如第三预设时长可以为1.5s。应理解,终端进行倒计时的起始点可以是终端完成冻结应用的时刻。The third preset time period and the second preset time period may be equal to or different from each other. For example, the third preset time length may be different from the second preset time length, for example, the third preset time length may be 1.5 seconds. It should be understood that the starting point for the terminal to countdown may be the moment when the terminal completes freezing the application.
S209,倒计时结束时,解冻应用。S209, when the countdown ends, unfreeze the application.
S209中的解冻应用可以参照S205中的相关描述。本申请实施例中,运行在后台且在进行网络定位的应用被解冻后,应用可以继续接收来自Location的终端的位置,以便实时更新终端的位置。For the unfreezing application in S209, please refer to the relevant description in S205. In the embodiment of this application, after the application running in the background and performing network positioning is unfrozen, the application can continue to receive the location of the terminal from Location, so as to update the location of the terminal in real time.
应理解,如第三预设时长可以为1.5s时,应用在该1.5s的时长内冻结,应用不占用终端资源,可以降低终端负载。另外,因为应用进行网络定位,即应用可以接受较低精度的定位,因此应用在1.5s的时长内不更新终端的位置,不会影响用户体验。It should be understood that, for example, when the third preset duration can be 1.5s, the application is frozen within the 1.5s duration, and the application does not occupy terminal resources, which can reduce terminal load. In addition, because the application performs network positioning, that is, the application can accept lower-precision positioning, so the application does not update the terminal's location within 1.5 seconds, which will not affect the user experience.
S210,检测终端是否绝对静置。若是,执行S207,若否,执行S211。S210, detect whether the terminal is absolutely stationary. If yes, execute S207; if not, execute S211.
终端绝对静置可以理解为:终端的位置和姿态未发生改变。在一种实施例中,终端可以根据来自Location的终端的位置,检测终端的位置是否发生改变。在一种实施例中,终端中可以包括加速度传感器、陀螺仪等,终端可以根据加速度传感器、陀螺仪等采集的数据,检测终端的姿态,进而可以检测终端的姿态是否发生改变,本申请实施例对终端获取终端的姿态的过程不做赘述。The absolute rest of the terminal can be understood as: the position and posture of the terminal have not changed. In one embodiment, the terminal may detect whether the terminal's location changes based on the terminal's location from Location. In one embodiment, the terminal may include an acceleration sensor, a gyroscope, etc., and the terminal may detect the posture of the terminal based on the data collected by the acceleration sensor, gyroscope, etc., and further detect whether the posture of the terminal changes. Embodiments of the present application The process of the terminal obtaining the posture of the terminal will not be described in detail.
其中,当终端的位置和姿态均未发生改变时,终端可以确定终端绝对静置。当终端处于绝对静置时,终端无需更新终端的位置,如此终端可以冻结后台运行的应用,以减少终端的资源占用。Among them, when neither the position nor the posture of the terminal changes, the terminal can determine that the terminal is absolutely stationary. When the terminal is absolutely stationary, the terminal does not need to update the location of the terminal. In this way, the terminal can freeze applications running in the background to reduce the resource usage of the terminal.
S211,不响应。S211, no response.
当终端的位置或姿态发生改变时,终端确定终端并非绝对静置,终端可以继续使用网络定位,即终端不响应,不冻结后台运行的应用。When the position or posture of the terminal changes, the terminal determines that the terminal is not absolutely stationary, and the terminal can continue to use network positioning, that is, the terminal does not respond and does not freeze applications running in the background.
如上实施例中,终端可以针对终端后台执行的用户可感知的任务,以及对应的冻结条件,来确定是否冻结后台运行的应用,以减少后台运行的应用对终端资源的占用。其中,用户可感知的任务如:播放音频,定位等。在该种实施例中,针对后台运行的用户可感知的应用,可以执行如上S201-S211。In the above embodiment, the terminal can determine whether to freeze applications running in the background based on user-perceivable tasks performed in the background of the terminal and corresponding freezing conditions, so as to reduce the occupation of terminal resources by applications running in the background. Among them, tasks that users can perceive include: playing audio, positioning, etc. In this embodiment, for user-perceivable applications running in the background, the above S201-S211 can be performed.
综上,下述结合图3对本申请实施例提供的应用处理方法进行描述。参照图3,当应用运行在前台时,终端不冻结应用。当应用切换至后台运行时,对于用户不感知的应用,终端可以在用户不感知的应用运行至一预设时长时冻结应用,对于用户可感知的应用,终端可以按需冻结,按需冻结可以理解为终端可以按照如上S201-S211中对应用进行冻结。 In summary, the application processing method provided by the embodiment of the present application is described below with reference to FIG. 3 . Referring to Figure 3, when the application is running in the foreground, the terminal does not freeze the application. When an application is switched to running in the background, for applications that the user is not aware of, the terminal can freeze the application when the application that the user is not aware of runs for a preset period of time. For applications that the user is aware of, the terminal can freeze the application on demand. Freezing on demand can It is understood that the terminal can freeze the application as described in S201-S211 above.
在一种实施例中,终端可以针对后台运行的不同类型的用户可感知的应用,适应性调整终端执行的步骤,也可以达到减少后台运行的应用占用终端资源的目的。示例性的,如终端中可以存储白名单,白名单中包括不同类型的用户可感知的应用的标识,以及应用运行在后台时的处理步骤。应用的标识可以包括但不限于:应用的名称、图片等用于区分应用的信息。In one embodiment, the terminal can adaptively adjust the steps performed by the terminal for different types of user-perceivable applications running in the background, and can also achieve the purpose of reducing the amount of terminal resources occupied by applications running in the background. For example, a whitelist may be stored in the terminal. The whitelist includes identification of different types of user-perceivable applications and processing steps when the application is running in the background. The identification of an application may include but is not limited to: the name of the application, a picture, and other information used to distinguish the application.
示例性的,白名单中存储的应用可以包括:第一类型的应用、第二类型的应用,以及第三类型的应用。其中,第一类型的应用运行在后台时仅播放音频,第二类型的应用运行在后台时仅进行定位,第三类型的应用运行在后台时既可以播放音频,也可以进行定位。示例性的,第一类型的应用如有声书应用、音频类应用,以及社交类应用等,第二类型的应用如城市停车类应用。第三类型的应用如导航类应用,导航类应用运行在后台时既可以定位,也可以播放导航音频。For example, the applications stored in the whitelist may include: first type applications, second type applications, and third type applications. Among them, the first type of application only plays audio when running in the background, the second type of application only performs positioning when running in the background, and the third type of application can both play audio and perform positioning when running in the background. For example, the first type of applications includes audiobook applications, audio applications, and social networking applications, and the second type of applications includes city parking applications. The third type of application is a navigation application. When the navigation application is running in the background, it can position and play navigation audio.
在该种实施例中,当第一类型的应用运行在后台时,终端可以执行S201-S205。其中,当第一类型的应用在后台未播放音频时,终端即使冻结应用,用户也无感知,因此当第一类型的应用在后台未播放音频时,终端可以冻结第一类型的应用。其中,当第一类型的应用在后台播放音频时,若终端检测到AudioFlinger的buffer中缓存的音频流的时长小于第一预设时长,表征buffer中缓存的音频流较少,终端可以不冻结第一类型的应用,以便AudioFlinger可以继续在buffer中缓存音频流,保证音频播放连续不中断,提高用户体验。In this embodiment, when the first type of application is running in the background, the terminal may perform S201-S205. Wherein, when the first type of application does not play audio in the background, even if the terminal freezes the application, the user will not notice it. Therefore, when the first type of application does not play audio in the background, the terminal can freeze the first type of application. Among them, when the first type of application plays audio in the background, if the terminal detects that the duration of the audio stream buffered in AudioFlinger's buffer is less than the first preset duration, it means that there are fewer audio streams buffered in the buffer, and the terminal does not need to freeze the first audio stream. A type of application so that AudioFlinger can continue to cache audio streams in the buffer to ensure continuous uninterrupted audio playback and improve user experience.
当第二类型的应用运行在后台时,终端可以执行S206-S211。当第三类型的应用在后台运行时,终端可以执行S201-S211。在该实施例中,针对后台运行的不同类型的用户可感知的应用,终端可以执行不同的处理操作,以检测应用是否满足冻结条件,在应用满足冻结条件时,终端可以冻结应用以减少应用对终端资源的占用,降低终端负载。另外,该实施例中针对第一类型的应用,以及第二类型的应用,终端可以适应性减少处理操作,提高处理效率。When the second type of application is running in the background, the terminal can execute S206-S211. When the third type of application is running in the background, the terminal can execute S201-S211. In this embodiment, for different types of user-perceivable applications running in the background, the terminal can perform different processing operations to detect whether the application meets the freezing conditions. When the application meets the freezing conditions, the terminal can freeze the application to reduce the impact of the application. Occupy terminal resources and reduce terminal load. In addition, in this embodiment, for the first type of application and the second type of application, the terminal can adaptively reduce processing operations and improve processing efficiency.
本申请实施例提供的应用处理方法,针对运行在后台且用户可感知的应用,终端可以检测应用是否满足冻结条件,进而在运行在后台且用户可感知的应用满足冻结条件时,冻结该应用,可以减少运行在后台且用户可感知的应用对终端资源的占用。另外,终端还可以进行倒计时以在倒计时结束时,解冻应用,以使得音频播放不中断,且终端可以继续更新终端位置,不会影响用户体验。According to the application processing method provided by the embodiment of the present application, for an application running in the background and perceivable by the user, the terminal can detect whether the application meets the freezing conditions, and then freeze the application when the application running in the background and perceivable by the user meets the freezing conditions. It can reduce the usage of terminal resources by applications running in the background and visible to users. In addition, the terminal can also perform a countdown to unfreeze the application when the countdown ends, so that the audio playback is not interrupted, and the terminal can continue to update the terminal location without affecting the user experience.
下面结合图1所示的终端的结构,从终端内部模块交互的角度,说明本申请实施例提供的应用处理方法。The following describes the application processing method provided by the embodiment of the present application from the perspective of internal module interaction of the terminal in conjunction with the structure of the terminal shown in Figure 1 .
参照图4,以运行在后台的应用播放音频为例,应用可以从服务端下载音频数据,应用调用AudioTrack解码音频数据,得到音频流。应用可以将音频流传输至AudioFlinger。AudioFlinger将接收到的音频流缓存在AudioFlinger的buffer中,且调用硬件抽象层的Audio HAL,控制音频硬件播放音频。Referring to Figure 4, taking an application running in the background playing audio as an example, the application can download audio data from the server, and the application calls AudioTrack to decode the audio data and obtain the audio stream. Applications can stream audio to AudioFlinger. AudioFlinger caches the received audio stream in AudioFlinger's buffer, and calls the Audio HAL of the hardware abstraction layer to control the audio hardware to play audio.
参照图5,以运行在后台的应用进行网络定位为例,应用可以在定位时,向Location发起注册请求。Location可以在终端的位置改变时,回调应用的接口,向应用反馈终端的位置。本申请实施例中,冻结模块可以连接应用和Location。其中,Location在终端的位置改变时,回调应用的接口,向冻结模块反馈终端的位置。在应用处于冻结状态时,冻结模块可以不向应用反馈终端的位置,即应用无法接收来自Location的终端的位置。在应用处于解冻状态时,冻结模块可以将来自Location的终端的位置反馈至应用,应用可以接收到终端的位置。Referring to Figure 5, taking an application running in the background performing network positioning as an example, the application can initiate a registration request to Location during positioning. Location can call back the application's interface when the terminal's location changes and feedback the terminal's location to the application. In the embodiment of this application, the freezing module can connect applications and locations. Among them, when the location of the terminal changes, Location calls back the application interface and feeds back the location of the terminal to the freezing module. When the application is in a frozen state, the freezing module may not feedback the location of the terminal to the application, that is, the application cannot receive the location of the terminal from Location. When the application is in the unfrozen state, the freezing module can feed back the location of the terminal from Location to the application, and the application can receive the location of the terminal.
参照图6,本申请实施例提供的应用处理方法可以包括:Referring to Figure 6, the application processing method provided by the embodiment of the present application may include:
S601,冻结模块检测后台运行的应用是否正在播放音频。若是,执行S602,若否,执行S608。S601: The freezing module detects whether the application running in the background is playing audio. If yes, execute S602; if not, execute S608.
在一种实施例中,冻结模块可以实时检测后台运行的应用是否正在播放音频。In one embodiment, the freezing module can detect in real time whether an application running in the background is playing audio.
在一种实施例中,冻结模块响应于来自事件传输模块的目标事件,可以检测后台运行的应用是否正在播放音频。目标事件可以参照S201中的相关描述。示例性的,在检测到终端启动应用、切换界面,或滑动掉帧等时,事件传输模块可以向冻结模块发送目标事件。冻结模块响应于目标事件,可以检测后台运行的应用是否正在播放音频事件传输模块。In one embodiment, the freezing module may detect whether an application running in the background is playing audio in response to a target event from the event transmission module. For the target event, please refer to the relevant description in S201. For example, when it is detected that the terminal starts an application, switches interfaces, or slides to drop frames, etc., the event transmission module can send a target event to the freezing module. The freeze module responds to the target event and can detect whether an application running in the background is playing audio event transport module.
冻结模块检测后台运行的应用是否正在播放音频的方式,可以参照S201中的相关描述。For the method of detecting whether the application running in the background is playing audio by the freezing module, please refer to the relevant description in S201.
S602,冻结模块检测AudioFlinger的buffer中缓存的音频流的时长是否大于或等于第一预设时长。若是,执行S603,若否,执行S608。S602. The freezing module detects whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration. If yes, execute S603; if not, execute S608.
S602可以参照S202中的相关描述。 S602 may refer to the relevant description in S202.
S603,冻结模块将后台运行的应用的进程的标识写入内核层的节点。S603: The freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
冻结模块在冻结后台运行的应用时,可以将后台运行的应用的进程的标识写入内核层的节点。示例性的,冻结模块可以将后台运行的应用的进程号写入内核层的节点。When freezing an application running in the background, the freezing module can write the identity of the process of the application running in the background to a node in the kernel layer. For example, the freezing module can write the process ID of the application running in the background to the node of the kernel layer.
在一种实施例中,冻结模块还可以在该节点中写入冻结的标识,以指示进程管理模块对写入的进程进行冻结。In one embodiment, the freezing module can also write a freezing identifier in the node to instruct the process management module to freeze the written process.
S604,进程管理模块响应于节点中写入的进程的标识,冻结进程。S604: The process management module freezes the process in response to the identification of the process written in the node.
进程管理模块可以监听节点,响应于节点中写入的进程的标识,可以检测进程的状态,进程的状态包括冻结状态和解冻状态。若进程管理模块检测到进程处于解冻状态,则进程管理模块响应于进程的标识,冻结进程。The process management module can monitor the node, and can detect the status of the process in response to the identification of the process written in the node. The status of the process includes frozen status and unfrozen status. If the process management module detects that the process is in a thawed state, the process management module freezes the process in response to the identification of the process.
在一种实施例中,当冻结模块还在节点中写入冻结的标识时,进程管理模块可以响应于节点中写入的冻结的标识,以及进程的标识,冻结进程。In one embodiment, when the freezing module also writes a frozen identification in the node, the process management module may freeze the process in response to the frozen identification written in the node and the identification of the process.
S605,冻结模块进行倒计时,倒计时的时长为第二预设时长。S605: The freezing module counts down, and the countdown time is the second preset time length.
S605可以参照S204中的相关描述。S605和S604没有先后顺序的区分,二者可以同时执行。S605 may refer to the relevant description in S204. There is no order distinction between S605 and S604, and both can be executed at the same time.
S606,倒计时结束时,冻结模块将后台运行的应用的进程的标识写入内核层的节点。S606: When the countdown ends, the freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
在一种实施例中,冻结模块还可以在该节点中写入解冻的标识,以指示对写入的进程进行解冻。In one embodiment, the freezing module can also write a defrosting identifier in the node to instruct the written process to be defrosted.
S607,进程管理模块响应于节点中写入的进程的标识,解冻进程。S607: The process management module responds to the identification of the process written in the node and unfreezes the process.
在一种实施例中,进程管理模块响应于节点中写入的进程的标识,可以检测进程的状态,若进程管理模块检测到进程处于冻结状态,则进程管理模块响应于进程的标识,解冻进程。In one embodiment, the process management module can detect the status of the process in response to the identification of the process written in the node. If the process management module detects that the process is in a frozen state, the process management module responds to the identification of the process and unfreezes the process. .
在一种实施例中,当冻结模块还在节点中写入解冻的标识时,进程管理模块可以响应于节点中写入的解冻的标识,以及进程的标识,解冻进程。In one embodiment, when the freezing module also writes the unfrozen identifier in the node, the process management module can unfreeze the process in response to the unfrozen identifier written in the node and the process identifier.
S608,冻结模块检测后台运行的应用是否在进行网络定位。若是,执行S609,若否,执行S616。S608: The freezing module detects whether the application running in the background is performing network positioning. If yes, execute S609; if not, execute S616.
S608可以参照S206中的相关描述。S608 may refer to the relevant description in S206.
S609,冻结模块将后台运行的应用的进程的标识写入内核层的节点。S609: The freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
S610,进程管理模块响应于节点中写入的进程的标识,冻结进程。S610: The process management module freezes the process in response to the identification of the process written in the node.
S609-S610可以参照S603-S604中的相关描述。For S609-S610, please refer to the relevant descriptions in S603-S604.
S611,冻结模块响应于接收到来自Location的终端的位置,不向应用反馈终端的位置。S611: The freezing module responds to receiving the location of the terminal from Location and does not feedback the location of the terminal to the application.
本申请实施例中,参照图5,在后台运行的应用处于冻结状态时,冻结模块在接收到来自Location的终端的位置时,可以不向应用反馈终端的位置。In the embodiment of the present application, referring to Figure 5, when the application running in the background is in a frozen state, the freezing module may not feed back the location of the terminal to the application when receiving the location of the terminal from Location.
S612,冻结模块进行倒计时,倒计时的时长为第三预设时长。S612, the freezing module counts down, and the countdown time is the third preset time length.
S612可以参照S208中的相关描述。S610和S609没有先后顺序的区分,二者可以同时执行。S612 may refer to the relevant description in S208. There is no order distinction between S610 and S609, and both can be executed at the same time.
S613,倒计时结束时,冻结模块将后台运行的应用的进程的标识写入内核层的节点。S613. When the countdown ends, the freezing module writes the identity of the process of the application running in the background into the node of the kernel layer.
S614,进程管理模块响应于节点中写入的进程的标识,解冻进程。S614. The process management module responds to the identification of the process written in the node and unfreezes the process.
S613-S614可以参照S606-S607中的相关描述。S613-S614 may refer to the relevant descriptions in S606-S607.
S615,冻结模块响应于接收到来自Location的终端的位置,向应用反馈终端的位置。S615: The freezing module responds to receiving the location of the terminal from Location and feeds back the location of the terminal to the application.
参照图5,在后台运行的应用处于解冻状态时,冻结模块在接收到来自Location的终端的位置时,可以向应用反馈终端的位置,应用可以根据来自冻结模块的终端的位置,更新终端的位置。Referring to Figure 5, when the application running in the background is in the unfrozen state, the freezing module can feedback the location of the terminal to the application when receiving the location of the terminal from Location. The application can update the location of the terminal based on the location of the terminal from the freezing module. .
S616,冻结模块检测终端是否绝对静置。若是,执行S609,若否,执行S617。S616: The freezing module detects whether the terminal is absolutely still. If yes, execute S609; if not, execute S617.
S616可以参照S210中的相关描述。S616 may refer to the relevant description in S210.
S617,冻结模块不响应。S617, the frozen module does not respond.
当终端的位置或姿态发生改变时,冻结模块确定终端并非绝对静置,可以继续进行网络定位,冻结模块不冻结后台运行的应用。When the position or attitude of the terminal changes, the freezing module determines that the terminal is not absolutely stationary and can continue to perform network positioning. The freezing module does not freeze applications running in the background.
在一种实施例中,图6中所示的部分步骤为可选步骤,且步骤之间可以相互组合。在一种实施例中,图6中所示的模块也可以组合,组合后的模块用于模块执行的步骤。In one embodiment, some of the steps shown in Figure 6 are optional steps, and the steps can be combined with each other. In one embodiment, the modules shown in Figure 6 can also be combined, and the combined modules are used for the steps performed by the modules.
本申请实施例中从终端内部模块交互的角度介绍了本申请实施例提供的应用处理方法,该方法中,可以实现对运行在后台且用户可感知的应用的冻结和解冻,一方面在应用冻结时可以减少应用对终端资源的占用,另一方面还可以及时对应用进行解冻,不影响用户体验。 In the embodiments of this application, the application processing method provided by the embodiments of this application is introduced from the perspective of internal module interaction of the terminal. In this method, freezing and thawing of applications running in the background and perceivable by the user can be realized. On the one hand, in the application freezing At the same time, it can reduce the application's occupation of terminal resources. On the other hand, it can also unfreeze the application in time without affecting the user experience.
在一种实施例中,本申请实施例还提供一种电子设备,该电子设备可以为上述实施例中所述的终端。参照图7,该电子设备中可以包括:处理器701(例如CPU)、存储器702。存储器702可能包含高速随机存取存储器(random-access memory,RAM),也可能还包括非易失性存储器(non-volatile memory,NVM),例如至少一个磁盘存储器,存储器702中可以存储各种指令,以用于完成各种处理功能以及实现本申请的方法步骤。In one embodiment, the embodiment of the present application further provides an electronic device, and the electronic device may be the terminal described in the above embodiment. Referring to FIG. 7 , the electronic device may include: a processor 701 (such as a CPU) and a memory 702 . The memory 702 may include high-speed random-access memory (RAM), and may also include non-volatile memory (non-volatile memory, NVM), such as at least one disk memory. Various instructions may be stored in the memory 702 , to complete various processing functions and implement the method steps of the present application.
可选的,本申请涉及的电子设备还可以包括:电源703、通信总线704以及通信端口705。上述通信端口705用于实现电子设备与其他外设之间进行连接通信。在本申请实施例中,存储器702用于存储计算机可执行程序代码,程序代码包括指令;当处理器701执行指令时,指令使电子设备的处理器701执行上述方法实施例中的动作,其实现原理和技术效果类似,在此不再赘述。Optionally, the electronic device involved in this application may also include: a power supply 703, a communication bus 704, and a communication port 705. The above-mentioned communication port 705 is used to realize connection and communication between the electronic device and other peripheral devices. In this embodiment of the present application, the memory 702 is used to store computer executable program code, and the program code includes instructions; when the processor 701 executes the instructions, the instructions cause the processor 701 of the electronic device to perform the actions in the above method embodiment, which implements The principles and technical effects are similar and will not be repeated here.
需要说明的是,上述实施例中所述的模块或部件可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个专用集成电路(application specific integrated circuit,ASIC),或,一个或多个微处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序代码的处理器如控制器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。It should be noted that the modules or components described in the above embodiments may be one or more integrated circuits configured to implement the above methods, such as: one or more application specific integrated circuits (ASICs), or , one or more microprocessors (digital signal processor, DSP), or one or more field programmable gate arrays (field programmable gate array, FPGA), etc. For another example, when one of the above modules is implemented in the form of a processing element scheduler code, the processing element can be a general processor, such as a central processing unit (CPU) or other processors that can call the program code such as a control device. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it may be implemented in whole or in part in the form of a computer program product. A computer program product includes one or more computer instructions. When computer program instructions are loaded and executed on a computer, processes or functions according to embodiments of the present application are generated in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable device. Computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g., computer instructions may be transmitted from a website, computer, server or data center via a wired link (e.g. Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) means to transmit to another website site, computer, server or data center. Computer-readable storage media can be any available media that can be accessed by a computer or a data storage device such as a server, data center, or other integrated media that contains one or more available media. Available media may be magnetic media (eg, floppy disk, hard disk, tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)), etc.
本文中的术语“多个”是指两个或两个以上。本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系;在公式中,字符“/”,表示前后关联对象是一种“相除”的关系。另外,需要理解的是,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。The term "plurality" as used herein means two or more. The term "and/or" in this article is just an association relationship that describes related objects, indicating that three relationships can exist. For example, A and/or B can mean: A exists alone, A and B exist simultaneously, and they exist alone. B these three situations. In addition, the character "/" in this article generally indicates that the related objects before and after are an "or" relationship; in the formula, the character "/" indicates that the related objects before and after are a "division" relationship. In addition, it should be understood that in the description of this application, words such as "first" and "second" are only used for the purpose of distinguishing the description, and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating. Or suggestive order.
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。It can be understood that the various numerical numbers involved in the embodiments of the present application are only for convenience of description and are not used to limit the scope of the embodiments of the present application.
可以理解的是,在本申请的实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请的实施例的实施过程构成任何限定。 It can be understood that in the embodiments of the present application, the size of the sequence numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its functions and internal logic, and should not be used in the implementation of the present application. The implementation of the examples does not constitute any limitations.

Claims (11)

  1. 一种应用处理方法,其特征在于,应用于终端,所述方法包括:An application processing method, characterized in that it is applied to a terminal, and the method includes:
    当运行在后台的应用正在播放音频时,检测AudioFlinger的缓存器中缓存的音频流的时长是否大于或等于第一预设时长;When the application running in the background is playing audio, detect whether the duration of the audio stream cached in the AudioFlinger buffer is greater than or equal to the first preset duration;
    响应于所述缓存器中缓存的音频流的时长大于或等于所述第一预设时长,冻结所述应用,当所述应用被冻结时,所述应用继续播放音频。In response to the duration of the audio stream cached in the cache being greater than or equal to the first preset duration, the application is frozen, and when the application is frozen, the application continues to play audio.
  2. 根据权利要求1所述的方法,其特征在于,所述冻结所述应用之后,还包括:The method according to claim 1, characterized in that after freezing the application, it further includes:
    进行倒计时,所述倒计时的时长为第二预设时长,所述第二预设时长小于所述第一预设时长;Perform a countdown, the duration of the countdown is a second preset duration, and the second preset duration is less than the first preset duration;
    倒计时结束时,解冻所述应用。When the countdown ends, unfreeze the app.
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:The method according to claim 1 or 2, characterized in that, the method further includes:
    响应于所述缓存器中缓存的音频流的时长小于所述第一预设时长,检测所述应用是否在进行网络定位;In response to the duration of the audio stream buffered in the buffer being less than the first preset duration, detect whether the application is performing network positioning;
    响应于所述应用在进行网络定位,冻结所述应用;In response to the application performing network location, freezing the application;
    进行倒计时,所述倒计时的时长为第三预设时长;Perform a countdown, the duration of the countdown being the third preset duration;
    倒计时结束时,解冻所述应用。When the countdown ends, unfreeze the app.
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method of claim 3, further comprising:
    响应于所述应用未进行网络定位,检测所述终端是否绝对静置;In response to the application not performing network positioning, detect whether the terminal is absolutely stationary;
    响应于所述终端绝对静置,冻结所述应用。In response to the terminal being absolutely still, the application is frozen.
  5. 根据权利要求1-4中任一项所述的方法,其特征在于,所述检测AudioFlinger的缓存器中缓存的音频流的时长是否大于或等于第一预设时长之前,还包括:The method according to any one of claims 1 to 4, characterized in that before detecting whether the duration of the audio stream buffered in the buffer of AudioFlinger is greater than or equal to the first preset duration, it further includes:
    响应于目标事件,检测运行在后台的应用是否正在播放音频,所述目标事件为如下任一项触发的事件:应用启动、界面切换,以及终端掉帧。In response to a target event, it is detected whether the application running in the background is playing audio. The target event is an event triggered by any of the following: application startup, interface switching, and terminal frame dropping.
  6. 根据权利要求5所述的方法,其特征在于,所述检测运行在后台的应用是否正在播放音频,包括:The method of claim 5, wherein detecting whether an application running in the background is playing audio includes:
    响应于所述缓存器中缓存有所述应用的音频流,确定所述应用正在播放音频。In response to the audio stream of the application being cached in the buffer, it is determined that the application is playing audio.
  7. 根据权利要求3或4所述的方法,其特征在于,所述终端包括:冻结模块和进程管理模块;The method according to claim 3 or 4, characterized in that the terminal includes: a freezing module and a process management module;
    所述冻结模块响应于所述缓存器中缓存的音频流的时长大于或等于所述第一预设时长,将所述音频流对应的进程的标识写入节点,所述进程为所述应用的进程;In response to the duration of the audio stream cached in the cache being greater than or equal to the first preset duration, the freezing module writes the identifier of the process corresponding to the audio stream into the node, and the process is the application's process;
    所述进程管理模块响应于所述节点中写入所述进程的标识,冻结所述进程。The process management module freezes the process in response to the identification of the process written in the node.
  8. 根据权利要求7所述的方法,其特征在于,所述终端还包括:Location,所述Location用于获取所述终端的位置,且反馈至所述冻结模块,所述方法还包括:The method according to claim 7, characterized in that the terminal further includes: Location, the Location is used to obtain the location of the terminal and feed it back to the freezing module, the method further includes:
    当所述应用在进行网络定位,且所述应用被冻结后,所述冻结模块响应于来自Location的所述终端的位置,不向所述应用发送所述终端的位置;When the application is performing network positioning and the application is frozen, the freezing module responds to the location of the terminal from Location and does not send the location of the terminal to the application;
    当所述应用在进行网络定位,且所述应用被解冻后,所述冻结模块响应于来自Location的所述终端的位置,向所述应用发送所述终端的位置。When the application is performing network positioning and the application is unfrozen, the freezing module responds to the location of the terminal from Location and sends the location of the terminal to the application.
  9. 一种电子设备,其特征在于,包括:处理器和存储器;An electronic device, characterized by including: a processor and a memory;
    所述存储器存储计算机指令;The memory stores computer instructions;
    所述处理器执行所述存储器存储的计算机指令,使得所述处理器执行如权利要求1-8中任一项所述的方法。The processor executes computer instructions stored in the memory, so that the processor executes the method according to any one of claims 1-8.
  10. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序或指令,当所述计算机程序或指令被运行时,实现如权利要求1-8中任一项所述的方法。A computer-readable storage medium, characterized in that computer programs or instructions are stored in the computer-readable storage medium. When the computer programs or instructions are run, the implementation of any one of claims 1-8 is achieved. method described.
  11. 一种程序产品,其特征在于,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,通信装置的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得通信装置实施如权利要求1‐8任意一项所述的方法。 A program product, characterized in that the program product includes a computer program, the computer program is stored in a readable storage medium, and at least one processor of the communication device can read the computer program from the readable storage medium , the at least one processor executes the computer program so that the communication device implements the method according to any one of claims 1-8.
PCT/CN2023/111084 2022-08-15 2023-08-03 Application processing method and electronic device WO2024037353A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210972739.3 2022-08-15
CN202210972739.3A CN117632452A (en) 2022-08-15 2022-08-15 Application processing method and electronic equipment

Publications (1)

Publication Number Publication Date
WO2024037353A1 true WO2024037353A1 (en) 2024-02-22

Family

ID=89940652

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/111084 WO2024037353A1 (en) 2022-08-15 2023-08-03 Application processing method and electronic device

Country Status (2)

Country Link
CN (1) CN117632452A (en)
WO (1) WO2024037353A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107423127A (en) * 2017-07-31 2017-12-01 广东欧珀移动通信有限公司 Management-control method, device, storage medium and the electronic equipment of application program
WO2019128549A1 (en) * 2017-12-29 2019-07-04 Oppo广东移动通信有限公司 Method and apparatus for freezing application, and terminal and computer-readable storage medium
CN110806925A (en) * 2018-08-06 2020-02-18 成都鼎桥通信技术有限公司 Audio playing method and equipment
CN111857859A (en) * 2019-04-30 2020-10-30 中兴通讯股份有限公司 Application control method, device, terminal and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107423127A (en) * 2017-07-31 2017-12-01 广东欧珀移动通信有限公司 Management-control method, device, storage medium and the electronic equipment of application program
WO2019128549A1 (en) * 2017-12-29 2019-07-04 Oppo广东移动通信有限公司 Method and apparatus for freezing application, and terminal and computer-readable storage medium
CN110806925A (en) * 2018-08-06 2020-02-18 成都鼎桥通信技术有限公司 Audio playing method and equipment
CN111857859A (en) * 2019-04-30 2020-10-30 中兴通讯股份有限公司 Application control method, device, terminal and computer readable storage medium

Also Published As

Publication number Publication date
CN117632452A (en) 2024-03-01

Similar Documents

Publication Publication Date Title
CN110300328B (en) Video playing control method and device and readable storage medium
CN109891390B (en) Application switching method and device
US20200285357A1 (en) Icon display method, device, and system
CN105955766A (en) Method and device for application preloading
CN111221638B (en) Concurrent task scheduling processing method, device, equipment and medium
WO2022111027A1 (en) Video acquisition method, electronic device, and storage medium
CN111240564B (en) Material display method and device, electronic equipment and storage medium
WO2022022132A1 (en) Image update method and apparatus, computer device, and storage medium
JP6772218B2 (en) Programs, information processing methods, terminals
CN113259744A (en) Video display method, device, equipment and medium
WO2020238241A1 (en) Media object playback method and apparatus, electronic device, and storage medium
US20220300144A1 (en) Method, system, and non-transitory computer readable record medium for providing chatroom in 3d form
CN110267088B (en) Video playing control method and device, electronic equipment and storage medium
CN114302208A (en) Video distribution method, video distribution device, electronic equipment, storage medium and program product
CN113760081B (en) Power consumption processing method based on service and terminal equipment
CN114265713B (en) RDMA event management method, RDMA event management device, RDMA event management computer equipment and storage medium
CN117724852B (en) Cloud computer computing resource allocation method and device
US20240126422A1 (en) Progress adjustment method and apparatus, electronic device and storage medium
CN114443189B (en) Image processing method and electronic equipment
JP2024521963A (en) Data access method, device and non-transitory computer-readable storage medium
CN109635131A (en) Multimedia content list display methods, method for pushing, device and storage medium
CN107670276B (en) Game application control method and equipment
KR102140294B1 (en) Advertising method of electronic apparatus and electronic apparatus thereof
WO2024037353A1 (en) Application processing method and electronic device
CN109587553A (en) Method for playing music, device, electronic equipment and computer storage medium

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: 23854257

Country of ref document: EP

Kind code of ref document: A1