WO2022267765A1 - 一种视频应用的保活方法以及电子设备 - Google Patents

一种视频应用的保活方法以及电子设备 Download PDF

Info

Publication number
WO2022267765A1
WO2022267765A1 PCT/CN2022/093745 CN2022093745W WO2022267765A1 WO 2022267765 A1 WO2022267765 A1 WO 2022267765A1 CN 2022093745 W CN2022093745 W CN 2022093745W WO 2022267765 A1 WO2022267765 A1 WO 2022267765A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
alive
keep
module
decision
Prior art date
Application number
PCT/CN2022/093745
Other languages
English (en)
French (fr)
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 荣耀终端有限公司
Priority to EP22827263.9A priority Critical patent/EP4216058A4/en
Priority to US18/033,647 priority patent/US20230325260A1/en
Publication of WO2022267765A1 publication Critical patent/WO2022267765A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/542Event management; Broadcasting; Multicasting; Notifications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44505Configuring for program initiating, e.g. using registry, configuration files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • 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/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Definitions

  • the present application relates to the field of application keep-alive, and in particular to a video application keep-alive method and electronic equipment.
  • Video applications are high-frequency applications used by mobile phone users daily. Users generally go through the steps of starting video applications, searching for videos, and watching advertisements when using video applications to watch videos. In the process of watching videos, users will inevitably cross-use other applications. For example, when using a certain video software to watch a video, if the user needs to answer a call or use a communication software to reply to someone else's message, at this time, the user will briefly switch to other applications. If the system memory is tight at this time, in order to ensure the normal use of the system, the system may clean up the video application, and the user needs to re-execute the steps of starting the video application, searching for videos, watching advertisements, and finding the progress of the last video watched. step.
  • the embodiment of the present application provides a video application keep-alive method.
  • the process of the application is kept alive within the keep-alive duration.
  • the video application is switched back to the foreground within the keep-alive time, the video application can continue to play the video played before switching to the background, which solves the problem of cleaning up the process of the video application due to insufficient system memory, causing the user to re-use the video application.
  • the playback state is a problem that consumes a lot of time.
  • an embodiment of the present application provides a method for keeping alive a video application, which is applied to an electronic device, and the method includes: determining that the memory usage of the electronic device is greater than a first threshold; determining the application type of the first application, The first application is in the background running state; if the type of the first application is a video type, determine whether the first application is in the video hold state; if the first application is in the video hold state, keep alive the process of the first application within the keep alive time live.
  • the video application can continue to play the video played before switching to the background, solving the problem The problem of cleaning up the process of the video application due to insufficient system memory, causing the user to use the video application again, and consuming a lot of time to restore the playback state before switching.
  • the method further includes: switching the first application on the first interface to run in the background.
  • the method further includes: switching the first application to run in the foreground within the keep-alive time;
  • the first application running in the foreground displays the first interface.
  • the first interface is a video playback interface, the first application switched back to the foreground, the video picture and audio played in the first interface are the same as the video picture and audio played before the first application is switched to the background The audio is consistent.
  • the determining whether the first application is in the video hold state includes: when the first application is switched to run in the background, the first interface is not the main interface, and the first application acquires The duration of the audio focus exceeds the first duration.
  • the electronic device can determine that the interface before the first application is switched to the background is a video playback interface, and the video playback time is longer than the first duration.
  • the method further includes: determining a system pressure level of the electronic device.
  • the first application is a keep-alive application program
  • keeping alive the process of the first application within the keep-alive time includes: determining whether the first application satisfies the ranking condition based on the system pressure level; if the ranking condition is met , keep alive the process of the first application within the keep alive time.
  • the electronic device may determine whether the first application is a keep-alive application program by adopting different criteria according to the stress level of the system.
  • the system pressure level includes a primary pressure and a secondary pressure
  • determining whether the first application satisfies the ranking condition based on the system pressure level includes: when the electronic device's When the system pressure level is level one pressure, determine whether the ranking of the first application in the first application queue is within the second threshold, the first application queue includes applications of the same type as the first application; if the first application is in the first If the ranking in the application queue is within the second threshold, it is determined that the first application satisfies the ranking condition; or, when the system pressure level of the electronic device is a secondary pressure, it is determined whether the ranking of the first application in the first application queue is Within the third threshold; if the ranking of the first application in the first application queue is within the third threshold, it is determined that the first application satisfies the ranking condition.
  • the electronic device can adopt different criteria to judge whether the first application satisfies the ranking condition according to the stress level of the system, so as to determine whether the first
  • the electronic device includes a system state identification module, a resource management module, and a keep-alive decision module
  • the method includes: the system identification module acquires the running memory of the current system from the resource management module usage; the system identification module determines that the running memory usage is greater than the first threshold; the system state identification module sends the running memory usage to the keep-alive decision-making module; in response to receiving the running memory usage, the keep-alive decision-making module obtains the amount through the resource management module System pressure coefficient; the keep-alive decision-making module judges whether the system pressure coefficient is greater than the fourth threshold; if it is greater than the fourth threshold, the keep-alive decision-making module determines that the system state is a high-pressure state; when the system state is a high-pressure state, the keep-alive decision-making module judges Whether the running memory usage exceeds the fifth threshold; if it exceeds the fifth threshold, it is determined that the system pressure level is the first-level pressure; if it does not
  • the keep-alive decision-making module can judge whether the system should clear the memory according to the pressure of the system memory, and judge the pressure level of the system when the system is under high pressure, so that the keep-alive decision-making module can take the corresponding keep-alive according to the pressure level of the system
  • the policy keeps alive the keep alive application.
  • the electronic device includes a keep-alive decision module and an application identification module, and before determining the application type of the first application, the method further includes: the keep-alive decision module uses the The application identification module obtains the application type of the first application; determines the application type of the first application, specifically: the keep-alive decision module determines that the type of the first application is a video type based on the application type.
  • the keep-alive decision-making module can determine that the first application is a video type, so that the keep-alive decision-making module judges whether the first application is based on the method for judging whether a video-type application is a keep-alive application (in the video hold state and meets the ranking conditions) for keep-alive applications.
  • the electronic device further includes an audio focus identification and an application switching identification module, and determining whether the first application is in the video hold state includes: the keep-alive decision module determines whether the application switching The second interface switching report is obtained in the module, and the second interface switching report includes at least the time T2 when the first application is switched to the background and the identification information of the first interface; the keep-alive decision-making module judges whether the identification information of the first interface is consistent with The sign information of the main interface of the first application is consistent; if consistent, the keep-alive decision-making module determines that the first application is not in the video hold state; if not consistent, the keep-alive decision-making module obtains the first application from the audio focus identification module Audio focus change report, the audio focus change report includes at least the moment T1 when the first application applies for audio focus; the keep-alive decision-making module calculates the modulus of T1 and T2; the keep-alive decision-making module analyzes whether the modulus is greater than or equal to
  • determining that the first application satisfies the ranking condition based on the system pressure level includes: when the system pressure level is level 1 pressure, the keep-alive decision-making module judges that the first application meets the ranking condition. Whether the ranking of an application in the first application queue is within the second threshold, the first application queue includes applications of the same type as the first application; if so, the keep-alive decision module determines that the first application meets the ranking condition; or , when the system pressure level is level two, the keep-alive decision-making module judges whether the ranking of the first application in the first application queue is within the third threshold; if so, the keep-alive decision-making module determines whether the first application Meet the ranking criteria.
  • the keep-alive decision module can judge whether the first application meets the keep-alive condition according to whether the first application satisfies the ranking condition, and if the keep-alive condition is met, the first application can be kept alive within the keep-alive duration.
  • the electronic device further includes an audio management module, and after the first application is switched to the foreground within the keep-alive time, it further includes: the first application applies for audio from the audio management module. Focus; the audio management module assigns audio focus to the first application. In this way, the first application switched back to the foreground regains the audio focus and can play audio.
  • the electronic device further includes an audio focus decision module, after keeping alive the process of the first application within the keep alive time, including: The focus decision module sends keep-alive information of the first application, where the keep-alive information includes a keep-alive duration SaveTime.
  • the audio focus decision module can judge whether the first application switched back to the foreground is a keep-alive application program according to the keep-alive information.
  • the electronic device further includes an audio management module, an event management module, and an interface management module, after the first application is switched to run in the foreground within the keep-alive time, It also includes: the interface management module sends a third interface switching report to the event management module, the third interface switching report includes the identification information of the first application, the identification information of the second application program, and the interface switching time T4; the event management module sends the application switching identification The module sends a third interface switching report; the application switching identification module determines that the identification information of the first application is inconsistent with the identification information of the second application program; the application switching identification module sends the third interface switching report to the audio focus decision module; the audio focus decision The module calculates the modulus of the T4 and the time T5 when the keep-alive information is received; when the modulus is greater than SaveTime, the audio decision-making management module sends a first request message to the event management module, and the first request message is used to instruct the audio management module An audio focus is allocated to
  • an embodiment of the present application provides an electronic device, which includes: one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program codes,
  • the computer program code includes computer instructions invoked by the one or more processors to cause the electronic device to: determine that the memory usage of the electronic device is greater than a first threshold; determine the application type of the first application, the first application In the background running state; if the type of the first application is a video type, determine whether the first application is in the video hold state; if the first application is in the video hold state, keep alive the process of the first application within the keep alive time.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: switching the first application on the first interface to run in the background.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: switching the first application to the foreground within the keep-alive time; running in the foreground The first application displays the first interface.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: determine the system pressure level of the electronic device.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: determine whether the first application satisfies the ranking condition based on the system stress level; if the ranking condition is met , keep alive the process of the first application within the keep alive time.
  • the one or more processors are further configured to call the computer instruction to make the electronic device perform: when the system pressure level of the electronic device is a first-level pressure, determine the first Whether the ranking of the application in the first application queue is within the second threshold, the first application queue includes applications of the same type as the first application; if the ranking of the first application in the first application queue is within the second threshold, Then determine that the first application satisfies the ranking condition; or, when the system pressure level of the electronic device is a secondary pressure, determine whether the ranking of the first application in the first application queue is within the third threshold; if the first application is in If the ranking in the first application queue is within the third threshold, it is determined that the first application satisfies the ranking condition.
  • the one or more processors are further configured to invoke the computer instruction to cause the electronic device to execute: acquire the running memory usage of the current system from the resource management module through the system identification module; Determine through the system identification module that the running memory usage is greater than the first threshold; send the running memory usage to the keep-alive decision-making module through the system status recognition module; in response to receiving the running memory usage, obtain through the resource management module through the keep-alive decision-making module System pressure coefficient; determine whether the system pressure coefficient is greater than the fourth threshold through the keep-alive decision-making module; if it is greater than the fourth threshold, determine the system state as a high-pressure state through the keep-alive decision-making module; The decision-making module judges whether the running memory usage exceeds the fifth threshold; if it exceeds the fifth threshold, it determines that the system pressure level is the first-level pressure; if it does not exceed the fifth threshold, then it determines that the system pressure level is the second-level pressure.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: acquiring the application of the first application through the keep-alive decision module and the application identification module Type: determining the application type of the first application, specifically: determining that the type of the first application is a video type based on the application type through the keep-alive decision module.
  • the one or more processors are further configured to invoke the computer instruction so that the electronic device executes: obtaining the second interface switching report from the application switching identification module through the keep-alive decision module , the second interface switching report at least includes the moment T2 when the first application is switched to the background, and the identification information of the first interface; whether the identification information of the first interface is determined by the keep-alive decision module is consistent with the sign of the main interface of the first application The information is consistent; if consistent, determine that the first application is not in the video hold state through the keep-alive decision-making module; if inconsistent, obtain the audio focus change report of the first application from the audio focus identification module through the keep-alive decision-making module,
  • the audio focus change report includes at least the moment T1 when the first application applies for audio focus; calculate the modulus of T1 and T2 through the keep-alive decision-making module; analyze whether the modulus is greater than or equal to the first duration through the keep-alive decision-making module; if so, The keep
  • the one or more processors are further configured to call the computer instruction so that the electronic device executes: when the system pressure level is level one pressure, through the keep-alive decision-making module Judging whether the ranking of the first application in the first application queue is within the second threshold, the first application queue includes applications of the same type as the first application; if so, determine that the first application satisfies the ranking through the keep-alive decision module condition; or, in the case that the system pressure level is a secondary pressure, the keep-alive decision-making module judges whether the ranking of the first application in the first application queue is within the third threshold; if so, through the keep-alive decision-making The module determines that the first application satisfies the ranking condition.
  • the one or more processors are further configured to call the computer instruction so that the electronic device executes: requesting an audio focus from an audio management module.
  • the one or more processors are further configured to call the computer instruction to make the electronic device execute: send the keep-alive of the first application to the audio focus decision-making module through the keep-alive decision-making module information, the keep-alive information includes the keep-alive duration SaveTime.
  • the one or more processors are further configured to call the computer instruction to make the electronic device perform: sending a third interface switching report to the event management module through the interface management module, and the third interface switching report.
  • the interface switching report includes the identification information of the first application, the identification information of the second application program, and the interface switching time T4; the third interface switching report is sent to the application switching identification module through the event management module; the first application is determined by the application switching identification module The identification information is inconsistent with the identification information of the second application program; the third interface switching report is sent to the audio focus decision-making module through the application switching identification module; the modulus between the T4 and the moment T5 when the keep-alive information is received is calculated by the audio focus decision-making module value; when the modulus value is greater than SaveTime, the audio decision management module sends the first request message to the event management module, and the first request message is used to instruct the audio management module to assign the audio focus to the first application; the event management module sends the audio to the audio The management module sends
  • an embodiment of the present application provides an electronic device, including: a touch screen, a camera, one or more processors, and one or more memories; the one or more processors and the touch screen , the camera, the one or more memories are coupled, the one or more memories are used to store computer program codes, the computer program codes include computer instructions, and when the one or more processors execute the computer instructions , so that the electronic device executes the method according to the first aspect or any implementation manner of the first aspect.
  • an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call a computer instruction so that the electronic device executes the first Aspect or the method described in any one embodiment of the first aspect.
  • the embodiment of the present application provides a computer program product containing instructions, and when the computer program product is run on the electronic device, the electronic device is made to execute any one of the first aspect or the first aspect. the method described.
  • the embodiment of the present application provides a computer-readable storage medium, including instructions, and when the instructions are run on the electronic device, the electronic device executes any one of the first aspect or the first aspect. the method described.
  • Figures 1A-1C are diagrams of an application scenario provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a hardware structure of an electronic device 100 provided by an embodiment of the present application
  • FIG. 3 is a block diagram of the software structure of the electronic device 100 provided by the embodiment of the present application.
  • FIG. 4 is a flow chart of a keep-alive video application process provided by an embodiment of the present application.
  • 5A-5E are diagrams of a video application interface provided by the embodiment of the present application.
  • FIG. 6 is a flow chart for judging that a video application is in a video hold state provided by an embodiment of the present application
  • Fig. 7 is a flow chart of allocating audio focus provided by the embodiment of the present application.
  • Fig. 8 is a flowchart of an interaction between an audio focus decision module and an AudioManager provided by an embodiment of the present application.
  • a unit may be, but is not limited to being limited to, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or distributed between two or more computers.
  • these units can execute from various computer readable media having various data structures stored thereon.
  • a unit may, for example, be based on a signal having one or more data packets (eg, data from a second unit interacting with another unit between a local system, a distributed system, and/or a network. For example, the Internet via a signal interacting with other systems) Communicate through local and/or remote processes.
  • FIG. 1A there are multiple software icons on the main interface 101 of the electronic device 100 , such as a video application 1011 , a communication application 1012 , a game application 1013 , a browser 1014 and so on.
  • the electronic device 100 detects the user's input operation (for example, click) on the video application 1011, the video application starts to start and enters the interface of the video application.
  • the electronic device 100 will display a call answering interface as shown in FIG. 1C .
  • the video application will be switched to the background, and the electronic device 100 will save the currently watched video status.
  • the system When the user makes a call, if the system's running memory is tight, the system will clean up some applications running in the background and release part of the running memory space, so as to ensure that the call application currently running in the foreground can run normally.
  • the electronic device first detects whether the application program running in the background is a keep-alive application program, and if it is a keep-alive application program, the electronic device will keep the application program alive within the keep-alive time. If it is not a keep-alive application program, the electronic device cleans up the process of the application program.
  • the applications currently running in the background include video application 1011, game application 1013, and browser 1014, and the system detects that video application 1011 is a keep-alive application and game application 1013 and browser 1014 are non-keep-alive applications, the system will The processes of the game application 1013 and the browser 1014 can be cleaned up, and the video application 1011 can be kept alive within the keep-alive time (for example, 5 minutes).
  • the video application 1011 When the video application 1011 is switched to the foreground again within 5 minutes, the video application 1011 directly displays the interface before being switched, and the user does not need to search for the video, test the accuracy of the last viewing, etc., saving the user's time to a certain extent .
  • the video being played is Documentary 1
  • the playback progress is currently 00:10:53.
  • the playback interface still plays the documentary 1, and the playback progress is 00:10:53.
  • FIG. 2 is a schematic diagram of a hardware structure of an electronic device 100 provided by an embodiment of the present application.
  • the electronic device 100 may be a mobile phone, a tablet computer, a remote controller, or a wearable electronic device with a wireless communication function (such as a smart watch, AR glasses) and the like.
  • the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (universal serial bus, USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, and an antenna 2 , mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, earphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and A subscriber identification module (subscriber identification module, SIM) card interface 195 and the like.
  • SIM subscriber identification module
  • the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, bone conduction sensor 180M, etc.
  • the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 100 .
  • the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or separate certain components, or arrange different components.
  • the illustrated components can be realized in hardware, software or a combination of software and hardware.
  • the processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processing unit (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), controller, memory, video codec, digital signal processor (digital signal processor, DSP), baseband processor, and/or neural network processor (neural-network processing unit, NPU) Wait. Wherein, different processing units may be independent devices, or may be integrated in one or more processors.
  • application processor application processor, AP
  • modem processor graphics processing unit
  • GPU graphics processing unit
  • image signal processor image signal processor
  • ISP image signal processor
  • controller memory
  • video codec digital signal processor
  • DSP digital signal processor
  • baseband processor baseband processor
  • neural network processor neural-network processing unit
  • the controller may be the nerve center and command center of the electronic device 100 .
  • the controller can generate an operation control signal according to the instruction opcode and timing signal, and complete the control of fetching and executing the instruction.
  • a memory may also be provided in the processor 110 for storing instructions and data.
  • the memory in processor 110 is a cache memory.
  • the memory may hold instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can be called directly from the memory. Repeated access is avoided, and the waiting time of the processor 110 is reduced, thus improving the efficiency of the system.
  • processor 110 may include one or more interfaces.
  • the interface may include an integrated circuit (inter-integrated circuit, I2C) interface, an integrated circuit built-in audio (inter-integrated circuit sound, I2S) interface, a pulse code modulation (pulse code modulation, PCM) interface, a universal asynchronous transmitter (universal asynchronous receiver/transmitter, UART) interface, mobile industry processor interface (mobile industry processor interface, MIPI), general-purpose input and output (general-purpose input/output, GPIO) interface, subscriber identity module (subscriber identity module, SIM) interface, and /or universal serial bus (universal serial bus, USB) interface, etc.
  • I2C integrated circuit
  • I2S integrated circuit built-in audio
  • PCM pulse code modulation
  • PCM pulse code modulation
  • UART universal asynchronous transmitter
  • MIPI mobile industry processor interface
  • GPIO general-purpose input and output
  • subscriber identity module subscriber identity module
  • SIM subscriber identity module
  • USB universal serial bus
  • the electronic device 100 realizes the display function through the GPU, the display screen 194 , and the application processor.
  • the GPU is a microprocessor for image processing, and is connected to the display screen 194 and the application processor. GPUs are used to perform mathematical and geometric calculations for graphics rendering.
  • Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
  • the display screen 194 is used to display images, videos and the like.
  • the display screen 194 includes a display panel.
  • the display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active matrix organic light emitting diode or an active matrix organic light emitting diode (active-matrix organic light emitting diode, AMOLED), flexible light-emitting diode (flex light-emitting diode, FLED), Miniled, MicroLed, Micro-oLed, quantum dot light emitting diodes (quantum dot light emitting diodes, QLED), etc.
  • the electronic device 100 may include 1 or N display screens 194 , where N is a positive integer greater than 1.
  • the electronic device 100 can realize the shooting function through the ISP, the camera 193 , the video codec, the GPU, the display screen 194 and the application processor.
  • the ISP is used for processing the data fed back by the camera 193 .
  • the light is transmitted to the photosensitive element of the camera through the lens, and the light signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing, and converts it into an image visible to the naked eye.
  • ISP can also perform algorithm optimization on image noise, brightness, and skin color.
  • ISP can also optimize the exposure, color temperature and other parameters of the shooting scene.
  • the ISP may be located in the camera 193 .
  • Digital signal processors are used to process digital signals. In addition to digital image signals, they can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the energy of the frequency point.
  • Video codecs are used to compress or decompress digital video.
  • the electronic device 100 may support one or more video codecs.
  • the electronic device 100 can play or record videos in various encoding formats, for example: moving picture experts group (moving picture experts group, MPEG) 1, MPEG2, MPEG3, MPEG4 and so on.
  • MPEG moving picture experts group
  • the NPU is a neural-network (NN) computing processor.
  • NN neural-network
  • Applications such as intelligent cognition of the electronic device 100 can be realized through the NPU, such as image recognition, face recognition, speech recognition, text understanding, and the like.
  • the electronic device 100 can implement audio functions through the audio module 170 , the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor. Such as music playback, recording, etc.
  • the audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal.
  • the audio module 170 may also be used to encode and decode audio signals.
  • the audio module 170 may be set in the processor 110 , or some functional modules of the audio module 170 may be set in the processor 110 .
  • Speaker 170A also referred to as a "horn" is used to convert audio electrical signals into sound signals.
  • Electronic device 100 can listen to music through speaker 170A, or listen to hands-free calls.
  • the pressure sensor 180A is used to sense the pressure signal and convert the pressure signal into an electrical signal.
  • pressure sensor 180A may be disposed on display screen 194 .
  • the magnetic sensor 180D includes a Hall sensor.
  • the electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip leather case.
  • the acceleration sensor 180E can detect the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to recognize the posture of terminal equipment, and can be used in applications such as horizontal and vertical screen switching, pedometers, etc.
  • Proximity light sensor 180G may include, for example, light emitting diodes (LEDs) and light detectors, such as photodiodes.
  • the light emitting diodes may be infrared light emitting diodes.
  • the electronic device 100 emits infrared light through the light emitting diode.
  • the electronic device 100 uses photodiodes to detect infrared reflected light from nearby objects, so as to automatically turn off the screen to save power.
  • the proximity light sensor 180G can also be used in leather case mode, automatic unlock and lock screen in pocket mode.
  • the ambient light sensor 180L is used for sensing ambient light brightness.
  • the electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness.
  • the ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures.
  • the ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in the pocket, so as to prevent accidental touch.
  • the fingerprint sensor 180H is used to collect fingerprints.
  • the electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access to application locks, take pictures with fingerprints, answer incoming calls with fingerprints, and the like.
  • Touch sensor 180K also known as "touch panel”.
  • the touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a “touch screen”.
  • the touch sensor 180K is used to detect a touch operation on or near it.
  • the touch sensor can pass the detected touch operation to the application processor to determine the type of touch event.
  • Visual output related to the touch operation can be provided through the display screen 194 .
  • the touch sensor 180K may also be disposed on the surface of the electronic device 100 , which is different from the position of the display screen 194 .
  • the software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture.
  • the software structure of the electronic device 100 is exemplarily described by taking an Android system with a layered architecture as an example.
  • FIG. 3 is a block diagram of the software structure of the electronic device 100 according to the embodiment of the present application.
  • the layered architecture divides the software into several layers, and each layer has a clear role and division of labor. Layers communicate through software interfaces.
  • the Android system is divided into four layers, which are respectively the application program layer, the application program framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer from top to bottom.
  • the application layer can consist of a series of application packages. As shown in FIG. 3, the application package may include application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video application, and short message.
  • application programs such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video application, and short message.
  • the application framework layer provides an application programming interface (application programming interface, API) and a programming framework for applications in the application layer.
  • the application framework layer includes some predefined functions.
  • the application framework layer may include an audio focus identification module, an application switching identification module, an event management module, AudioManager (audio management module), ActivityManager (interface management module), a keep alive decision module, an audio focus decision module, Application identification module, user habit identification module and system status identification module, etc.
  • the audio focus identification module is used to identify whether the application has applied for the audio focus.
  • the application switching identification module is used to identify whether the application program/interface is switched. Wherein, switching is divided into switching in and switching out, where switching in means that an application running in the background is switched to the foreground, and switching out means that an application running in the foreground is switched to the background.
  • the event management module is used for communication between working modules such as the audio focus identification module, the application switching module, and the keep-alive decision-making module, and ActivityManager and AudioManager.
  • AudioManager is used to assign/revoke the application's audio focus.
  • ActivityManager is used to query the interface that the application is running on and identify interface switching.
  • the keep-alive decision module is used to analyze the keep-alive application program in the system, and keep alive the process of the keep-alive application program within a specified time according to the keep-alive policy.
  • the audio focus decision module is used to manage the audio focus of the application switched to the foreground and background.
  • the application identification module is used to identify the type of the application program, for example, identify the application program as a social application program, a video application program, a shopping application program and so on.
  • the user habit recognition module is used to analyze user behavior based on user data. For example, applications are classified into high-frequency applications and low-frequency applications according to the frequency used to use the application within a period of time and the time of each use of the application.
  • the system status identification module is used to obtain the current memory usage of the system.
  • the Android Runtime includes core library and virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
  • the core library consists of two parts: one part is the function function that the java language needs to call, and the other part is the core library of Android.
  • the application layer and the application framework layer run in virtual machines.
  • the virtual machine executes the java files of the application program layer and the application program framework layer as binary files.
  • the virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
  • a system library can include multiple function modules. For example: Surface Manager (Surface Manager), Media Library (Media Libraries), 3D graphics processing library (eg: OpenGL ES), 2D graphics engine (eg: SGL), etc.
  • Surface Manager Surface Manager
  • Media Libraries Media Libraries
  • 3D graphics processing library eg: OpenGL ES
  • 2D graphics engine eg: SGL
  • the surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
  • the media library supports playback and recording of various commonly used audio and video formats, as well as still image files, etc.
  • the media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing, etc.
  • 2D graphics engine is a drawing engine for 2D drawing.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer includes at least a display driver, a camera driver, an audio driver, a resource management module, and a sensor driver.
  • the resource management module is used to store data resources generated by the system's running memory.
  • FIG. 1A-FIG. 1C introduce the application scenario in which the system keeps alive the video application.
  • the system divides the applications running in the background into keep-alive applications and non-keep-alive applications.
  • the system will clean up the processes of non-keep-alive applications and keep alive the processes of the keep-alive applications within the keep-alive duration.
  • the keep-alive duration is exceeded and the keep-alive applications are not The system will no longer keep the app alive when switching to the foreground.
  • the embodiment of the present application provides a video application keep-alive method.
  • the electronic device system runs out of memory and the video application running in the background is a keep-alive application
  • the electronic device will keep alive the video application according to the keep-alive policy.
  • the application is kept alive.
  • the first application is a video application for illustration.
  • FIG. 4 the flow of the system keep-alive video application process will be described. Please refer to FIG. 4.
  • FIG. 4 is a flow chart of a system keep-alive video application process provided by an embodiment of the present application. The specific process is as follows:
  • Step S401 Start a video application.
  • the electronic device 100 when the electronic device 100 detects an input operation (for example, click) on the icon 501 of the video application, it displays a video application loading interface 502 as shown in FIG. During the process of loading the interface 502, the relevant process of the video application is started. After the video application is started, enter the video application main interface 503 as shown in Figure 5C.
  • an input operation for example, click
  • Step S402 Enter the video playback interface.
  • the video playback interface is a working interface for the video application to play videos.
  • a video for example, Documentary 1
  • the video application displays the video playback interface 505 as shown in FIG. 5D.
  • FIG. 5D As shown in FIG. User selected video (documentary 1).
  • Step S403 the video application applies to the AudioManager for audio focus.
  • the video application when entering the video playback interface, the video application will apply to the AudioManager for audio focus, so that the video application can play the audio of the video resource.
  • the video application can call the function AudioFocus_Request() to request the audio focus from the AudioManager.
  • Step S404 AudioManager assigns audio focus to the video application.
  • the AudioManager assigns the audio focus to the video application, and returns the constant GRANTED to the video application through the function AudioFocus_Request, which is used to indicate that the video application has successfully applied for the audio focus .
  • Step S405 the video application plays the video.
  • the video application plays the video on the video playback interface.
  • the user can see the playing screen of the video application and hear the corresponding audio content.
  • Step S406 The video application is switched to the background.
  • the user can actively switch the video application to the background, or other applications can be started to run in the foreground, causing the video application to be switched to the background. If the user receives an incoming call while watching a video, the video application is switched to the background to run. After the video application is switched to the background, the video application may or may not release the audio focus, which is not limited in this embodiment of the present application.
  • Step S407 The system state identification module acquires the running memory usage of the current system from the resource management module.
  • the system status identification module periodically/regularly monitors the current operating status of the system after the electronic device is turned on. Get the amount of running memory used by the system. Exemplarily, the usage of the operating memory of the system is 5G.
  • Step S408 the system state identification module determines that the running memory usage of the system is greater than the first threshold.
  • the system state identification module judges whether the running memory usage of the system exceeds the first threshold, and if the running memory usage of the system exceeds the first threshold, the system state recognition module sends the running memory usage of the system to the keep-alive decision module , execute step S409. Otherwise, the system state recognition module does not send the running memory usage of the system.
  • the preset threshold is 3G
  • the running memory usage of the system is 5G. Since the running memory usage of the system exceeds the preset threshold, the system state identification module needs to send the running memory usage of the system to the keep-alive decision module .
  • Step S409 the system state identification module sends the running memory usage of the system to the keep-alive decision-making module.
  • the system state identification module can call the function Memory_Send to send the running memory usage of the system to the keep-alive decision-making module.
  • Step S410 The keep-alive decision-making module obtains the system pressure coefficient from the resource management module.
  • the keep-alive decision-making module can obtain the system pressure coefficient from the resource management module.
  • the system pressure coefficient may include: an IO pressure coefficient (for example, 90), a CPU pressure coefficient (for example, 90), and a memory pressure coefficient (for example, 80).
  • the keep-alive decision-making module can obtain the system pressure coefficient from the resource management module at the kernel layer by calling the function Pressure_Request.
  • Step S411 The keep-alive decision-making module determines the system pressure level based on the system's running memory usage and system pressure coefficient.
  • the keep-alive decision-making module judges whether the system pressure coefficients all reach the fourth threshold, and if the system pressure coefficients are greater than the fourth threshold, it is in a high-pressure state, otherwise it is in a low-pressure state.
  • the fourth threshold may be obtained based on empirical values, historical data, or experimental data, which is not limited in this embodiment of the present application.
  • the fifth threshold determines whether the operating memory usage of the system exceeds the fifth threshold. If the operating memory usage of the system exceeds the fifth threshold, it is judged that the system pressure level is a first-level pressure, otherwise it is a second-level pressure. In practical applications, multiple pressure state levels can also be divided according to specific situations.
  • the fifth threshold may be obtained from historical experience values, historical data, or experimental data, which is not limited in this embodiment of the present application.
  • Step S412 When the system is in a high-voltage state, the keep-alive decision-making module obtains the applications currently running in the background and the process corresponding to each background application from the Activitymanager.
  • the keep-alive decision-making module obtains from the Activitymanager is an application queue, which includes all applications running in the background, and each application corresponds to a process queue.
  • the keep-alive decision-making module acquires ten applications running in the background from the resource management module, and the keep-alive decision-making module may determine which applications to clean up based on the current system pressure level.
  • the keep-alive decision-making module can obtain the applications currently running in the background and the processes corresponding to each background application from the Activitymanager by calling the function Process_Request.
  • Step S413 The keep-alive decision module obtains the type of video application from the application identification module.
  • the keep-alive decision module can obtain the type information of the video application through the function Request_Type(App_1).
  • App_1 is the package name of the video application.
  • a corresponding table of application package name and application type can be preset in the application identification module, and the application type corresponding to the application can be queried through the corresponding table.
  • the application identification module queries the type information Video of the video application in the corresponding table based on the package name App_1 of the video application, and calls the function Type_CallBack to return the type information to the keep-alive decision module.
  • Video is used to indicate that the type of the application is a video type.
  • Step S414 The keep-alive decision-making module determines that the video application is a video application.
  • Step S415 The keep-alive decision-making module judges whether the video application is in a video hold state.
  • step S416 is executed. If it is judged as no, then there is no need to keep alive the video application, and the video application can be set in the non-keep alive queue.
  • Step S416 In the case of judging that the video application is in the video holding state, the keep-alive decision module determines whether the video application satisfies the ranking condition based on the system pressure level.
  • the ranking condition may be whether the ranking of the video application in the first application reaches a preset ranking range.
  • the first application is a video application in the electronic device.
  • the keep-alive decision-making module reads parameters such as the frequency of use f of the first application, the time t1 of each use, and the duration of the application being switched to the background this time from the user habit identification module, and calculates each application based on these parameters. score value and rank apps based on the score value.
  • the keep-alive decision-making module judges the size of the preset ranking range based on the stress state level.
  • the preset ranking range is the second threshold, that is, when the ranking of the video application is within the first second threshold ( Including the second threshold), the ranking condition is met, and step S417 is executed.
  • the ranking condition is not met, and the video application may be set in the non-keep-alive queue.
  • the preset ranking range is the third threshold, that is, when the ranking of the video application is within the first third threshold (including the third threshold), the ranking condition is met, and step S417 is executed.
  • the ranking of the video application is not within the first third threshold (including the third threshold)
  • the ranking condition is not satisfied, and there is no need to keep alive the video application, and the video application can be set in a non-keep alive queue.
  • Step S417 If the video application satisfies the ranking condition, the keep-alive decision module keeps alive the video application within the keep-alive time according to the keep-alive policy.
  • the keep-alive decision-making module has different keep-alive durations for the video application. For example, when the system is in the first-level stress state, the keep-alive decision-making module keeps alive the video application for 3 minutes; when the system is not in the first-level stress state, the keep-alive decision-making module keeps alive the video application for 3 minutes 5 minutes.
  • the keep-alive decision-making module keeps alive the video application for 3 minutes 5 minutes.
  • the keep-alive decision module can group processes, which can be divided into keep-alive queues and non-keep-alive queues. If it is determined that the application needs to be kept alive, the application will be placed in the keep-alive queue. If it is not necessary to keep the application alive Or the application is placed in the non-keep-alive queue after the keep-alive time is exceeded. When memory cleaning is required, the application process corresponding to the application in the non-keep-alive list can be checked and killed.
  • Step S418 The video application is switched to the foreground within the keep-alive time.
  • step S406 if the audio focus is released after the video application is switched to the background, or another application applies for the audio focus after the video application is switched to the background, then in step S418, the video application will apply again Audio focus.
  • the video application re-applying for the audio focus please refer to step S403-step S404, which will not be repeated in this embodiment of the present application. If the audio focus is not released after the video application is switched to the background, it is not necessary to re-apply for the audio focus.
  • Step S419 The video application continues to play the video.
  • the video application switches to the foreground, it continues to play the video before switching to the background, and the video playback progress is the same as that before switching to the background.
  • the playing video is documentary 1
  • the playback progress is 00:33:00.
  • the playing video is documentary 1
  • the playback progress is 00:33 :00.
  • the system state identification module may also be in the keep-alive decision-making module, that is, the keep-alive decision-making module may be used to perform the function of the system state identification module.
  • the keep-alive decision-making module may periodically/regularly call the function Memory_Request to read the running memory usage of the system from the resource management module at the kernel layer. Based on the running memory usage of the system, it is determined whether the current system needs to perform memory cleaning. If cleaning is required, the system pressure coefficient is obtained through the resource management module. The keep-alive decision-making module determines the system pressure level based on the running memory usage of the system and the system pressure coefficient.
  • the keep-alive decision-making module may also obtain the occupancy rate of the system running memory and the system pressure coefficient at the same time, and determine the system pressure level based on the usage of the system running memory and the system pressure coefficient. For example, in a high pressure state, it is judged whether the operating memory usage of the system exceeds the second threshold. If the operating memory usage of the system exceeds the second threshold, it is judged that the system state is a first-level pressure state, otherwise it is a second-level pressure state. In practical applications, multiple pressure state levels can also be divided according to specific situations.
  • the system state recognition module can determine whether the system needs to perform memory processing based on whether the running memory usage exceeds the first threshold. clean up. If the first threshold is exceeded, memory cleaning is required, and the system state identification module sends the running memory usage of the system to the keep-alive decision-making module. Then, the keep-alive decision-making module obtains the system pressure coefficient from the resource management module, and then determines the system pressure level according to the system pressure coefficient.
  • the keep-alive decision-making module judges whether the system pressure coefficients have reached the preset upper limit, and if the system pressure coefficients are greater than the upper limit, then it is judged that the system pressure level is the first-level pressure, otherwise it is the second-level pressure. Then, the keep-alive decision-making module obtains the applications currently running in the background and the process corresponding to each background application from the Activitymanager.
  • the keep-alive decision module may directly execute step 412 to obtain the background application and the process corresponding to the background application from the Activitymanager. That is, after the system state identification module sends the running memory usage of the system to the keep-alive decision-making module, the keep-alive decision-making module obtains the applications currently running in the background and the processes corresponding to each background application from the Activitymanager. Then, the keep-alive decision module obtains the type of video application from the application identification module, and after determining that the video application is a video application, judges whether the video application is in a video hold state.
  • the keep-alive decision-making module When judging that the video application is in the video hold state, the keep-alive decision-making module obtains the system pressure coefficient from the resource management module, and determines the system pressure level according to the system pressure coefficient. Then, the keep-alive decision module determines whether the video application satisfies the ranking condition based on the system pressure level.
  • the video application when the system running memory is under high pressure, it is judged whether the video application is a keep-alive application, and if the video application is a keep-alive application, the video application is kept alive according to the keep-alive policy.
  • the system is running normally, ensure that the process of the video application can continue to run in the background.
  • the user switches the video application back to the foreground within the keep-alive duration, the video application is in the video playback state before the switch, and the user's video viewing progress is consistent with that before the switch. Users no longer need to perform cumbersome operations such as starting video applications, searching for videos, and searching for historical viewing progress, saving users time and giving users a good experience.
  • Step S601 The audio focus recognition module subscribes to the event management module for audio focus change events.
  • the audio focus identification module calls the function Subscribe_Change(AudioEvent, AudioCallBack) to subscribe the audio focus change event to the event management module after the electronic device is turned on.
  • AudioEvent is used to indicate that the subscribed event type is an audio focus change event
  • AudioCallBack is a callback function in the audio focus identification module.
  • Step S602 The application switching recognition module subscribes to the event management module for interface switching change events.
  • the application switching recognition module calls the function Subscribe_Change(BoundarChange, BoundarCallBack) to subscribe the interface switching change event to the event management module.
  • BoundarChange is used to indicate that the subscribed event type is an interface switching change event
  • BoundarCallBack is a callback function in the application switching identification module.
  • step S601 may be performed before step S602, or may be performed after step S602, or may be performed simultaneously with step S602.
  • This embodiment of the present application is only for illustration and not limitation.
  • Step S603 Start the video application.
  • Step S604 Enter the video playback interface.
  • step S603-step S604 please refer to the relevant description of step S401-step S402 in the embodiment of FIG. 4 above, and the embodiment of the present application will not repeat them here.
  • Step S605 The ActivityManager sends the first interface switching report to the event management module.
  • the activity at the top of the activity stack of the video application is the Activity corresponding to the video playback interface.
  • the main interface before the video application enters the video playback interface is taken as an example for illustration. Wherein, the identifier of the video application is App_1, the interface identifier of the main interface is Act_1, and the interface identifier of the video playback interface is Act_2.
  • the ActivityManager can call the function Boundar_Send1() to send the first interface switching report to the event management module.
  • the first interface switching report includes the interface identification (Act_2) of the switching interface, the package name (App_1) of the switching interface application program, the interface identification (Act_1) of the switched interface, the package name (App_1) of the switched interface application program and Time T3 when the main interface is switched to the video playback interface.
  • Step S606 The event management module sends the first interface switching report to the application switching identification module.
  • the event management module may send the first interface switching report to the application switching identification module by calling the function BoundarCallBack.
  • Step S607 the video application applies to the AudioManager for audio focus.
  • Step S608 AudioManager assigns audio focus to the video application.
  • step S607-step S608 please refer to the relevant description of step S403-step S404 in the embodiment of FIG. 4 above, and the embodiment of the present application will not repeat them here.
  • the execution sequence of step S605 and step S607 is not limited by this embodiment of the present application.
  • Step S609 AudioManager sends the audio focus change report of the video application to the event management module.
  • AudioFocus_Send1 to send the audio focus change report of the application to the event management module.
  • the audio focus change report of the video application includes the package name (App_1) of the video application, the parameter Request, and the time (T1) of applying for the audio focus, and the Request is used to indicate that the video application has acquired the audio focus.
  • the format of the audio focus change report may be (App_1, Request, T1).
  • Step S610 The event management module sends the audio focus change report of the video application to the audio focus identification module.
  • the audio focus recognition module subscribes to the event management module for the audio focus change event after the electronic device is turned on, when the event management module receives the audio focus change report of the video application sent by the AudioManager, it calls the function AudioCallBack to send the audio The focus change report is sent to the audio focus recognition module.
  • Step S611 the video application is switched to the background.
  • the user can actively switch the video application to the background, or other applications can be started to run in the foreground, causing the video application to be switched to the background. If the user receives an incoming call while watching a video, the video application is switched to the background to run. After the video application is switched to the background, the video application may or may not release the audio focus, which is not limited in this embodiment of the present application.
  • Step S612 The ActivityManager sends a second interface switching report to the event management module.
  • the interfaces of two different application programs may switch. For example, if a video application is switched to the background when playing a video, at this time, if the application switched to the foreground is a playback interface of a certain music application. Then, the second interface switching report includes: the package name (App_1) of the video application, the interface identification (Act_2) of the video playback interface, the package name of the music application (for example, App_2), the interface identification of the music playback interface (for example, is Act_3) and the time T2 when the video application is switched to the background.
  • the package name (App_1) of the video application the interface identification (Act_2) of the video playback interface
  • the package name of the music application for example, App_2
  • the interface identification of the music playback interface for example, is Act_3
  • Step S613 The event management module sends a second interface switching report to the application switching identification module.
  • the event management module can send the second interface switching report to the application switching identification module by calling the function BoundarCallBack.
  • the specific step S415 includes:
  • Step S614 The keep-alive decision-making module obtains the second interface switching report from the application switching identification module.
  • the keep-alive decision module can obtain the second interface switching report by calling the function Request_BoundarChange(App_1).
  • App_1 is the package name of the video application.
  • the application switching module returns the latest interface switching report (second interface switching report) of the video application based on App_1 in the Request_BoundarChange.
  • Step S615 The keep-alive decision module determines whether the interface before the video application switches to the background is the main interface based on the second interface switching report.
  • the keep-alive decision-making module reads Act_2 in the second interface switching report, and judges whether it is consistent with the interface identifier of the main interface of the video application. If not, it means that the interface of the video application is not the main interface before being switched to the background, and step S616 is executed; if they are consistent, it is determined that the video application is not in the video holding state.
  • Step S616 The keep-alive decision module obtains the audio focus change report of the video application from the audio focus identification module.
  • the keep-alive decision module may obtain the audio focus change report of the video application from the audio focus identification module by calling the function Request_AudioFocusChange(App_1).
  • Step S617 The keep-alive decision-making module determines whether the duration of the video application acquiring the audio focus is greater than or equal to the first duration based on the second interface switching report and the audio focus change report of the video application.
  • the keep-alive decision-making module needs to determine whether the duration for the video application to obtain the audio focus is greater than the first duration.
  • the specific calculation process is: the keep-alive decision-making module reads T1 in the audio focus change report and T2 in the second interface switching report, calculates the modulus of T1 and T2, and determines whether the modulus is greater than or equal to the first duration. If the modulus value is greater than or equal to the first duration, then determine that the video application obtains the audio focus duration is greater than or equal to the first duration; if the modulus value is less than the first duration, then determine that the video application obtains the audio focus duration less than First time.
  • Step S618 In the case that the duration of the video application retaining the audio focus is greater than or equal to the first duration, the keep-alive decision module determines that the video application is in a video hold state.
  • the keep-alive decision-making module helps the keep-alive decision-making module judge whether the video application is a keep-alive application by judging whether the video application is in the video hold state. Keep alive the video application during the live time. When the user switches the video application back to the foreground within the keep alive time, the video application will be in the video playback state before switching, and the progress of the user watching the video is consistent with that before switching. Users no longer need to perform cumbersome operations such as starting video applications, searching for videos, and searching for historical viewing progress, saving users time and giving users a good experience.
  • FIG. 7 is a flow chart of allocating audio focus provided by the embodiment of the present application. The specific process is as follows:
  • Step S701 Start a video application.
  • Step S702 the video application enters the video playing interface.
  • Step S703 the video application applies to the AudioManager for audio focus.
  • Step S704 AudioManager allocates audio focus to the video application.
  • Step S705 the video application plays the video.
  • Step S706 The video application is switched to the background.
  • Step S707 The system state identification module obtains the running memory usage of the current system from the resource management module.
  • Step S708 the system state identification module determines that the running memory usage of the system is greater than the first threshold.
  • Step S709 the system state identification module sends the running memory usage of the system to the keep-alive decision-making module.
  • Step S710 The keep-alive decision-making module obtains the system pressure coefficient from the resource management module.
  • Step S711 The keep-alive decision-making module determines the system pressure level based on the system's running memory usage and system pressure coefficient.
  • Step S712 When the system is under high pressure, the keep-alive decision-making module obtains the applications currently running in the background and the process corresponding to each background application from the Activitymanager.
  • Step S713 The keep-alive decision module obtains the type information of the video application from the application identification module.
  • Step S714 The keep-alive decision module determines that the video application is a video application based on the type information of the video application.
  • Step S715 The keep-alive decision-making module judges whether the video application is in a video hold state.
  • Step S716 In the case of judging that the video application is in the video hold state, the keep-alive decision module determines whether the video application satisfies the ranking condition based on the system stress level.
  • Step S717 If the video application satisfies the ranking condition, the keep-alive decision module keeps alive the video application within the keep-alive time according to the keep-alive policy.
  • steps S701 to S717 please refer to the relevant descriptions of the above steps S401 to S417, which will not be repeated in this embodiment of the present application.
  • Step S718 the keep alive decision module sends the keep alive information of the video application to the audio focus decision module.
  • the keep-alive decision-making module determines the keep-alive application, it will call the Save_App function to send the keep-alive information (App_1, SaveTime) of the video application to the audio focus decision-making module.
  • SaveTime is the keep-alive duration of the video application.
  • Step S719 the video application is switched to the foreground within the keep-alive time.
  • Step S720 The audio focus decision module sends a first request message to the AudioManager based on the keep-alive information.
  • the first request message is used to instruct AudioManage to allocate audio focus to the video application, including the package name App_1 of the video application.
  • the audio focus needs to be obtained when the video application is switched to the foreground again.
  • Step S721 AudioManager assigns audio focus to the video application based on the first request message.
  • Step S722 The video application continues to play the video.
  • step S722 please refer to the relevant description in the above step S419, and the embodiment of the present application will not repeat it here.
  • the system state identification module may also be in the keep-alive decision-making module, that is, the keep-alive decision-making module may be used to perform the function of the system state identification module.
  • the keep-alive decision-making module may periodically/regularly call the function Memory_Request to read the running memory usage of the system from the resource management module at the kernel layer. Based on the running memory usage of the system, it is determined whether the current system needs to perform memory cleaning. If cleaning is required, the system pressure coefficient is obtained through the resource management module. The keep-alive decision-making module determines the system pressure level based on the running memory usage of the system and the system pressure coefficient.
  • the keep-alive decision-making module may also obtain the occupancy rate of the system running memory and the system pressure coefficient at the same time, and determine the system pressure level based on the usage of the system running memory and the system pressure coefficient. For example, in a high pressure state, it is judged whether the operating memory usage of the system exceeds the second threshold. If the operating memory usage of the system exceeds the second threshold, it is judged that the system state is a first-level pressure state, otherwise it is a second-level pressure state. In practical applications, multiple pressure state levels can also be divided according to specific situations.
  • the system state recognition module can determine whether the system needs to perform memory processing based on whether the running memory usage exceeds the first threshold. clean up. If it is judged to be yes, memory cleaning is required, and the system state identification module sends the running memory usage of the system to the keep-alive decision-making module. Then, the keep-alive decision-making module obtains the system pressure coefficient from the resource management module, and then determines the system pressure level according to the system pressure coefficient. For example, the keep-alive decision-making module judges whether the system pressure coefficients all reach the preset upper limit value.
  • the keep-alive decision-making module obtains the applications currently running in the background and the process corresponding to each background application from the Activitymanager.
  • the keep-alive decision-making module obtains the applications currently running in the background and the processes corresponding to each background application from the Activitymanager. Then, the keep-alive decision module obtains the type of video application from the application identification module, and after determining that the video application is a video application, judges whether the video application is in a video hold state. When judging that the video application is in the video hold state, the keep-alive decision-making module obtains the system pressure coefficient from the resource management module, and determines the system pressure level according to the system pressure coefficient. Then, the keep-alive decision module determines whether the video application satisfies the ranking condition based on the system pressure level.
  • the audio decision-making module reassigns the audio focus to the video application switched back to the foreground through the AudioManager, so that the video application currently in the video playback interface can play audio.
  • Step S801 The audio focus decision module subscribes to the application switching change event from the application switching identification module.
  • the audio focus decision-making module can call the function Subscribe_Change (AppChange, AppCallBack) to subscribe to the application switching change event to the application switching identification module when the electronic device is turned on. arrive.
  • AppChange is used to indicate that the type of subscription event is an application switching change event
  • AppCallBack is a callback function of the audio decision module.
  • Step S802 The application switching recognition module subscribes to the event management module for interface switching change events.
  • step S602 for the specific process of subscribing the interface switching change event by the application switching identification module to the event management module, which will not be repeated here.
  • Step S803 the keep-alive decision module sends the keep-alive information of the video application to the audio focus decision module.
  • step S719 for the process of sending the keep-alive information of the video application to the audio focus decision-making module by the keep-alive decision-making module, which will not be repeated in this embodiment of the present application.
  • Step S804 The video application is switched to the foreground within the keep-alive time.
  • Step S805 The ActivityManager sends a third interface switching report to the event management module.
  • the third interface switching report includes App_1, App_2, Act_a, Act_b, and T4.
  • App_1 is the package name of the video application
  • App_2 is the package name (the second application program) of the application program switched to the background by the video application
  • Act_a is the identification information (the second interface identification) of the current working interface of the video application
  • Act_b is the identification information of the interface to be switched (the first interface identification)
  • T4 is the time when the interface is switched.
  • the format of the third interface switching report may be (App_2, Act_b, App_1, Act_a, T4).
  • Step S806 The event management module sends the third interface switching report to the application switching identification module.
  • the event management module can send the third interface switching report to the application switching identification module by calling the function BoundarCallBack.
  • Step S807 the application switching recognition module sends a third interface switching report to the audio focus decision module.
  • the application switching identification module receives the third interface switching report, it compares App_2 and App_1 and finds that the two are inconsistent, and the application switching identification module determines that application switching has occurred. Because the audio focus decision-making module subscribes to the application switching change event to the application switching identification module when the electronic device is powered on. Therefore, when the application switching recognition module recognizes that the switching of the video application to the foreground is a switching between applications, the function AppCallBack is called to send the third interface switching report to the audio focus decision module.
  • Step S808 the audio focus decision module sends a first request message to the event management module based on the third interface switching report.
  • the audio decision module invokes the keep-alive information of the video application after receiving the application switching change report, and determines that the video application is a keep-alive application according to App_1 in the third interface switching report. Then, the audio focus decision module can calculate the modulus between the time T5 of receiving the video application keep-alive information and T4 in the third interface switching report, and judge whether the modulus is greater than SaveTime. If the judgment is negative, the video application is switched back to the foreground within the keep-alive time, and the audio focus decision-making module sends a first request message to the event management module. If the judgment is yes, the video application is not switched back to the foreground within the keep-alive time, and the audio focus decision module does not send the first request message to the event management module.
  • Step S809 the event management module sends a first request message to AudioManage.
  • the event management module calls the function AudioFocus_Distribut_1 (App_1) to send the first request message to the AudioManager.
  • the audio focus decision module sends a first request message to the AudioManager, so that the AudioManager assigns the audio focus to the application, so that the video application currently in the video playback interface can play audio.
  • all or part of them may be implemented by software, hardware, firmware or any combination thereof.
  • software When implemented using software, it may be implemented in whole or in part in the form of a computer program product.
  • the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the processes or functions according to the present application will be generated in whole or in part.
  • the computer can be a general purpose computer, a special purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website, computer, server or data center Transmission to another website site, computer, server, or data center by wired (eg, coaxial cable, optical fiber, DSL) or wireless (eg, infrared, wireless, microwave, etc.) means.
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server or a data center integrated with one or more available media.
  • the available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, DVD), or a semiconductor medium (for example, a Solid State Disk).
  • the processes can be completed by computer programs to instruct related hardware.
  • the programs can be stored in computer-readable storage media.
  • When the programs are executed may include the processes of the foregoing method embodiments.
  • the aforementioned storage medium includes: ROM or random access memory RAM, magnetic disk or optical disk, and other various media that can store program codes.

Landscapes

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

Abstract

本申请提供了一种视频应用的保活方法以及电子设备,该视频应用的保活方法包括:当系统的运行内存使用量超出第一阈值时,电子设备判断该第一应用是否为视频类型。在第一应用为视频类型的情况下,确定第一应用是否处于视频保持状态。若第一应用处于视频保持状态,且该应用满足排名条件,电子设备在保活时长内对第一应用进行保活。

Description

一种视频应用的保活方法以及电子设备
本申请要求于2021年6月26日提交中国专利局、申请号为202110715306.5、发明名称为“一种视频应用的保活方法以及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及应用保活领域,尤其涉及一种视频应用的保活方法以及电子设备。
背景技术
视频应用是手机用户日常使用的高频应用,用户在使用视频应用观看视频一般都要经过:启动视频应用、搜索视频、观看广告的步骤。用户在观看视频的过程中,难免会出现交叉使用其他应用的情况。例如,当在使用某一视频软件观看视频时,如果用户需要接听电话或者需要使用通信软件回复别人消息,这时,用户会短暂地切换到其它应用。如果这时系统出现内存紧张,为保证系统的正常使用,系统可能会将视频应用清理掉,用户观看之前的视频则需要重新执行启动视频应用、搜索视频、观看广告、查找上次观看视频进度的步骤。这一系列的步骤会使得用户找回之前播放状态的成本增大,给用户较差的使用体验。因此,如何在系统应用的清理方案中保证系统正常运行的情况下,对视频应用的播放状态进行短时间的保活是当前及未来的研究方向。
发明内容
本申请实施例提供了一种视频应用的保活方法,当系统运行内存紧张且运行在后台的视频应用为保活应用程序时,在保活时长内对该应用程序的进程保活,当该视频应用在保活时长内切换回前台时,视频应用可以继续播放切换到后台前播放的视频,解决了因系统内存不足清理了视频应用的进程,导致用户重新使用视频应用,因恢复切换前的播放状态,而耗费大量时间的问题。
第一方面,本申请实施例提供了一种视频应用的保活方法,应用于电子设备,所述方法包括:确定该电子设备的内存使用量大于第一阈值;确定第一应用的应用类型,第一应用处于后台运行状态;若第一应用的类型为视频类型,确定第一应用是否处于视频保持状态;若第一应用处于视频保持状态,在保活时间内对第一应用的进程进行保活。这样,当系统运行内存紧张时,第一应用在保活时长内被保活,当第一应用在保活时长内重新切换到前台后,视频应用可以继续播放切换到后台前播放的视频,解决了因系统内存不足清理了视频应用的进程,导致用户重新使用视频应用,因恢复切换前的播放状态,而耗费大量时间的问题。
结合第一方面,在一种可能的实现方式中,确定该电子设备的内存使用量大于第一阈值之前,所述方法还包括:将处于第一界面的所述第一应用切换到后台运行。
结合第一方面,在一种可能的实现方式中,在保活时间内对第一应用的进程进行保活之后,所述方法还包括:将第一应用在保活时间内切换到前台运行;在前台运行的第一应 用显示所述第一界面。在上述实施例中,第一界面为视频播放界面,切换回前台的第一应用,其第一界面中的播放的视频画面和音频与第一应用被切换到后台前的视播放的视频画面和音频一致。
结合第一方面,在一种可能的实现方式中,所述确定第一应用是否处于视频保持状态,包括:第一应用被切换到后台运行时,第一界面不是主界面,并且第一应用获取音频焦点的时长超过第一时长。这样,电子设备可以确定第一应用切换到后台前的界面为视频播放界面,且播放视频的时间大于第一时长。
结合第一方面,在一种可能的实现方式中,所述确定该电子设备的内存使用量大于第一阈值之后,所述方法还包括:确定该电子设备的系统压力等级。这样,在第一应用为保活应用程序的情况下,以便于第一设备针对系统压力等级,采取相应的保活策略对第一应用进行保活。
结合第一方面,在一种可能实现的方式中,在保活时间内对所述第一应用的进程进行保活,包括:基于系统压力等级确定第一应用是否满足排名条件;若满足排名条件,则在保活时间内对第一应用的进程进行保活。这样,电子设备可以根据系统的压力等级采取不同的标准对第一应用是否为保活应用程序进行判定。
结合第一方面,在一种可能实现的方式中,系统压力等级包括一级压力和二级压力,基于所述系统压力等级确定所述第一应用是否满足排名条件,包括:当该电子设备的系统压力等级为一级压力时,确定第一应用在第一应用队列中的排名是否在第二阈值之内,第一应用队列包括与第一应用相同类型的应用;若第一应用在第一应用队列中的排名在第二阈值之内,则确定第一应用满足排名条件;或者,当该电子设备的系统压力等级为二级压力时,确定第一应用在第一应用队列中的排名是否在第三阈值之内;若第一应用在第一应用队列中的排名在第三阈值之内,则确定第一应用满足排名条件。这样,电子设备可以根据系统的压力等级采取不同的标准对第一应用是否满足排名条件进行判断,从而判断出第一应用是否为保活应用。
结合第一方面,在一种可能实现的方式中,该电子设备包括系统状态识别模块、资源管理模块以及保活决策模块,所述方法包括:系统识别模块从资源管理模块获取当前系统的运行内存使用量;系统识别模块确定运行内存使用量大于第一阈值;系统状态识别模块向保活决策模块发送运行内存使用量;响应于接收所述运行内存使用量,保活决策模块通过资源管理模块获取系统压力系数;保活决策模块判断系统压力系数是否大于第四阈值;若大于第四阈值,保活决策模块确定系统状态为高压状态;在系统状态为高压状态的情况下,保活决策模块判断所述运行内存使用量是否超过第五阈值;若超过第五阈值,则确定系统压力等级为一级压力;若未超过第五阈值,则确定系统压力等级为二级压力。这样,保活决策模块可以根据系统内存的压力判断出系统是否应该清理内存,以及在系统处于高压状态下,判断出系统的压力等级,以便保活决策模块根据系统的压力等级采取对应的保活策略(保活时间等)对保活应用程序进行保活。
结合第一方面,在一种可能实现的方式中,所述电子设备包括保活决策模块和应用识别模块,确定第一应用的应用类型之前,所述方法还包括:保活决策模块通过所述应用识别模块获取第一应用的应用类型;确定第一应用的应用类型,具体为:保活决策模块基于 应用类型确定第一应用的类型为视频类型。这样,保活决策模块可以判断出第一应用为视频类型,以便于保活决策模块根据判断视频类应用是否为保活应用程序的方法(处于视频保持状态且满足排名条件)判断第一应用是否为保活应用程序。
结合第一方面,在一种可能实现的方式中,所述电子设备还包括音频焦点识别和应用切换识别模块,确定所述第一应用是否处于视频保持状态包括:保活决策模块从应用切换识别模块中获取第二界面切换报告,第二界面切换报告至少包括第一应用切换到后台的时刻T2、所述第一界面的标识信息;保活决策模块判断所述第一界面的标识信息是否与第一应用主界面的标志信息一致;若一致,保活决策模块确定所述第一应用不处于视频保持状态;若不一致,保活决策模块从所述音频焦点识别模块获取所述第一应用的音频焦点变化报告,音频焦点变化报告至少包括第一应用申请音频焦点的时刻T1;保活决策模块计算所述T1与T2的模值;保活决策模块分析该模值是否大于或等于第一时长;若是,保活模块确定所述第一应用处于视频保持状态;若否,保活模块确定所述第一应用不处于视频保持状态。这样,保活决策模块在判断出第一应用处于视频保持状态的情况下,通过判断第一应用是否满足排名条件来判断第一应用是否满足保活条件。
结合第一方面,在一种可能实现的方式中,基于所述系统压力等级确定所述第一应用满足排名条件,包括:在系统压力等级为一级压力的情况下,保活决策模块判断第一应用在第一应用队列中的排名是否在第二阈值之内,第一应用队列包括与第一应用相同类型的应用;若在,保活决策模块确定所述第一应用满足排名条件;或者,在系统压力等级为二级压力的情况下,保活决策模块判断所述第一应用在第一应用队列中的排名是否在第三阈值之内;若在,保活决策模块确定第一应用满足排名条件。这样,保活决策模块可以根据第一应用是否满足排名条件对第一应用是否满足保活条件进行判断,若满足保活条件,便可对第一应用在保活时长内进行保活。
结合第一方面,在一种可能实现的方式中,该电子设备还包括音频管理模块,将第一应用在保活时间内切换到前台运行之后,还包括:第一应用向音频管理模块申请音频焦点;音频管理模块向第一应用分配音频焦点。这样,重新切换回前台的第一应用重新获取音频焦点,可以播放音频。
结合第一方面,在一种可能实现的方式中,该电子设备还包括音频焦点决策模块,在保活时间内对所述第一应用的进程进行保活之后,包括:保活决策模块向音频焦点决策模块发送第一应用的保活信息,该保活信息包括保活时长SaveTime。这样,音频焦点决策模块可以根据保活信息判断切换回前台的第一应用是否为保活应用程序。
结合第一方面,在一种可能实现的方式中,该电子设备还包括音频管理模块、事件管理模块和界面管理模块,将所述第一应用在所述保活时间内切换到前台运行之后,还包括:界面管理模块向事件管理模块发送第三界面切换报告,第三界面切换报告包括第一应用的标识信息、第二应用程序的标识信息以及界面切换时刻T4;事件管理模块向应用切换识别模块发送第三界面切换报告;应用切换识别模块确定第一应用的标识信息与第二应用程序 的标识信息不一致;应用切换识别模块向音频焦点决策模块发送所述第三界面切换报告;音频焦点决策模块计算所述T4与接收保活信息的时刻T5的模值;在模值大于SaveTime的情况下,音频决策管理模块向事件管理模块发送第一请求消息,第一请求消息用于指示音频管理模块向第一应用分配音频焦点;事件管理模块向所述音频管理模块发送第一请求消息;音频管理模块向第一应用分配音频焦点。这样,重新切换回前台的第一应用重新获取音频焦点,可以播放音频。
第二方面,本申请实施例提供了一种电子设备,该电子设备包括:一个或多个处理器和存储器;该存储器与该一个或多个处理器耦合,该存储器用于存储计算机程序代码,该计算机程序代码包括计算机指令,该一个或多个处理器调用该计算机指令以使得该电子设备执行:确定该电子设备的内存使用量大于第一阈值;确定第一应用的应用类型,第一应用处于后台运行状态;若第一应用的类型为视频类型,确定第一应用是否处于视频保持状态;若第一应用处于视频保持状态,在保活时间内对第一应用的进程进行保活。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:将处于第一界面的所述第一应用切换到后台运行。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:将第一应用在保活时间内切换到前台运行;在前台运行的第一应用显示所述第一界面。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:确定该电子设备的系统压力等级。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:基于系统压力等级确定第一应用是否满足排名条件;若满足排名条件,则在保活时间内对第一应用的进程进行保活。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:当该电子设备的系统压力等级为一级压力时,确定第一应用在第一应用队列中的排名是否在第二阈值之内,第一应用队列包括与第一应用相同类型的应用;若第一应用在第一应用队列中的排名在第二阈值之内,则确定第一应用满足排名条件;或者,当该电子设备的系统压力等级为二级压力时,确定第一应用在第一应用队列中的排名是否在第三阈值之内;若第一应用在第一应用队列中的排名在第三阈值之内,则确定第一应用满足排名条件。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:通过系统识别模块从资源管理模块获取当前系统的运行内存使用量;通过系统识别模块确定运行内存使用量大于第一阈值;通过系统状态识别模块向保活决策模块发送运行内存使用量;响应于接收所述运行内存使用量,通过保活决策模块通过资源管理模块获取系统压力系数;通过保活决策模块判断系统压力系数是否大于第四阈值;若大于第四阈值,通过保活决策模块确定系统状态为高压状态;在系统状态为高压状态的情况下,通过保活决策模块判断所述运行内存使用量是否超过第五阈值;若超过第五阈值,则确定系统压力等级为一级压力;若未超过第五阈值,则确定系统压力等级为二级压力。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:通过保活决策模块通过所述应用识别模块获取第一应用的应用类型;确定第一应用的应用类型,具体为:通过保活决策模块基于应用类型确定第一应用的类型为视频类型。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:通过保活决策模块从应用切换识别模块中获取第二界面切换报告,第二界面切换报告至少包括第一应用切换到后台的时刻T2、所述第一界面的标识信息;通过保活决策模块判断所述第一界面的标识信息是否与第一应用主界面的标志信息一致;若一致,通过保活决策模块确定所述第一应用不处于视频保持状态;若不一致,通过保活决策模块从所述音频焦点识别模块获取所述第一应用的音频焦点变化报告,音频焦点变化报告至少包括第一应用申请音频焦点的时刻T1;通过保活决策模块计算所述T1与T2的模值;通过保活决策模块分析该模值是否大于或等于第一时长;若是,通过保活模块确定所述第一应用处于视频保持状态;若否,通过保活模块确定所述第一应用不处于视频保持状态。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:在系统压力等级为一级压力的情况下,通过保活决策模块判断第一应用在第一应用队列中的排名是否在第二阈值之内,第一应用队列包括与第一应用相同类型的应用;若在,通过保活决策模块确定所述第一应用满足排名条件;或者,在系统压力等级为二级压力的情况下,通过保活决策模块判断所述第一应用在第一应用队列中的排名是否在第三阈值之内;若在,通过保活决策模块确定第一应用满足排名条件。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:向音频管理模块申请音频焦点。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:通过保活决策模块向音频焦点决策模块发送第一应用的保活信息,该保活信息包括保活时长SaveTime。
结合第二方面,在一种实施方式中,该一个或多个处理器还用于调用该计算机指令以使得该电子设备执行:通过界面管理模块向事件管理模块发送第三界面切换报告,第三界面切换报告包括第一应用的标识信息、第二应用程序的标识信息以及界面切换时刻T4;通过事件管理模块向应用切换识别模块发送第三界面切换报告;通过应用切换识别模块确定第一应用的标识信息与第二应用程序的标识信息不一致;通过应用切换识别模块向音频焦点决策模块发送所述第三界面切换报告;通过音频焦点决策模块计算所述T4与接收保活信息的时刻T5的模值;在模值大于SaveTime的情况下通过音频决策管理模块向事件管理模块发送第一请求消息,第一请求消息用于指示音频管理模块向第一应用分配音频焦点;事件管理模块向所述音频管理模块发送第一请求消息;音频管理模块向第一应用分配音频焦点。
第三方面,本申请实施例提供了一种电子设备,包括:触控屏、摄像头、一个或多个处理器和一个或多个存储器;所述一个或多个处理器与所述触控屏、所述摄像头、所述一个或多个存储器耦合,所述一个或多个存储器用于存储计算机程序代码,计算机程序代码 包括计算机指令,当所述一个或多个处理器执行所述计算机指令时,使得所述电子设备执行如第一方面或第一方面的任意一种实施方式所述的方法。
第四方面,本申请实施例提供了一种芯片系统,该芯片系统应用于电子设备,该芯片系统包括一个或多个处理器,该处理器用于调用计算机指令以使得该电子设备执行如第一方面或第一方面的任意一种实施方式所述的方法。
第五方面,本申请实施例提供了一种包含指令的计算机程序产品,当该计算机程序产品在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实施方式所述的方法。
第六方面,本申请实施例提供了一种计算机可读存储介质,包括指令,当该指令在电子设备上运行时,使得该电子设备执行如第一方面或第一方面的任意一种实施方式所述的方法。
附图说明
图1A-图1C是本申请实施例提供的一种应用场景图;
图2是本申请实施例提供的电子设备100的硬件结构示意图;
图3是本申请实施例提供的电子设备100的软件结构框图;
图4是本申请实施例提供的一种保活视频应用进程的流程图;
图5A-图5E是本申请实施例提供的一种视频应用界面图;
图6是本申请实施例提供的一种判断视频应用为视频保持状态的流程图;
图7是本申请实施例提供的一种分配音频焦点的流程图;
图8是本申请实施例提供的一种音频焦点决策模块与AudioManager的交互流程图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。在本文中提及“实施例”意味着,结合实施例描述的特定特征、结构或者特性可以包含在本实施例申请的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是相同的实施例,也不是与其它实施例互斥的独立的或是备选的实施例。本领域技术人员可以显式地和隐式地理解的是,本文所描述的实施例可以与其它实施例相结合。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请的说明书和权利要求书及所述附图中术语“第一”、“第二”、“第三”等是区别于不同的对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排他的包含。例如,包含了一系列步骤或单元,或者可选地,还包括没有列出的步骤或单元,或者可选地还包括这些过程、方法、产品或设备固有的其它 步骤或单元。
附图中仅示出了与本申请相关的部分而非全部内容。在更加详细地讨论示例性实施例之前,应当提到的是,一些示例性实施例被描述成作为流程图描绘的处理或方法。虽然流程图将各项操作(或步骤)描述成顺序的处理,但是其中的许多操作可以并行地、并发地或者同时实施。此外,各项操作的顺序可以被重新安排。当其操作完成时所述处理可以被终止,但是还可以具有未包括在附图中的附加步骤。所述处理可以对应于方法、函数、规程、子例程、子程序等等。
在本说明书中使用的术语“部件”、“模块”、“系统”、“单元”等用于表示计算机相关的实体、硬件、固件、硬件和软件的组合、软件或执行中的软件。例如,单元可以是但不限于在处理器上运行的进程、处理器、对象、可执行文件、执行线程、程序和/或分布在两个或多个计算机之间。此外,这些单元可从在上面存储有各种数据结构的各种计算机可读介质执行。单元可例如根据具有一个或多个数据分组(例如来自与本地系统、分布式系统和/或网络间的另一单元交互的第二单元数据。例如,通过信号与其它系统交互的互联网)的信号通过本地和/或远程进程来通信。
下面,结合图1A-图1C介绍本申请实施例提供的应用场景。
如图1A所示,电子设备100的主界面101中存在多款软件的图标,例如视频应用1011、通信应用1012、游戏应用1013、浏览器1014等。当电子设备100检测到用户针对视频应用1011的输入操作(例如单击)时,视频应用开始启动,进入视频应用的界面。在用户使用视频应用观看如图1B所示的纪录片1的过程中,若有好友向该用户拨打电话时,电子设备100就会显示如图1C所示的电话接听界面。当用户接听电话时,视频应用就会被切换到后台,电子设备100会保存当前观看的视频状态。
在用户拨打电话的过程中,如果系统的运行内存紧张,系统会将运行在后台的部分应用程序清理,释放部分运行内存空间,以保证当前运行在前台的通话应用能够正常运行。电子设备首先会检测在后台运行的应用程序是否为保活应用程序,若为保活应用程序,电子设备则会在保活时间内对该应用程序进行保活。若不为保活应用程序,则电子设备清理该应用程序的进程。若当前运行在后台的应用程序包括视频应用1011、游戏应用1013、浏览器1014,系统检测到视频应用1011为保活应用程序,游戏应用1013和浏览器1014为非保活应用程序时,系统会可以将游戏应用1013和浏览器1014的进程清理掉,对视频应用1011在保活时间内(例如5分钟)进行保活。
当视频应用1011在5分钟内重新被切换到前台时,视频应用1011直接显示被切换前的界面,用户无需重新再进行查找视频、测试上次观看精度等步骤,一定程度上节约了用户的时间。例如,在图1B中,播放的视频为纪录片1,播放进度当前为00:10:53。当视频应用1011被重新切换到前台后,播放界面依然播放纪录片1,且播放进度为00:10:53。
下面,对电子设备100的硬件结构进行介绍。请参阅图2,图2是本申请实施例提供的电子设备100的硬件结构示意图。其中,电子设备100可以为手机、平板电脑、遥控器或具备无线通讯功能的可穿戴电子设备(如智能手表、AR眼镜)等等。
电子设备100可以包括处理器110,外部存储器接口120,内部存储器121,通用串行总线(universal serial bus,USB)接口130,充电管理模块140,电源管理模块141,电池142,天线1,天线2,移动通信模块150,无线通信模块160,音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,传感器模块180,按键190,马达191,指示器192,摄像头193,显示屏194,以及用户标识模块(subscriber identification module,SIM)卡接口195等。其中传感器模块180可以包括压力传感器180A,陀螺仪传感器180B,气压传感器180C,磁传感器180D,加速度传感器180E,距离传感器180F,接近光传感器180G,指纹传感器180H,温度传感器180J,触摸传感器180K,环境光传感器180L,骨传导传感器180M等。
可以理解的是,本发明实施例示意的结构并不构成对电子设备100的具体限定。在本申请另一些实施例中,电子设备100可以包括比图示更多或更少的部件,或者组合某些部件,或者拆分某些部件,或者不同的部件布置。图示的部件可以以硬件,软件或软件和硬件的组合实现。
处理器110可以包括一个或多个处理单元,例如:处理器110可以包括应用处理器(application processor,AP),调制解调处理器,图形处理器(graphics processing unit,GPU),图像信号处理器(image signal processor,ISP),控制器,存储器,视频编解码器,数字信号处理器(digital signal processor,DSP),基带处理器,和/或神经网络处理器(neural-network processing unit,NPU)等。其中,不同的处理单元可以是独立的器件,也可以集成在一个或多个处理器中。
其中,控制器可以是电子设备100的神经中枢和指挥中心。控制器可以根据指令操作码和时序信号,产生操作控制信号,完成取指令和执行指令的控制。
处理器110中还可以设置存储器,用于存储指令和数据。在一些实施例中,处理器110中的存储器为高速缓冲存储器。该存储器可以保存处理器110刚用过或循环使用的指令或数据。如果处理器110需要再次使用该指令或数据,可从所述存储器中直接调用。避免了重复存取,减少了处理器110的等待时间,因而提高了系统的效率。
在一些实施例中,处理器110可以包括一个或多个接口。接口可以包括集成电路(inter-integrated circuit,I2C)接口,集成电路内置音频(inter-integrated circuit sound,I2S)接口,脉冲编码调制(pulse code modulation,PCM)接口,通用异步收发传输器(universal asynchronous receiver/transmitter,UART)接口,移动产业处理器接口(mobile industry processor interface,MIPI),通用输入输出(general-purpose input/output,GPIO)接口,用户标识模块(subscriber identity module,SIM)接口,和/或通用串行总线(universal serial bus,USB)接口等。
电子设备100通过GPU,显示屏194,以及应用处理器等实现显示功能。GPU为图像处理的微处理器,连接显示屏194和应用处理器。GPU用于执行数学和几何计算,用于图形渲染。处理器110可包括一个或多个GPU,其执行程序指令以生成或改变显示信息。
显示屏194用于显示图像,视频等。显示屏194包括显示面板。显示面板可以采用液晶显示屏(liquid crystal display,LCD),有机发光二极管(organic light-emitting diode,OLED),有源矩阵有机发光二极体或主动矩阵有机发光二极体(active-matrix organic light emitting  diode的,AMOLED),柔性发光二极管(flex light-emitting diode,FLED),Miniled,MicroLed,Micro-oLed,量子点发光二极管(quantum dot light emitting diodes,QLED)等。在一些实施例中,电子设备100可以包括1个或N个显示屏194,N为大于1的正整数。
电子设备100可以通过ISP,摄像头193,视频编解码器,GPU,显示屏194以及应用处理器等实现拍摄功能。
ISP用于处理摄像头193反馈的数据。例如,拍照时,打开快门,光线通过镜头被传递到摄像头感光元件上,光信号转换为电信号,摄像头感光元件将所述电信号传递给ISP处理,转化为肉眼可见的图像。ISP还可以对图像的噪点,亮度,肤色进行算法优化。ISP还可以对拍摄场景的曝光,色温等参数优化。在一些实施例中,ISP可以设置在摄像头193中。
数字信号处理器用于处理数字信号,除了可以处理数字图像信号,还可以处理其他数字信号。例如,当电子设备100在频点选择时,数字信号处理器用于对频点能量进行傅里叶变换等。
视频编解码器用于对数字视频压缩或解压缩。电子设备100可以支持一种或多种视频编解码器。这样,电子设备100可以播放或录制多种编码格式的视频,例如:动态图像专家组(moving picture experts group,MPEG)1,MPEG2,MPEG3,MPEG4等。
NPU为神经网络(neural-network,NN)计算处理器,通过借鉴生物神经网络结构,例如借鉴人脑神经元之间传递模式,对输入信息快速处理,还可以不断的自学习。通过NPU可以实现电子设备100的智能认知等应用,例如:图像识别,人脸识别,语音识别,文本理解等。
电子设备100可以通过音频模块170,扬声器170A,受话器170B,麦克风170C,耳机接口170D,以及应用处理器等实现音频功能。例如音乐播放,录音等。
音频模块170用于将数字音频信息转换成模拟音频信号输出,也用于将模拟音频输入转换为数字音频信号。音频模块170还可以用于对音频信号编码和解码。在一些实施例中,音频模块170可以设置于处理器110中,或将音频模块170的部分功能模块设置于处理器110中。
扬声器170A,也称“喇叭”,用于将音频电信号转换为声音信号。电子设备100可以通过扬声器170A收听音乐,或收听免提通话。
压力传感器180A用于感受压力信号,可以将压力信号转换成电信号。在一些实施例中,压力传感器180A可以设置于显示屏194。
磁传感器180D包括霍尔传感器。电子设备100可以利用磁传感器180D检测翻盖皮套的开合。
加速度传感器180E可检测电子设备100在各个方向上(一般为三轴)加速度的大小。当电子设备100静止时可检测出重力的大小及方向。还可以用于识别终端设备姿态,应用于横竖屏切换,计步器等应用。
接近光传感器180G可以包括例如发光二极管(LED)和光检测器,例如光电二极管。发光二极管可以是红外发光二极管。电子设备100通过发光二极管向外发射红外光。电子设备100使用光电二极管检测来自附近物体的红外反射光,以便自动熄灭屏幕达到省电的 目的。接近光传感器180G也可用于皮套模式,口袋模式自动解锁与锁屏。
环境光传感器180L用于感知环境光亮度。电子设备100可以根据感知的环境光亮度自适应调节显示屏194亮度。环境光传感器180L也可用于拍照时自动调节白平衡。环境光传感器180L还可以与接近光传感器180G配合,检测电子设备100是否在口袋里,以防误触。
指纹传感器180H用于采集指纹。电子设备100可以利用采集的指纹特性实现指纹解锁,访问应用锁,指纹拍照,指纹接听来电等。
触摸传感器180K,也称“触控面板”。触摸传感器180K可以设置于显示屏194,由触摸传感器180K与显示屏194组成触摸屏,也称“触控屏”。触摸传感器180K用于检测作用于其上或附近的触摸操作。触摸传感器可以将检测到的触摸操作传递给应用处理器,以确定触摸事件类型。可以通过显示屏194提供与触摸操作相关的视觉输出。在另一些实施例中,触摸传感器180K也可以设置于电子设备100的表面,与显示屏194所处的位置不同。
电子设备100的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明电子设备100的软件结构。图3是本申请实施例的电子设备100的软件结构框图。分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。
应用程序层可以包括一系列应用程序包。如图3所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频应用,短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。如图3所示,应用程序框架层可以包括音频焦点识别模块、应用切换识别模块、事件管理模块、AudioManager(音频管理模块)、ActivityManager(界面管理模块)、保活决策模块、音频焦点决策模块、应用识别模块、用户习惯识别模块和系统状态识别模块等等。
音频焦点识别模块用于识别应用程序是否申请了音频焦点。
应用切换识别模块用于识别应用程序/界面是否发生切换。其中,切换分成切入和切出,切入为运行在后台的应用程序被切换到前台,切出为运行在前台的应用程序被切换到后台。
事件管理模块用于音频焦点识别模块、应用切换模块、保活决策模块等工作模块与ActivityManager、AudioManager之间的通信。
AudioManager用于分配/撤销应用程序的音频焦点。
ActivityManager用于查询应用程序运行的界面以及识别界面切换。
保活决策模块用于分析系统中的保活应用程序,以及根据保活策略在规定时间内对保活应用程序的进程进行保活。
音频焦点决策模块用于管理切换到前后台的应用程序的音频焦点。
应用识别模块用于识别应用程序的类型,例如识别应用程序为社交类应用程序、视频类应用程序、购物类应用程序等等。用户习惯识别模块用于根据用户数据对用户行为进行 分析。例如,根据用于在一段时间内使用应用程序的频率和每次使用应用程序的时间,将应用程序分为高频应用程序和低频应用程序。
系统状态识别模块用于获取系统当前的内存运行使用量。
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如:表面管理器(Surface Manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,资源管理模块、传感器驱动。
资源管理模块用于存储系统运行内存所产生的数据资源。
上述图1A-图1C的实施例介绍了系统对视频应用进行保活的应用场景。系统将运行在后台的应用程序分为保活应用程序和非保活应用程序。当系统的运行内存紧张时,系统会将非保活应用程序的进程清理掉,并在保活时长内对保活应用程序的进程进行保活,当超出保活时长且保活应用程序未被切换到前台时,系统将不再保活该应用程序。
在系统运行内存紧张的情况下,运行在后台的视频应用的进程常常容易被清理掉。这就使得,当用户想继续使用视频应用观看视频时,需要重新执行打开视频应用→寻找目标视频→观看广告→查找进度等繁琐的操作,给用户带来了极大的时间成本以及极差的使用体验。
针对上述问题,本申请实施例提供了一种视频应用的保活方法,当电子设备系统运行内存紧张,且运行在后台的视频应用为保活应用程序时,电子设备根据保活策略对该视频应用进行保活。本申请实施例以第一应用为视频应用,进行举例说明。下面,结合图4,对系统保活视频应用进程的流程进行说明。请参见图4,图4是本申请实施例提供的一种系统保活视频应用进程的流程图,具体流程如下:
步骤S401:启动视频应用。
示例性的,如图5A所示,当电子设备100检测到针对视频应用的图标501的输入操作(例如单击)后,显示如图5B所示的视频应用加载界面502,电子设备在显示应用加载界面502的过程中,启动该视频应用的相关进程。当视频应用完成启动后,进入如图5C所 示的视频应用主界面503。
步骤S402:进入视频播放界面。
具体地,视频播放界面是视频应用播放视频的工作界面。示例性的,当用户从图5C的视频应用主界面点击一个视频(例如,纪录片1)后,视频应用显示如图5D所示的视频播放界面505,如图5D所示,视频播放界面在播放用户选择的视频(纪录片1)。
步骤S403:视频应用向AudioManager申请音频焦点。
具体地,在进入视频播放界面的同时,视频应用会向AudioManager申请音频焦点,以便视频应用播放视频资源的音频。示例性的,视频应用可以调用函数AudioFocus_Request()向AudioManager申请音频焦点。
步骤S404:AudioManager向视频应用分配音频焦点。
具体地,AudioManager接收到所述视频应用申请音频焦点的请求后,为该视频应用分配音频焦点,并通过函数AudioFocus_Request向视频应用程序返回常量GRANTED,所述常量用于表征该视频应用成功申请音频焦点。
步骤S405:视频应用播放视频。
具体的,在成功申请音频焦点后,视频应用在视频播放界面播放视频。此时,用户可以通过看到视频应用的播放画面并听到相应的音频内容。
步骤S406:视频应用被切换到后台。
具体地,用户可以主动将视频应用切换到后台,也可以是其他应用启动到前台运行导致视频应用被切换到后台,如用户看视频过程中接收到来电,则视频应用被切换到后台运行。当视频应用被切换到后台后,视频应用可以释放音频焦点,也可以不释放音频焦点,本申请实施例对此不做限制。
步骤S407:系统状态识别模块从资源管理模块获取当前系统的运行内存使用量。
具体地,系统状态识别模块在电子设备开机后,周期性/定时地监测系统当前运行状态,监测的具体方式为:系统状态识别模块周期性/定时地调用函数Memory_Request从位于内核层的资源管理模块中获取系统的运行内存的使用量。示例性的,系统运行内存的使用量为5G。
步骤S408:系统状态识别模块确定系统的运行内存使用量大于第一阈值。
示例性的,系统状态识别模块判断系统的运行内存使用量是否超过第一阈值,若系统的运行内存使用量超过了第一阈值,系统状态识别模块向保活决策模块发送系统的运行内存使用量,执行步骤S409。否则,系统状态识别模块不发送系统的运行内存使用量。例如,预设的阈值为3G,系统的运行内存使用量为5G,由于系统的运行内存使用量超过了预设的阈值,因此系统状态识别模块要向保活决策模块发送系统的运行内存使用量。
步骤S409:系统状态识别模块向保活决策模块发送系统的运行内存使用量。
具体地,系统状态识别模块可以调用函数Memory_Send将系统的运行内存使用量发送给保活决策模块。
步骤S410:保活决策模块向资源管理模块获取系统压力系数。
具体地,保活决策模块在接收到系统状态识别模块发送的系统运行内存使用量后,保活决策模块可以向资源管理模块获取系统压力系数。系统压力系数可以包括:IO压力系数 (例如,90)、CPU压力系数(例如,90)以及内存压力系数(例如,80)。示例性的,保活决策模块可以通过调用函数Pressure_Request从位于内核层的资源管理模块中获取系统压力系数。
步骤S411:保活决策模块基于系统的运行内存使用量和系统压力系数确定系统压力等级。
具体地,保活决策模块判断系统压力系数是否均达到第四阈值,若系统压力系数均大于第四阈值,则处于高压状态,否则为低压状态。其中,第四阈值可以基于经验值得到,也可以基于历史数据得到,还可以基于实验数据得到,本申请实施例对此不做限制。
如果系统处于高压状态,则判断系统压力较大,需要清理部分或全部在后台运行的应用程序,如果系统处于低压状态,则判断系统压力较小,不需要清理运行在后台的应用程序。
如果是高压状态,则确定系统的运行内存使用量是否超过第五阈值,若系统的运行内存使用量超过第五阈值,则为判断系统压力等级为一级压力,否则为二级压力。实际应用中也可以根据具体情况划分多个压力状态等级。其中,第五阈值可以由历史经验值得到,也可以由历史数据得到,还可以由实验数据得到,本申请实施例对此不做限制。
步骤S412:在系统处于高压状态下,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。
具体地,保活决策模块从Activitymanager中获取的是应用队列,该应用队列包括所有在后台运行的应用,且每个应用都对应一个进程队列。示例性的,保活决策模块从资源管理模块中获取在后台运行的应用有十个,保活决策模块可基于当前系统的压力等级确定要清理哪些应用。保活决策模块可以通过调用函数Process_Request从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。
步骤S413:保活决策模块从应用识别模块获取视频应用的类型。
具体地,保活决策模块可以通过函数Request_Type(App_1)获取该视频应用的类型信息。其中,App_1为该视频应用的包名。应用识别模块中可预置有应用包名和应用类型的对应表,通过该对应表可以查询到该应用对应的应用类型。应用识别模块基于视频应用的包名App_1在对应表中查询该视频应用的类型信息Video,并调用函数Type_CallBack将该类型信息返回给保活决策模块。其中,Video用于指示应用的类型为视频类型。
步骤S414:保活决策模块确定该视频应用为视频类应用。
步骤S415:保活决策模块判断该视频应用是否为视频保持状态。
具体地,若判断为是,执行步骤S416。若判断为否,则无需对该视频应用进行保活,可以将该视频应用设置在非保活队列中。
步骤S416:在判断该视频应用为视频保持状态的情况下,保活决策模块基于系统压力等级确定该视频应用是否满足排名条件。
具体地,排名条件可以是该视频应用在第一应用中的排名是否达到预设排名范围。第一应用为电子设备中的视频类应用。例如,保活决策模块从用户习惯识别模块中读取第一应用的使用频率f、每次使用的时间t1、应用本次被切换到后台的时长等参数,并基于这些参数计算每个应用的分数值,并基于分数值对应用进行排名。
保活决策模块基于压力状态等级判断预设排名范围的大小,当系统压力等级为一级压力时,预设排名范围为第二阈值,即当所述视频应用的排名在前第二阈值以内(包括第二阈值),满足排名条件,执行步骤S417。当该视频应用的排名不在前第二阈值以内(包括第二阈值),则不满足排名条件,可以将该视频应用设置在非保活队列中。在系统压力状态等级为二级压力状态时,预设排名范围为第三阈值,即当所述视频应用的排名在前第三阈值以内(包括第三阈值),满足排名条件,执行步骤S417。当该视频应用的排名不在前第三阈值以内(包括第三阈值),则不满足排名条件,无需对视频应用进行保活,可以将该视频应用设置在非保活队列中。
步骤S417:在所述视频应用满足排名条件的情况下,保活决策模块根据保活策略,在保活时间内对所述视频应用进行保活。
具体地,若所述视频应用在第一应用程序中的排名达到预设排名范围,该视频应用为保活应用程序,保活决策模块会根据保活策略对其进行保活。所述保活策略为:根据系统压力状态等级不同,保活决策模块对所述视频应用的保活时长也不同。例如,当系统处于一级压力状态时,保活决策模块对该视频应用的保活时长为3分钟,当系统不处于一级压力状态时,保活决策模块对该视频应用的保活时长为5分钟。当系统处于一级压力状态时,若该视频应用在3分钟后还未被切换到前台,取消对该视频应用的保活,该视频应用设置在非保活队列中。
保活决策模块对进程可以进行分组,具体可以分成保活队列和非保活队列,如果确定需要对该应用进行保活则将该应用放在保活队列中,如果不需要对该应用保活或者该应用超出保活时间便将该应用放在非保活队列中。在需要进行内存清理时,可以对非保活对列中的应用对应的应用进程进行查杀。
步骤S418:该视频应用在保活时间内被切换到前台。
具体地,在步骤S406中,若视频应用被切换到后台后,释放音频焦点,或者在该视频应用切到后台后有其他应用申请音频焦点,则在步骤S418中,则视频应用则会再次申请音频焦点。该视频应用重新申请音频焦点的过程请参见步骤S403-步骤S404,本申请实施例在此不再赘述。如果视频应用被切换到后台后,未释放音频焦点,则也可以不重新申请音频焦点。
步骤S419:视频应用继续播放视频。
具体地,视频应用在切换到前台后,继续播放切换在后台前的视频,且视频播放进度与切换到后台前的视频播放进度相同。例如,在图5E中,视频应用切换到后台前,播放的视频为纪录片1,播放进度为00:33:00,视频应用切换到前台后,播放的视频为纪录片1,播放进度为00:33:00。
在一种可能实现的方式中,系统状态识别模块也可以是在保活决策模块中,也就是说,保活决策模块可以用来执行系统状态识别模块的功能。具体的,保活决策模块可以周期性/定时地调用函数Memory_Request从位于内核层的资源管理模块中读取系统的运行内存使用量。基于系统的运行内存使用量确定当前系统是否要进行内存清理,如果需要清理,则通过资源管理模块获取系统压力系数,保活决策模块基于系统的运行内存使用量和系统压力系数确定系统压力等级。
示例性的,保活决策模块也可以同时获取系统运行内存的占用率和系统压力系数,基于系统运行内存的使用量和系统压力系数确定系统压力等级。例如,在高压状态下,判断系统的运行内存使用量是否超过第二阈值,若系统的运行内存使用量超过第二阈值,则为判断系统状态为一级压力状态,否则为二级压力状态。实际应用中也可以根据具体情况划分多个压力状态等级。
在一种可能的实现方式中,在系统状态识别模块从资源管理模块获取当前系统的运行内存使用量后,系统状态识别模块可以基于运行内存使用量是否超过第一阈值,判断系统是否需要进行内存清理。若超过第一阈值,则需要内存清理,系统状态识别模块向保活决策模块发送系统的运行内存使用量。然后,保活决策模块向资源管理模块获取系统压力系数,再根据系统压力系数确定系统压力等级。例如,保活决策模块判断系统压力系数是否均达到预设的上限值,若系统压力系数均大于该上限值,则判断系统压力等级为一级压力,否则为二级压力。然后,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。
在一种可能实现的方式中,执行步骤409后,可以直接执行步骤412保活决策模块从Activitymanager中获取后台应用和后台应用对应的进程。即系统状态识别模块向保活决策模块发送系统的运行内存使用量后,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。然后,保活决策模块从应用识别模块获取视频应用的类型,在确定该视频应用为视频类应用后,判断该视频应用是否为视频保持状态。在判断该视频应用为视频保持状态的情况下,保活决策模块向资源管理模块获取系统压力系数,并根据系统压力系数确定系统压力等级。然后,保活决策模块基于系统压力等级确定该视频应用是否满足排名条件。
本申请实施例,在系统运行内存处于高压状态时,判断视频应用是否为保活应用程序,在视频应用为保活应用程序的情况下,根据保活策略对该视频应用进行保活,在保证系统能够正常运行的情况下,保证视频应用的进程在后台能够继续运行。当用户在保活时长内将该视频应用重新切回前台时,视频应用为切换前的视频播放状态,用户观看视频的进度与切换前的一致。用户不必再执行启动视频应用、查找视频、寻找历史观看进度等繁琐操作,为用户节约了时间,给用户良好的体验。
上述图4实施例介绍了系统在其运行内存处于高压状态下对视频应用进行保活的流程。下面,结合图6,对上述步骤S415中,判断视频应用是否为视频保持状态的具体流程进行展开说明。具体流程如下:
步骤S601:音频焦点识别模块向事件管理模块订阅音频焦点变化事件。
具体地,音频焦点识别模块在电子设备开机后,调用函数Subcribe_Change(AudioEvent,AudioCallBack)向事件管理模块订阅音频焦点变化事件。其中,AudioEvent用于指示订阅的事件类型为音频焦点变化事件,AudioCallBack为在音频焦点识别模块内的回调函数。这样,事件管理模块接收到AudioManager调用函数AudioFocus_Send1()发送的该视频应用的音频焦点变化报告后,事件管理模块可以调用回调函数AudioCallBack将该音频焦点变化报告发送给音频焦点识别模块。
步骤S602:应用切换识别模块向事件管理模块订阅界面切换变化事件。
具体地,应用切换识别模块在电子设备开机后,调用函数Subscribe_Change(BoundarChange,BoundarCallBack)向事件管理模块订阅界面切换变化事件。其中,BoundarChange用于指示订阅的事件类型为界面切换变化事件,BoundarCallBack为在应用切换识别模块内的回调函数。这样,当有界面或应用程序发生切换时,事件管理模块调用函数BoundarCallBack向应用切换识别模块发送界面切换变化报告。
需要说明的是,步骤S601可以先于步骤S602执行,也可以后于步骤S602执行,还可以与步骤S602同时执行,本申请实施例仅作举例说明,不做限制。
步骤S603:启动视频应用。
步骤S604:进入视频播放界面。
步骤S603-步骤S604请参考上述图4实施例中步骤S401-步骤S402的相关叙述,本申请实施例在此不再赘述。
步骤S605:ActivityManager向事件管理模块发送第一界面切换报告。
具体地,视频应用从其它界面切换到视频播放界面的同时,视频应用Activity栈的栈顶Activity为视频播放界面对应的Activity。可以事先对ActivityManager进行代码插桩,即:在ActivityManager中插入一段代码,当ActivityManager检测到栈顶Activity的变化后会向事件管理模块发送界面切换报告。以视频应用进入视频播放界面前的界面为主界面为例,进行说明。其中,该视频应用的标识为App_1,主界面的界面标识为Act_1,视频播放界面的界面标识为Act_2。当视频应用从主界面切换到视频播放界面后,ActivityManager可以调用函数Boundar_Send1()向事件管理模块发送第一界面切换报告。其中,第一界面切换报告包括切换界面的界面标识(Act_2)、切换界面应用程序的包名(App_1)、被切换界面的界面标识(Act_1)、被切换界面应用程序的包名(App_1)以及主界面切换到视频播放界面的时刻T3。
步骤S606:事件管理模块将第一界面切换报告发送给应用切换识别模块。
具体地,事件管理模块可以通过调用函数BoundarCallBack将第一界面切换报告发送给应用切换识别模块。
步骤S607:视频应用向AudioManager申请音频焦点。
步骤S608:AudioManager向视频应用分配音频焦点。
步骤S607-步骤S608请参考上述图4实施例中步骤S403-步骤S404的相关叙述,本申请实施例在此不再赘述。步骤S605和步骤S607步骤执行顺序,本申请实施例不予限定。
步骤S609:AudioManager向事件管理模块发送所述视频应用的音频焦点变化报告。
具体地,在AudioManager中进行代码插桩,即在AudioManager中预先插入一段代码,当AudioManager向应用程序分配或撤销音频焦点时,运行该代码。然后,AudioManager调用函数AudioFocus_Send1将该应用程序的音频焦点变化报告发送给事件管理模块。所述视频应用的音频焦点变化报告包括所述视频应用的包名(App_1)、参数Request、申请音频焦点的时间(T1),所述Request用于表征所述视频应用获取音频焦点。例如,所述音频焦点变化报告的形式可以为(App_1,Request,T1)。
步骤S610:事件管理模块向音频焦点识别模块发送所述视频应用的音频焦点变化报告。
具体地,由于音频焦点识别模块在电子设备开机后向事件管理模块订阅了音频焦点变化事件,当事件管理模块接收到AudioManager发送的所述视频应用的音频焦点变化报告后,调用函数AudioCallBack将该音频焦点变化报告发送给音频焦点识别模块。
步骤S611:所述视频应用被切换到后台。
具体地,用户可以主动将视频应用切换到后台,也可以是其他应用启动到前台运行导致视频应用被切换到后台,如用户看视频过程中接收到来电,则视频应用被切换到后台运行。当视频应用被切换到后台后,视频应用可以释放音频焦点,也可以不释放音频焦点,本申请实施例对此不做限制。
步骤S612:ActivityManager向事件管理模块发送第二界面切换报告。
具体地,当该视频应用被切换到后台时,会存在两个不同应用程序的界面切换的情况。例如,若视频应用在播放视频时被切换到后台,此时,若切换到前台的应用程序为某一音乐应用的播放界面。那么,第二界面切换报告包括:该视频应用的包名(App_1)、视频播放界面的界面标识(Act_2)、音乐应用的包名(例如,为App_2)、音乐播放界面的界面标识(例如,为Act_3)以及该视频应用被切换到后台的时刻T2。
步骤S613:事件管理模块向应用切换识别模块发送第二界面切换报告。
具体地,事件管理模块可以通过调用函数BoundarCallBack将第二界面切换报告发送给应用切换识别模块。
在系统处于高压状态的情况下,具体步骤S415包括:
步骤S614:保活决策模块从应用切换识别模块中获取第二界面切换报告。
具体地,保活决策模块可以通过调用函数Request_BoundarChange(App_1)获取第二界面切换报告。其中,App_1为该视频应用的包名。应用切换模块基于Request_BoundarChange中App_1为返回视频应用最新的界面切换报告(第二界面切换报告)。
步骤S615:保活决策模块基于第二界面切换报告判断该视频应用切换到后台前的界面是否为主界面。
具体地,保活决策模块读取第二界面切换报告中的Act_2,判断其是否与视频应用主界面的界面标识一致。若不一致,则说明视频应用被切换到后台前,其界面不为主界面,执行步骤S616,若一致,则确定该视频应用不为视频保持状态。
步骤S616:保活决策模块从音频焦点识别模块获取所述视频应用的音频焦点变化报告。
具体地,保活决策模块可以通过调用函数Request_AudioFocusChange(App_1)从音频焦点识别模块获取所述视频应用的音频焦点变化报告。
步骤S617:保活决策模块基于第二界面切换报告和所述视频应用的音频焦点变化报告判断所述视频应用获取音频焦点的时长是否大于或等于第一时长。
具体地,为了排除类似“在进入播放界面之后立即退出该界面”这种在视频播放界面停留时间很短的场景,保活决策模块需要判断视频应用获取音频焦点的时长是否大于第一时长。具体计算过程为:保活决策模块读取音频焦点变化报告中的T1和第二界面切换报告中的T2,计算T1与T2的模值,并判断该模值是否大于或等于第一时长。若该模值大于或等于第一时长,则确定所述视频应用获取音频焦点的时长大于或等于第一时长,若该模值 小于第一时长,则确定所述视频应用获取音频焦点的时长小于第一时长。
步骤S618:在所述视频应用保留音频焦点的时长大于或等于第一时长的情况下,保活决策模块判断视频应用处于视频保持状态。
本申请实施例,保活决策模块通过判断视频应用是否处于视频保持状态,有利于保活决策模块判断视频应用是否为保活应用程序,当该视频应用为保活应用程序的情况下,在保活时间内对该视频应用进行保活,当用户在保活时长内将该视频应用重新切回前台时,视频应用为切换前的视频播放状态,用户观看视频的进度与切换前的一致。用户不必再执行启动视频应用、查找视频、寻找历史观看进度等繁琐操作,为用户节约了时间,给用户良好的体验。
在上述图4实施例中,当视频应用在保活时间内被切换回前台时,视频应用会重新申请音频焦点。本申请实施例提供另外一种为重新切换到前台的视频应用分配音频焦点的方法。下面,结合图7,对另一种分配音频焦点的方法进行展开说明。请参见图7,图7是本申请实施例提供的一种分配音频焦点的流程图,具体流程如下:
步骤S701:启动视频应用。
步骤S702:视频应用进入视频播放界面。
步骤S703:视频应用向AudioManager申请音频焦点。
步骤S704:AudioManager向视频应用分配音频焦点。
步骤S705:视频应用播放视频。
步骤S706:视频应用被切换到后台。
步骤S707:系统状态识别模块从资源管理模块获取当前系统的运行内存使用量。
步骤S708:系统状态识别模块确定系统的运行内存使用量大于第一阈值。
步骤S709:系统状态识别模块向保活决策模块发送系统的运行内存使用量。
步骤S710:保活决策模块向资源管理模块获取系统压力系数。
步骤S711:保活决策模块基于系统的运行内存使用量和系统压力系数确定系统压力等级。
步骤S712:在系统处于高压状态下,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。
步骤S713:保活决策模块从应用识别模块获取视频应用的类型信息。
步骤S714:保活决策模块基于该视频应用的类型信息确定该视频应用为视频类应用。
步骤S715:保活决策模块判断该视频应用是否为视频保持状态。
步骤S716:在判断该视频应用为视频保持状态的情况下,保活决策模块基于系统压力状态等级确定该视频应用是否满足排名条件。
步骤S717:在所述视频应用满足排名条件的情况下,保活决策模块根据保活策略,在保活时间内对所述视频应用进行保活。
步骤S701-步骤S717请参考上述步骤S401-步骤S417的相关叙述,本申请实施例在此不再赘述。
步骤S718:保活决策模块向音频焦点决策模块发送该视频应用的保活信息。
具体地,保活决策模块确定保活应用程序后,会调用Save_App函数向音频焦点决策模块发送所述视频应用的保活信息(App_1,SaveTime)。其中,SaveTime为视频应用的保活时长。
步骤S719:该视频应用在保活时间内被切换到前台。
步骤S720:音频焦点决策模块基于保活信息向AudioManager发送第一请求消息。
具体地,所述第一请求消息用于指示AudioManage向所述视频应用分配音频焦点,包括所述视频应用的包名App_1。在步骤S706中,若视频应用被切换到后台后,释放音频焦点,或者在该视频应用切到后台后有其他应用申请音频焦点,当视频应用被再次切换到前台后,需要获得音频焦点。
步骤S721:AudioManager基于第一请求消息为该视频应用分配音频焦点。
步骤S722:视频应用继续播放视频。
步骤S722请参考上述步骤S419中的相关叙述,本申请实施例在此不再赘述。
在一种可能实现的方式中,系统状态识别模块也可以是在保活决策模块中,也就是说,保活决策模块可以用来执行系统状态识别模块的功能。具体的,保活决策模块可以周期性/定时地调用函数Memory_Request从位于内核层的资源管理模块中读取系统的运行内存使用量。基于系统的运行内存使用量确定当前系统是否要进行内存清理,如果需要清理,则通过资源管理模块获取系统压力系数,保活决策模块基于系统的运行内存使用量和系统压力系数确定系统压力等级。
示例性的,保活决策模块也可以同时获取系统运行内存的占用率和系统压力系数,基于系统运行内存的使用量和系统压力系数确定系统压力等级。例如,在高压状态下,判断系统的运行内存使用量是否超过第二阈值,若系统的运行内存使用量超过第二阈值,则为判断系统状态为一级压力状态,否则为二级压力状态。实际应用中也可以根据具体情况划分多个压力状态等级。
在一种可能的实现方式中,在系统状态识别模块从资源管理模块获取当前系统的运行内存使用量后,系统状态识别模块可以基于运行内存使用量是否超过第一阈值,判断系统是否需要进行内存清理。若判断为是,则需要内存清理,系统状态识别模块向保活决策模块发送系统的运行内存使用量。然后,保活决策模块向资源管理模块获取系统压力系数,再根据系统压力系数确定系统压力等级。例如,保活决策模块判断系统压力系数是否均达到预设的上限值,若系统压力系数均该上限值,则判断系统压力等级为一级压力,否则为二级压力。然后,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。
在一种可能实现的方式中,系统状态识别模块向保活决策模块发送系统的运行内存使用量后,保活决策模块从Activitymanager中获取当前在后台运行的应用和每个后台应用对应的进程。然后,保活决策模块从应用识别模块获取视频应用的类型,在确定该视频应用为视频类应用后,判断该视频应用是否为视频保持状态。在判断该视频应用为视频保持状态的情况下,保活决策模块向资源管理模块获取系统压力系数,并根据系统压力系数确定系统压力等级。然后,保活决策模块基于系统压力等级确定该视频应用是否满足排名条件。
本申请实施例,音频决策模块通过AudioManager为切换回前台的视频应用重新分配音 频焦点,使得当前处于视频播放界面的视频应用能够播放音频。
上述图7实施例中,对另一种为切换到前台的视频应用分配音频焦点的方法进行介绍。下面,结合图8,对上述步骤S720中音频焦点决策模块基于保活信息向AudioManager发送第一请求消息的具体流程进行说明,具体流程如下:
步骤S801:音频焦点决策模块向应用切换识别模块订阅应用切换变化事件。
具体地,音频焦点决策模块在电子设备开机时可以调用函数Subcribe_Change(AppChange,AppCallBack)向应用切换识别模块订阅应用切换变化事件,当有应用程序发生切换时,音频决策模块可以通过应用切换识别模块监听到。其中,AppChange用于指示订阅事件的类型为应用切换变化事件,AppCallBack为音频决策模块的回调函数。
步骤S802:应用切换识别模块向事件管理模块订阅界面切换变化事件。
具体地,应用切换识别模块向事件管理模块订阅界面切换变化事件的具体过程请参考步骤S602,在此不再赘述。
步骤S803:保活决策模块向音频焦点决策模块发送所述视频应用的保活信息。
具体地,保活决策模块向音频焦点决策模块发送所述视频应用的保活信息的过程请参考步骤S719,本申请实施例在此不再赘述。
步骤S804:所述视频应用在保活时间内被切换到前台。
步骤S805:ActivityManager向事件管理模块发送第三界面切换报告。
具体地,所述第三界面切换报告包括App_1、App_2、Act_a、Act_b、T4。其中,App_1为所述视频应用的包名,App_2为被视频应用切换到后台的应用程序的包名(第二应用程序)、Act_a为视频应用当前工作界面的标识信息(第二界面标识)、Act_b为被切换界面的标识信息(第一界面标识),T4是界面切换的时间。例如,第三界面切换报告的形式可以为(App_2,Act_b,App_1,Act_a,T4)。
在视频应用在保活时间内被切换到前台的情况下,具体步骤S720如下:
步骤S806:事件管理模块将第三界面切换报告发送给应用切换识别模块。
具体地,事件管理模块可以通过调用函数BoundarCallBack将第三界面切换报告发送给应用切换识别模块。
步骤S807:应用切换识别模块向音频焦点决策模块发送第三界面切换报告。
具体地,应用切换识别模块接收到第三界面切换报告后,将App_2和App_1进行比较,发现二者不一致,应用切换识别模块确定发生了应用切换。由于音频焦点决策模块在电子设备开机时向应用切换识别模块订阅了应用切换变化事件。因此,当应用切换识别模块识别到所述视频应用切换到前台为应用程序之间的切换时,调用函数AppCallBack将第三界面切换报告发送给音频焦点决策模块。
步骤S808:音频焦点决策模块基于第三界面切换报告向事件管理模块发送第一请求消息。
具体地,音频决策模块在接收到应用切换变化报告后调用视频应用的保活信息,并根据第三界面切换报告中App_1确定该视频应用为保活应用程序。然后,音频焦点决策模块可以计算接收该视频应用保活信息的时间T5与第三界面切换报告中的T4的模值,并判断 该模值是否大于SaveTime。若判断为否,则该视频应用是在保活时间内被切回前台的,音频焦点决策模块向事件管理模块发送第一请求消息。若判断为是,则该视频应用不是在保活时间内被切回前台的,音频焦点决策模块不向事件管理模块发送第一请求消息。
步骤S809:事件管理模块向AudioManage发送第一请求消息。
具体地,事件管理模块调用函数AudioFocus_Distribut_1(App_1)向AudioManager发送第一请求消息。
本申请实施例,音频焦点决策模块向AudioManager发送第一请求消息,从而使得AudioManager向该应用程序分配音频焦点,使得当前处于视频播放界面的视频应用能够播放音频。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本申请所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线)或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk)等。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,该流程可以由计算机程序来指令相关的硬件完成,该程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法实施例的流程。而前述的存储介质包括:ROM或随机存储记忆体RAM、磁碟或者光盘等各种可存储程序代码的介质。
总之,以上所述仅为本发明技术方案的实施例而已,并非用于限定本发明的保护范围。凡根据本发明的揭露,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (28)

  1. 一种视频应用的保活方法,其特征在于,应用于电子设备,所述方法包括:
    确定所述电子设备的内存使用量大于第一阈值;
    确定第一应用的应用类型,所述第一应用处于后台运行状态;
    若所述第一应用的类型为视频类型,确定所述第一应用是否处于视频保持状态;
    若所述第一应用处于视频保持状态,在保活时间内对所述第一应用的进程进行保活。
  2. 如权利要求1所述的方法,其特征在于,所述确定所述电子设备的内存使用量大于第一阈值之前,所述方法还包括:
    将处于第一界面的所述第一应用切换到后台运行。
  3. 如权利要求2所述的方法,其特征在于,所述在保活时间内对所述第一应用的进程进行保活之后,所述方法还包括:
    将所述第一应用在所述保活时间内切换到前台运行;
    所述第一应用显示所述第一界面。
  4. 如权利要求2-3任一项所述的方法,其特征在于,所述确定所述第一应用是否处于视频保持状态,包括:
    所述第一应用被切换到后台运行时,所述第一界面不是主界面,并且所述第一应用获取音频焦点的时长超过第一时长。
  5. 如权利要求1-4任一项所述的方法,其特征在于,所述确定所述电子设备的内存使用量大于第一阈值之后,所述方法还包括:
    确定所述电子设备的系统压力等级。
  6. 如权利要求5所述的方法,其特征在于,所述在保活时间内对所述第一应用的进程进行保活,包括:
    基于所述系统压力等级确定所述第一应用是否满足排名条件;
    若满足排名条件,则在保活时间内对所述第一应用的进程进行保活。
  7. 如权利要求6所述的方法,其特征在于,所述系统压力等级包括一级压力和二级压力,所述基于所述系统压力等级确定所述第一应用是否满足排名条件,包括:
    当所述电子设备的系统压力等级为所述一级压力时,确定所述第一应用在第一应用队列中的排名是否在第二阈值之内,所述第一应用队列包括与所述第一应用相同类型的应用;
    若所述第一应用在第一应用队列中的排名在第二阈值之内,则确定所述第一应用满足排名条件;
    或者,
    当所述电子设备的系统压力等级为所述二级压力时,确定所述第一应用在第一应用队列中的排名是否在第三阈值之内;
    若所述第一应用在第一应用队列中的排名在第三阈值之内,则确定所述第一应用满足排名条件。
  8. 如权利要求1-7任一项所述的方法,其特征在于,所述电子设备包括系统状态识别模块、资源管理模块以及保活决策模块,所述方法包括:
    所述系统识别模块从所述资源管理模块获取当前系统的运行内存使用量;
    所述系统识别模块确定所述运行内存使用量大于第一阈值;
    所述系统状态识别模块向所述保活决策模块发送所述运行内存使用量;
    响应于接收所述运行内存使用量,所述保活决策模块通过所述资源管理模块获取系统压力系数;
    所述保活决策模块判断所述系统压力系数是否大于第四阈值;
    若大于第四阈值,所述保活决策模块确定系统状态为高压状态;
    在所述系统状态为高压状态的情况下,所述保活决策模块判断所述运行内存使用量是否超过第五阈值;
    若超过第五阈值,则确定系统压力等级为一级压力;
    若未超过第五阈值,则确定系统压力等级为二级压力。
  9. 如权利要求1-8任一项所述的方法,其特征在于,所述电子设备包括保活决策模块和应用识别模块,所述确定第一应用的应用类型之前,所述方法还包括:
    所述保活决策模块通过所述应用识别模块获取所述第一应用的应用类型;
    所述确定第一应用的应用类型,具体为:
    所述保活决策模块基于所述应用类型确定所述第一应用的类型为视频类型。
  10. 如权利要求1-9任一项所述的方法,其特征在于,所述电子设备还包括音频焦点识别和应用切换识别模块,所述确定所述第一应用是否处于视频保持状态,包括:
    所述保活决策模块从所述应用切换识别模块中获取第二界面切换报告,所述第二界面切换报告至少包括所述第一应用切换到后台的时刻T2、所述第一界面的标识信息;
    所述保活决策模块判断所述第一界面的标识信息是否与所述第一应用主界面的标志信息一致;
    若一致,所述保活决策模块确定所述第一应用不处于视频保持状态;
    若不一致,所述保活决策模块从所述音频焦点识别模块获取所述第一应用的音频焦点变化报告,所述音频焦点变化报告至少包括所述第一应用申请音频焦点的时刻T1;
    所述保活决策模块计算所述T1与所述T2的模值;
    所述保活决策模块确定所述模值是否大于或等于第一时长;
    若是,所述保活模块确定所述第一应用处于视频保持状态;
    若否,所述保活模块确定所述第一应用不处于视频保持状态。
  11. 如权利要求7-10任一项所述的方法,其特征在于,所述基于所述系统压力等级确定所述第一应用满足排名条件,
    包括:
    在系统压力等级为所述一级压力的情况下,所述保活决策模块判断所述第一应用在第一应用队列中的排名是否在第二阈值之内,所述第一应用队列包括与所述第一应用相同类型的应用;
    若在,所述保活决策模块确定所述第一应用满足排名条件;
    或者,在系统压力等级为所述二级压力的情况下,所述保活决策模块判断所述第一应用在第一应用队列中的排名是否在第三阈值之内;
    若在,所述保活决策模块确定所述第一应用满足排名条件。
  12. 如权利要求3-11任一项所述的方法,其特征在于,所述电子设备还包括音频管理模块,所述将所述第一应用在所述保活时间内切换到前台运行之后,还包括:
    所述第一应用向所述音频管理模块申请音频焦点;
    所述音频管理模块向所述第一应用分配音频焦点。
  13. 如权利要求3-11任一项所述的方法,其特征在于,所述电子设备还包括音频焦点决策模块,所述在保活时间内对所述第一应用的进程进行保活之后,包括:
    所述保活决策模块向所述音频焦点决策模块发送所述第一应用的保活信息,所述保活信息包括保活时长SaveTime。
  14. 如权利要求13所述的方法,其特征在于,所述电子设备还包括音频管理模块、事件管理模块和界面管理模块,所述将所述第一应用在所述保活时间内切换到前台运行之后,还包括:
    所述界面管理模块向所述事件管理模块发送第三界面切换报告,所述第三界面切换报告包括所述第一应用的标识信息、第二应用程序的标识信息以及界面切换时刻T4;
    所述事件管理模块向所述应用切换识别模块发送所述第三界面切换报告;
    所述应用切换识别模块确定所述第一应用的标识信息与第二应用程序的标识信息不一致;
    所述应用切换识别模块向所述音频焦点决策模块发送所述第三界面切换报告;
    所述音频焦点决策模块计算所述T4与接收所述保活信息的时刻T5的模值;
    在所述模值大于所述SaveTime的情况下所述音频焦点决策模块向所述事件管理模块发送第一请求消息,所述第一请求消息用于指示所述音频管理模块向所述第一应用分配音频焦点;
    所述事件管理模块向所述音频管理模块发送所述第一请求消息;
    所述音频管理模块向所述第一应用分配音频焦点。
  15. 一种视频应用的保活方法,其特征在于,应用于电子设备,所述方法包括:
    将处于第一界面的第一应用切换到后台运行;
    确定所述电子设备的内存使用量大于第一阈值;
    确定第一应用的应用类型为视频类型;
    确定所述第一应用是否处于视频保持状态,其中,在所述第一应用被切换到后台运行,且所述第一界面不是主界面,并且所述第一应用获取音频焦点的时长超过第一时长的情况下,确定所述第一应用处于视频保持状态;
    若所述第一应用处于视频保持状态,在保活时间内对所述第一应用的进程进行保活;
    将所述第一应用在所述保活时间内切换到前台运行;
    所述第一应用显示所述第一界面。
  16. 如权利要求15所述的方法,其特征在于,所述确定所述电子设备的内存使用量大于第一阈值之后,所述方法还包括:
    确定所述电子设备的系统压力等级。
  17. 如权利要求16所述的方法,其特征在于,所述在保活时间内对所述第一应用的进程进行保活,包括:
    基于所述系统压力等级确定所述第一应用是否满足排名条件;
    若满足排名条件,则在保活时间内对所述第一应用的进程进行保活。
  18. 如权利要求17所述的方法,其特征在于,所述系统压力等级包括一级压力和二级压力,所述基于所述系统压力等级确定所述第一应用是否满足排名条件,包括:
    当所述电子设备的系统压力等级为所述一级压力时,确定所述第一应用在第一应用队列中的排名是否在第二阈值之内,所述第一应用队列包括与所述第一应用相同类型的应用;
    若所述第一应用在第一应用队列中的排名在第二阈值之内,则确定所述第一应用满足排名条件;
    或者,
    当所述电子设备的系统压力等级为所述二级压力时,确定所述第一应用在第一应用队列中的排名是否在第三阈值之内;
    若所述第一应用在第一应用队列中的排名在第三阈值之内,则确定所述第一应用满足排名条件。
  19. 如权利要求18所述的方法,其特征在于,所述电子设备包括系统状态识别模块、资源管理模块以及保活决策模块,所述方法包括:
    所述系统状态识别模块从所述资源管理模块获取当前系统的运行内存使用量;
    所述系统状态识别模块确定所述运行内存使用量大于第一阈值;
    所述系统状态识别模块向所述保活决策模块发送所述运行内存使用量;
    响应于接收所述运行内存使用量,所述保活决策模块通过所述资源管理模块获取系统 压力系数;
    所述保活决策模块判断所述系统压力系数是否大于第四阈值;
    若大于第四阈值,所述保活决策模块确定系统状态为高压状态;
    在所述系统状态为高压状态的情况下,所述保活决策模块判断所述运行内存使用量是否超过第五阈值;
    若超过第五阈值,则确定系统压力等级为一级压力;
    若未超过第五阈值,则确定系统压力等级为二级压力。
  20. 如权利要求19所述的方法,其特征在于,所述电子设备还包括音频焦点识别和应用切换识别模块,所述确定所述第一应用是否处于视频保持状态,包括:
    所述保活决策模块从所述应用切换识别模块中获取第二界面切换报告,所述第二界面切换报告至少包括所述第一应用切换到后台的时刻T2、所述第一界面的标识信息;
    所述保活决策模块判断所述第一界面的标识信息是否与所述第一应用主界面的标志信息一致;
    若一致,所述保活决策模块确定所述第一应用不处于视频保持状态;
    若不一致,所述保活决策模块从所述音频焦点识别模块获取所述第一应用的音频焦点变化报告,所述音频焦点变化报告至少包括所述第一应用申请音频焦点的时刻T1;
    所述保活决策模块计算所述T1与所述T2的模值;
    所述保活决策模块确定所述模值是否大于或等于第一时长;
    若是,所述保活决策模块确定所述第一应用处于视频保持状态;
    若否,所述保活决策模块确定所述第一应用不处于视频保持状态。
  21. 如权利要求19所述的方法,其特征在于,所述基于所述系统压力等级确定所述第一应用满足排名条件,
    包括:
    在系统压力等级为所述一级压力的情况下,所述保活决策模块判断所述第一应用在第一应用队列中的排名是否在第二阈值之内,所述第一应用队列包括与所述第一应用相同类型的应用;
    若在,所述保活决策模块确定所述第一应用满足排名条件;
    或者,在系统压力等级为所述二级压力的情况下,所述保活决策模块判断所述第一应用在第一应用队列中的排名是否在第三阈值之内;
    若在,所述保活决策模块确定所述第一应用满足排名条件。
  22. 如权利要求15所述的方法,其特征在于,所述电子设备还包括音频管理模块,所述将所述第一应用在所述保活时间内切换到前台运行之后,还包括:
    所述第一应用向所述音频管理模块申请音频焦点;
    所述音频管理模块向所述第一应用分配音频焦点。
  23. 如权利要求19所述的方法,其特征在于,所述电子设备还包括音频焦点决策模块,所述在保活时间内对所述第一应用的进程进行保活之后,包括:
    所述保活决策模块向所述音频焦点决策模块发送所述第一应用的保活信息,所述保活信息包括保活时长SaveTime。
  24. 如权利要求23所述的方法,其特征在于,所述电子设备还包括音频管理模块、事件管理模块和界面管理模块,所述将所述第一应用在所述保活时间内切换到前台运行之后,还包括:
    所述界面管理模块向所述事件管理模块发送第三界面切换报告,所述第三界面切换报告包括所述第一应用的标识信息、第二应用程序的标识信息以及界面切换时刻T4;
    所述事件管理模块向所述应用切换识别模块发送所述第三界面切换报告;
    所述应用切换识别模块确定所述第一应用的标识信息与第二应用程序的标识信息不一致;
    所述应用切换识别模块向所述音频焦点决策模块发送所述第三界面切换报告;
    所述音频焦点决策模块计算所述T4与接收所述保活信息的时刻T5的模值;
    在所述模值大于所述SaveTime的情况下所述音频焦点决策模块向所述事件管理模块发送第一请求消息,所述第一请求消息用于指示所述音频管理模块向所述第一应用分配音频焦点;
    所述事件管理模块向所述音频管理模块发送所述第一请求消息;
    所述音频管理模块向所述第一应用分配音频焦点。
  25. 一种电子设备,其特征在于,包括:触控屏、摄像头、一个或多个处理器和一个或多个存储器;所述一个或多个处理器与所述触控屏、所述摄像头、所述一个或多个存储器耦合,所述一个或多个存储器用于存储计算机程序代码,计算机程序代码包括计算机指令,当所述一个或多个处理器执行所述计算机指令时,使得所述电子设备执行如权利要求1-24中的任一项所述的方法。
  26. 一种计算机可读存储介质,包括指令,其特征在于,当所述指令在电子设备上运行时,使得所述电子设备执行如权利要求1-24中任一项所述的方法。
  27. 一种芯片系统,所述芯片系统应用于电子设备,所述芯片系统包括一个或多个处理器,所述处理器用于调用计算机指令以使得所述电子设备执行如权利要求1-24中任一项所述的方法。
  28. 一种包含指令的计算机程序产品,其特征在于,当所述计算机程序产品在电子设备上运行时,使得所述电子设备执行如权利要求1-24中任一项所述的方法。
PCT/CN2022/093745 2021-06-26 2022-05-19 一种视频应用的保活方法以及电子设备 WO2022267765A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP22827263.9A EP4216058A4 (en) 2021-06-26 2022-05-19 CONNECTION MAINTENANCE METHOD FOR VIDEO APPLICATION AND ELECTRONIC DEVICE
US18/033,647 US20230325260A1 (en) 2021-06-26 2022-05-19 Video application keepalive method and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110715306.5A CN113741994B (zh) 2021-06-26 2021-06-26 一种视频应用的保活方法以及电子设备
CN202110715306.5 2021-06-26

Publications (1)

Publication Number Publication Date
WO2022267765A1 true WO2022267765A1 (zh) 2022-12-29

Family

ID=78728528

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093745 WO2022267765A1 (zh) 2021-06-26 2022-05-19 一种视频应用的保活方法以及电子设备

Country Status (4)

Country Link
US (1) US20230325260A1 (zh)
EP (1) EP4216058A4 (zh)
CN (2) CN115525356A (zh)
WO (1) WO2022267765A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115525356A (zh) * 2021-06-26 2022-12-27 荣耀终端有限公司 一种视频应用的保活方法以及电子设备

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015196967A1 (zh) * 2014-06-24 2015-12-30 北京奇虎科技有限公司 应用程序常驻操作系统后台的方法及装置
CN110489215A (zh) * 2019-06-29 2019-11-22 华为技术有限公司 一种应用程序中等待场景的处理方法和装置
CN113535250A (zh) * 2020-04-13 2021-10-22 华为技术有限公司 一种应用保活方法、装置和电子设备
CN113741994A (zh) * 2021-06-26 2021-12-03 荣耀终端有限公司 一种视频应用的保活方法以及电子设备

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU2003266466A1 (en) * 2002-12-06 2004-06-24 Transit Video Enterprises Pty Ltd Provision of Audio-visual Content in a Mobile Environment
EP3008943A4 (en) * 2013-06-11 2017-02-22 Seven Networks, LLC Optimizing keepalive and other background traffic in a wireless network
US10552179B2 (en) * 2014-05-30 2020-02-04 Apple Inc. Resource management with dynamic resource policies
CN109324879B (zh) * 2017-07-28 2022-04-22 华为技术有限公司 管理触发器的方法及终端设备
CN108055408B (zh) * 2017-12-28 2019-12-24 维沃移动通信有限公司 一种应用程序控制方法及移动终端
CN109992310B (zh) * 2019-03-12 2024-04-05 中国平安财产保险股份有限公司 应用程序保活方法、装置、计算机设备和存储介质
CN111913750B (zh) * 2019-05-10 2022-04-22 华为技术有限公司 一种应用程序管理方法、装置及设备
CN111193954A (zh) * 2020-03-05 2020-05-22 成都金麦客科技有限公司 一种Android MV视频后台播放系统
CN111615002B (zh) * 2020-04-30 2021-07-27 腾讯科技(深圳)有限公司 视频后台播放控制方法、装置、系统及电子设备
CN111857919A (zh) * 2020-07-16 2020-10-30 北京字节跳动网络技术有限公司 一种视频处理方法、装置、终端设备及介质
CN112988282B (zh) * 2021-04-27 2021-08-20 荣耀终端有限公司 应用保活方法和终端设备

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015196967A1 (zh) * 2014-06-24 2015-12-30 北京奇虎科技有限公司 应用程序常驻操作系统后台的方法及装置
CN110489215A (zh) * 2019-06-29 2019-11-22 华为技术有限公司 一种应用程序中等待场景的处理方法和装置
CN113535250A (zh) * 2020-04-13 2021-10-22 华为技术有限公司 一种应用保活方法、装置和电子设备
CN113741994A (zh) * 2021-06-26 2021-12-03 荣耀终端有限公司 一种视频应用的保活方法以及电子设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4216058A4

Also Published As

Publication number Publication date
CN113741994B (zh) 2022-07-12
CN115525356A (zh) 2022-12-27
EP4216058A1 (en) 2023-07-26
EP4216058A4 (en) 2024-01-03
US20230325260A1 (en) 2023-10-12
CN113741994A (zh) 2021-12-03

Similar Documents

Publication Publication Date Title
CN113553130B (zh) 应用执行绘制操作的方法及电子设备
CN113778663B (zh) 一种多核处理器的调度方法及电子设备
CN111555825B (zh) 射频资源分配方法及装置
WO2022100141A1 (zh) 插件管理方法、系统及装置
WO2022078105A1 (zh) 内存管理方法、电子设备以及计算机可读存储介质
WO2022052878A1 (zh) 推送消息的管理方法及相关装置
WO2022100222A1 (zh) 信息检索方法、装置、系统及存储介质
WO2022160991A1 (zh) 权限控制方法和电子设备
WO2024016564A1 (zh) 二维码识别方法、电子设备以及存储介质
WO2021169370A1 (zh) 服务元素的跨设备分配方法、终端设备及存储介质
WO2021104122A1 (zh) 呼叫需求响应方法、装置及电子设备
CN115292199B (zh) 一种显存泄露的处理方法及相关装置
WO2022267765A1 (zh) 一种视频应用的保活方法以及电子设备
WO2022194190A1 (zh) 调整触摸手势的识别参数的数值范围的方法和装置
CN115333941A (zh) 获取应用运行情况的方法及相关设备
WO2022095906A1 (zh) 一种按键映射方法、电子设备及系统
CN112712377A (zh) 一种产品缺陷整理汇总管理数据库平台系统
CN116755748B (zh) 卡片更新方法、电子设备以及计算机可读存储介质
CN117690177B (zh) 人脸对焦方法、人脸对焦装置、电子设备及存储介质
WO2022242312A1 (zh) 基于应用的设备连接关系建立方法及相关装置
CN117149294B (zh) 相机应用配置方法、设备及存储介质
EP4372579A1 (en) Application recommendation method and electronic device
WO2023001208A1 (zh) 多文件同步方法及电子设备
WO2022111640A1 (zh) 应用分类方法、电子设备及芯片系统
WO2024139947A1 (zh) 一种终端设备的管理方法、装置及通信系统

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

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2022827263

Country of ref document: EP

Effective date: 20230419

NENP Non-entry into the national phase

Ref country code: DE